mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-15 03:53:32 +01:00
make: Re-add files necessary for building jw-python
Re-add everything necessary for building and packaging jw-python. ldlibpath.mk is not strictly necessary, but might be with other Python packages backed by compiled C-code, so leave it in. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
5b758023ac
commit
0a9340af49
7 changed files with 261 additions and 0 deletions
28
make/cleandirs.mk
Normal file
28
make/cleandirs.mk
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
.NOTPARALLEL:
|
||||
|
||||
all: do.all
|
||||
install: do.install
|
||||
clean: do.clean
|
||||
distclean: do.distclean
|
||||
|
||||
include $(JWBDIR)/make/defs.mk
|
||||
|
||||
SUBDIRS ?= $(FIND_SUBDIRS)
|
||||
|
||||
ifeq ($(FORCE_REBUILD_CLEANDIRS),true)
|
||||
SUBDIRS_ALL = $(SUBDIRS)
|
||||
SUBDIRS_INSTALL = $(SUBDIRS)
|
||||
else
|
||||
SUBDIRS_ALL ?=
|
||||
SUBDIRS_INSTALL ?=
|
||||
endif
|
||||
|
||||
do.all:
|
||||
set -e; for d in $(SUBDIRS_ALL); do make -wC $$d $*; done
|
||||
|
||||
do.install:
|
||||
set -e; for d in $(SUBDIRS_INSTALL); do make -wC $$d $*; done
|
||||
|
||||
do.%:
|
||||
set -e; for d in $(SUBDIRS); do make -wC $$d $*; done
|
||||
$(RM) -rf $(TEXTCLEAN) $(CLEAN) *.done *~ .*.swp *.tmp core *.rep dirs-*.done
|
||||
17
make/ldlibpath.mk
Normal file
17
make/ldlibpath.mk
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# jan's utility modules
|
||||
# (c) 2001-2005 jannet it services
|
||||
# contact@jannet.de
|
||||
# $Id$
|
||||
|
||||
LD_LIB_PATH_ENV := $(LD_LIBRARY_PATH)
|
||||
EXE_SEARCH_PATH_ENV := $(PATH)
|
||||
LD_LIB_PATH_LDFLAGS = $(shell echo $(FINAL_LDFLAGS) | $(SED) 's/^-[^L] *[^ ]*/ /g; s/[ ]-[^L] *[^ ]*/ /g; s/-L[ ]*\([^ ]*\)[ ]*/\1:/g')
|
||||
|
||||
ifeq ($(TARGET),mingw)
|
||||
DLL_PATH = $(shell echo $(LD_LIBRARY_PATH) | $(SED) 's/:/;/g');$(CROSS_TOOL_DIR)/bin
|
||||
endif
|
||||
|
||||
#export LD_LIBRARY_PATH = $(shell echo $(strip $(LD_LIB_PATH_LDFLAGS):$(LD_LIB_PATH):$(LD_LIB_PATH_ENV)) | $(SED) 's/ /:/g; s/::/:/g')
|
||||
LD_LIBRARY_PATH := $(call proj_query, ldlibpath $(PROJECT) $(PREREQ_BUILD))
|
||||
export LD_LIBRARY_PATH
|
||||
export PATH := $(call proj_query, exepath $(PROJECT) $(PREREQ_BUILD)):$(EXE_SEARCH_PATH_ENV)
|
||||
26
make/profile.mk
Normal file
26
make/profile.mk
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# generic utility modules
|
||||
# (c) 2001 jannet it services
|
||||
# contact@jannet.de
|
||||
# $Id$
|
||||
|
||||
PATH_PROFILE ?= path-$(PROJECT).sh
|
||||
EXE_SH =
|
||||
|
||||
ifeq ($(PROFILE),)
|
||||
PROFILE = $(PATH_PROFILE)
|
||||
endif
|
||||
|
||||
PROFILE += $(filter-out $(PATH_PROFILE),$(wildcard *.sh))
|
||||
|
||||
include $(JWBDIR)/make/defs.mk
|
||||
include $(JWBDIR)/make/rules.mk
|
||||
|
||||
all: $(PROFILE)
|
||||
install: install_files_PROFILE
|
||||
clean: allclean localclean doneclean textclean clean.profile
|
||||
|
||||
path-%.sh:
|
||||
@echo "export PATH=\$$PATH:$(INSTALL_EXEDIR)" > $@.tmp
|
||||
mv $@.tmp $@
|
||||
clean.profile:
|
||||
/bin/bash $(JWB_SCRIPT_DIR)/scm.sh clean -f $(PROFILE)
|
||||
119
make/py-defs.mk
Normal file
119
make/py-defs.mk
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
ENV_PYTHONPATH := $(PYTHONPATH)
|
||||
|
||||
include $(JWBDIR)/make/py-version.mk
|
||||
|
||||
ifeq ($(DEVELOPMENT),true)
|
||||
PY_SITE_PACKAGES_PATH := $(PREFIX)/python$(PYTHON_VERSION)/site-packages
|
||||
else
|
||||
PY_SITE_PACKAGES_PATH := $(shell $(PYTHON) -c "import site; print([d for d in site.getsitepackages() if d.find('/local/') == -1][0])")
|
||||
endif
|
||||
|
||||
ifndef PY_PREREQ_BUILD
|
||||
PY_PREREQ_BUILD := $(shell $(proj_query_cmd) pkg-requires --subsections jw -d ' ' -p --no-version build $(PROJECT))
|
||||
endif
|
||||
|
||||
ifndef PY_PREREQ_BUILD_DIRS
|
||||
PY_PREREQ_BUILD_DIRS := $(shell $(proj_query_cmd) proj-dir $(PY_PREREQ_BUILD))
|
||||
endif
|
||||
|
||||
PY_MYPY ?= mypy --ignore-missing-imports --no-namespace-packages
|
||||
|
||||
PY_SRC_PY ?= $(wildcard *.py)
|
||||
PY_ALL_PY = $(PY_SRC_PY)
|
||||
|
||||
ifneq ($(PYTHON_MAJOR),3)
|
||||
PY_PYC = $(patsubst %.py,%.pyc,$(PY_ALL_PY))
|
||||
else
|
||||
PY_CPYTHON_PREFIX := $(shell $(PYTHON) -c "import sys; print('cpython-{}{}'.format(sys.version_info[0],sys.version_info[1]))")
|
||||
PY_PYC = $(patsubst %.py,__pycache__/%.$(PY_CPYTHON_PREFIX).pyc,$(PY_ALL_PY))
|
||||
endif
|
||||
|
||||
ifneq ($(PY_INSTALL_DIR),)
|
||||
PY_INSTALL_DIR_PY ?= $(PY_INSTALL_DIR)
|
||||
endif
|
||||
|
||||
# deduce PY_INSTALL_DIR_PY from working directory below .. python/
|
||||
ifeq ($(PY_INSTALL_DIR_PY),)
|
||||
PY_INSTALL_PKG_MOD ?= $(shell $(ECHO) $(CWD) | $(SED) 's%.*/python/%%; s%/.*%%')
|
||||
PY_INSTALL_SUB_MOD ?= $(shell $(ECHO) $(CWD) | $(SED) "s%.*/$(PY_INSTALL_PKG_MOD)\(/\|$$\)%%")
|
||||
ifneq ($(PY_INSTALL_SUB_MOD),)
|
||||
PY_INSTALL_MOD ?= $(PY_INSTALL_PKG_MOD)/$(PY_INSTALL_SUB_MOD)
|
||||
else
|
||||
PY_INSTALL_MOD ?= $(PY_INSTALL_PKG_MOD)
|
||||
endif
|
||||
PY_MOD ?= $(subst /,.,$(PY_INSTALL_MOD))
|
||||
PY_ALL_PY += __init__.py
|
||||
PY_INSTALL_DIR_PY ?= $(ENV_PREFIX)$(PY_SITE_PACKAGES_PATH)/$(patsubst .,/,$(PY_INSTALL_MOD))
|
||||
else
|
||||
ifeq ($(PY_INSTALL_DIR_PY),)
|
||||
$(error PY_INSTALL_DIR_PY is undefined)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(PYTHON_MAJOR),3)
|
||||
PY_INSTALL_DIR_PYC ?= $(PY_INSTALL_DIR_PY)/__pycache__
|
||||
else
|
||||
PY_INSTALL_DIR_PYC ?= $(PY_INSTALL_DIR_PY)
|
||||
endif
|
||||
|
||||
PY_INSTALL ?= true
|
||||
PY_INSTALL_REG ?= true
|
||||
ifneq ($(PY_INSTALL),true)
|
||||
PY_INSTALL_REG = false
|
||||
endif
|
||||
PY_INSTALL_PYC ?= true
|
||||
ifneq ($(PY_INSTALL_REG),true)
|
||||
PY_INSTALL_PYC = false
|
||||
endif
|
||||
|
||||
PY_INSTALL_DIRS ?= $(sort $(PY_INSTALL_DIR_PY) $(PY_INSTALL_DIR_PYC))
|
||||
PY_INSTALLED_PY = $(addprefix $(PY_INSTALL_DIR_PY)/,$(sort $(PY_ALL_PY)))
|
||||
ifeq ($(PY_INSTALL_PYC),true)
|
||||
PY_INSTALLED_PYC = $(addprefix $(PY_INSTALL_DIR_PY)/,$(PY_PYC))
|
||||
endif
|
||||
ifeq ($(PY_INSTALL_REG),true)
|
||||
PY_INSTALLED_REG = $(PY_INSTALLED_PY) $(PY_INSTALLED_PYC)
|
||||
endif
|
||||
|
||||
ifeq ($(origin PYTHONPATH),undefined)
|
||||
PYTHONPATH := $(call proj_query, pythonpath $(PROJECT) $(PY_PREREQ_RUN))
|
||||
endif
|
||||
#PYTHONPATH = $(subst $(space),,$(ENV_PYTHONPATH)$(foreach d,$(PY_MODULE_DIRS),:$(d)))
|
||||
MYPYPATH = $(PYTHONPATH)
|
||||
export PYTHONPATH MYPYPATH
|
||||
|
||||
# not used anywhere
|
||||
#PY_PROJ_MODULE_DIRS ?= $(wildcard $(foreach subdir,/tools/python /src/python,$(addsuffix $(subdir),$(TOPDIR) $(PY_PREREQ_BUILD_DIRS))))
|
||||
#PY_MODULE_DIRS ?= $(PY_PROJ_MODULE_DIRS)
|
||||
#PY_MODULES ?= $(PY_PROJ_MODULES)
|
||||
#PY_PROJ_MODULES += $(dir $(wildcard $(PY_MODULE_DIRS)/*/__init__.py))
|
||||
|
||||
ifneq ($(PY_DEFS_MK_INCLUDED),true)
|
||||
all:
|
||||
clean: pyc.clean
|
||||
|
||||
echo-py:
|
||||
@echo "PYTHON = $(PYTHON)"
|
||||
@echo "PY_INSTALL_DIR_PY = $(PY_INSTALL_DIR_PY)"
|
||||
@echo "PROJECT = $(PROJECT)"
|
||||
@echo "PY_SITE_PACKAGES_PATH = $(PY_SITE_PACKAGES_PATH)"
|
||||
@echo "PY_MODULES = $(PY_MODULES)"
|
||||
@echo "PYTHONPATH = $(PYTHONPATH)"
|
||||
@echo "MYPYPATH = $(MYPYPATH)"
|
||||
@echo "PY_INSTALL_MOD = $(PY_INSTALL_MOD)"
|
||||
@echo "PY_INSTALL_SUB_MOD = $(PY_INSTALL_SUB_MOD)"
|
||||
# not used anywhere"
|
||||
#@echo "PY_PROJ_MODULE_DIRS = $(PY_PROJ_MODULE_DIRS)"
|
||||
#@echo "PY_MODULE_DIRS = $(PY_MODULE_DIRS)"
|
||||
|
||||
pyc.clean:
|
||||
$(RM) -rf $(wildcard *.pyc) __pycache__
|
||||
libpath: py-libpath
|
||||
py-libpath:
|
||||
@echo export PYTHONPATH=$(PYTHONPATH)
|
||||
@echo export MYPYPATH=$(MYPYPATH)
|
||||
endif
|
||||
|
||||
PY_DEFS_MK_INCLUDED := true
|
||||
|
||||
include $(JWBDIR)/make/ldlibpath.mk
|
||||
24
make/py-mod.mk
Normal file
24
make/py-mod.mk
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
include $(JWBDIR)/make/defs.mk
|
||||
include $(JWBDIR)/make/py-defs.mk
|
||||
include $(JWBDIR)/make/dirs.mk
|
||||
include $(JWBDIR)/make/dev-utils.mk
|
||||
|
||||
PY_INIT_TMPL = $(wildcard __init__.py.tmpl)
|
||||
PY_SED_EXTRACT_EXPORT ?= /\(\(class\|def\)\s\+[a-zA-Z_].*\|^ *\S\+\s*=.*\)\# *export/ !d; /^\s*\#/ d; s/\(async\)* *\(class\|def\) *//; s/[(:=].*//
|
||||
PY_INIT_FILTER ?= cat
|
||||
|
||||
#leftparen := (
|
||||
#PY_EXPORT ?= $(shell sed '/\(class\|def\) ..*\# *export/ !d; s/\(class\|def\) *//; s/[$(leftparen):].*//' $(PY_SRC_PY))
|
||||
|
||||
all: $(PY_PYC)
|
||||
install: install-dirs.done install-reg.done
|
||||
clean: py.clean
|
||||
distclean:
|
||||
|
||||
include $(JWBDIR)/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
|
||||
/bin/bash +H $(JWB_SCRIPT_DIR)/python-tools.sh create-init -m $(PY_MOD) -e "$(PY_SED_EXTRACT_EXPORT)" \
|
||||
$(filter-out __init__.py,$(PY_ALL_PY)) $(SUBDIRS_TO_ITERATE) | $(PY_INIT_FILTER) | tee -a $@.tmp
|
||||
mv $@.tmp $@
|
||||
14
make/py-mods.mk
Normal file
14
make/py-mods.mk
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
include $(JWBDIR)/make/defs.mk
|
||||
include $(JWBDIR)/make/py-defs.mk
|
||||
include $(JWBDIR)/make/dirs.mk
|
||||
include $(JWBDIR)/make/dev-utils.mk
|
||||
include $(JWBDIR)/make/py-rules.mk
|
||||
|
||||
all:
|
||||
install:
|
||||
clean: py.clean
|
||||
distclean:
|
||||
|
||||
ifeq ($(PY_RUN_CHECK_AFTER_BUILD),true)
|
||||
all: check
|
||||
endif
|
||||
33
make/py-rules.mk
Normal file
33
make/py-rules.mk
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
all:
|
||||
|
||||
py.clean:
|
||||
$(RM) -f *.done *.pyc *.rep
|
||||
/bin/bash $(JWB_SCRIPT_DIR)/scm.sh clean -f __init__.py
|
||||
$(RM) -rf __pycache__ .mypy_cache
|
||||
|
||||
install-dirs.done:
|
||||
$(INSTALL) -d -m $(PYJWBDIRMODE) -o $(PYJWBDIROWNER) -g $(PYJWBDIRGROUP) $(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_MAJOR),3)
|
||||
%.pyc: %.py
|
||||
else
|
||||
__pycache__/%.$(PY_CPYTHON_PREFIX).pyc: %.py
|
||||
endif
|
||||
$(PYTHON) -c "import py_compile; py_compile.compile(\"$<\", doraise=True)"
|
||||
|
||||
ifeq ($(PYTHON_MAJOR),3)
|
||||
$(PY_INSTALL_DIR_PY)/__pycache__/%.$(PY_CPYTHON_PREFIX).pyc: __pycache__/%.$(PY_CPYTHON_PREFIX).pyc
|
||||
else
|
||||
$(PY_INSTALL_DIR_PY)/%.pyc: %.pyc
|
||||
endif
|
||||
$(INSTALL) -p -m $(PYMODMODE) -o $(PYMODOWNER) -g $(PYMODGROUP) $< $@
|
||||
|
||||
check:
|
||||
$(PY_MYPY) $(shell /bin/bash $(JWB_SCRIPT_DIR)/scm.sh ls-files | grep '\.py$$')
|
||||
Loading…
Add table
Add a link
Reference in a new issue