py.mk 3.5 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
# where autogenerated header files go
5
HEADER_BUILD = $(BUILD)/genhdr
6

7
# file containing qstr defs for the core Python bit
8
9
PY_QSTR_DEFS = $(PY_SRC)/qstrdefs.h

10
11
12
# some code is performance bottleneck and compiled with other optimization options
CSUPEROPT = -O3

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

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

113
114
115
116
# Anything that depends on FORCE will be considered out-of-date
FORCE:
.PHONY: FORCE

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

121
122
# qstr data

123
# Adding an order only dependency on $(HEADER_BUILD) causes $(HEADER_BUILD) to get
124
# created before we run the script to generate the .h
125
126
127
$(HEADER_BUILD)/qstrdefs.generated.h: $(PY_QSTR_DEFS) $(QSTR_DEFS) $(PY_SRC)/makeqstrdata.py mpconfigport.h $(PY_SRC)/mpconfig.h | $(HEADER_BUILD)
	$(ECHO) "CPP $<"
	$(Q)$(CPP) $(CFLAGS) $(PY_QSTR_DEFS) -o $(HEADER_BUILD)/qstrdefs.preprocessed.h
128
	$(ECHO) "makeqstrdata $(PY_QSTR_DEFS) $(QSTR_DEFS)"
129
	$(Q)$(PYTHON) $(PY_SRC)/makeqstrdata.py $(HEADER_BUILD)/qstrdefs.preprocessed.h $(QSTR_DEFS) > $@
130

131
132
133
134
135
# 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.
136
$(PY_O): | $(HEADER_BUILD)/qstrdefs.generated.h $(HEADER_BUILD)/py-version.h
137

138
# emitters
139

140
141
142
$(PY_BUILD)/emitnx64.o: CFLAGS += -DN_X64
$(PY_BUILD)/emitnx64.o: py/emitnative.c
	$(call compile_c)
143

144
145
146
$(PY_BUILD)/emitnthumb.o: CFLAGS += -DN_THUMB
$(PY_BUILD)/emitnthumb.o: py/emitnative.c
	$(call compile_c)
147

148
# optimising gc for speed; 5ms down to 4ms on pybv2
149
$(PY_BUILD)/gc.o: CFLAGS += $(CSUPEROPT)
150

151
# optimising vm for speed, adds only a small amount to code size but makes a huge difference to speed (20% faster)
152
$(PY_BUILD)/vm.o: CFLAGS += $(CSUPEROPT)
153