forked from SynoCommunity/spksrc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspksrc.python-module.mk
45 lines (35 loc) · 1.39 KB
/
spksrc.python-module.mk
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
### Python module rules
# Invoke make to (cross-) compile a python module.
# You can do some customization through python-cc.mk
# Python module targets
ifeq ($(strip $(CONFIGURE_TARGET)),)
CONFIGURE_TARGET = nope
endif
ifeq ($(strip $(COMPILE_TARGET)),)
COMPILE_TARGET = compile_python_module
endif
ifeq ($(strip $(INSTALL_TARGET)),)
INSTALL_TARGET = install_python_module
endif
# Resume with standard spksrc.cross-cc.mk
include ../../mk/spksrc.cross-cc.mk
# Fetch python variables
-include $(WORK_DIR)/python-cc.mk
# Python module variables
PYTHONPATH = $(PYTHON_SITE_PACKAGES_NATIVE):$(PYTHON_LIB_NATIVE):$(INSTALL_DIR)$(INSTALL_PREFIX)/$(PYTHON_LIB_DIR)/site-packages/
### Python module rules
compile_python_module:
@$(RUN) PYTHONPATH=$(PYTHONPATH) $(HOSTPYTHON) setup.py build_ext -I $(STAGING_INSTALL_PREFIX)/include -L $(STAGING_INSTALL_PREFIX)/lib $(BUILD_ARGS)
install_python_module:
@$(RUN) PYTHONPATH=$(PYTHONPATH) $(HOSTPYTHON) setup.py install --root $(INSTALL_DIR) --prefix $(INSTALL_PREFIX) $(INSTALL_ARGS)
fix_shebang_python_module:
@cat PLIST | sed 's/:/ /' | while read type file ; \
do \
case $${type} in \
bin) \
echo -n "Fixing shebang for $${file}... " ; \
sed -i -e 's|^#!.*$$|#!$(PYTHON_INTERPRETER)|g' $(INSTALL_DIR)$(INSTALL_PREFIX)/$${file} > /dev/null 2>&1 && echo "ok" || echo "failed!" \
;; \
esac ; \
done
all: install fix_shebang_python_module