Makefile 1.3 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
	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 \
33
	repl.o \
34
35

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

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

$(BUILD):
	mkdir $@

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

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

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

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

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

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

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