| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 | CC ?= gcc
|
| 8 |
|
| 9 | LDFLAGS ?= -lcpupower
|
| 10 | HAVE_SWIG := $(shell if which swig >/dev/null 2>&1; then echo 1; else echo 0; fi)
|
| 11 | HAVE_PYCONFIG := $(shell if which python-config >/dev/null 2>&1; then echo 1; else echo 0; fi)
|
| 12 |
|
| 13 | PY_INCLUDE ?= $(firstword $(shell python-config --includes))
|
| 14 | INSTALL_DIR ?= $(shell python3 -c "import site; print(site.getsitepackages()[0])")
|
| 15 |
|
| 16 | all: _raw_pylibcpupower.so
|
| 17 |
|
| 18 | _raw_pylibcpupower.so: raw_pylibcpupower_wrap.o
|
| 19 | $(CC) -shared $(LDFLAGS) raw_pylibcpupower_wrap.o -o _raw_pylibcpupower.so
|
| 20 |
|
| 21 | raw_pylibcpupower_wrap.o: raw_pylibcpupower_wrap.c
|
| 22 | $(CC) $(CFLAGS) $(PY_INCLUDE) -fPIC -c raw_pylibcpupower_wrap.c
|
| 23 |
|
| 24 | raw_pylibcpupower_wrap.c: raw_pylibcpupower.swg
|
| 25 | ifeq ($(HAVE_SWIG),0)
|
| 26 | $(error "swig was not found. Make sure you have it installed and in the PATH to generate the bindings.")
|
| 27 | else ifeq ($(HAVE_PYCONFIG),0)
|
| 28 | $(error "python-config was not found. Make sure you have it installed and in the PATH to generate the bindings.")
|
| 29 | endif
|
| 30 | swig -python raw_pylibcpupower.swg
|
| 31 |
|
| 32 |
|
| 33 | install: _raw_pylibcpupower.so
|
| 34 | install -D _raw_pylibcpupower.so $(INSTALL_DIR)/_raw_pylibcpupower.so
|
| 35 | install -D raw_pylibcpupower.py $(INSTALL_DIR)/raw_pylibcpupower.py
|
| 36 |
|
| 37 | uninstall:
|
| 38 | rm -f $(INSTALL_DIR)/_raw_pylibcpupower.so
|
| 39 | rm -f $(INSTALL_DIR)/raw_pylibcpupower.py
|
| 40 |
|
| 41 |
|
| 42 | clean:
|
| 43 | rm -f raw_pylibcpupower.py raw_pylibcpupower_wrap.c raw_pylibcpupower_wrap.o _raw_pylibcpupower.so
|