Makefile 1.35 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

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
	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 \
32
33
34
	map.o \
	obj.o \
	builtin.o \
35
	vm.o \
Damien's avatar
Damien committed
36
	showbc.o \
37
	repl.o \
38
39

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

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

$(BUILD):
	mkdir $@

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

52
$(BUILD)/%.o: $(PYSRC)/%.s
Damien's avatar
Damien committed
53
	$(AS) -o $@ $<
54

55
$(BUILD)/%.o: $(PYSRC)/%.c mpyconfig.h
56
	$(CC) $(CFLAGS) -c -o $@ $<
57
58

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

$(BUILD)/emitnthumb.o: $(PYSRC)/emitnative.c $(PYSRC)/emit.h
62
	$(CC) $(CFLAGS) -DN_THUMB -c -o $@ $<
63
64
65

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

68
$(BUILD)/main.o: mpyconfig.h
69
70
71
72
73
74
75
$(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)