Makefile 1.65 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
	nlrx64.o \
13
14
	malloc.o \
	qstr.o \
15
	vstr.o \
16
17
	misc.o \
	lexer.o \
18
	lexerunix.o \
19
20
21
22
23
24
25
26
27
28
29
30
31
	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 \
32
33
	map.o \
	obj.o \
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
	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 \
53
	builtin.o \
54
	vm.o \
Damien's avatar
Damien committed
55
	showbc.o \
56
	repl.o \
57
58

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

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

$(BUILD):
68
	mkdir -p $@
69
70
71
72

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

73
$(BUILD)/%.o: $(PYSRC)/%.s
Damien's avatar
Damien committed
74
	$(AS) -o $@ $<
75

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

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

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

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

89
$(BUILD)/main.o: mpconfig.h
90
91
92
93
94
95
96
$(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)
97
98

.PHONY: clean