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

CC = gcc
5
CFLAGS = -I. -I$(PYSRC) -Wall -Werror -ansi -std=gnu99 -Os -DUSE_READLINE #-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
48
	objbool.o \
	objboundmeth.o \
	objcell.o \
	objclass.o \
	objclosure.o \
	objcomplex.o \
	objdict.o \
	objexcept.o \
	objfloat.o \
	objfun.o \
	objgenerator.o \
	objinstance.o \
	objlist.o \
49
	objmodule.o \
50
51
52
53
54
55
	objnone.o \
	objrange.o \
	objset.o \
	objstr.o \
	objtuple.o \
	objtype.o \
56
	builtin.o \
57
	builtinimport.o \
58
	vm.o \
Damien's avatar
Damien committed
59
	showbc.o \
60
	repl.o \
61
62

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

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

$(BUILD):
74
	mkdir -p $@
75
76
77
78

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

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

82
$(BUILD)/%.o: $(PYSRC)/%.c mpconfig.h
83
	$(CC) $(CFLAGS) -c -o $@ $<
84
85

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

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

# 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
93
	$(CC) $(CFLAGS) -O3 -c -o $@ $<
94

95
$(BUILD)/main.o: mpconfig.h
96
97
98
99
100
101
$(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:
102
	/bin/rm -rf $(BUILD)
103
104

.PHONY: clean