1include ../py/mkenv.mk 2 3# define main target 4PROG = mpy-cross 5 6# qstr definitions (must come before including py.mk) 7QSTR_DEFS = qstrdefsport.h 8 9# OS name, for simple autoconfig 10UNAME_S := $(shell uname -s) 11 12# include py core make definitions 13include $(TOP)/py/py.mk 14 15INC += -I. 16INC += -I$(BUILD) 17INC += -I$(TOP) 18 19# compiler settings 20CWARN = -Wall -Werror 21CWARN += -Wextra -Wno-unused-parameter -Wpointer-arith 22CFLAGS = $(INC) $(CWARN) -std=gnu99 $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA) 23CFLAGS += -fdata-sections -ffunction-sections -fno-asynchronous-unwind-tables 24 25# Debugging/Optimization 26ifdef DEBUG 27CFLAGS += -g 28COPT = -O0 29else 30COPT = -Os #-DNDEBUG 31endif 32 33# On OSX, 'gcc' is a symlink to clang unless a real gcc is installed. 34# The unix port of MicroPython on OSX must be compiled with clang, 35# while cross-compile ports require gcc, so we test here for OSX and 36# if necessary override the value of 'CC' set in py/mkenv.mk 37ifeq ($(UNAME_S),Darwin) 38CC = clang 39# Use clang syntax for map file 40LDFLAGS_ARCH = -Wl,-map,$@.map -Wl,-dead_strip 41else 42# Use gcc syntax for map file 43LDFLAGS_ARCH = -Wl,-Map=$@.map,--cref -Wl,--gc-sections 44endif 45LDFLAGS = $(LDFLAGS_MOD) $(LDFLAGS_ARCH) -lm $(LDFLAGS_EXTRA) 46 47# source files 48SRC_C = \ 49 main.c \ 50 gccollect.c \ 51 shared/runtime/gchelper_generic.c \ 52 53# Add fmode when compiling with mingw gcc 54COMPILER_TARGET := $(shell $(CC) -dumpmachine) 55ifneq (,$(findstring mingw,$(COMPILER_TARGET))) 56 SRC_C += ports/windows/fmode.c 57endif 58 59OBJ = $(PY_CORE_O) 60OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o)) 61 62include $(TOP)/py/mkrules.mk 63