diff --git a/make/py-mod.mk b/make/py-mod.mk index 5d82fe44..63423ba9 100644 --- a/make/py-mod.mk +++ b/make/py-mod.mk @@ -14,34 +14,7 @@ install: install-dirs.done install-reg.done clean: py.clean distclean: -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) $< $@ +include $(MODDIR)/make/py-rules.mk __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 diff --git a/make/py-rules.mk b/make/py-rules.mk new file mode 100644 index 00000000..e8de5dfb --- /dev/null +++ b/make/py-rules.mk @@ -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) $< $@