2017-04-25 21:34:22 -04:00
|
|
|
# The following is a temporary hack to forefully undefine vars that might have
|
|
|
|
# be defined by a calling Makefile (from recursive make).
|
|
|
|
# TODO: Find a better way to be able to call this Makefile recursively.
|
2017-05-25 08:04:51 -04:00
|
|
|
ifneq ($(findstring undefine,$(.FEATURES)),)
|
2017-04-25 21:34:22 -04:00
|
|
|
override undefine COPT
|
|
|
|
override undefine CFLAGS_EXTRA
|
|
|
|
override undefine LDFLAGS_EXTRA
|
|
|
|
override undefine FROZEN_DIR
|
|
|
|
override undefine FROZEN_MPY_DIR
|
|
|
|
override undefine BUILD
|
|
|
|
override undefine PROG
|
2017-05-25 08:04:51 -04:00
|
|
|
endif
|
2017-04-25 21:34:22 -04:00
|
|
|
|
2016-02-11 17:37:26 -05:00
|
|
|
include ../py/mkenv.mk
|
|
|
|
|
|
|
|
# define main target
|
|
|
|
PROG = mpy-cross
|
|
|
|
|
|
|
|
# qstr definitions (must come before including py.mk)
|
|
|
|
QSTR_DEFS = qstrdefsport.h
|
|
|
|
|
|
|
|
# OS name, for simple autoconfig
|
|
|
|
UNAME_S := $(shell uname -s)
|
|
|
|
|
|
|
|
# include py core make definitions
|
|
|
|
include ../py/py.mk
|
|
|
|
|
|
|
|
INC += -I.
|
|
|
|
INC += -I..
|
|
|
|
INC += -I$(BUILD)
|
|
|
|
|
|
|
|
# compiler settings
|
|
|
|
CWARN = -Wall -Werror
|
|
|
|
CWARN += -Wpointer-arith -Wuninitialized
|
2017-03-05 07:28:27 -05:00
|
|
|
CFLAGS = $(INC) $(CWARN) -std=gnu99 $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA)
|
2016-02-11 17:37:26 -05:00
|
|
|
CFLAGS += -fdata-sections -ffunction-sections -fno-asynchronous-unwind-tables
|
|
|
|
|
|
|
|
# Debugging/Optimization
|
|
|
|
ifdef DEBUG
|
|
|
|
CFLAGS += -g
|
|
|
|
COPT = -O0
|
|
|
|
else
|
|
|
|
COPT = -Os #-DNDEBUG
|
|
|
|
endif
|
|
|
|
|
|
|
|
# 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
|
|
|
|
ifeq ($(UNAME_S),Darwin)
|
|
|
|
CC = clang
|
|
|
|
# Use clang syntax for map file
|
2016-07-08 19:02:02 -04:00
|
|
|
LDFLAGS_ARCH = -Wl,-map,$@.map -Wl,-dead_strip
|
2016-02-11 17:37:26 -05:00
|
|
|
else
|
|
|
|
# Use gcc syntax for map file
|
2016-07-08 19:02:02 -04:00
|
|
|
LDFLAGS_ARCH = -Wl,-Map=$@.map,--cref -Wl,--gc-sections
|
2016-02-11 17:37:26 -05:00
|
|
|
endif
|
|
|
|
LDFLAGS = $(LDFLAGS_MOD) $(LDFLAGS_ARCH) -lm $(LDFLAGS_EXTRA)
|
|
|
|
|
|
|
|
# source files
|
|
|
|
SRC_C = \
|
|
|
|
main.c \
|
|
|
|
gccollect.c \
|
|
|
|
|
2016-08-10 04:19:16 -04:00
|
|
|
# Add fmode when compiling with mingw gcc
|
|
|
|
COMPILER_TARGET := $(shell $(CC) -dumpmachine)
|
|
|
|
ifneq (,$(findstring mingw,$(COMPILER_TARGET)))
|
|
|
|
SRC_C += windows/fmode.c
|
2016-07-22 05:54:26 -04:00
|
|
|
endif
|
|
|
|
|
2016-02-11 17:37:26 -05:00
|
|
|
OBJ = $(PY_O)
|
|
|
|
OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
|
|
|
|
|
|
|
|
include ../py/mkrules.mk
|