py.mk 3.19 KB
Newer Older
Dave Hylands's avatar
Dave Hylands committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
##########
# The following should eventually go into a more central location
# when a reorg is done.
#
# Turn on increased build verbosity by defining BUILD_VERBOSE in your main
# Makefile or in your environment. You can also use V=1 on the make command
# line.
ifeq ("$(origin V)", "command line")
BUILD_VERBOSE=$(V)
endif
ifndef BUILD_VERBOSE
BUILD_VERBOSE = 0
endif
ifeq ($(BUILD_VERBOSE),0)
Q = @
else
Q =
endif
# Since this is a new feature, advertise it
ifeq ($(BUILD_VERBOSE),0)
$(info Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.)
endif
#
#########

26
27
# default settings; can be overriden in main Makefile

28
29
PY_SRC ?= ../py
BUILD ?= build
30
31
32
33

# to create the build directory

$(BUILD):
Dave Hylands's avatar
Dave Hylands committed
34
	$(Q)mkdir -p $@
35
36
37
38
39

# where py object files go (they have a name prefix to prevent filename clashes)

PY_BUILD = $(BUILD)/py.

40
41
42
43
# file containing qstr defs for the core Python bit

PY_QSTR_DEFS = $(PY_SRC)/qstrdefs.h

44
45
46
47
48
49
50
# py object files

PY_O_BASENAME = \
	nlrx86.o \
	nlrx64.o \
	nlrthumb.o \
	malloc.o \
51
	gc.o \
52
53
54
55
	qstr.o \
	vstr.o \
	unicode.o \
	lexer.o \
56
	lexerstr.o \
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
	lexerunix.o \
	parse.o \
	scope.o \
	compile.o \
	emitcommon.o \
	emitpass1.o \
	emitcpy.o \
	emitbc.o \
	asmx64.o \
	emitnx64.o \
	asmthumb.o \
	emitnthumb.o \
	emitinlinethumb.o \
	runtime.o \
	map.o \
xyb's avatar
xyb committed
72
	strtonum.o \
73
	obj.o \
74
	objarray.o \
75
76
77
78
79
80
	objbool.o \
	objboundmeth.o \
	objcell.o \
	objclosure.o \
	objcomplex.o \
	objdict.o \
John R. Lenton's avatar
John R. Lenton committed
81
	objenumerate.o \
82
	objexcept.o \
John R. Lenton's avatar
John R. Lenton committed
83
	objfilter.o \
84
85
86
87
	objfloat.o \
	objfun.o \
	objgenerator.o \
	objint.o \
88
	objint_longlong.o \
89
	objlist.o \
John R. Lenton's avatar
John R. Lenton committed
90
	objmap.o \
91
92
93
94
95
96
97
98
	objmodule.o \
	objnone.o \
	objrange.o \
	objset.o \
	objslice.o \
	objstr.o \
	objtuple.o \
	objtype.o \
99
	objzip.o \
100
	sequence.o \
101
	stream.o \
102
103
	builtin.o \
	builtinimport.o \
Damien George's avatar
Damien George committed
104
	builtineval.o \
105
	builtinmp.o \
106
107
108
109
110
111
112
113
	vm.o \
	showbc.o \
	repl.o \

# prepend the build destination prefix to the py object files

PY_O = $(addprefix $(PY_BUILD), $(PY_O_BASENAME))

114
115
116
117
118
119
120
121
122
123
# qstr data

$(PY_BUILD)qstr.o: $(PY_BUILD)qstrdefs.generated.h

$(PY_BUILD)qstrdefs.generated.h: $(PY_QSTR_DEFS) $(QSTR_DEFS) $(PY_SRC)/makeqstrdata.py
	$(ECHO) "makeqstrdata $(PY_QSTR_DEFS) $(QSTR_DEFS)"
	$(Q)python $(PY_SRC)/makeqstrdata.py $(PY_QSTR_DEFS) $(QSTR_DEFS) > $@

# emitters

124
$(PY_BUILD)emitnx64.o: $(PY_SRC)/emitnative.c $(PY_SRC)/emit.h mpconfigport.h
Dave Hylands's avatar
Dave Hylands committed
125
126
	$(ECHO) "CC $<"
	$(Q)$(CC) $(CFLAGS) -DN_X64 -c -o $@ $<
127
128

$(PY_BUILD)emitnthumb.o: $(PY_SRC)/emitnative.c $(PY_SRC)/emit.h mpconfigport.h
Dave Hylands's avatar
Dave Hylands committed
129
130
	$(ECHO) "CC $<"
	$(Q)$(CC) $(CFLAGS) -DN_THUMB -c -o $@ $<
131

132
133
# general source files

134
$(PY_BUILD)%.o: $(PY_SRC)/%.S
Dave Hylands's avatar
Dave Hylands committed
135
136
	$(ECHO) "CC $<"
	$(Q)$(CC) $(CFLAGS) -c -o $@ $<
137

138
$(PY_BUILD)%.o: $(PY_SRC)/%.c mpconfigport.h $(PY_SRC)/qstr.h $(PY_QSTR_DEFS) $(QSTR_DEFS)
Dave Hylands's avatar
Dave Hylands committed
139
140
	$(ECHO) "CC $<"
	$(Q)$(CC) $(CFLAGS) -c -o $@ $<
141

142
143
# optimising gc for speed; 5ms down to 4ms on pybv2
$(PY_BUILD)gc.o: $(PY_SRC)/gc.c
Dave Hylands's avatar
Dave Hylands committed
144
145
	$(ECHO) "CC $<"
	$(Q)$(CC) $(CFLAGS) -O3 -c -o $@ $<
146

147
148
# optimising vm for speed, adds only a small amount to code size but makes a huge difference to speed (20% faster)
$(PY_BUILD)vm.o: $(PY_SRC)/vm.c
Dave Hylands's avatar
Dave Hylands committed
149
150
	$(ECHO) "CC $<"
	$(Q)$(CC) $(CFLAGS) -O3 -c -o $@ $<
151
152
153
154
155

# header dependencies

$(PY_BUILD)parse.o: $(PY_SRC)/grammar.h
$(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