2019-10-22 20:20:07 -04:00
|
|
|
# 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
|
|
|
|
|
2017-09-06 00:09:13 -04:00
|
|
|
include ../../py/mkenv.mk
|
2019-10-22 20:20:07 -04:00
|
|
|
-include mpconfigport.mk
|
|
|
|
include $(VARIANT_DIR)/mpconfigvariant.mk
|
2014-01-24 04:05:30 -05:00
|
|
|
|
2019-09-09 10:50:04 -04:00
|
|
|
# use FROZEN_MANIFEST for new projects, others are legacy
|
2020-06-09 02:45:17 -04:00
|
|
|
FROZEN_MANIFEST ?= variants/manifest.py
|
2019-09-09 10:50:04 -04:00
|
|
|
FROZEN_DIR =
|
|
|
|
FROZEN_MPY_DIR =
|
2016-11-07 10:13:56 -05:00
|
|
|
|
2019-10-22 20:20:07 -04:00
|
|
|
# This should be configured by the mpconfigvariant.mk
|
|
|
|
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
|
2019-10-22 20:20:07 -04:00
|
|
|
QSTR_GLOBAL_DEPENDENCIES = $(VARIANT_DIR)/mpconfigvariant.h
|
2014-01-21 16:40:13 -05:00
|
|
|
|
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
|
2017-08-10 22:22:19 -04:00
|
|
|
include $(TOP)/py/py.mk
|
2013-10-12 09:30:21 -04:00
|
|
|
|
2020-04-19 21:50:02 -04:00
|
|
|
GIT_SUBMODULES += lib/axtls lib/berkeley-db-1.xx lib/libffi
|
2019-10-13 21:09:06 -04:00
|
|
|
|
2015-10-19 11:22:16 -04:00
|
|
|
INC += -I.
|
2017-08-10 22:22:19 -04:00
|
|
|
INC += -I$(TOP)
|
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
|
2015-01-22 09:10:11 -05:00
|
|
|
CWARN = -Wall -Werror
|
2020-10-03 05:31:13 -04:00
|
|
|
CWARN += -Wextra -Wno-unused-parameter -Wpointer-arith -Wdouble-promotion -Wfloat-conversion
|
2020-01-23 19:51:21 -05:00
|
|
|
CFLAGS += $(INC) $(CWARN) -std=gnu99 -DUNIX $(CFLAGS_MOD) $(COPT) -I$(VARIANT_DIR) $(CFLAGS_EXTRA)
|
2014-02-14 17:37:37 -05:00
|
|
|
|
2014-06-20 12:19:06 -04:00
|
|
|
# Debugging/Optimization
|
|
|
|
ifdef DEBUG
|
2020-04-02 21:55:14 -04:00
|
|
|
COPT ?= -O0
|
2014-06-20 12:19:06 -04:00
|
|
|
else
|
2020-04-02 21:55:14 -04:00
|
|
|
COPT ?= -Os
|
|
|
|
COPT += -DNDEBUG
|
|
|
|
endif
|
|
|
|
|
2020-08-14 02:40:55 -04:00
|
|
|
# Remove unused sections.
|
|
|
|
COPT += -fdata-sections -ffunction-sections
|
|
|
|
|
2020-04-02 21:55:14 -04:00
|
|
|
# Always enable symbols -- They're occasionally useful, and don't make it into the
|
|
|
|
# final .bin/.hex/.dfu so the extra size doesn't matter.
|
|
|
|
CFLAGS += -g
|
|
|
|
|
|
|
|
ifndef DEBUG
|
2016-01-26 12:46:40 -05:00
|
|
|
# _FORTIFY_SOURCE is a feature in gcc/glibc which is intended to provide extra
|
|
|
|
# security for detecting buffer overflows. Some distros (Ubuntu at the very least)
|
|
|
|
# have it enabled by default.
|
|
|
|
#
|
|
|
|
# gcc already optimizes some printf calls to call puts and/or putchar. When
|
|
|
|
# _FORTIFY_SOURCE is enabled and compiling with -O1 or greater, then some
|
|
|
|
# printf calls will also be optimized to call __printf_chk (in glibc). Any
|
|
|
|
# printfs which get redirected to __printf_chk are then no longer synchronized
|
|
|
|
# with printfs that go through mp_printf.
|
|
|
|
#
|
|
|
|
# In MicroPython, we don't want to use the runtime library's printf but rather
|
|
|
|
# go through mp_printf, so that stdout is properly tied into streams, etc.
|
|
|
|
# This means that we either need to turn off _FORTIFY_SOURCE or provide our
|
|
|
|
# own implementation of __printf_chk. We've chosen to turn off _FORTIFY_SOURCE.
|
|
|
|
# It should also be noted that the use of printf in MicroPython is typically
|
|
|
|
# quite limited anyways (primarily for debug and some error reporting, etc
|
|
|
|
# in the unix version).
|
|
|
|
#
|
|
|
|
# Information about _FORTIFY_SOURCE seems to be rather scarce. The best I could
|
|
|
|
# find was this: https://securityblog.redhat.com/2014/03/26/fortify-and-you/
|
|
|
|
# Original patchset was introduced by
|
|
|
|
# https://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html .
|
|
|
|
#
|
|
|
|
# Turning off _FORTIFY_SOURCE is only required when compiling with -O1 or greater
|
|
|
|
CFLAGS += -U _FORTIFY_SOURCE
|
2014-06-20 12:19:06 -04:00
|
|
|
endif
|
|
|
|
|
2014-09-23 09:42:18 -04:00
|
|
|
# On OSX, 'gcc' is a symlink to clang unless a real gcc is installed.
|
2017-06-30 03:22:17 -04:00
|
|
|
# The unix port of MicroPython on OSX must be compiled with clang,
|
2016-06-02 13:10:39 -04:00
|
|
|
# while cross-compile ports require gcc, so we test here for OSX and
|
2014-09-23 09:42:18 -04:00
|
|
|
# if necessary override the value of 'CC' set in py/mkenv.mk
|
2014-09-22 15:16:14 -04:00
|
|
|
ifeq ($(UNAME_S),Darwin)
|
2016-06-02 13:10:39 -04:00
|
|
|
ifeq ($(MICROPY_FORCE_32BIT),1)
|
|
|
|
CC = clang -m32
|
|
|
|
else
|
2014-09-22 15:16:14 -04:00
|
|
|
CC = clang
|
2016-06-02 13:10:39 -04:00
|
|
|
endif
|
2015-01-08 04:32:45 -05:00
|
|
|
# Use clang syntax for map file
|
2016-06-25 11:59:49 -04:00
|
|
|
LDFLAGS_ARCH = -Wl,-map,$@.map -Wl,-dead_strip
|
2014-09-22 23:00:42 -04:00
|
|
|
else
|
2014-09-23 09:42:18 -04:00
|
|
|
# Use gcc syntax for map file
|
2016-06-25 11:59:49 -04:00
|
|
|
LDFLAGS_ARCH = -Wl,-Map=$@.map,--cref -Wl,--gc-sections
|
2014-09-22 15:16:14 -04:00
|
|
|
endif
|
2020-01-23 19:51:21 -05:00
|
|
|
LDFLAGS += $(LDFLAGS_MOD) $(LDFLAGS_ARCH) -lm $(LDFLAGS_EXTRA)
|
2014-02-01 13:06:55 -05:00
|
|
|
|
2018-09-08 19:40:51 -04:00
|
|
|
# Flags to link with pthread library
|
|
|
|
LIBPTHREAD = -lpthread
|
|
|
|
|
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-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)
|
2017-08-10 22:22:19 -04:00
|
|
|
INC += -I$(TOP)/lib/mp-readline
|
2014-02-27 11:10:40 -05:00
|
|
|
CFLAGS_MOD += -DMICROPY_USE_READLINE=1
|
2015-05-24 17:36:31 -04:00
|
|
|
LIB_SRC_C_EXTRA += mp-readline/readline.c
|
|
|
|
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
|
2017-10-23 05:09:37 -04:00
|
|
|
SRC_MOD += modusocket.c
|
2015-01-11 12:28:27 -05:00
|
|
|
endif
|
2016-04-22 18:53:51 -04:00
|
|
|
ifeq ($(MICROPY_PY_THREAD),1)
|
2016-07-09 11:48:06 -04:00
|
|
|
CFLAGS_MOD += -DMICROPY_PY_THREAD=1 -DMICROPY_PY_THREAD_GIL=0
|
2018-09-08 19:40:51 -04:00
|
|
|
LDFLAGS_MOD += $(LIBPTHREAD)
|
2016-04-22 18:53:51 -04:00
|
|
|
endif
|
2015-08-30 03:57:38 -04:00
|
|
|
|
2020-08-14 01:46:53 -04:00
|
|
|
# If the variant enables it, enable modbluetooth.
|
2020-04-07 01:02:52 -04:00
|
|
|
ifeq ($(MICROPY_PY_BLUETOOTH),1)
|
2020-04-07 09:01:43 -04:00
|
|
|
|
|
|
|
HAVE_LIBUSB := $(shell (which pkg-config > /dev/null && pkg-config --exists libusb-1.0) 2>/dev/null && echo '1')
|
2020-08-14 01:46:53 -04:00
|
|
|
|
|
|
|
# Only one stack can be enabled.
|
|
|
|
ifeq ($(MICROPY_BLUETOOTH_NIMBLE),1)
|
|
|
|
ifeq ($(MICROPY_BLUETOOTH_BTSTACK),1)
|
|
|
|
$(error Cannot enable both NimBLE and BTstack at the same time)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Default to btstack, but a variant (or make command line) can set NimBLE
|
|
|
|
# explicitly (which is always via H4 UART).
|
|
|
|
ifneq ($(MICROPY_BLUETOOTH_NIMBLE),1)
|
|
|
|
ifneq ($(MICROPY_BLUETOOTH_BTSTACK),1)
|
|
|
|
MICROPY_BLUETOOTH_BTSTACK ?= 1
|
|
|
|
endif
|
|
|
|
endif
|
2020-04-07 09:01:43 -04:00
|
|
|
|
2020-04-07 01:02:52 -04:00
|
|
|
CFLAGS_MOD += -DMICROPY_PY_BLUETOOTH=1
|
|
|
|
CFLAGS_MOD += -DMICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE=1
|
|
|
|
|
2020-08-14 01:46:53 -04:00
|
|
|
ifeq ($(MICROPY_BLUETOOTH_BTSTACK),1)
|
|
|
|
|
|
|
|
# Figure out which BTstack transport to use.
|
|
|
|
ifeq ($(MICROPY_BLUETOOTH_BTSTACK_H4),1)
|
|
|
|
ifeq ($(MICROPY_BLUETOOTH_BTSTACK_USB),1)
|
|
|
|
$(error Cannot enable BTstack support for USB and H4 UART at the same time)
|
|
|
|
endif
|
|
|
|
else
|
|
|
|
ifeq ($(HAVE_LIBUSB),1)
|
|
|
|
# Default to btstack-over-usb.
|
2020-04-07 01:02:52 -04:00
|
|
|
MICROPY_BLUETOOTH_BTSTACK_USB ?= 1
|
2020-08-14 01:46:53 -04:00
|
|
|
else
|
|
|
|
# Fallback to HCI controller via a H4 UART (e.g. Zephyr on nRF) over a /dev/tty serial port.
|
|
|
|
MICROPY_BLUETOOTH_BTSTACK_H4 ?= 1
|
|
|
|
endif
|
|
|
|
endif
|
2020-04-07 01:02:52 -04:00
|
|
|
|
2020-08-14 01:46:53 -04:00
|
|
|
# BTstack is enabled.
|
2020-04-19 21:50:02 -04:00
|
|
|
GIT_SUBMODULES += lib/btstack
|
2020-04-07 01:02:52 -04:00
|
|
|
include $(TOP)/extmod/btstack/btstack.mk
|
2021-05-13 09:33:32 -04:00
|
|
|
SRC_BTSTACK += lib/btstack/platform/embedded/btstack_run_loop_embedded.c
|
2020-08-14 01:46:53 -04:00
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
# NimBLE is enabled.
|
|
|
|
GIT_SUBMODULES += lib/mynewt-nimble
|
2020-10-15 09:15:16 -04:00
|
|
|
CFLAGS_MOD += -DMICROPY_PY_BLUETOOTH_ENABLE_L2CAP_CHANNELS=1
|
2020-08-14 01:46:53 -04:00
|
|
|
include $(TOP)/extmod/nimble/nimble.mk
|
2020-04-07 01:02:52 -04:00
|
|
|
|
2020-04-07 09:01:43 -04:00
|
|
|
endif
|
2020-08-14 01:43:09 -04:00
|
|
|
|
2020-04-07 09:01:43 -04:00
|
|
|
endif
|
|
|
|
|
2014-05-24 18:03:12 -04:00
|
|
|
ifeq ($(MICROPY_PY_FFI),1)
|
2015-08-30 03:57:38 -04:00
|
|
|
|
|
|
|
ifeq ($(MICROPY_STANDALONE),1)
|
2018-07-28 09:39:33 -04:00
|
|
|
LIBFFI_CFLAGS_MOD := -I$(shell ls -1d $(BUILD)/lib/libffi/out/lib/libffi-*/include)
|
2015-08-30 03:57:38 -04:00
|
|
|
ifeq ($(MICROPY_FORCE_32BIT),1)
|
2018-07-28 09:39:33 -04:00
|
|
|
LIBFFI_LDFLAGS_MOD = $(BUILD)/lib/libffi/out/lib32/libffi.a
|
2015-08-30 03:57:38 -04:00
|
|
|
else
|
2018-07-28 09:39:33 -04:00
|
|
|
LIBFFI_LDFLAGS_MOD = $(BUILD)/lib/libffi/out/lib/libffi.a
|
2015-08-30 03:57:38 -04:00
|
|
|
endif
|
|
|
|
else
|
2014-04-20 04:30:46 -04:00
|
|
|
LIBFFI_CFLAGS_MOD := $(shell pkg-config --cflags libffi)
|
2015-08-30 03:57:38 -04:00
|
|
|
LIBFFI_LDFLAGS_MOD := $(shell pkg-config --libs libffi)
|
|
|
|
endif
|
|
|
|
|
2014-06-07 03:16:42 -04:00
|
|
|
ifeq ($(UNAME_S),Linux)
|
2015-08-30 03:57:38 -04:00
|
|
|
LIBFFI_LDFLAGS_MOD += -ldl
|
2014-06-07 03:16:42 -04:00
|
|
|
endif
|
2015-08-30 03:57:38 -04:00
|
|
|
|
|
|
|
CFLAGS_MOD += $(LIBFFI_CFLAGS_MOD) -DMICROPY_PY_FFI=1
|
2014-06-07 03:16:42 -04:00
|
|
|
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
|
|
|
|
|
2015-09-11 10:57:47 -04:00
|
|
|
ifeq ($(MICROPY_PY_JNI),1)
|
|
|
|
# Path for 64-bit OpenJDK, should be adjusted for other JDKs
|
|
|
|
CFLAGS_MOD += -I/usr/lib/jvm/java-7-openjdk-amd64/include -DMICROPY_PY_JNI=1
|
|
|
|
SRC_MOD += modjni.c
|
|
|
|
endif
|
2013-10-12 09:30:21 -04:00
|
|
|
|
2014-01-07 09:54:15 -05:00
|
|
|
# source files
|
2020-10-29 02:33:34 -04:00
|
|
|
SRC_C += \
|
2013-10-12 09:30:21 -04:00
|
|
|
main.c \
|
2014-02-10 17:44:37 -05:00
|
|
|
gccollect.c \
|
2015-05-24 15:00:50 -04:00
|
|
|
unix_mphal.c \
|
2016-04-22 18:53:51 -04:00
|
|
|
mpthreadport.c \
|
2014-05-07 10:15:00 -04:00
|
|
|
input.c \
|
2015-12-12 17:15:33 -05:00
|
|
|
modmachine.c \
|
2014-05-14 15:08:45 -04:00
|
|
|
modos.c \
|
2017-01-26 23:14:49 -05:00
|
|
|
moduos_vfs.c \
|
2016-06-17 16:35:00 -04:00
|
|
|
modtime.c \
|
2015-11-16 17:35:29 -05:00
|
|
|
moduselect.c \
|
2014-09-03 17:47:23 -04:00
|
|
|
alloc.c \
|
2016-02-13 16:03:23 -05:00
|
|
|
fatfs_port.c \
|
2020-08-14 01:46:53 -04:00
|
|
|
mpbthciport.c \
|
2020-08-14 01:43:09 -04:00
|
|
|
mpbtstackport_common.c \
|
2020-08-14 01:46:53 -04:00
|
|
|
mpbtstackport_h4.c \
|
2020-08-14 01:43:09 -04:00
|
|
|
mpbtstackport_usb.c \
|
|
|
|
mpnimbleport.c \
|
2019-10-22 20:20:07 -04:00
|
|
|
$(SRC_MOD) \
|
|
|
|
$(wildcard $(VARIANT_DIR)/*.c)
|
2013-10-12 09:30:21 -04:00
|
|
|
|
2020-04-07 01:02:52 -04:00
|
|
|
LIB_SRC_C += $(addprefix lib/,\
|
2015-05-24 17:36:31 -04:00
|
|
|
$(LIB_SRC_C_EXTRA) \
|
2016-06-15 17:03:24 -04:00
|
|
|
timeutils/timeutils.c \
|
2020-04-23 02:12:55 -04:00
|
|
|
utils/gchelper_generic.c \
|
2016-06-15 17:03:24 -04:00
|
|
|
)
|
|
|
|
|
2020-10-08 10:52:25 -04:00
|
|
|
SRC_CXX += \
|
|
|
|
$(SRC_MOD_CXX)
|
|
|
|
|
2015-05-24 17:36:31 -04:00
|
|
|
OBJ = $(PY_O)
|
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
|
2020-10-08 10:52:25 -04:00
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_CXX:.cpp=.o))
|
2015-05-24 17:36:31 -04:00
|
|
|
OBJ += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o))
|
2020-04-07 01:02:52 -04:00
|
|
|
OBJ += $(addprefix $(BUILD)/, $(EXTMOD_SRC_C:.c=.o))
|
2013-10-12 09:30:21 -04:00
|
|
|
|
py: Add rules for automated extraction of qstrs from sources.
- add template rule that converts a specified source file into a qstring file
- add special rule for generating a central header that contains all
extracted/autogenerated strings - defined by QSTR_DEFS_COLLECTED
variable. Each platform appends a list of sources that may contain
qstrings into a new build variable: SRC_QSTR. Any autogenerated
prerequisities are should be appened to SRC_QSTR_AUTO_DEPS variable.
- remove most qstrings from py/qstrdefs, keep only qstrings that
contain special characters - these cannot be easily detected in the
sources without additional annotations
- remove most manual qstrdefs, use qstrdef autogen for: py, cc3200,
stmhal, teensy, unix, windows, pic16bit:
- remove all micropython generic qstrdefs except for the special strings that contain special characters (e.g. /,+,<,> etc.)
- remove all port specific qstrdefs except for special strings
- append sources for qstr generation in platform makefiles (SRC_QSTR)
2016-03-10 04:22:41 -05:00
|
|
|
# List of sources for qstr extraction
|
2020-10-08 10:52:25 -04:00
|
|
|
SRC_QSTR += $(SRC_C) $(SRC_CXX) $(LIB_SRC_C) $(EXTMOD_SRC_C)
|
py: Add rules for automated extraction of qstrs from sources.
- add template rule that converts a specified source file into a qstring file
- add special rule for generating a central header that contains all
extracted/autogenerated strings - defined by QSTR_DEFS_COLLECTED
variable. Each platform appends a list of sources that may contain
qstrings into a new build variable: SRC_QSTR. Any autogenerated
prerequisities are should be appened to SRC_QSTR_AUTO_DEPS variable.
- remove most qstrings from py/qstrdefs, keep only qstrings that
contain special characters - these cannot be easily detected in the
sources without additional annotations
- remove most manual qstrdefs, use qstrdef autogen for: py, cc3200,
stmhal, teensy, unix, windows, pic16bit:
- remove all micropython generic qstrdefs except for the special strings that contain special characters (e.g. /,+,<,> etc.)
- remove all port specific qstrdefs except for special strings
- append sources for qstr generation in platform makefiles (SRC_QSTR)
2016-03-10 04:22:41 -05:00
|
|
|
# Append any auto-generated sources that are needed by sources listed in
|
|
|
|
# SRC_QSTR
|
|
|
|
SRC_QSTR_AUTO_DEPS +=
|
|
|
|
|
2019-09-09 10:50:04 -04:00
|
|
|
ifneq ($(FROZEN_MANIFEST)$(FROZEN_MPY_DIR),)
|
|
|
|
# To use frozen code create a manifest.py file with a description of files to
|
|
|
|
# freeze, then invoke make with FROZEN_MANIFEST=manifest.py (be sure to build from scratch).
|
2016-05-16 18:17:11 -04:00
|
|
|
CFLAGS += -DMICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool
|
|
|
|
CFLAGS += -DMICROPY_MODULE_FROZEN_MPY
|
|
|
|
CFLAGS += -DMPZ_DIG_SIZE=16 # force 16 bits to work on both 32 and 64 bit archs
|
2017-01-04 23:55:06 -05:00
|
|
|
MPY_CROSS_FLAGS += -mcache-lookup-bc
|
2016-05-16 18:17:11 -04:00
|
|
|
endif
|
|
|
|
|
2019-10-18 09:39:11 -04:00
|
|
|
ifneq ($(FROZEN_MANIFEST)$(FROZEN_DIR),)
|
|
|
|
CFLAGS += -DMICROPY_MODULE_FROZEN_STR
|
|
|
|
endif
|
py: Add rules for automated extraction of qstrs from sources.
- add template rule that converts a specified source file into a qstring file
- add special rule for generating a central header that contains all
extracted/autogenerated strings - defined by QSTR_DEFS_COLLECTED
variable. Each platform appends a list of sources that may contain
qstrings into a new build variable: SRC_QSTR. Any autogenerated
prerequisities are should be appened to SRC_QSTR_AUTO_DEPS variable.
- remove most qstrings from py/qstrdefs, keep only qstrings that
contain special characters - these cannot be easily detected in the
sources without additional annotations
- remove most manual qstrdefs, use qstrdef autogen for: py, cc3200,
stmhal, teensy, unix, windows, pic16bit:
- remove all micropython generic qstrdefs except for the special strings that contain special characters (e.g. /,+,<,> etc.)
- remove all port specific qstrdefs except for special strings
- append sources for qstr generation in platform makefiles (SRC_QSTR)
2016-03-10 04:22:41 -05:00
|
|
|
|
2020-10-08 10:52:25 -04:00
|
|
|
HASCPP17 = $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \>= 7)
|
|
|
|
ifeq ($(HASCPP17), 1)
|
|
|
|
CXXFLAGS += -std=c++17
|
|
|
|
else
|
|
|
|
CXXFLAGS += -std=c++11
|
|
|
|
endif
|
|
|
|
CXXFLAGS += $(filter-out -Wmissing-prototypes -Wold-style-definition -std=gnu99,$(CFLAGS) $(CXXFLAGS_MOD))
|
|
|
|
|
2020-03-11 02:03:01 -04:00
|
|
|
ifeq ($(MICROPY_FORCE_32BIT),1)
|
|
|
|
RUN_TESTS_MPY_CROSS_FLAGS = --mpy-cross-flags='-mcache-lookup-bc -march=x86'
|
|
|
|
else
|
|
|
|
RUN_TESTS_MPY_CROSS_FLAGS = --mpy-cross-flags='-mcache-lookup-bc'
|
|
|
|
endif
|
|
|
|
|
2017-08-10 22:22:19 -04:00
|
|
|
include $(TOP)/py/mkrules.mk
|
2013-12-29 13:01:01 -05:00
|
|
|
|
2019-10-22 20:20:07 -04:00
|
|
|
.PHONY: test test_full
|
2014-04-16 15:38:16 -04:00
|
|
|
|
2021-03-11 00:09:27 -05:00
|
|
|
test: $(PROG) $(TOP)/tests/run-tests.py
|
2017-09-06 00:09:13 -04:00
|
|
|
$(eval DIRNAME=ports/$(notdir $(CURDIR)))
|
2021-03-11 00:09:27 -05:00
|
|
|
cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/$(PROG) ./run-tests.py
|
2014-08-11 13:47:00 -04:00
|
|
|
|
2021-03-11 00:09:27 -05:00
|
|
|
test_full: $(PROG) $(TOP)/tests/run-tests.py
|
2019-10-22 20:20:07 -04:00
|
|
|
$(eval DIRNAME=ports/$(notdir $(CURDIR)))
|
2021-03-11 00:09:27 -05:00
|
|
|
cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/$(PROG) ./run-tests.py
|
|
|
|
cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/$(PROG) ./run-tests.py -d thread
|
|
|
|
cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/$(PROG) ./run-tests.py --emit native
|
|
|
|
cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/$(PROG) ./run-tests.py --via-mpy $(RUN_TESTS_MPY_CROSS_FLAGS) -d basics float micropython
|
|
|
|
cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/$(PROG) ./run-tests.py --via-mpy $(RUN_TESTS_MPY_CROSS_FLAGS) --emit native -d basics float micropython
|
2019-10-22 20:20:07 -04:00
|
|
|
cat $(TOP)/tests/basics/0prelim.py | ./$(PROG) | grep -q 'abc'
|
2014-08-11 13:47:00 -04:00
|
|
|
|
2019-10-22 20:20:07 -04:00
|
|
|
test_gcov: test_full
|
|
|
|
gcov -o $(BUILD)/py $(TOP)/py/*.c
|
|
|
|
gcov -o $(BUILD)/extmod $(TOP)/extmod/*.c
|
2014-11-01 10:01:21 -04:00
|
|
|
|
2015-08-30 03:57:38 -04:00
|
|
|
# Value of configure's --host= option (required for cross-compilation).
|
2017-05-29 03:08:14 -04:00
|
|
|
# Deduce it from CROSS_COMPILE by default, but can be overridden.
|
2015-08-30 03:57:38 -04:00
|
|
|
ifneq ($(CROSS_COMPILE),)
|
|
|
|
CROSS_COMPILE_HOST = --host=$(patsubst %-,%,$(CROSS_COMPILE))
|
|
|
|
else
|
|
|
|
CROSS_COMPILE_HOST =
|
|
|
|
endif
|
|
|
|
|
2015-09-19 10:12:02 -04:00
|
|
|
deplibs: libffi axtls
|
2015-08-30 03:57:38 -04:00
|
|
|
|
2018-07-28 09:39:33 -04:00
|
|
|
libffi: $(BUILD)/lib/libffi/include/ffi.h
|
|
|
|
|
|
|
|
$(TOP)/lib/libffi/configure: $(TOP)/lib/libffi/autogen.sh
|
|
|
|
cd $(TOP)/lib/libffi; ./autogen.sh
|
|
|
|
|
2015-10-19 13:28:06 -04:00
|
|
|
# install-exec-recursive & install-data-am targets are used to avoid building
|
|
|
|
# docs and depending on makeinfo
|
2018-07-28 09:39:33 -04:00
|
|
|
$(BUILD)/lib/libffi/include/ffi.h: $(TOP)/lib/libffi/configure
|
|
|
|
mkdir -p $(BUILD)/lib/libffi; cd $(BUILD)/lib/libffi; \
|
|
|
|
$(abspath $(TOP))/lib/libffi/configure $(CROSS_COMPILE_HOST) --prefix=$$PWD/out --disable-structs CC="$(CC)" CXX="$(CXX)" LD="$(LD)" CFLAGS="-Os -fomit-frame-pointer -fstrict-aliasing -ffast-math -fno-exceptions"; \
|
2017-06-07 11:51:01 -04:00
|
|
|
$(MAKE) install-exec-recursive; $(MAKE) -C include install-data-am
|
2015-09-19 10:12:02 -04:00
|
|
|
|
2018-09-05 00:10:41 -04:00
|
|
|
axtls: $(TOP)/lib/axtls/README
|
2016-05-28 13:59:34 -04:00
|
|
|
|
2017-08-10 22:22:19 -04:00
|
|
|
$(TOP)/lib/axtls/README:
|
2016-05-28 13:59:34 -04:00
|
|
|
@echo "You cloned without --recursive, fetching submodules for you."
|
2017-08-10 22:22:19 -04:00
|
|
|
(cd $(TOP); git submodule update --init --recursive)
|
2020-02-12 18:17:09 -05:00
|
|
|
|
|
|
|
PREFIX = /usr/local
|
|
|
|
BINDIR = $(DESTDIR)$(PREFIX)/bin
|
|
|
|
|
|
|
|
install: $(PROG)
|
2020-04-08 16:15:02 -04:00
|
|
|
install -d $(BINDIR)
|
|
|
|
install $(PROG) $(BINDIR)/$(PROG)
|
2020-02-12 18:17:09 -05:00
|
|
|
|
|
|
|
uninstall:
|
|
|
|
-rm $(BINDIR)/$(PROG)
|