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

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

SRC_C = \
	main.c \

PY_O = \
12
	nlrx64.o \
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
	malloc.o \
	qstr.o \
	misc.o \
	lexer.o \
	lexerfile.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))
LIB =
PROG = py

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

$(BUILD):
	mkdir $@

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

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

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

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

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

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

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