Makefile 2.04 KB
Newer Older
1
include ../py/mkenv.mk
2
-include mpconfigport.mk
3

4
# define main target
5
PROG = micropython
6

7
8
9
# qstr definitions (must come before including py.mk)
QSTR_DEFS = qstrdefsport.h

10
11
# include py core make definitions
include ../py/py.mk
12

13
14
INC =  -I.
INC += -I$(PY_SRC)
15
INC += -I$(BUILD)
16

17
# compiler settings
18
19
CWARN = -Wall -Werror
CFLAGS = $(INC) $(CWARN) -ansi -std=gnu99 -DUNIX $(CFLAGS_MOD) $(COPT)
20
21
22

UNAME_S := $(shell uname -s)
 ifeq ($(UNAME_S),Darwin)
23
    LDFLAGS = $(LDFLAGS_MOD) -lm -Wl,-map,$@.map,-order_file,$(BUILD)/order.def
24
 else
25
26
    LDFLAGS = $(LDFLAGS_MOD) -lm -Wl,-Map=$@.map,--cref
 endif
27

28
29
30
ifeq ($(MICROPY_FORCE_32BIT),1)
CFLAGS += -m32
LDFLAGS += -m32
31
ifeq ($(MICROPY_PY_FFI),1)
32
33
34
35
36
37
ifeq ($(UNAME_S),Linux)
CFLAGS_MOD += -I/usr/include/i686-linux-gnu
endif
endif
endif

38
39
40
41
42
43
ifeq ($(MICROPY_USE_READLINE),1)
CFLAGS_MOD += -DMICROPY_USE_READLINE=1
LDFLAGS_MOD += -lreadline
# the following is needed for BSD
#LDFLAGS_MOD += -ltermcap
endif
44
45
ifeq ($(MICROPY_PY_TIME),1)
CFLAGS_MOD += -DMICROPY_PY_TIME=1
46
SRC_MOD += modtime.c
47
endif
48
ifeq ($(MICROPY_PY_FFI),1)
49
50
LIBFFI_LDFLAGS_MOD := $(shell pkg-config --libs libffi)
LIBFFI_CFLAGS_MOD := $(shell pkg-config --cflags libffi)
51
CFLAGS_MOD += $(LIBFFI_CFLAGS_MOD) -DMICROPY_PY_FFI=1
52
53
54
55
ifeq ($(UNAME_S),Linux)
LDFLAGS_MOD += -ldl
endif
LDFLAGS_MOD += $(LIBFFI_LDFLAGS_MOD)
56
SRC_MOD += modffi.c
57
58
endif

59

60
# Debugging/Optimization
61
ifdef DEBUG
62
63
CFLAGS += -g
COPT = -O0
64
else
65
COPT = -Os #-DNDEBUG
66
67
endif

68
# source files
69
70
SRC_C = \
	main.c \
71
	gccollect.c \
Dave Hylands's avatar
Dave Hylands committed
72
	input.c \
73
	file.c \
74
	modsocket.c \
75
	modos.c \
76
	$(SRC_MOD)
77

78
ifeq ($(UNAME_S),Darwin)
79
# Must be the last file in list of sources
80
SRC_C += seg_helpers.c
81
82
83
84
85
86
87

# making seg_helpers.c rely on order.def will force order.def to be created
seg_helpers.c: $(BUILD)/order.def

# create order.def in build directory
$(BUILD)/order.def:
	$(Q)echo "seg_helpers.o: ___bss_start" > $@
88
89
endif
	
90
OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
91

92
include ../py/mkrules.mk
93

94
95
96
97
.PHONY: test

test: $(PROG) ../tests/run-tests
	$(eval DIRNAME=$(notdir $(CURDIR)))
98
	cd ../tests && MICROPY_MICROPYTHON=../$(DIRNAME)/$(PROG) ./run-tests