py.mk 2.76 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
28
29
30
31
32
33
34
35
36
37
38
# default settings; can be overriden in main Makefile

ifndef PY_SRC
PY_SRC = ../py
endif

ifndef BUILD
BUILD = build
endif

# to create the build directory

$(BUILD):
Dave Hylands's avatar
Dave Hylands committed
39
	$(Q)mkdir -p $@
40
41
42
43
44
45
46
47
48
49
50
51

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

PY_BUILD = $(BUILD)/py.

# py object files

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

# prepend the build destination prefix to the py object files

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

$(PY_BUILD)emitnx64.o: $(PY_SRC)/emitnative.c $(PY_SRC)/emit.h mpconfigport.h
Dave Hylands's avatar
Dave Hylands committed
114
115
	$(ECHO) "CC $<"
	$(Q)$(CC) $(CFLAGS) -DN_X64 -c -o $@ $<
116
117

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

$(PY_BUILD)%.o: $(PY_SRC)/%.S
Dave Hylands's avatar
Dave Hylands committed
122
123
	$(ECHO) "CC $<"
	$(Q)$(CC) $(CFLAGS) -c -o $@ $<
124
125

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

129
130
# 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
131
132
	$(ECHO) "CC $<"
	$(Q)$(CC) $(CFLAGS) -O3 -c -o $@ $<
133

134
135
# 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
136
137
	$(ECHO) "CC $<"
	$(Q)$(CC) $(CFLAGS) -O3 -c -o $@ $<
138
139
140
141
142
143
144

# header dependencies

$(PY_BUILD)parse.o: $(PY_SRC)/grammar.h
$(PY_BUILD)compile.o: $(PY_SRC)/grammar.h
$(PY_BUILD)/emitcpy.o: $(PY_SRC)/emit.h
$(PY_BUILD)emitbc.o: $(PY_SRC)/emit.h