2014-01-24 09:05:30 +00:00
|
|
|
include ../py/mkenv.mk
|
2014-02-01 18:06:55 +00:00
|
|
|
-include mpconfigport.mk
|
2014-01-24 09:05:30 +00:00
|
|
|
|
2014-01-07 14:54:15 +00:00
|
|
|
# define main target
|
2014-01-20 00:02:39 +00:00
|
|
|
PROG = micropython
|
2014-01-07 14:54:15 +00:00
|
|
|
|
2014-01-21 21:40:13 +00:00
|
|
|
# qstr definitions (must come before including py.mk)
|
|
|
|
QSTR_DEFS = qstrdefsport.h
|
|
|
|
|
2014-06-20 17:25:54 +01:00
|
|
|
# OS name, for simple autoconfig
|
|
|
|
UNAME_S := $(shell uname -s)
|
|
|
|
|
2014-01-07 14:54:15 +00:00
|
|
|
# include py core make definitions
|
|
|
|
include ../py/py.mk
|
2013-10-12 14:30:21 +01:00
|
|
|
|
2014-04-16 22:10:33 +01:00
|
|
|
INC = -I.
|
|
|
|
INC += -I$(PY_SRC)
|
2014-04-17 18:03:27 +01:00
|
|
|
INC += -I$(BUILD)
|
2014-04-16 22:10:33 +01:00
|
|
|
|
2014-01-07 14:54:15 +00:00
|
|
|
# compiler settings
|
2014-10-29 09:05:55 +00:00
|
|
|
CWARN = -Wall -Wpointer-arith -Werror
|
2014-06-20 17:27:51 +01:00
|
|
|
CFLAGS = $(INC) $(CWARN) -ansi -std=gnu99 -DUNIX $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA)
|
2014-02-14 22:37:37 +00:00
|
|
|
|
2014-06-20 17:19:06 +01:00
|
|
|
# Debugging/Optimization
|
|
|
|
ifdef DEBUG
|
|
|
|
CFLAGS += -g
|
|
|
|
COPT = -O0
|
|
|
|
else
|
|
|
|
COPT = -Os #-DNDEBUG
|
|
|
|
endif
|
|
|
|
|
2014-09-23 14:42:18 +01: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 20:16:14 +01:00
|
|
|
ifeq ($(UNAME_S),Darwin)
|
|
|
|
CC = clang
|
2014-09-23 14:42:18 +01:00
|
|
|
# Use clang syntax for map file and set osx specific flags
|
|
|
|
LDFLAGS_ARCH = -Wl,-order_file,$(BUILD)/order.def -Wl,-map,$@.map
|
2014-09-23 04:00:42 +01:00
|
|
|
else
|
2014-09-23 14:42:18 +01:00
|
|
|
# Use gcc syntax for map file
|
|
|
|
LDFLAGS_ARCH = -Wl,-Map=$@.map,--cref
|
2014-09-22 20:16:14 +01:00
|
|
|
endif
|
2014-09-23 14:42:18 +01:00
|
|
|
LDFLAGS = $(LDFLAGS_MOD) $(LDFLAGS_ARCH) -lm $(LDFLAGS_EXTRA)
|
2014-02-01 18:06:55 +00:00
|
|
|
|
2014-04-16 01:46:01 +01:00
|
|
|
ifeq ($(MICROPY_FORCE_32BIT),1)
|
2014-10-11 18:29:51 +01:00
|
|
|
# Note: you may need to install i386 versions of dependency packages,
|
|
|
|
# starting with linux-libc-dev:i386
|
2014-04-16 01:46:01 +01:00
|
|
|
CFLAGS += -m32
|
|
|
|
LDFLAGS += -m32
|
2014-05-24 23:03:12 +01:00
|
|
|
ifeq ($(MICROPY_PY_FFI),1)
|
2014-04-16 01:46:01 +01:00
|
|
|
ifeq ($(UNAME_S),Linux)
|
|
|
|
CFLAGS_MOD += -I/usr/include/i686-linux-gnu
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2014-02-27 16:10:40 +00: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 23:03:12 +01:00
|
|
|
ifeq ($(MICROPY_PY_TIME),1)
|
|
|
|
CFLAGS_MOD += -DMICROPY_PY_TIME=1
|
2014-04-04 18:32:26 +01:00
|
|
|
SRC_MOD += modtime.c
|
2014-02-01 22:57:06 +00:00
|
|
|
endif
|
2014-08-19 08:23:14 +01:00
|
|
|
ifeq ($(MICROPY_PY_TERMIOS),1)
|
|
|
|
CFLAGS_MOD += -DMICROPY_PY_TERMIOS=1
|
|
|
|
SRC_MOD += modtermios.c
|
|
|
|
endif
|
2014-05-24 23:03:12 +01:00
|
|
|
ifeq ($(MICROPY_PY_FFI),1)
|
2014-04-20 09:30:46 +01:00
|
|
|
LIBFFI_LDFLAGS_MOD := $(shell pkg-config --libs libffi)
|
|
|
|
LIBFFI_CFLAGS_MOD := $(shell pkg-config --cflags libffi)
|
2014-05-24 23:03:12 +01:00
|
|
|
CFLAGS_MOD += $(LIBFFI_CFLAGS_MOD) -DMICROPY_PY_FFI=1
|
2014-06-07 08:16:42 +01:00
|
|
|
ifeq ($(UNAME_S),Linux)
|
|
|
|
LDFLAGS_MOD += -ldl
|
|
|
|
endif
|
|
|
|
LDFLAGS_MOD += $(LIBFFI_LDFLAGS_MOD)
|
2014-04-04 18:32:26 +01:00
|
|
|
SRC_MOD += modffi.c
|
2014-02-01 18:06:55 +00:00
|
|
|
endif
|
|
|
|
|
2013-10-12 14:30:21 +01:00
|
|
|
|
2014-01-07 14:54:15 +00:00
|
|
|
# source files
|
2013-10-12 14:30:21 +01:00
|
|
|
SRC_C = \
|
|
|
|
main.c \
|
2014-02-10 22:44:37 +00:00
|
|
|
gccollect.c \
|
2014-05-07 15:15:00 +01:00
|
|
|
input.c \
|
2014-01-08 00:52:20 +00:00
|
|
|
file.c \
|
2014-04-04 18:32:26 +01:00
|
|
|
modsocket.c \
|
2014-05-14 20:08:45 +01:00
|
|
|
modos.c \
|
2014-09-03 22:47:23 +01:00
|
|
|
alloc.c \
|
2014-02-01 18:06:55 +00:00
|
|
|
$(SRC_MOD)
|
2013-10-12 14:30:21 +01:00
|
|
|
|
2014-05-11 20:28:26 +01:00
|
|
|
ifeq ($(UNAME_S),Darwin)
|
2014-05-21 19:56:54 +01:00
|
|
|
# Must be the last file in list of sources
|
2014-05-11 20:28:26 +01:00
|
|
|
SRC_C += seg_helpers.c
|
2014-05-21 19:56:54 +01:00
|
|
|
|
|
|
|
# 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" > $@
|
2014-05-11 20:28:26 +01:00
|
|
|
endif
|
2014-09-22 20:16:14 +01:00
|
|
|
|
2014-01-21 21:40:13 +00:00
|
|
|
OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
|
2013-10-12 14:30:21 +01:00
|
|
|
|
2014-01-24 09:05:30 +00:00
|
|
|
include ../py/mkrules.mk
|
2013-12-29 18:01:01 +00:00
|
|
|
|
2014-04-16 20:38:16 +01:00
|
|
|
.PHONY: test
|
|
|
|
|
|
|
|
test: $(PROG) ../tests/run-tests
|
|
|
|
$(eval DIRNAME=$(notdir $(CURDIR)))
|
2014-04-17 01:26:25 +01:00
|
|
|
cd ../tests && MICROPY_MICROPYTHON=../$(DIRNAME)/$(PROG) ./run-tests
|
2014-08-11 18:47:00 +01:00
|
|
|
|
|
|
|
# install micropython in /usr/local/bin
|
|
|
|
TARGET = micropython
|
|
|
|
PREFIX = $(DESTDIR)/usr/local
|
|
|
|
BINDIR = $(PREFIX)/bin
|
2014-08-26 16:03:57 +01:00
|
|
|
PIPSRC = ../tools/pip-micropython
|
|
|
|
PIPTARGET = pip-micropython
|
2014-08-11 18:47:00 +01:00
|
|
|
|
|
|
|
install: micropython
|
|
|
|
install -D $(TARGET) $(BINDIR)/$(TARGET)
|
2014-08-26 16:03:57 +01:00
|
|
|
install -D $(PIPSRC) $(BINDIR)/$(PIPTARGET)
|
2014-08-11 18:47:00 +01:00
|
|
|
|
|
|
|
# uninstall micropython
|
|
|
|
uninstall:
|
|
|
|
-rm $(BINDIR)/$(TARGET)
|
2014-08-26 16:03:57 +01:00
|
|
|
-rm $(BINDIR)/$(PIPTARGET)
|
2014-11-01 14:01:21 +00:00
|
|
|
|
|
|
|
# build synthetically fast interpreter for benchmarking
|
|
|
|
fast:
|
|
|
|
@echo Make sure to run make -B
|
|
|
|
$(MAKE) COPT="-O2 -DNDEBUG" CFLAGS_EXTRA='-DMP_CONFIGFILE="<mpconfigport_fast.h>"' BUILD=build-fast
|