py-mod.mk, py-rules.mk: Split up py-mod.mk in py-mod.mk and py-rules.mk

py-rules.mk is meant to be usable outside of a jw Python module
context, just for generating .pyc, for example

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2019-06-22 10:11:44 +00:00
commit fb2f57b7b9
2 changed files with 31 additions and 28 deletions

View file

@ -14,34 +14,7 @@ install: install-dirs.done install-reg.done
clean: py.clean clean: py.clean
distclean: distclean:
py.clean: include $(MODDIR)/make/py-rules.mk
$(RM) -f *.done *.pyc
/bin/bash $(MOD_SCRIPT_DIR)/scm.sh clean -f __init__.py
$(RM) -rf __pycache__
install-dirs.done:
$(INSTALL) -d -m $(PYMODDIRMODE) -o $(PYMODDIROWNER) -g $(PYMODDIRGROUP) $(PY_INSTALL_DIRS)
touch $@
install-reg.done: install-dirs.done $(PY_INSTALLED_REG)
touch $@
$(PY_INSTALL_DIR_PY)/%.py: %.py
$(INSTALL) -p -m $(PYMODMODE) -o $(PYMODOWNER) -g $(PYMODGROUP) $< $@
ifneq ($(PYTHON_VERSION),3)
%.pyc: %.py
else
__pycache__/%.cpython-37.pyc: %.py
endif
$(PYTHON) -c "import py_compile; py_compile.compile(\"$<\", doraise=True)"
ifeq ($(PYTHON_VERSION),3)
$(PY_INSTALL_DIR_PY)/__pycache__/%.cpython-37.pyc: __pycache__/%.cpython-37.pyc
else
$(PY_INSTALL_DIR_PY)/%.pyc: %.pyc
endif
$(INSTALL) -p -m $(PYMODMODE) -o $(PYMODOWNER) -g $(PYMODGROUP) $< $@
__init__.py: $(PY_INIT_TMPL) $(filter-out __init__.py,$(PY_SRC_PY)) __init__.py: $(PY_INIT_TMPL) $(filter-out __init__.py,$(PY_SRC_PY))
if [ "$(PY_INIT_TMPL)" ]; then cat "$(PY_INIT_TMPL)" > $@.tmp; else > $@.tmp; fi if [ "$(PY_INIT_TMPL)" ]; then cat "$(PY_INIT_TMPL)" > $@.tmp; else > $@.tmp; fi

30
make/py-rules.mk Normal file
View file

@ -0,0 +1,30 @@
all:
py.clean:
$(RM) -f *.done *.pyc
/bin/bash $(MOD_SCRIPT_DIR)/scm.sh clean -f __init__.py
$(RM) -rf __pycache__
install-dirs.done:
$(INSTALL) -d -m $(PYMODDIRMODE) -o $(PYMODDIROWNER) -g $(PYMODDIRGROUP) $(PY_INSTALL_DIRS)
touch $@
install-reg.done: install-dirs.done $(PY_INSTALLED_REG)
touch $@
$(PY_INSTALL_DIR_PY)/%.py: %.py
$(INSTALL) -p -m $(PYMODMODE) -o $(PYMODOWNER) -g $(PYMODGROUP) $< $@
ifneq ($(PYTHON_VERSION),3)
%.pyc: %.py
else
__pycache__/%.cpython-37.pyc: %.py
endif
$(PYTHON) -c "import py_compile; py_compile.compile(\"$<\", doraise=True)"
ifeq ($(PYTHON_VERSION),3)
$(PY_INSTALL_DIR_PY)/__pycache__/%.cpython-37.pyc: __pycache__/%.cpython-37.pyc
else
$(PY_INSTALL_DIR_PY)/%.pyc: %.pyc
endif
$(INSTALL) -p -m $(PYMODMODE) -o $(PYMODOWNER) -g $(PYMODGROUP) $< $@