py.mk 3.08 KB
Newer Older
1
# where py object files go (they have a name prefix to prevent filename clashes)
2
PY_BUILD = $(BUILD)/py
3

4
5
6
7
# file containing qstr defs for the core Python bit

PY_QSTR_DEFS = $(PY_SRC)/qstrdefs.h

8
9
10
11
12
13
# py object files
PY_O_BASENAME = \
	nlrx86.o \
	nlrx64.o \
	nlrthumb.o \
	malloc.o \
14
	gc.o \
15
16
17
	qstr.o \
	vstr.o \
	unicode.o \
18
	mpz.o \
19
	lexer.o \
20
	lexerstr.o \
21
22
	lexerunix.o \
	parse.o \
23
	parsehelper.o \
24
25
26
27
28
29
30
31
32
33
34
	scope.o \
	compile.o \
	emitcommon.o \
	emitpass1.o \
	emitcpy.o \
	emitbc.o \
	asmx64.o \
	emitnx64.o \
	asmthumb.o \
	emitnthumb.o \
	emitinlinethumb.o \
35
	formatfloat.o \
36
	parsenumbase.o \
37
	parsenum.o \
38
	emitglue.o \
39
40
41
	runtime.o \
	map.o \
	obj.o \
42
	objarray.o \
43
44
45
46
47
48
	objbool.o \
	objboundmeth.o \
	objcell.o \
	objclosure.o \
	objcomplex.o \
	objdict.o \
John R. Lenton's avatar
John R. Lenton committed
49
	objenumerate.o \
50
	objexcept.o \
John R. Lenton's avatar
John R. Lenton committed
51
	objfilter.o \
52
53
54
	objfloat.o \
	objfun.o \
	objgenerator.o \
55
	objgetitemiter.o \
56
	objint.o \
57
	objint_longlong.o \
58
	objint_mpz.o \
59
	objlist.o \
John R. Lenton's avatar
John R. Lenton committed
60
	objmap.o \
61
	objmodule.o \
Damien George's avatar
Damien George committed
62
	objobject.o \
63
	objnone.o \
64
	objnamedtuple.o \
65
66
67
68
69
70
	objrange.o \
	objset.o \
	objslice.o \
	objstr.o \
	objtuple.o \
	objtype.o \
71
	objzip.o \
72
	opmethods.o \
73
	sequence.o \
74
	stream.o \
75
	binary.o \
76
77
	builtin.o \
	builtinimport.o \
Damien George's avatar
Damien George committed
78
	builtinevex.o \
79
80
81
	builtintables.o \
	modarray.o \
	modcollections.o \
Paul Sokolovsky's avatar
Paul Sokolovsky committed
82
	modio.o \
83
84
	modmath.o \
	modmicropython.o \
85
	modstruct.o \
86
87
88
	vm.o \
	showbc.o \
	repl.o \
89
	smallint.o \
Dave Hylands's avatar
Dave Hylands committed
90
	pfenv.o \
91
92

# prepend the build destination prefix to the py object files
93
PY_O = $(addprefix $(PY_BUILD)/, $(PY_O_BASENAME))
94

95
96
97
98
99
100
101
102
# Anything that depends on FORCE will be considered out-of-date
FORCE:
.PHONY: FORCE

$(PY_BUILD)/py-version.h: FORCE
	$(Q)$(PY_SRC)/py-version.sh > $@.tmp
	$(Q)if [ -f "$@" ] && cmp -s $@ $@.tmp; then rm $@.tmp; else echo "Generating $@"; mv $@.tmp $@; fi

103
104
# qstr data

105
106
# Adding an order only dependency on $(PY_BUILD) causes $(PY_BUILD) to get
# created before we run the script to generate the .h
107
$(PY_BUILD)/qstrdefs.generated.h: | $(PY_BUILD)/
108
$(PY_BUILD)/qstrdefs.generated.h: $(PY_QSTR_DEFS) $(QSTR_DEFS) $(PY_SRC)/makeqstrdata.py mpconfigport.h $(PY_SRC)/mpconfig.h
109
	$(ECHO) "makeqstrdata $(PY_QSTR_DEFS) $(QSTR_DEFS)"
110
111
	$(CPP) $(CFLAGS) $(PY_QSTR_DEFS) -o $(PY_BUILD)/qstrdefs.preprocessed.h
	$(Q)$(PYTHON) $(PY_SRC)/makeqstrdata.py $(PY_BUILD)/qstrdefs.preprocessed.h $(QSTR_DEFS) > $@
112

113
114
115
116
117
# We don't know which source files actually need the generated.h (since
# it is #included from str.h). The compiler generated dependencies will cause
# the right .o's to get recompiled if the generated.h file changes. Adding
# an order-only dependendency to all of the .o's will cause the generated .h
# to get built before we try to compile any of them.
118
$(PY_O): | $(PY_BUILD)/qstrdefs.generated.h $(PY_BUILD)/py-version.h
119

120
# emitters
121

122
123
124
$(PY_BUILD)/emitnx64.o: CFLAGS += -DN_X64
$(PY_BUILD)/emitnx64.o: py/emitnative.c
	$(call compile_c)
125

126
127
128
$(PY_BUILD)/emitnthumb.o: CFLAGS += -DN_THUMB
$(PY_BUILD)/emitnthumb.o: py/emitnative.c
	$(call compile_c)
129

130
# optimising gc for speed; 5ms down to 4ms on pybv2
131
$(PY_BUILD)/gc.o: CFLAGS += -O3
132

133
# optimising vm for speed, adds only a small amount to code size but makes a huge difference to speed (20% faster)
134
$(PY_BUILD)/vm.o: CFLAGS += -O3
135