py.mk 3.81 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
	scope.o \
	compile.o \
	emitcommon.o \
	emitpass1.o \
	emitcpy.o \
	emitbc.o \
	asmx64.o \
	emitnx64.o \
38
39
	asmx86.o \
	emitnx86.o \
40
41
42
	asmthumb.o \
	emitnthumb.o \
	emitinlinethumb.o \
Fabian Vogt's avatar
Fabian Vogt committed
43
44
	asmarm.o \
	emitnarm.o \
45
	formatfloat.o \
46
	parsenumbase.o \
47
	parsenum.o \
48
	emitglue.o \
49
	runtime.o \
50
	nativeglue.o \
51
	stackctrl.o \
52
	argcheck.o \
53
54
	map.o \
	obj.o \
55
	objarray.o \
56
57
58
59
60
61
	objbool.o \
	objboundmeth.o \
	objcell.o \
	objclosure.o \
	objcomplex.o \
	objdict.o \
John R. Lenton's avatar
John R. Lenton committed
62
	objenumerate.o \
63
	objexcept.o \
John R. Lenton's avatar
John R. Lenton committed
64
	objfilter.o \
65
66
67
	objfloat.o \
	objfun.o \
	objgenerator.o \
68
	objgetitemiter.o \
69
	objint.o \
70
	objint_longlong.o \
71
	objint_mpz.o \
72
	objlist.o \
John R. Lenton's avatar
John R. Lenton committed
73
	objmap.o \
74
	objmodule.o \
Damien George's avatar
Damien George committed
75
	objobject.o \
76
	objproperty.o \
77
	objnone.o \
78
	objnamedtuple.o \
79
	objrange.o \
80
	objreversed.o \
81
82
83
	objset.o \
	objslice.o \
	objstr.o \
84
	objstrunicode.o \
85
	objstringio.o \
86
87
	objtuple.o \
	objtype.o \
88
	objzip.o \
89
	opmethods.o \
90
	sequence.o \
91
	stream.o \
92
	binary.o \
93
94
	builtin.o \
	builtinimport.o \
Damien George's avatar
Damien George committed
95
	builtinevex.o \
96
97
98
	builtintables.o \
	modarray.o \
	modcollections.o \
99
	modgc.o \
Paul Sokolovsky's avatar
Paul Sokolovsky committed
100
	modio.o \
101
	modmath.o \
102
	modcmath.o \
103
	modmicropython.o \
104
	modstruct.o \
105
	modsys.o \
106
	vm.o \
107
	bc.o \
108
109
	showbc.o \
	repl.o \
110
	smallint.o \
Dave Hylands's avatar
Dave Hylands committed
111
	pfenv.o \
112
	pfenv_printf.o \
113
	../extmod/moductypes.o \
114
	../extmod/modujson.o \
115
	../extmod/modure.o \
116
	../extmod/moduzlib.o \
117
118

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

121
122
123
124
# Anything that depends on FORCE will be considered out-of-date
FORCE:
.PHONY: FORCE

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

129
130
# qstr data

131
# Adding an order only dependency on $(HEADER_BUILD) causes $(HEADER_BUILD) to get
132
# created before we run the script to generate the .h
133
134
135
$(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
136
	$(ECHO) "makeqstrdata $(PY_QSTR_DEFS) $(QSTR_DEFS)"
137
	$(Q)$(PYTHON) $(PY_SRC)/makeqstrdata.py $(HEADER_BUILD)/qstrdefs.preprocessed.h $(QSTR_DEFS) > $@
138

139
140
141
142
143
# 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.
144
$(PY_O): | $(HEADER_BUILD)/qstrdefs.generated.h $(HEADER_BUILD)/py-version.h
145

146
# emitters
147

148
149
150
$(PY_BUILD)/emitnx64.o: CFLAGS += -DN_X64
$(PY_BUILD)/emitnx64.o: py/emitnative.c
	$(call compile_c)
151

152
153
154
155
$(PY_BUILD)/emitnx86.o: CFLAGS += -DN_X86
$(PY_BUILD)/emitnx86.o: py/emitnative.c
	$(call compile_c)

156
157
158
$(PY_BUILD)/emitnthumb.o: CFLAGS += -DN_THUMB
$(PY_BUILD)/emitnthumb.o: py/emitnative.c
	$(call compile_c)
159

Fabian Vogt's avatar
Fabian Vogt committed
160
161
162
163
$(PY_BUILD)/emitnarm.o: CFLAGS += -DN_ARM
$(PY_BUILD)/emitnarm.o: py/emitnative.c
	$(call compile_c)

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

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