|
1 | | -########## |
2 | | -# The following should eventually go into a more central location |
3 | | -# when a reorg is done. |
4 | | -# |
5 | | -# Turn on increased build verbosity by defining BUILD_VERBOSE in your main |
6 | | -# Makefile or in your environment. You can also use V=1 on the make command |
7 | | -# line. |
8 | | -ifeq ("$(origin V)", "command line") |
9 | | -BUILD_VERBOSE=$(V) |
10 | | -endif |
11 | | -ifndef BUILD_VERBOSE |
12 | | -BUILD_VERBOSE = 0 |
13 | | -endif |
14 | | -ifeq ($(BUILD_VERBOSE),0) |
15 | | -Q = @ |
16 | | -else |
17 | | -Q = |
18 | | -endif |
19 | | -# Since this is a new feature, advertise it |
20 | | -ifeq ($(BUILD_VERBOSE),0) |
21 | | -$(info Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.) |
22 | | -endif |
23 | | -# |
24 | | -######### |
25 | | - |
26 | | -# default settings; can be overriden in main Makefile |
27 | | - |
28 | | -PY_SRC ?= ../py |
29 | | -BUILD ?= build |
30 | | - |
31 | | -# to create the build directory |
32 | | - |
33 | | -$(BUILD): |
34 | | - $(Q)mkdir -p $@ |
35 | | - |
36 | 1 | # where py object files go (they have a name prefix to prevent filename clashes) |
37 | | - |
38 | | -PY_BUILD = $(BUILD)/py. |
| 2 | +PY_BUILD = $(BUILD)/py |
39 | 3 |
|
40 | 4 | # file containing qstr defs for the core Python bit |
41 | 5 |
|
42 | 6 | PY_QSTR_DEFS = $(PY_SRC)/qstrdefs.h |
43 | 7 |
|
44 | 8 | # py object files |
45 | | - |
46 | 9 | PY_O_BASENAME = \ |
47 | 10 | nlrx86.o \ |
48 | 11 | nlrx64.o \ |
@@ -108,50 +71,37 @@ PY_O_BASENAME = \ |
108 | 71 | repl.o \ |
109 | 72 |
|
110 | 73 | # prepend the build destination prefix to the py object files |
111 | | - |
112 | | -PY_O = $(addprefix $(PY_BUILD), $(PY_O_BASENAME)) |
| 74 | +PY_O = $(addprefix $(PY_BUILD)/, $(PY_O_BASENAME)) |
113 | 75 |
|
114 | 76 | # qstr data |
115 | 77 |
|
116 | | -$(PY_BUILD)qstr.o: $(PY_BUILD)qstrdefs.generated.h |
117 | | - |
118 | | -$(PY_BUILD)qstrdefs.generated.h: $(PY_QSTR_DEFS) $(QSTR_DEFS) $(PY_SRC)/makeqstrdata.py |
| 78 | +# Adding an order only dependency on $(PY_BUILD) causes $(PY_BUILD) to get |
| 79 | +# created before we run the script to generate the .h |
| 80 | +$(PY_BUILD)/qstrdefs.generated.h: | $(PY_BUILD) |
| 81 | +$(PY_BUILD)/qstrdefs.generated.h: $(PY_QSTR_DEFS) $(QSTR_DEFS) $(PY_SRC)/makeqstrdata.py |
119 | 82 | $(ECHO) "makeqstrdata $(PY_QSTR_DEFS) $(QSTR_DEFS)" |
120 | 83 | $(Q)python $(PY_SRC)/makeqstrdata.py $(PY_QSTR_DEFS) $(QSTR_DEFS) > $@ |
121 | 84 |
|
122 | | -# emitters |
123 | | - |
124 | | -$(PY_BUILD)emitnx64.o: $(PY_SRC)/emitnative.c $(PY_SRC)/emit.h mpconfigport.h |
125 | | - $(ECHO) "CC $<" |
126 | | - $(Q)$(CC) $(CFLAGS) -DN_X64 -c -o $@ $< |
| 85 | +# We don't know which source files actually need the generated.h (since |
| 86 | +# it is #included from str.h). The compiler generated dependencies will cause |
| 87 | +# the right .o's to get recompiled if the generated.h file changes. Adding |
| 88 | +# an order-only dependendency to all of the .o's will cause the generated .h |
| 89 | +# to get built before we try to compile any of them. |
| 90 | +$(PY_O): | $(PY_BUILD)/qstrdefs.generated.h |
127 | 91 |
|
128 | | -$(PY_BUILD)emitnthumb.o: $(PY_SRC)/emitnative.c $(PY_SRC)/emit.h mpconfigport.h |
129 | | - $(ECHO) "CC $<" |
130 | | - $(Q)$(CC) $(CFLAGS) -DN_THUMB -c -o $@ $< |
131 | | - |
132 | | -# general source files |
| 92 | +# emitters |
133 | 93 |
|
134 | | -$(PY_BUILD)%.o: $(PY_SRC)/%.S |
135 | | - $(ECHO) "CC $<" |
136 | | - $(Q)$(CC) $(CFLAGS) -c -o $@ $< |
| 94 | +$(PY_BUILD)/emitnx64.o: CFLAGS += -DN_X64 |
| 95 | +$(PY_BUILD)/emitnx64.o: py/emitnative.c |
| 96 | + $(call compile_c) |
137 | 97 |
|
138 | | -$(PY_BUILD)%.o: $(PY_SRC)/%.c mpconfigport.h $(PY_SRC)/qstr.h $(PY_QSTR_DEFS) $(QSTR_DEFS) |
139 | | - $(ECHO) "CC $<" |
140 | | - $(Q)$(CC) $(CFLAGS) -c -o $@ $< |
| 98 | +$(PY_BUILD)/emitnthumb.o: CFLAGS += -DN_THUMB |
| 99 | +$(PY_BUILD)/emitnthumb.o: py/emitnative.c |
| 100 | + $(call compile_c) |
141 | 101 |
|
142 | 102 | # optimising gc for speed; 5ms down to 4ms on pybv2 |
143 | | -$(PY_BUILD)gc.o: $(PY_SRC)/gc.c |
144 | | - $(ECHO) "CC $<" |
145 | | - $(Q)$(CC) $(CFLAGS) -O3 -c -o $@ $< |
| 103 | +$(PY_BUILD)gc.o: CFLAGS += -O3 |
146 | 104 |
|
147 | 105 | # optimising vm for speed, adds only a small amount to code size but makes a huge difference to speed (20% faster) |
148 | | -$(PY_BUILD)vm.o: $(PY_SRC)/vm.c |
149 | | - $(ECHO) "CC $<" |
150 | | - $(Q)$(CC) $(CFLAGS) -O3 -c -o $@ $< |
151 | | - |
152 | | -# header dependencies |
| 106 | +$(PY_BUILD)vm.o: CFLAGS += -O3 |
153 | 107 |
|
154 | | -$(PY_BUILD)parse.o: $(PY_SRC)/grammar.h |
155 | | -$(PY_BUILD)compile.o: $(PY_SRC)/grammar.h |
156 | | -$(PY_BUILD)emitcpy.o: $(PY_SRC)/emit.h |
157 | | -$(PY_BUILD)emitbc.o: $(PY_SRC)/emit.h |
0 commit comments