Makefile 1.69 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
Damien's avatar
Damien committed
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
19
	misc.o \
	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
49
50
51
52
53
54
	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 \
	objnone.o \
	objrange.o \
	objset.o \
	objstr.o \
	objtuple.o \
	objtype.o \
55
	builtin.o \
56
	vm.o \
Damien's avatar
Damien committed
57
	showbc.o \
58
	repl.o \
59
60

OBJ = $(addprefix $(BUILD)/, $(SRC_C:.c=.o) $(PY_O))
Damien's avatar
Damien committed
61
LIB = -lreadline
62
63
64
65
PROG = py

$(PROG): $(BUILD) $(OBJ)
	$(CC) -o $@ $(OBJ) $(LIB) $(LDFLAGS)
66
67
	strip $(PROG)
	size $(PROG)
68
69

$(BUILD):
70
	mkdir -p $@
71
72
73
74

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

75
76
77
$(BUILD)/%.o: $(PYSRC)/%.S
	$(CC) $(CFLAGS) -c -o $@ $<

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

$(BUILD)/emitnx64.o: $(PYSRC)/emitnative.c $(PYSRC)/emit.h
82
	$(CC) $(CFLAGS) -DN_X64 -c -o $@ $<
83
84

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

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

91
$(BUILD)/main.o: mpconfig.h
92
93
94
95
96
97
98
$(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:
	/bin/rm -r $(BUILD)
99
100

.PHONY: clean