blob: 4574ec9a68a69021995badb8a9f65d9a7ed8037f [file] [log] [blame]
Damien George136f6752014-01-07 14:54:15 +00001# where py object files go (they have a name prefix to prevent filename clashes)
Dave Hylandsc89c6812014-01-24 01:05:30 -08002PY_BUILD = $(BUILD)/py
Damien George136f6752014-01-07 14:54:15 +00003
Andrew Scheller70a7d7a2014-04-16 22:10:33 +01004# where autogenerated header files go
Damien Georged553be52014-04-17 18:03:27 +01005HEADER_BUILD = $(BUILD)/genhdr
Andrew Scheller70a7d7a2014-04-16 22:10:33 +01006
7# file containing qstr defs for the core Python bit
Damien George55baff42014-01-21 21:40:13 +00008PY_QSTR_DEFS = $(PY_SRC)/qstrdefs.h
9
Paul Sokolovsky1c1d902c2014-04-24 02:59:43 +030010# some code is performance bottleneck and compiled with other optimization options
11CSUPEROPT = -O3
12
Paul Sokolovskye0f5df52015-10-19 18:22:16 +030013INC += -I../lib/netutils
14
Paul Sokolovskyaaa88672015-10-06 18:10:00 +030015ifeq ($(MICROPY_PY_USSL),1)
16CFLAGS_MOD += -DMICROPY_PY_USSL=1 -I../lib/axtls/ssl -I../lib/axtls/crypto -I../lib/axtls/config
17LDFLAGS_MOD += -L../lib/axtls/_stage -laxtls
18endif
19
Paul Sokolovskye0d77402015-10-27 00:04:33 +030020#ifeq ($(MICROPY_PY_LWIP),1)
21#CFLAGS_MOD += -DMICROPY_PY_LWIP=1 -I../lib/lwip/src/include -I../lib/lwip/src/include/ipv4 -I../extmod/lwip-include
22#endif
23
24ifeq ($(MICROPY_PY_LWIP),1)
25LWIP_DIR = lib/lwip/src
26INC += -I../lib/lwip/src/include -I../lib/lwip/src/include/ipv4 -I../extmod/lwip-include
27CFLAGS_MOD += -DMICROPY_PY_LWIP=1
28SRC_MOD += extmod/modlwip.c lib/netutils/netutils.c
29SRC_MOD += $(addprefix $(LWIP_DIR)/,\
30 core/def.c \
31 core/dns.c \
32 core/init.c \
33 core/mem.c \
34 core/memp.c \
35 core/netif.c \
36 core/pbuf.c \
37 core/raw.c \
38 core/stats.c \
39 core/sys.c \
40 core/tcp.c \
41 core/tcp_in.c \
42 core/tcp_out.c \
43 core/timers.c \
44 core/udp.c \
45 core/ipv4/autoip.c \
46 core/ipv4/icmp.c \
47 core/ipv4/igmp.c \
48 core/ipv4/inet.c \
49 core/ipv4/inet_chksum.c \
50 core/ipv4/ip_addr.c \
51 core/ipv4/ip.c \
52 core/ipv4/ip_frag.c \
53 )
54ifeq ($(MICROPY_PY_LWIP_SLIP),1)
55CFLAGS_MOD += -DMICROPY_PY_LWIP_SLIP=1
56SRC_MOD += $(LWIP_DIR)/netif/slipif.c
57endif
58endif
59
Damien George136f6752014-01-07 14:54:15 +000060# py object files
Damien George136f6752014-01-07 14:54:15 +000061PY_O_BASENAME = \
Damien Georgeb4b10fd2015-01-01 23:30:53 +000062 mpstate.o \
Damien George136f6752014-01-07 14:54:15 +000063 nlrx86.o \
64 nlrx64.o \
65 nlrthumb.o \
Damien George2399aa02014-11-27 20:29:33 +000066 nlrxtensa.o \
Paul Sokolovsky3a83b802014-04-17 00:16:45 +030067 nlrsetjmp.o \
Damien George136f6752014-01-07 14:54:15 +000068 malloc.o \
Damien Georged3ebe482014-01-07 15:20:33 +000069 gc.o \
Damien George136f6752014-01-07 14:54:15 +000070 qstr.o \
71 vstr.o \
Damien George7f9d1d62015-04-09 23:56:15 +010072 mpprint.o \
Damien George136f6752014-01-07 14:54:15 +000073 unicode.o \
Damien George438c88d2014-02-22 19:25:23 +000074 mpz.o \
Damien George136f6752014-01-07 14:54:15 +000075 lexer.o \
Damien George9193f892014-01-08 15:28:26 +000076 lexerstr.o \
Damien George136f6752014-01-07 14:54:15 +000077 lexerunix.o \
78 parse.o \
79 scope.o \
80 compile.o \
81 emitcommon.o \
Damien George136f6752014-01-07 14:54:15 +000082 emitbc.o \
83 asmx64.o \
84 emitnx64.o \
Damien Georgec90f59e2014-09-06 23:06:36 +010085 asmx86.o \
86 emitnx86.o \
Damien George136f6752014-01-07 14:54:15 +000087 asmthumb.o \
88 emitnthumb.o \
89 emitinlinethumb.o \
Fabian Vogtfe3d16e2014-08-16 22:55:53 +020090 asmarm.o \
91 emitnarm.o \
Damien George8bfec2b2014-03-10 13:27:02 +000092 formatfloat.o \
Damien George06201ff2014-03-01 19:50:50 +000093 parsenumbase.o \
Damien George20773972014-02-22 18:12:43 +000094 parsenum.o \
Damien George2326d522014-03-27 23:26:35 +000095 emitglue.o \
Damien George136f6752014-01-07 14:54:15 +000096 runtime.o \
Damien George110ba352014-08-28 23:37:02 +010097 nativeglue.o \
Paul Sokolovsky23668692014-06-25 03:03:34 +030098 stackctrl.o \
Damien Georgea3f94e02014-04-20 00:13:22 +010099 argcheck.o \
Paul Sokolovsky8a8c1fc2015-01-01 09:29:28 +0200100 warning.o \
Damien George136f6752014-01-07 14:54:15 +0000101 map.o \
102 obj.o \
Paul Sokolovsky427905c2014-01-18 19:24:47 +0200103 objarray.o \
Damien George5aa311d2015-04-21 14:14:24 +0000104 objattrtuple.o \
Damien George136f6752014-01-07 14:54:15 +0000105 objbool.o \
106 objboundmeth.o \
107 objcell.o \
Damien George136f6752014-01-07 14:54:15 +0000108 objclosure.o \
109 objcomplex.o \
110 objdict.o \
John R. Lenton9daa7892014-01-14 23:55:01 +0000111 objenumerate.o \
Damien George136f6752014-01-07 14:54:15 +0000112 objexcept.o \
John R. Lentonfca456b2014-01-15 01:37:08 +0000113 objfilter.o \
Damien George136f6752014-01-07 14:54:15 +0000114 objfloat.o \
115 objfun.o \
116 objgenerator.o \
Damien George7c9c6672014-01-25 00:17:36 +0000117 objgetitemiter.o \
Damien George136f6752014-01-07 14:54:15 +0000118 objint.o \
Paul Sokolovsky966879c2014-01-17 20:01:36 +0200119 objint_longlong.o \
Damien George438c88d2014-02-22 19:25:23 +0000120 objint_mpz.o \
Damien George136f6752014-01-07 14:54:15 +0000121 objlist.o \
John R. Lenton39b174e2014-01-15 01:10:09 +0000122 objmap.o \
Damien George136f6752014-01-07 14:54:15 +0000123 objmodule.o \
Damien George3ec0a1a2014-03-22 21:31:28 +0000124 objobject.o \
Paul Sokolovsky1a1ccea2015-12-14 23:48:12 +0200125 objpolyiter.o \
Damien George777b0f32014-04-13 18:59:45 +0100126 objproperty.o \
Damien George136f6752014-01-07 14:54:15 +0000127 objnone.o \
Paul Sokolovskyd08fd682014-02-27 22:22:04 +0200128 objnamedtuple.o \
Damien George136f6752014-01-07 14:54:15 +0000129 objrange.o \
Damien George4c03b3a2014-08-12 18:33:40 +0100130 objreversed.o \
Damien George136f6752014-01-07 14:54:15 +0000131 objset.o \
Paul Sokolovsky76677272015-05-05 22:18:07 +0300132 objsingleton.o \
Damien George136f6752014-01-07 14:54:15 +0000133 objslice.o \
134 objstr.o \
Paul Sokolovsky97319122014-06-13 22:01:26 +0300135 objstrunicode.o \
Paul Sokolovskycb9dc082014-04-26 20:26:14 +0300136 objstringio.o \
Damien George136f6752014-01-07 14:54:15 +0000137 objtuple.o \
138 objtype.o \
Damien George55baff42014-01-21 21:40:13 +0000139 objzip.o \
Paul Sokolovsky68e7c512014-04-13 11:53:15 +0300140 opmethods.o \
Paul Sokolovsky439542f2014-01-21 00:19:19 +0200141 sequence.o \
Paul Sokolovskye98cf402014-01-08 02:43:48 +0200142 stream.o \
Paul Sokolovsky8bc35162014-02-14 17:16:35 +0200143 binary.o \
Damien George136f6752014-01-07 14:54:15 +0000144 builtinimport.o \
Damien Georgeca476792014-02-03 22:44:10 +0000145 builtinevex.o \
Damien Georgecaac5422014-03-25 14:18:18 +0000146 modarray.o \
Damien George78d702c2014-12-09 16:19:48 +0000147 modbuiltins.o \
Damien Georgecaac5422014-03-25 14:18:18 +0000148 modcollections.o \
Paul Sokolovskyf9e54e02014-05-06 02:16:43 +0300149 modgc.o \
Paul Sokolovsky98a627d2014-04-03 14:57:53 +0300150 modio.o \
Damien Georgecaac5422014-03-25 14:18:18 +0000151 modmath.o \
Damien Georgedbdfee12014-04-17 17:11:03 +0100152 modcmath.o \
Damien Georgecaac5422014-03-25 14:18:18 +0000153 modmicropython.o \
Paul Sokolovskye9db8402014-04-10 03:45:38 +0300154 modstruct.o \
Paul Sokolovsky5500cde2014-04-13 06:43:18 +0300155 modsys.o \
Damien George136f6752014-01-07 14:54:15 +0000156 vm.o \
Damien Georgeb534e1b2014-09-04 14:44:01 +0100157 bc.o \
Damien George136f6752014-01-07 14:54:15 +0000158 showbc.o \
159 repl.o \
Damien Georgeecf5b772014-04-04 11:13:51 +0000160 smallint.o \
Paul Sokolovsky640e0b22015-01-20 11:52:12 +0200161 frozenmod.o \
Paul Sokolovsky510296f2014-08-08 22:51:40 +0300162 ../extmod/moductypes.o \
Damien George612045f2014-09-17 22:56:34 +0100163 ../extmod/modujson.o \
Paul Sokolovskyc71e0452014-09-12 18:48:07 +0300164 ../extmod/modure.o \
Paul Sokolovsky34162872014-10-12 08:16:34 -0700165 ../extmod/moduzlib.o \
Damien Georgef5d69792014-10-22 17:37:18 +0000166 ../extmod/moduheapq.o \
Paul Sokolovskyf4b19c82014-11-22 01:19:13 +0200167 ../extmod/moduhashlib.o \
Paul Sokolovskybfdc2052014-11-29 06:19:30 +0200168 ../extmod/modubinascii.o \
Dave Hylandsf9251652015-12-12 17:15:33 -0500169 ../extmod/machine_mem.o \
Paul Sokolovskyaaa88672015-10-06 18:10:00 +0300170 ../extmod/modussl.o \
Paul Sokolovsky3a1bbcc2015-11-25 00:43:11 +0200171 ../extmod/fsusermount.o \
Paul Sokolovskyddea7cb2016-01-01 13:02:53 +0200172 ../extmod/moduos_dupterm.o \
Damien George136f6752014-01-07 14:54:15 +0000173
174# prepend the build destination prefix to the py object files
Dave Hylandsc89c6812014-01-24 01:05:30 -0800175PY_O = $(addprefix $(PY_BUILD)/, $(PY_O_BASENAME))
Damien George136f6752014-01-07 14:54:15 +0000176
Dave Hylandsbf7d6902014-04-03 16:32:58 -0700177# Anything that depends on FORCE will be considered out-of-date
178FORCE:
179.PHONY: FORCE
180
Damien George95f53462015-04-22 17:38:05 +0100181$(HEADER_BUILD)/mpversion.h: FORCE | $(HEADER_BUILD)
182 $(Q)$(PYTHON) $(PY_SRC)/makeversionhdr.py $@
Dave Hylandsbf7d6902014-04-03 16:32:58 -0700183
Paul Sokolovskya19ba5f2015-06-11 01:24:54 +0300184# mpconfigport.mk is optional, but changes to it may drastically change
185# overall config, so they need to be caught
186MPCONFIGPORT_MK = $(wildcard mpconfigport.mk)
187
Damien George55baff42014-01-21 21:40:13 +0000188# qstr data
189
Damien Georged553be52014-04-17 18:03:27 +0100190# Adding an order only dependency on $(HEADER_BUILD) causes $(HEADER_BUILD) to get
Dave Hylandsc89c6812014-01-24 01:05:30 -0800191# created before we run the script to generate the .h
Damien Georgedb52fd82015-05-30 23:14:34 +0100192# Note: we need to protect the qstr names from the preprocessor, so we wrap
193# the lines in "" and then unwrap after the preprocessor is finished.
Paul Sokolovskya19ba5f2015-06-11 01:24:54 +0300194$(HEADER_BUILD)/qstrdefs.generated.h: $(PY_QSTR_DEFS) $(QSTR_DEFS) $(PY_SRC)/makeqstrdata.py mpconfigport.h $(MPCONFIGPORT_MK) $(PY_SRC)/mpconfig.h | $(HEADER_BUILD)
Damien Georgedb52fd82015-05-30 23:14:34 +0100195 $(ECHO) "GEN $@"
196 $(Q)cat $(PY_QSTR_DEFS) $(QSTR_DEFS) | $(SED) 's/^Q(.*)/"&"/' | $(CPP) $(CFLAGS) - | sed 's/^"\(Q(.*)\)"/\1/' > $(HEADER_BUILD)/qstrdefs.preprocessed.h
197 $(Q)$(PYTHON) $(PY_SRC)/makeqstrdata.py $(HEADER_BUILD)/qstrdefs.preprocessed.h > $@
Damien George55baff42014-01-21 21:40:13 +0000198
199# emitters
200
Dave Hylandsc89c6812014-01-24 01:05:30 -0800201$(PY_BUILD)/emitnx64.o: CFLAGS += -DN_X64
202$(PY_BUILD)/emitnx64.o: py/emitnative.c
203 $(call compile_c)
Damien George136f6752014-01-07 14:54:15 +0000204
Damien Georgec90f59e2014-09-06 23:06:36 +0100205$(PY_BUILD)/emitnx86.o: CFLAGS += -DN_X86
206$(PY_BUILD)/emitnx86.o: py/emitnative.c
207 $(call compile_c)
208
Dave Hylandsc89c6812014-01-24 01:05:30 -0800209$(PY_BUILD)/emitnthumb.o: CFLAGS += -DN_THUMB
210$(PY_BUILD)/emitnthumb.o: py/emitnative.c
211 $(call compile_c)
Damien George136f6752014-01-07 14:54:15 +0000212
Fabian Vogtfe3d16e2014-08-16 22:55:53 +0200213$(PY_BUILD)/emitnarm.o: CFLAGS += -DN_ARM
214$(PY_BUILD)/emitnarm.o: py/emitnative.c
215 $(call compile_c)
216
Damien Georged3ebe482014-01-07 15:20:33 +0000217# optimising gc for speed; 5ms down to 4ms on pybv2
Paul Sokolovsky1c1d902c2014-04-24 02:59:43 +0300218$(PY_BUILD)/gc.o: CFLAGS += $(CSUPEROPT)
Damien Georged3ebe482014-01-07 15:20:33 +0000219
Damien George136f6752014-01-07 14:54:15 +0000220# optimising vm for speed, adds only a small amount to code size but makes a huge difference to speed (20% faster)
Paul Sokolovsky1c1d902c2014-04-24 02:59:43 +0300221$(PY_BUILD)/vm.o: CFLAGS += $(CSUPEROPT)
Paul Sokolovsky23f1b5f2014-12-28 07:44:09 +0200222# Optimizing vm.o for modern deeply pipelined CPUs with branch predictors
223# may require disabling tail jump optimization. This will make sure that
224# each opcode has its own dispatching jump which will improve branch
225# branch predictor efficiency.
226# http://article.gmane.org/gmane.comp.lang.lua.general/75426
227# http://hg.python.org/cpython/file/b127046831e2/Python/ceval.c#l828
228# http://www.emulators.com/docs/nx25_nostradamus.htm
229#-fno-crossjumping