2014-01-24 04:05:30 -05:00
|
|
|
include ../py/mkenv.mk
|
2014-02-01 13:06:55 -05:00
|
|
|
-include mpconfigport.mk
|
2014-01-24 04:05:30 -05:00
|
|
|
|
2014-01-07 09:54:15 -05:00
|
|
|
# define main target
|
2014-01-19 19:02:39 -05:00
|
|
|
PROG = micropython
|
2014-01-07 09:54:15 -05:00
|
|
|
|
2014-01-21 16:40:13 -05:00
|
|
|
# qstr definitions (must come before including py.mk)
|
|
|
|
QSTR_DEFS = qstrdefsport.h
|
|
|
|
|
2014-06-20 12:25:54 -04:00
|
|
|
# OS name, for simple autoconfig
|
|
|
|
UNAME_S := $(shell uname -s)
|
|
|
|
|
2014-01-07 09:54:15 -05:00
|
|
|
# include py core make definitions
|
|
|
|
include ../py/py.mk
|
2013-10-12 09:30:21 -04:00
|
|
|
|
2014-04-16 17:10:33 -04:00
|
|
|
INC = -I.
|
2014-12-27 09:11:49 -05:00
|
|
|
INC += -I..
|
2014-04-17 13:03:27 -04:00
|
|
|
INC += -I$(BUILD)
|
2014-04-16 17:10:33 -04:00
|
|
|
|
2014-01-07 09:54:15 -05:00
|
|
|
# compiler settings
|
2014-10-29 05:05:55 -04:00
|
|
|
CWARN = -Wall -Wpointer-arith -Werror
|
2014-06-20 12:27:51 -04:00
|
|
|
CFLAGS = $(INC) $(CWARN) -ansi -std=gnu99 -DUNIX $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA)
|
2014-02-14 17:37:37 -05:00
|
|
|
|
2014-06-20 12:19:06 -04:00
|
|
|
# Debugging/Optimization
|
|
|
|
ifdef DEBUG
|
|
|
|
CFLAGS += -g
|
|
|
|
COPT = -O0
|
|
|
|
else
|
|
|
|
COPT = -Os #-DNDEBUG
|
|
|
|
endif
|
|
|
|
|
2014-09-23 09:42:18 -04:00
|
|
|
# On OSX, 'gcc' is a symlink to clang unless a real gcc is installed.
|
|
|
|
# The unix port of micropython on OSX must be compiled with clang,
|
|
|
|
# while cross-compile ports require gcc, so we test here for OSX and
|
|
|
|
# if necessary override the value of 'CC' set in py/mkenv.mk
|
2014-09-22 15:16:14 -04:00
|
|
|
ifeq ($(UNAME_S),Darwin)
|
|
|
|
CC = clang
|
2015-01-08 04:32:45 -05:00
|
|
|
# Use clang syntax for map file
|
|
|
|
LDFLAGS_ARCH = -Wl,-map,$@.map
|
2014-09-22 23:00:42 -04:00
|
|
|
else
|
2014-09-23 09:42:18 -04:00
|
|
|
# Use gcc syntax for map file
|
|
|
|
LDFLAGS_ARCH = -Wl,-Map=$@.map,--cref
|
2014-09-22 15:16:14 -04:00
|
|
|
endif
|
2014-09-23 09:42:18 -04:00
|
|
|
LDFLAGS = $(LDFLAGS_MOD) $(LDFLAGS_ARCH) -lm $(LDFLAGS_EXTRA)
|
2014-02-01 13:06:55 -05:00
|
|
|
|
2014-04-15 20:46:01 -04:00
|
|
|
ifeq ($(MICROPY_FORCE_32BIT),1)
|
2014-10-11 13:29:51 -04:00
|
|
|
# Note: you may need to install i386 versions of dependency packages,
|
|
|
|
# starting with linux-libc-dev:i386
|
2014-04-15 20:46:01 -04:00
|
|
|
CFLAGS += -m32
|
|
|
|
LDFLAGS += -m32
|
2014-05-24 18:03:12 -04:00
|
|
|
ifeq ($(MICROPY_PY_FFI),1)
|
2014-04-15 20:46:01 -04:00
|
|
|
ifeq ($(UNAME_S),Linux)
|
|
|
|
CFLAGS_MOD += -I/usr/include/i686-linux-gnu
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2014-02-27 11:10:40 -05:00
|
|
|
ifeq ($(MICROPY_USE_READLINE),1)
|
|
|
|
CFLAGS_MOD += -DMICROPY_USE_READLINE=1
|
|
|
|
LDFLAGS_MOD += -lreadline
|
|
|
|
# the following is needed for BSD
|
|
|
|
#LDFLAGS_MOD += -ltermcap
|
|
|
|
endif
|
2014-05-24 18:03:12 -04:00
|
|
|
ifeq ($(MICROPY_PY_TIME),1)
|
|
|
|
CFLAGS_MOD += -DMICROPY_PY_TIME=1
|
2014-04-04 13:32:26 -04:00
|
|
|
SRC_MOD += modtime.c
|
2014-02-01 17:57:06 -05:00
|
|
|
endif
|
2014-08-19 03:23:14 -04:00
|
|
|
ifeq ($(MICROPY_PY_TERMIOS),1)
|
|
|
|
CFLAGS_MOD += -DMICROPY_PY_TERMIOS=1
|
|
|
|
SRC_MOD += modtermios.c
|
|
|
|
endif
|
2015-01-11 12:28:27 -05:00
|
|
|
ifeq ($(MICROPY_PY_SOCKET),1)
|
|
|
|
CFLAGS_MOD += -DMICROPY_PY_SOCKET=1
|
|
|
|
SRC_MOD += modsocket.c
|
|
|
|
endif
|
2014-05-24 18:03:12 -04:00
|
|
|
ifeq ($(MICROPY_PY_FFI),1)
|
2014-04-20 04:30:46 -04:00
|
|
|
LIBFFI_LDFLAGS_MOD := $(shell pkg-config --libs libffi)
|
|
|
|
LIBFFI_CFLAGS_MOD := $(shell pkg-config --cflags libffi)
|
2014-05-24 18:03:12 -04:00
|
|
|
CFLAGS_MOD += $(LIBFFI_CFLAGS_MOD) -DMICROPY_PY_FFI=1
|
2014-06-07 03:16:42 -04:00
|
|
|
ifeq ($(UNAME_S),Linux)
|
|
|
|
LDFLAGS_MOD += -ldl
|
|
|
|
endif
|
|
|
|
LDFLAGS_MOD += $(LIBFFI_LDFLAGS_MOD)
|
2014-04-04 13:32:26 -04:00
|
|
|
SRC_MOD += modffi.c
|
2014-02-01 13:06:55 -05:00
|
|
|
endif
|
|
|
|
|
2013-10-12 09:30:21 -04:00
|
|
|
|
2014-01-07 09:54:15 -05:00
|
|
|
# source files
|
2013-10-12 09:30:21 -04:00
|
|
|
SRC_C = \
|
|
|
|
main.c \
|
2014-02-10 17:44:37 -05:00
|
|
|
gccollect.c \
|
2014-05-07 10:15:00 -04:00
|
|
|
input.c \
|
2014-01-07 19:52:20 -05:00
|
|
|
file.c \
|
2014-05-14 15:08:45 -04:00
|
|
|
modos.c \
|
2014-09-03 17:47:23 -04:00
|
|
|
alloc.c \
|
2014-02-01 13:06:55 -05:00
|
|
|
$(SRC_MOD)
|
2013-10-12 09:30:21 -04:00
|
|
|
|
2014-09-22 15:16:14 -04:00
|
|
|
|
2014-01-21 16:40:13 -05:00
|
|
|
OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
|
2013-10-12 09:30:21 -04:00
|
|
|
|
2014-01-24 04:05:30 -05:00
|
|
|
include ../py/mkrules.mk
|
2013-12-29 13:01:01 -05:00
|
|
|
|
2014-04-16 15:38:16 -04:00
|
|
|
.PHONY: test
|
|
|
|
|
|
|
|
test: $(PROG) ../tests/run-tests
|
|
|
|
$(eval DIRNAME=$(notdir $(CURDIR)))
|
2014-04-16 20:26:25 -04:00
|
|
|
cd ../tests && MICROPY_MICROPYTHON=../$(DIRNAME)/$(PROG) ./run-tests
|
2014-08-11 13:47:00 -04:00
|
|
|
|
|
|
|
# install micropython in /usr/local/bin
|
|
|
|
TARGET = micropython
|
|
|
|
PREFIX = $(DESTDIR)/usr/local
|
|
|
|
BINDIR = $(PREFIX)/bin
|
2014-08-26 11:03:57 -04:00
|
|
|
PIPSRC = ../tools/pip-micropython
|
|
|
|
PIPTARGET = pip-micropython
|
2014-08-11 13:47:00 -04:00
|
|
|
|
|
|
|
install: micropython
|
|
|
|
install -D $(TARGET) $(BINDIR)/$(TARGET)
|
2014-08-26 11:03:57 -04:00
|
|
|
install -D $(PIPSRC) $(BINDIR)/$(PIPTARGET)
|
2014-08-11 13:47:00 -04:00
|
|
|
|
|
|
|
# uninstall micropython
|
|
|
|
uninstall:
|
|
|
|
-rm $(BINDIR)/$(TARGET)
|
2014-08-26 11:03:57 -04:00
|
|
|
-rm $(BINDIR)/$(PIPTARGET)
|
2014-11-01 10:01:21 -04:00
|
|
|
|
|
|
|
# build synthetically fast interpreter for benchmarking
|
|
|
|
fast:
|
|
|
|
@echo Make sure to run make -B
|
2015-01-11 12:28:27 -05:00
|
|
|
$(MAKE) COPT="-O2 -DNDEBUG -fno-crossjumping" CFLAGS_EXTRA='-DMP_CONFIGFILE="<mpconfigport_fast.h>"' BUILD=build-fast PROG=micropython_fast
|
|
|
|
|
|
|
|
# build a minimal interpreter
|
|
|
|
minimal:
|
|
|
|
@echo Make sure to run make -B
|
|
|
|
$(MAKE) COPT="-Os -DNDEBUG" CFLAGS_EXTRA='-DMP_CONFIGFILE="<mpconfigport_minimal.h>"' BUILD=build-minimal PROG=micropython_minimal MICROPY_PY_TIME=0 MICROPY_PY_TERMIOS=0 MICROPY_PY_SOCKET=0 MICROPY_PY_FFI=0
|
2015-01-29 09:54:38 -05:00
|
|
|
|
|
|
|
# build an interpreter for coverage testing and do the testing
|
|
|
|
coverage:
|
|
|
|
@echo Make sure to run make -B
|
|
|
|
$(MAKE) COPT="-O0" CFLAGS_EXTRA='-fprofile-arcs -ftest-coverage' LDFLAGS_EXTRA='-fprofile-arcs -ftest-coverage' BUILD=build-coverage PROG=micropython_coverage
|
2015-03-01 08:37:27 -05:00
|
|
|
|
|
|
|
coverage_test: coverage
|
2015-01-29 09:54:38 -05:00
|
|
|
$(eval DIRNAME=$(notdir $(CURDIR)))
|
|
|
|
cd ../tests && MICROPY_MICROPYTHON=../$(DIRNAME)/micropython_coverage ./run-tests
|
|
|
|
gcov -o build-coverage/py ../py/*.c
|