summaryrefslogtreecommitdiff
path: root/project/pycgen.mk
blob: 0c15bf9f965bb7d6fc5ea1ef3b2b8fab15c326a9 (plain)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
PYCGEN        = $(CURDIR)/$(PYCOMPILE)

PYDIST_ENCDIR = $(PYDIST_PYCDIR)/./encodings
PYDIST_IMPDIR = $(PYDIST_PYCDIR)/./importlib
PYDIST_COLDIR = $(PYDIST_PYCDIR)/./collections
PYDIST_URLDIR = $(PYDIST_PYCDIR)/./urllib

PYCGEN_PYCDIR = $(PYCOMPILE_DIR)/$(PYDIST_PYCDIR)/.
PYCGEN_ENCDIR = $(PYCOMPILE_DIR)/$(PYDIST_PYCDIR)/./encodings
PYCGEN_IMPDIR = $(PYCOMPILE_DIR)/$(PYDIST_PYCDIR)/./importlib
PYCGEN_COLDIR = $(PYCOMPILE_DIR)/$(PYDIST_PYCDIR)/./collections
PYCGEN_URLDIR = $(PYCOMPILE_DIR)/$(PYDIST_PYCDIR)/./urllib

PYCGEN_CFGDAT = $(PYCOMPILE_DIR)/$(PYDIST_PYCDIR)/./_sysconfigdata_$(PYTHON_ABIFL)_$(NATIVE_OS)_.py
PYCGEN_PYSRCS = $(PYDIST_SRCS:$(PYDIST_PYCDIR)/./%.py=$(PYCGEN_PYCDIR)/%.py)
PYCGEN_PYENCS = $(PYDIST_ENCODINGS_SRCS:$(PYDIST_ENCDIR)/%.py=$(PYCGEN_ENCDIR)/%.py)
PYCGEN_PYIMPS = $(PYDIST_IMPORTLIB_SRCS:$(PYDIST_IMPDIR)/%.py=$(PYCGEN_IMPDIR)/%.py)
PYCGEN_PYCOLS = $(PYDIST_COLLECTIONS_SRCS:$(PYDIST_COLDIR)/%.py=$(PYCGEN_COLDIR)/%.py)
PYCGEN_PYURLS = $(PYDIST_URLLIB_SRCS:$(PYDIST_URLDIR)/%.py=$(PYCGEN_URLDIR)/%.py)

$(PYDIST_PYCDIR)/./_sysconfigdata_$(PYTHON_ABIFL)_$(PYTHON_PLATFORM)_.py:
		mkdir -p $(PYDIST_PYCDIR)
		printf 'build_time_vars = {\n\t%s: %s\n}\n' \
			"'VERSION'" "'"$(PYTHON_MAJOR).$(PYTHON_MINOR)"'" > $@

$(PYCGEN_CFGDAT): $(PYCOMPILE_DIR)/tree.tag
		printf 'build_time_vars = {\n\t%s: %s\n}\n' \
			"'VERSION'" "'"$(PYTHON_MAJOR).$(PYTHON_MINOR)"'" > $@

$(PYCOMPILE_DIR)/$(PYDIST_PYCDIR)/./%.py: $(SOURCE_DIR)/Lib/%.py $(PYCOMPILE_DIR)/tree.tag
		PYCOPY_PYTHON=$(PYCOMPILE) \
		PYCOPY_PREFIX=$(PYCOMPILE_PREFIX) \
		PYCOPY_DSTDIR=$(PYCOMPILE_DIR)/$(PYDIST_PYCDIR) \
		$(PYCOPY) $<

$(PYCOMPILE_DIR)/$(PYDIST_PYCDIR)/./encodings/%.py: $(SOURCE_DIR)/Lib/encodings/%.py $(PYCOMPILE_DIR)/tree.tag
		PYCOPY_PYTHON=$(PYCOMPILE) \
		PYCOPY_PREFIX=$(PYCOMPILE_PREFIX) \
		PYCOPY_DSTDIR=$(PYCOMPILE_DIR)/$(PYDIST_PYCDIR)/encodings \
		$(PYCOPY) $<

$(PYCOMPILE_DIR)/$(PYDIST_PYCDIR)/./importlib/%.py: $(SOURCE_DIR)/Lib/importlib/%.py $(PYCOMPILE_DIR)/tree.tag
		PYCOPY_PYTHON=$(PYCOMPILE) \
		PYCOPY_PREFIX=$(PYCOMPILE_PREFIX) \
		PYCOPY_DSTDIR=$(PYCOMPILE_DIR)/$(PYDIST_PYCDIR)/importlib \
		$(PYCOPY) $<

$(PYCOMPILE_DIR)/$(PYDIST_PYCDIR)/./collections/%.py: $(SOURCE_DIR)/Lib/collections/%.py $(PYCOMPILE_DIR)/tree.tag
		PYCOPY_PYTHON=$(PYCOMPILE) \
		PYCOPY_PREFIX=$(PYCOMPILE_PREFIX) \
		PYCOPY_DSTDIR=$(PYCOMPILE_DIR)/$(PYDIST_PYCDIR)/collections \
		$(PYCOPY) $<

$(PYCOMPILE_DIR)/$(PYDIST_PYCDIR)/./urllib/%.py: $(SOURCE_DIR)/Lib/urllib/%.py $(PYCOMPILE_DIR)/tree.tag
		PYCOPY_PYTHON=$(PYCOMPILE) \
		PYCOPY_PREFIX=$(PYCOMPILE_PREFIX) \
		PYCOPY_DSTDIR=$(PYCOMPILE_DIR)/$(PYDIST_PYCDIR)/urllib \
		$(PYCOPY) $<

$(PYDIST_PYCDIR)/./lib2to3/tests/data/%.pyx: $(PYCOMPILE_DIR)/tree.tag
$(PYDIST_PYCDIR)/./lib2to3/tests/data/%.pyx: $(PYDIST_PYCDIR)/./lib2to3/tests/data/%.py
		touch $@

PYCGEN_SRCS = \
	$(PYCGEN_CFGDAT) \
	$(PYCGEN_PYSRCS) \
	$(PYCGEN_PYENCS) \
	$(PYCGEN_PYIMPS) \
	$(PYCGEN_PYCOLS) \
	$(PYCGEN_PYURLS) \

%.pyx: %.py	$(PYCOMPILE) $(PYCGEN_SRCS)
		PYCGEN_PYTHON=$(PYCGEN_PYTHON) \
		$(PYCGEN) -m py_compile $<
		touch $@

PYCGEN_OBJS   = $(PYDIST_PY_SRCS:%.py=%.pyx)

pycgen-deps:	$(PYCGEN_SRCS)

pycgen-objs:	$(PYCGEN_OBJS)

all:		pycgen-objs

pycgen-objs-clean:
	rm -f $(PYCGEN_PYSRCS)
	rm -f $(PYCGEN_PYENCS)
	rm -f $(PYCGEN_PYIMPS)
	rm -f $(PYCGEN_PYCOLS)
	rm -f $(PYCGEN_CFGDAT)
	rm -f $(PYCGEN_OBJS)

clean:	pycgen-objs-clean

.PHONY:	pycgen-deps
.PHONY:	pycgen-objs
.PHONY:	pycgen-objs-clean