aboutsummaryrefslogtreecommitdiff
path: root/ports/unix/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'ports/unix/Makefile')
-rw-r--r--ports/unix/Makefile107
1 files changed, 40 insertions, 67 deletions
diff --git a/ports/unix/Makefile b/ports/unix/Makefile
index 2fa1373e7..567b1d5c2 100644
--- a/ports/unix/Makefile
+++ b/ports/unix/Makefile
@@ -1,16 +1,29 @@
--include mpconfigport.mk
+# Select the variant to build for.
+VARIANT ?= standard
+
+# If the build directory is not given, make it reflect the variant name.
+BUILD ?= build-$(VARIANT)
+
+VARIANT_DIR ?= variants/$(VARIANT)
+ifeq ($(wildcard $(VARIANT_DIR)/.),)
+$(error Invalid VARIANT specified: $(VARIANT_DIR))
+endif
+
include ../../py/mkenv.mk
+-include mpconfigport.mk
+include $(VARIANT_DIR)/mpconfigvariant.mk
# use FROZEN_MANIFEST for new projects, others are legacy
FROZEN_MANIFEST ?= manifest.py
FROZEN_DIR =
FROZEN_MPY_DIR =
-# define main target
-PROG = micropython
+# This should be configured by the mpconfigvariant.mk
+PROG ?= micropython
# qstr definitions (must come before including py.mk)
QSTR_DEFS = qstrdefsport.h
+QSTR_GLOBAL_DEPENDENCIES = $(VARIANT_DIR)/mpconfigvariant.h
# OS name, for simple autoconfig
UNAME_S := $(shell uname -s)
@@ -27,7 +40,7 @@ INC += -I$(BUILD)
# compiler settings
CWARN = -Wall -Werror
CWARN += -Wpointer-arith -Wuninitialized
-CFLAGS = $(INC) $(CWARN) -std=gnu99 -DUNIX $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA)
+CFLAGS = $(INC) $(CWARN) -std=gnu99 -DUNIX $(CFLAGS_MOD) $(COPT) -I$(VARIANT_DIR) $(CFLAGS_EXTRA)
# Debugging/Optimization
ifdef DEBUG
@@ -156,7 +169,8 @@ SRC_C = \
alloc.c \
coverage.c \
fatfs_port.c \
- $(SRC_MOD)
+ $(SRC_MOD) \
+ $(wildcard $(VARIANT_DIR)/*.c)
LIB_SRC_C = $(addprefix lib/,\
$(LIB_SRC_C_EXTRA) \
@@ -188,83 +202,42 @@ endif
include $(TOP)/py/mkrules.mk
-.PHONY: test
+.PHONY: test test_full
test: $(PROG) $(TOP)/tests/run-tests
$(eval DIRNAME=ports/$(notdir $(CURDIR)))
cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/$(PROG) ./run-tests
-# install micropython in /usr/local/bin
-TARGET = micropython
-PREFIX = $(DESTDIR)/usr/local
-BINDIR = $(PREFIX)/bin
-
-install: micropython
- install -d $(BINDIR)
- install $(TARGET) $(BINDIR)/$(TARGET)
+test_full: $(PROG) $(TOP)/tests/run-tests
+ $(eval DIRNAME=ports/$(notdir $(CURDIR)))
+ cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/$(PROG) ./run-tests
+ cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/$(PROG) ./run-tests -d thread
+ cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/$(PROG) ./run-tests --emit native
+ cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/$(PROG) ./run-tests --via-mpy -d basics float micropython
+ cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/$(PROG) ./run-tests --via-mpy --emit native -d basics float micropython
+ cat $(TOP)/tests/basics/0prelim.py | ./$(PROG) | grep -q 'abc'
-# uninstall micropython
-uninstall:
- -rm $(BINDIR)/$(TARGET)
+test_gcov: test_full
+ gcov -o $(BUILD)/py $(TOP)/py/*.c
+ gcov -o $(BUILD)/extmod $(TOP)/extmod/*.c
-# build synthetically fast interpreter for benchmarking
+# Maintain historical targets from pre-variant configurations.
fast:
- $(MAKE) COPT="-O2 -DNDEBUG -fno-crossjumping" CFLAGS_EXTRA='-DMP_CONFIGFILE="<mpconfigport_fast.h>"' BUILD=build-fast PROG=micropython_fast FROZEN_MANIFEST=
+ $(MAKE) VARIANT=fast
-# build a minimal interpreter
minimal:
- $(MAKE) COPT="-Os -DNDEBUG" CFLAGS_EXTRA='-DMP_CONFIGFILE="<mpconfigport_minimal.h>"' \
- BUILD=build-minimal PROG=micropython_minimal FROZEN_MANIFEST= \
- MICROPY_PY_BTREE=0 MICROPY_PY_FFI=0 MICROPY_PY_SOCKET=0 MICROPY_PY_THREAD=0 \
- MICROPY_PY_TERMIOS=0 MICROPY_PY_USSL=0 \
- MICROPY_USE_READLINE=0
+ $(MAKE) VARIANT=minimal
-# build interpreter with nan-boxing as object model
nanbox:
- $(MAKE) \
- CFLAGS_EXTRA='-DMP_CONFIGFILE="<mpconfigport_nanbox.h>"' \
- BUILD=build-nanbox \
- PROG=micropython_nanbox \
- MICROPY_FORCE_32BIT=1
+ $(MAKE) VARIANT=nanbox
freedos:
- $(MAKE) \
- CC=i586-pc-msdosdjgpp-gcc \
- STRIP=i586-pc-msdosdjgpp-strip \
- SIZE=i586-pc-msdosdjgpp-size \
- CFLAGS_EXTRA='-DMP_CONFIGFILE="<mpconfigport_freedos.h>" -DMICROPY_NLR_SETJMP -Dtgamma=gamma -DMICROPY_EMIT_X86=0 -DMICROPY_NO_ALLOCA=1 -DMICROPY_PY_USELECT_POSIX=0' \
- BUILD=build-freedos \
- PROG=micropython_freedos \
- MICROPY_PY_SOCKET=0 \
- MICROPY_PY_FFI=0 \
- MICROPY_PY_JNI=0 \
- MICROPY_PY_BTREE=0 \
- MICROPY_PY_THREAD=0 \
- MICROPY_PY_USSL=0
-
-# build an interpreter for coverage testing and do the testing
+ $(MAKE) VARIANT=freedos
+
coverage:
- $(MAKE) \
- COPT="-O0" CFLAGS_EXTRA='$(CFLAGS_EXTRA) -DMP_CONFIGFILE="<mpconfigport_coverage.h>" \
- -fprofile-arcs -ftest-coverage \
- -Wdouble-promotion -Wformat -Wmissing-declarations -Wmissing-prototypes -Wsign-compare \
- -Wold-style-definition -Wpointer-arith -Wshadow -Wuninitialized -Wunused-parameter \
- -DMICROPY_UNIX_COVERAGE' \
- LDFLAGS_EXTRA='-fprofile-arcs -ftest-coverage' \
- MICROPY_VFS_FAT=1 MICROPY_VFS_LFS1=1 MICROPY_VFS_LFS2=1 \
- FROZEN_MANIFEST=manifest_coverage.py \
- BUILD=build-coverage PROG=micropython_coverage
-
-coverage_test: coverage
- $(eval DIRNAME=ports/$(notdir $(CURDIR)))
- cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/micropython_coverage ./run-tests
- cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/micropython_coverage ./run-tests -d thread
- cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/micropython_coverage ./run-tests --emit native
- cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/micropython_coverage ./run-tests --via-mpy -d basics float micropython
- cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/micropython_coverage ./run-tests --via-mpy --emit native -d basics float micropython
- cat $(TOP)/tests/basics/0prelim.py | ./micropython_coverage | grep -q 'abc'
- gcov -o build-coverage/py $(TOP)/py/*.c
- gcov -o build-coverage/extmod $(TOP)/extmod/*.c
+ $(MAKE) VARIANT=coverage
+coverage_test:
+ $(MAKE) VARIANT=coverage test_gcov
# Value of configure's --host= option (required for cross-compilation).
# Deduce it from CROSS_COMPILE by default, but can be overridden.