Makefile 1.84 KB
Newer Older
1
2
3
4
PYSRC=../py
BUILD=build

CC = gcc
5
CFLAGS = -I. -I$(PYSRC) -Wall -Werror -ansi -std=gnu99 -Os #-DNDEBUG
6
LDFLAGS = -lm
7
8
9
10
11

SRC_C = \
	main.c \

PY_O = \
12
	nlrx86.o \
13
	nlrx64.o \
14
	nlrthumb.o \
15
16
	malloc.o \
	qstr.o \
17
	vstr.o \
18
	unicode.o \
19
	lexer.o \
20
	lexerunix.o \
21
22
23
24
25
26
27
28
29
30
31
32
33
	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 \
34
35
	map.o \
	obj.o \
36
37
38
39
40
41
42
43
44
45
46
47
	objbool.o \
	objboundmeth.o \
	objcell.o \
	objclass.o \
	objclosure.o \
	objcomplex.o \
	objdict.o \
	objexcept.o \
	objfloat.o \
	objfun.o \
	objgenerator.o \
	objinstance.o \
48
	objint.o \
49
	objlist.o \
50
	objmodule.o \
51
52
53
	objnone.o \
	objrange.o \
	objset.o \
54
	objslice.o \
55
56
57
	objstr.o \
	objtuple.o \
	objtype.o \
58
	builtin.o \
59
	builtinimport.o \
60
	vm.o \
Damien's avatar
Damien committed
61
	showbc.o \
62
	repl.o \
63
64

OBJ = $(addprefix $(BUILD)/, $(SRC_C:.c=.o) $(PY_O))
Damien's avatar
Damien committed
65
LIB = -lreadline
66
67
# the following is needed for BSD
#LIB += -ltermcap
68
69
70
71
PROG = py

$(PROG): $(BUILD) $(OBJ)
	$(CC) -o $@ $(OBJ) $(LIB) $(LDFLAGS)
72
73
	strip $(PROG)
	size $(PROG)
74
75

$(BUILD):
76
	mkdir -p $@
77
78
79
80

$(BUILD)/%.o: %.c
	$(CC) $(CFLAGS) -c -o $@ $<

81
82
83
$(BUILD)/%.o: $(PYSRC)/%.S
	$(CC) $(CFLAGS) -c -o $@ $<

84
$(BUILD)/%.o: $(PYSRC)/%.c mpconfigport.h
85
	$(CC) $(CFLAGS) -c -o $@ $<
86

87
$(BUILD)/emitnx64.o: $(PYSRC)/emitnative.c $(PYSRC)/emit.h mpconfigport.h
88
	$(CC) $(CFLAGS) -DN_X64 -c -o $@ $<
89

90
$(BUILD)/emitnthumb.o: $(PYSRC)/emitnative.c $(PYSRC)/emit.h mpconfigport.h
91
	$(CC) $(CFLAGS) -DN_THUMB -c -o $@ $<
92
93
94

# optimising vm for speed, adds only a small amount to code size but makes a huge difference to speed (20% faster)
$(BUILD)/vm.o: $(PYSRC)/vm.c
95
	$(CC) $(CFLAGS) -O3 -c -o $@ $<
96

97
$(BUILD)/main.o: mpconfigport.h
98
99
100
101
102
103
$(BUILD)/parse.o: $(PYSRC)/grammar.h
$(BUILD)/compile.o: $(PYSRC)/grammar.h
$(BUILD)/emitcpy.o: $(PYSRC)/emit.h
$(BUILD)/emitbc.o: $(PYSRC)/emit.h

clean:
104
	/bin/rm -rf $(BUILD)
105
106

.PHONY: clean