-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
97 lines (84 loc) · 3.12 KB
/
Makefile
File metadata and controls
97 lines (84 loc) · 3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# vortex - GCode machine emulator
# Copyright (C) 2024-2025 Mitko Haralanov
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# This project uses Meson and meson-python as the build system.
# However, to simplify development, this Makefile is here for
# convinience and to record the require build commands.
PYTHON ?= $(shell which python3)
PYTHON_DEBUG ?= $(shell which python3-debug)
GDB := $(shell which gdb)
VENV ?=
VENV_PYTHON := $(VENV)/bin/python3
DEBUG_OPTS :=
MESON_DEBUG_OPTS :=
GCC_BUILD_OPTS :=
VERSION=$(shell git describe --tags --abbrev=0)
KVER := $(shell uname -r)
ARCH := $(shell uname -m)
PYTHON_VERSION=$(shell $(PYTHON) -c "import platform; print(platform.python_version())")
PYTHON_VERSION_NUMS = $(subst ., ,$(PYTHON_VERSION))
ifeq ($(DEBUG),1)
GCC_BUILD_OPTS=CFLAGS='-DVORTEX_DEBUG -g'
MESON_BUILD_OPTS=--config-settings=setup-args="-Dbuildtype=debug"
endif
all: version
$(GCC_BUILD_OPTS) $(PYTHON) -m pip install --no-build-isolation \
--editable . $(MESON_BUILD_OPTS)
@if [ ! -L compile_commands.json ]; then \
ln -s build/cp$(word 1,$(PYTHON_VERSION_NUMS))$(word 2,$(PYTHON_VERSION_NUMS))/compile_commands.json \
compile_commands.json; \
fi
kmod:
mkdir -p build/kmod
$(MAKE) -C /lib/modules/$(KVER)/build M=$${PWD}/src/kmod
kmod_sign: kmod
/lib/modules/$(KVER)/build/scripts/sign-file sha256 \
/etc/pki/akmods/private/private_key.priv \
/etc/pki/akmods/certs/public_key.der \
$${PWD}/src/kmod/vortex.ko
kmod_install: kmod_sign
$(MAKE) -C /lib/modules/$(KVER)/build M=$${PWD}/src/kmod modules_install
version:
@echo $(VERSION) > version.txt
venv:
@if [ -z "$(VENV)" ]; then \
echo "ERROR: Virtual environment path not set"; \
exit 1; \
fi
@echo "Creating virtual environment in $(VENV)..."
@if [ ! -d $(VENV) ]; then \
virtualenv $(VENV); \
fi
@echo "Installing dependencies..."
$(VENV)/bin/pip install -r ./virtualenv.txt
wheel: venv version
$(VENV_PYTHON) -m build -w .
package: version
$(PYTHON) -m build -w .
mkdir -p vortex-$(VERSION)-$(ARCH)
mkdir vortex-$(VERSION)-$(ARCH)/vortex-kmod
cp src/kmod/vortex.[ch] src/kmod/Makefile vortex-$(VERSION)-$(ARCH)/vortex-kmod
cp dist/vortex-*.whl vortex-$(VERSION)-$(ARCH)
tar -jcf vortex-$(VERSION)-$(ARCH).tar.bz2 vortex-$(VERSION)-$(ARCH)
rm -rf vortex-$(VERSION)-$(ARCH)
install: wheel
$(VENV_PYTHON) -m pip install --force-reinstall dist/vortex-*.whl
gdb:
$(GDB) $(PYTHON_DEBUG) -ex 'r ./vortex_run.py $(GDB_OPTS)'
clean:
$(MAKE) -C /lib/modules/$(KVER)/build M=$${PWD}/src/kmod clean
rm -rf build dist builddir
rm -f compile_commands.json version.txt vortex-*.tar.bz2