Makefile 1.63 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
CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 -DUNIX $(CFLAGS_MOD) $(COPT)
19
20
21
22
23
24
25

UNAME_S := $(shell uname -s)
 ifeq ($(UNAME_S),Darwin)
    LDFLAGS = $(LDFLAGS_MOD) -lm -Wl,-map,$@.map
else
    LDFLAGS = $(LDFLAGS_MOD) -lm -Wl,-Map=$@.map,--cref
 endif
26

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

37
38
39
40
41
42
ifeq ($(MICROPY_USE_READLINE),1)
CFLAGS_MOD += -DMICROPY_USE_READLINE=1
LDFLAGS_MOD += -lreadline
# the following is needed for BSD
#LDFLAGS_MOD += -ltermcap
endif
43
44
ifeq ($(MICROPY_MOD_TIME),1)
CFLAGS_MOD += -DMICROPY_MOD_TIME=1
45
SRC_MOD += modtime.c
46
endif
47
ifeq ($(MICROPY_MOD_FFI),1)
48
49
50
51
LIBFFI_LDFLAGS_MOD := $(shell pkg-config --libs libffi)
LIBFFI_CFLAGS_MOD := $(shell pkg-config --cflags libffi)
CFLAGS_MOD += $(LIBFFI_CFLAGS_MOD) -DMICROPY_MOD_FFI=1
LDFLAGS_MOD += -ldl $(LIBFFI_LDFLAGS_MOD)
52
SRC_MOD += modffi.c
53
54
endif

55

56
# Debugging/Optimization
57
ifdef DEBUG
58
59
CFLAGS += -g
COPT = -O0
60
else
61
COPT = -Os #-DNDEBUG
62
63
endif

64
# source files
65
66
SRC_C = \
	main.c \
67
	gccollect.c \
Dave Hylands's avatar
Dave Hylands committed
68
	input.c \
69
	file.c \
70
	modsocket.c \
71
	$(SRC_MOD)
72

73
OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
74

75
include ../py/mkrules.mk
76

77
78
79
80
.PHONY: test

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