2013-10-12 09:30:21 -04:00
|
|
|
PYSRC=../py
|
|
|
|
BUILD=build
|
|
|
|
|
|
|
|
CC = gcc
|
2013-12-17 13:33:53 -05:00
|
|
|
CFLAGS = -I. -I$(PYSRC) -Wall -Werror -ansi -std=gnu99 -Os #-DNDEBUG
|
2013-11-02 15:47:57 -04:00
|
|
|
LDFLAGS = -lm
|
2013-10-12 09:30:21 -04:00
|
|
|
|
|
|
|
SRC_C = \
|
|
|
|
main.c \
|
2013-10-20 09:41:27 -04:00
|
|
|
lexerunix.c \
|
2013-10-12 09:30:21 -04:00
|
|
|
|
|
|
|
PY_O = \
|
2013-10-15 17:25:17 -04:00
|
|
|
nlrx64.o \
|
2013-10-12 09:30:21 -04:00
|
|
|
malloc.o \
|
|
|
|
qstr.o \
|
2013-10-20 09:41:27 -04:00
|
|
|
vstr.o \
|
2013-10-12 09:30:21 -04:00
|
|
|
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 \
|
2013-12-17 13:33:53 -05:00
|
|
|
map.o \
|
|
|
|
obj.o \
|
2013-12-21 13:17:45 -05:00
|
|
|
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 \
|
2013-12-17 13:33:53 -05:00
|
|
|
builtin.o \
|
2013-10-12 09:30:21 -04:00
|
|
|
vm.o \
|
2013-11-17 08:20:13 -05:00
|
|
|
showbc.o \
|
2013-10-22 17:32:27 -04:00
|
|
|
repl.o \
|
2013-10-12 09:30:21 -04:00
|
|
|
|
|
|
|
OBJ = $(addprefix $(BUILD)/, $(SRC_C:.c=.o) $(PY_O))
|
2013-10-18 14:58:12 -04:00
|
|
|
LIB = -lreadline
|
2013-10-12 09:30:21 -04:00
|
|
|
PROG = py
|
|
|
|
|
|
|
|
$(PROG): $(BUILD) $(OBJ)
|
|
|
|
$(CC) -o $@ $(OBJ) $(LIB) $(LDFLAGS)
|
2013-12-21 13:17:45 -05:00
|
|
|
strip $(PROG)
|
|
|
|
size $(PROG)
|
2013-10-12 09:30:21 -04:00
|
|
|
|
|
|
|
$(BUILD):
|
|
|
|
mkdir $@
|
|
|
|
|
|
|
|
$(BUILD)/%.o: %.c
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
|
|
|
|
2013-10-15 17:25:17 -04:00
|
|
|
$(BUILD)/%.o: $(PYSRC)/%.s
|
2013-12-20 09:22:59 -05:00
|
|
|
$(AS) -o $@ $<
|
2013-10-15 17:25:17 -04:00
|
|
|
|
2013-12-21 13:17:45 -05:00
|
|
|
$(BUILD)/%.o: $(PYSRC)/%.c mpconfig.h
|
2013-10-15 17:25:17 -04:00
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
2013-10-12 09:30:21 -04:00
|
|
|
|
|
|
|
$(BUILD)/emitnx64.o: $(PYSRC)/emitnative.c $(PYSRC)/emit.h
|
2013-10-15 17:25:17 -04:00
|
|
|
$(CC) $(CFLAGS) -DN_X64 -c -o $@ $<
|
2013-10-12 09:30:21 -04:00
|
|
|
|
|
|
|
$(BUILD)/emitnthumb.o: $(PYSRC)/emitnative.c $(PYSRC)/emit.h
|
2013-10-15 17:25:17 -04:00
|
|
|
$(CC) $(CFLAGS) -DN_THUMB -c -o $@ $<
|
2013-10-12 09:30:21 -04:00
|
|
|
|
|
|
|
# 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
|
2013-10-15 17:25:17 -04:00
|
|
|
$(CC) $(CFLAGS) -O3 -c -o $@ $<
|
2013-10-12 09:30:21 -04:00
|
|
|
|
2013-12-21 13:17:45 -05:00
|
|
|
$(BUILD)/main.o: mpconfig.h
|
2013-10-12 09:30:21 -04:00
|
|
|
$(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)
|