Makefile 1.29 KB
Newer Older
1
2
3
4
5
6
7
8
9
PYSRC=../py
BUILD=build

CC = gcc
CFLAGS = -I. -I$(PYSRC) -Wall -ansi -std=gnu99 -Os #-DNDEBUG
LDFLAGS =

SRC_C = \
	main.c \
10
	lexerunix.c \
11
12

PY_O = \
13
	nlrx64.o \
14
15
	malloc.o \
	qstr.o \
16
	vstr.o \
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
	misc.o \
	lexer.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 \
	vm.o \

OBJ = $(addprefix $(BUILD)/, $(SRC_C:.c=.o) $(PY_O))
Damien's avatar
Damien committed
35
LIB = -lreadline
36
37
38
39
40
41
42
43
44
45
46
PROG = py

$(PROG): $(BUILD) $(OBJ)
	$(CC) -o $@ $(OBJ) $(LIB) $(LDFLAGS)

$(BUILD):
	mkdir $@

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

47
48
49
$(BUILD)/%.o: $(PYSRC)/%.s
	$(AS) -c -o $@ $<

50
$(BUILD)/%.o: $(PYSRC)/%.c mpyconfig.h
51
	$(CC) $(CFLAGS) -c -o $@ $<
52
53

$(BUILD)/emitnx64.o: $(PYSRC)/emitnative.c $(PYSRC)/emit.h
54
	$(CC) $(CFLAGS) -DN_X64 -c -o $@ $<
55
56

$(BUILD)/emitnthumb.o: $(PYSRC)/emitnative.c $(PYSRC)/emit.h
57
	$(CC) $(CFLAGS) -DN_THUMB -c -o $@ $<
58
59
60

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

63
$(BUILD)/main.o: mpyconfig.h
64
65
66
67
68
69
70
$(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)