Commit 2d1f865d authored by Damien George's avatar Damien George
Browse files

Merge branch 'relocatable-build-dir' of github.com:lurch/micropython into...

Merge branch 'relocatable-build-dir' of github.com:lurch/micropython into lurch-relocatable-build-dir
parents eeffbb69 70a7d7a9
...@@ -8,8 +8,12 @@ include ../py/py.mk ...@@ -8,8 +8,12 @@ include ../py/py.mk
CROSS_COMPILE = arm-none-eabi- CROSS_COMPILE = arm-none-eabi-
INC = -I.
INC += -I$(PY_SRC)
INC += -I$(BUILD)/includes
CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mabi=aapcs-linux -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -fsingle-precision-constant -Wdouble-promotion CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mabi=aapcs-linux -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -fsingle-precision-constant -Wdouble-promotion
CFLAGS = -I. -I$(PY_SRC) -Wall -Werror -ansi -std=gnu99 $(CFLAGS_CORTEX_M4) $(COPT) CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 $(CFLAGS_CORTEX_M4) $(COPT)
#Debugging/Optimization #Debugging/Optimization
ifeq ($(DEBUG), 1) ifeq ($(DEBUG), 1)
......
...@@ -59,10 +59,16 @@ $(BUILD)/%.pp: %.c ...@@ -59,10 +59,16 @@ $(BUILD)/%.pp: %.c
# object directories (but only for existance), and the object directories # object directories (but only for existance), and the object directories
# will be created if they don't exist. # will be created if they don't exist.
OBJ_DIRS = $(sort $(dir $(OBJ))) OBJ_DIRS = $(sort $(dir $(OBJ)))
$(OBJ): $(PY_BUILD)/qstrdefs.generated.h | $(OBJ_DIRS) $(OBJ): $(HEADER_PY_BUILD)/qstrdefs.generated.h | $(OBJ_DIRS)
$(OBJ_DIRS): $(OBJ_DIRS):
$(MKDIR) -p $@ $(MKDIR) -p $@
$(HEADER_BUILD):
$(MKDIR) -p $@
$(HEADER_PY_BUILD):
$(MKDIR) -p $@
ifneq ($(PROG),) ifneq ($(PROG),)
# Build a standalone executable (unix and unix-cpy do this) # Build a standalone executable (unix and unix-cpy do this)
......
# where py object files go (they have a name prefix to prevent filename clashes) # where py object files go (they have a name prefix to prevent filename clashes)
PY_BUILD = $(BUILD)/py PY_BUILD = $(BUILD)/py
# file containing qstr defs for the core Python bit # where autogenerated header files go
HEADER_BUILD = $(BUILD)/includes/build
# where autogenerated py header files go
HEADER_PY_BUILD = $(HEADER_BUILD)/py
# file containing qstr defs for the core Python bit
PY_QSTR_DEFS = $(PY_SRC)/qstrdefs.h PY_QSTR_DEFS = $(PY_SRC)/qstrdefs.h
# py object files # py object files
...@@ -100,26 +105,25 @@ PY_O = $(addprefix $(PY_BUILD)/, $(PY_O_BASENAME)) ...@@ -100,26 +105,25 @@ PY_O = $(addprefix $(PY_BUILD)/, $(PY_O_BASENAME))
FORCE: FORCE:
.PHONY: FORCE .PHONY: FORCE
$(PY_BUILD)/py-version.h: FORCE $(HEADER_PY_BUILD)/py-version.h: FORCE
$(Q)$(PY_SRC)/py-version.sh > $@.tmp $(Q)$(PY_SRC)/py-version.sh > $@.tmp
$(Q)if [ -f "$@" ] && cmp -s $@ $@.tmp; then rm $@.tmp; else echo "Generating $@"; mv $@.tmp $@; fi $(Q)if [ -f "$@" ] && cmp -s $@ $@.tmp; then rm $@.tmp; else echo "Generating $@"; mv $@.tmp $@; fi
# qstr data # qstr data
# Adding an order only dependency on $(PY_BUILD) causes $(PY_BUILD) to get # Adding an order only dependency on $(HEADER_PY_BUILD) causes $(HEADER_PY_BUILD) to get
# created before we run the script to generate the .h # created before we run the script to generate the .h
$(PY_BUILD)/qstrdefs.generated.h: | $(PY_BUILD)/ $(HEADER_PY_BUILD)/qstrdefs.generated.h: $(PY_QSTR_DEFS) $(QSTR_DEFS) $(PY_SRC)/makeqstrdata.py mpconfigport.h $(PY_SRC)/mpconfig.h | $(HEADER_PY_BUILD)
$(PY_BUILD)/qstrdefs.generated.h: $(PY_QSTR_DEFS) $(QSTR_DEFS) $(PY_SRC)/makeqstrdata.py mpconfigport.h $(PY_SRC)/mpconfig.h
$(ECHO) "makeqstrdata $(PY_QSTR_DEFS) $(QSTR_DEFS)" $(ECHO) "makeqstrdata $(PY_QSTR_DEFS) $(QSTR_DEFS)"
$(CPP) $(CFLAGS) $(PY_QSTR_DEFS) -o $(PY_BUILD)/qstrdefs.preprocessed.h $(CPP) $(CFLAGS) $(PY_QSTR_DEFS) -o $(HEADER_PY_BUILD)/qstrdefs.preprocessed.h
$(Q)$(PYTHON) $(PY_SRC)/makeqstrdata.py $(PY_BUILD)/qstrdefs.preprocessed.h $(QSTR_DEFS) > $@ $(Q)$(PYTHON) $(PY_SRC)/makeqstrdata.py $(HEADER_PY_BUILD)/qstrdefs.preprocessed.h $(QSTR_DEFS) > $@
# We don't know which source files actually need the generated.h (since # We don't know which source files actually need the generated.h (since
# it is #included from str.h). The compiler generated dependencies will cause # it is #included from str.h). The compiler generated dependencies will cause
# the right .o's to get recompiled if the generated.h file changes. Adding # the right .o's to get recompiled if the generated.h file changes. Adding
# an order-only dependendency to all of the .o's will cause the generated .h # an order-only dependendency to all of the .o's will cause the generated .h
# to get built before we try to compile any of them. # to get built before we try to compile any of them.
$(PY_O): | $(PY_BUILD)/qstrdefs.generated.h $(PY_BUILD)/py-version.h $(PY_O): | $(HEADER_PY_BUILD)/qstrdefs.generated.h $(HEADER_PY_BUILD)/py-version.h
# emitters # emitters
......
...@@ -60,7 +60,6 @@ const static qstr_pool_t const_pool = { ...@@ -60,7 +60,6 @@ const static qstr_pool_t const_pool = {
(const byte*) "\0\0\0\0", // invalid/no qstr has empty data (const byte*) "\0\0\0\0", // invalid/no qstr has empty data
(const byte*) "\0\0\0\0", // empty qstr (const byte*) "\0\0\0\0", // empty qstr
#define Q(id, str) str, #define Q(id, str) str,
// TODO having 'build/' here is a bit of a hack, should take config variable from Makefile
#include "build/py/qstrdefs.generated.h" #include "build/py/qstrdefs.generated.h"
#undef Q #undef Q
}, },
......
...@@ -8,7 +8,6 @@ enum { ...@@ -8,7 +8,6 @@ enum {
MP_QSTR_NULL = 0, // indicates invalid/no qstr MP_QSTR_NULL = 0, // indicates invalid/no qstr
MP_QSTR_ = 1, // the empty qstr MP_QSTR_ = 1, // the empty qstr
#define Q(id, str) MP_QSTR_##id, #define Q(id, str) MP_QSTR_##id,
// TODO having 'build/py.' here is a bit of a hack, should take config variable from Makefile
#include "build/py/qstrdefs.generated.h" #include "build/py/qstrdefs.generated.h"
#undef Q #undef Q
MP_QSTR_number_of, MP_QSTR_number_of,
......
...@@ -17,12 +17,19 @@ DFU=../tools/dfu.py ...@@ -17,12 +17,19 @@ DFU=../tools/dfu.py
CROSS_COMPILE = arm-none-eabi- CROSS_COMPILE = arm-none-eabi-
INC = -I.
INC += -I$(PY_SRC)
INC += -I$(BUILD)/includes
INC += -I$(CMSIS_DIR)
INC += -I$(STMPERIPH_DIR)
INC += -I$(STMUSB_DIR)
INC += -I$(STMUSBD_DIR)
INC += -I$(STMUSBH_DIR)
INC += -I$(FATFS_DIR)
#INC += -I$(CC3K_DIR)
CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mabi=aapcs-linux -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -fsingle-precision-constant -Wdouble-promotion CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mabi=aapcs-linux -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -fsingle-precision-constant -Wdouble-promotion
CFLAGS = -I. -I$(PY_SRC) -I$(CMSIS_DIR) -I$(STMPERIPH_DIR) -I$(STMUSB_DIR) -Wall -Werror -ansi -std=gnu99 $(CFLAGS_CORTEX_M4) $(COPT) CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 $(CFLAGS_CORTEX_M4) $(COPT)
CFLAGS += -I$(STMUSBD_DIR)
CFLAGS += -I$(STMUSBH_DIR)
CFLAGS += -I$(FATFS_DIR)
#CFLAGS += -I$(CC3K_DIR)
BOARD ?= PYBOARD4 BOARD ?= PYBOARD4
ifeq ($(wildcard boards/$(BOARD)/.),) ifeq ($(wildcard boards/$(BOARD)/.),)
......
...@@ -18,6 +18,7 @@ CROSS_COMPILE = arm-none-eabi- ...@@ -18,6 +18,7 @@ CROSS_COMPILE = arm-none-eabi-
INC = -I. INC = -I.
INC += -I$(PY_SRC) INC += -I$(PY_SRC)
INC += -I$(BUILD)/includes
INC += -I$(CMSIS_DIR)/inc INC += -I$(CMSIS_DIR)/inc
INC += -I$(CMSIS_DIR)/devinc INC += -I$(CMSIS_DIR)/devinc
INC += -I$(HAL_DIR)/inc INC += -I$(HAL_DIR)/inc
...@@ -208,28 +209,28 @@ BOARD_PINS = boards/$(BOARD)/pins.csv ...@@ -208,28 +209,28 @@ BOARD_PINS = boards/$(BOARD)/pins.csv
AF_FILE = boards/stm32f4xx-af.csv AF_FILE = boards/stm32f4xx-af.csv
PREFIX_FILE = boards/stm32f4xx-prefix.c PREFIX_FILE = boards/stm32f4xx-prefix.c
GEN_PINS_SRC = $(BUILD)/pins_$(BOARD).c GEN_PINS_SRC = $(BUILD)/pins_$(BOARD).c
GEN_PINS_HDR = $(BUILD)/pins.h GEN_PINS_HDR = $(HEADER_BUILD)/pins.h
INSERT_USB_IDS = ../tools/insert-usb-ids.py INSERT_USB_IDS = ../tools/insert-usb-ids.py
FILE2H = ../tools/file2h.py FILE2H = ../tools/file2h.py
USB_IDS_FILE = usbd_desc_cdc_msc.c USB_IDS_FILE = usbd_desc_cdc_msc.c
CDCINF_TEMPLATE = pybcdc.inf_template CDCINF_TEMPLATE = pybcdc.inf_template
GEN_CDCINF_FILE = $(BUILD)/pybcdc.inf GEN_CDCINF_FILE = $(HEADER_BUILD)/pybcdc.inf
GEN_CDCINF_HEADER = $(BUILD)/pybcdc_inf.h GEN_CDCINF_HEADER = $(HEADER_BUILD)/pybcdc_inf.h
# Making OBJ use an order-only depenedency on the generated pins.h file # Making OBJ use an order-only depenedency on the generated pins.h file
# has the side effect of making the pins.h file before we actually compile # has the side effect of making the pins.h file before we actually compile
# any of the objects. The normal dependency generation will deal with the # any of the objects. The normal dependency generation will deal with the
# case when pins.h is modified. But when it doesn't exist, we don't know # case when pins.h is modified. But when it doesn't exist, we don't know
# which source files might need it. # which source files might need it.
$(OBJ): | $(BUILD)/pins.h $(OBJ): | $(HEADER_BUILD)/pins.h
$(BUILD)/main.o: $(GEN_CDCINF_HEADER) $(BUILD)/main.o: $(GEN_CDCINF_HEADER)
# Use a pattern rule here so that make will only call make-pins.py once to make # Use a pattern rule here so that make will only call make-pins.py once to make
# both pins_$(BOARD).c and pins.h # both pins_$(BOARD).c and pins.h
$(BUILD)/%_$(BOARD).c $(BUILD)/%.h: boards/$(BOARD)/%.csv $(MAKE_PINS) $(AF_FILE) $(PREFIX_FILE) $(BUILD)/%_$(BOARD).c $(HEADER_BUILD)/%.h: boards/$(BOARD)/%.csv $(MAKE_PINS) $(AF_FILE) $(PREFIX_FILE)
$(ECHO) "Create $@" $(ECHO) "Create $@"
$(Q)$(PYTHON) $(MAKE_PINS) --board $(BOARD_PINS) --af $(AF_FILE) --prefix $(PREFIX_FILE) --hdr $(GEN_PINS_HDR) > $(GEN_PINS_SRC) $(Q)$(PYTHON) $(MAKE_PINS) --board $(BOARD_PINS) --af $(AF_FILE) --prefix $(PREFIX_FILE) --hdr $(GEN_PINS_HDR) > $(GEN_PINS_SRC)
......
...@@ -17,7 +17,13 @@ CROSS_COMPILE = $(COMPILER_PATH)/arm-none-eabi- ...@@ -17,7 +17,13 @@ CROSS_COMPILE = $(COMPILER_PATH)/arm-none-eabi-
CFLAGS_TEENSY = -DF_CPU=96000000 -DUSB_SERIAL -D__MK20DX256__ CFLAGS_TEENSY = -DF_CPU=96000000 -DUSB_SERIAL -D__MK20DX256__
CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mcpu=cortex-m4 -fsingle-precision-constant -Wdouble-promotion $(CFLAGS_TEENSY) CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mcpu=cortex-m4 -fsingle-precision-constant -Wdouble-promotion $(CFLAGS_TEENSY)
CFLAGS = -I. -I$(PY_SRC) -I$(CORE_PATH) -Wall -ansi -std=gnu99 $(CFLAGS_CORTEX_M4)
INC = -I.
INC += -I$(PY_SRC)
INC += -I$(BUILD)/includes
INC += -I$(CORE_PATH)
CFLAGS = $(INC) -Wall -ansi -std=gnu99 $(CFLAGS_CORTEX_M4)
LDFLAGS = -nostdlib -T mk20dx256.ld LDFLAGS = -nostdlib -T mk20dx256.ld
LIBS = -L $(COMPILER_PATH)/../lib/gcc/arm-none-eabi/4.7.2/thumb2 -lgcc LIBS = -L $(COMPILER_PATH)/../lib/gcc/arm-none-eabi/4.7.2/thumb2 -lgcc
......
...@@ -6,8 +6,12 @@ PROG = cpy ...@@ -6,8 +6,12 @@ PROG = cpy
# include py core make definitions # include py core make definitions
include ../py/py.mk include ../py/py.mk
INC = -I.
INC += -I$(PY_SRC)
INC += -I$(BUILD)/includes
# compiler settings # compiler settings
CFLAGS = -I. -I$(PY_SRC) -Wall -Werror -ansi -std=gnu99 -DUNIX CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 -DUNIX
LDFLAGS = -lm LDFLAGS = -lm
# Debugging/Optimization # Debugging/Optimization
......
...@@ -10,8 +10,12 @@ QSTR_DEFS = qstrdefsport.h ...@@ -10,8 +10,12 @@ QSTR_DEFS = qstrdefsport.h
# include py core make definitions # include py core make definitions
include ../py/py.mk include ../py/py.mk
INC = -I.
INC += -I$(PY_SRC)
INC += -I$(BUILD)/includes
# compiler settings # compiler settings
CFLAGS = -I. -I$(PY_SRC) -Wall -Werror -ansi -std=gnu99 -DUNIX $(CFLAGS_MOD) $(COPT) CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 -DUNIX $(CFLAGS_MOD) $(COPT)
UNAME_S := $(shell uname -s) UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin) ifeq ($(UNAME_S),Darwin)
......
...@@ -9,8 +9,12 @@ QSTR_DEFS = ../unix/qstrdefsport.h ...@@ -9,8 +9,12 @@ QSTR_DEFS = ../unix/qstrdefsport.h
# include py core make definitions # include py core make definitions
include ../py/py.mk include ../py/py.mk
INC = -I.
INC += -I$(PY_SRC)
INC += -I$(BUILD)/includes
# compiler settings # compiler settings
CFLAGS = -I. -I$(PY_SRC) -Wall -Werror -ansi -std=gnu99 -DUNIX CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 -DUNIX
LDFLAGS = -lm LDFLAGS = -lm
# Debugging/Optimization # Debugging/Optimization
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment