summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2022-10-08 23:08:53 +1100
committerDamien George <damien@micropython.org>2022-10-11 23:17:41 +1100
commit17f2783e4aa4534823e2dc33e77389ad498f2d24 (patch)
tree7d35ac04c022084fe516bbb95dd6e353b1e325e7
parent8e912a501a926f59f330f8a71c2ac1bd4af88a9e (diff)
all: Use += rather than = everywhere for CFLAGS/LDFLAGS/LIBS.
This avoids a surprise where an = can cancel out an earlier +=. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
-rw-r--r--docs/develop/porting.rst4
-rw-r--r--examples/embedding/Makefile4
-rw-r--r--examples/embedding/Makefile.upylib4
-rw-r--r--ports/cc3200/Makefile4
-rw-r--r--ports/esp8266/Makefile6
-rw-r--r--ports/mimxrt/Makefile2
-rw-r--r--ports/minimal/Makefile8
-rw-r--r--ports/nrf/Makefile2
-rw-r--r--ports/pic16bit/Makefile6
-rw-r--r--ports/powerpc/Makefile4
-rw-r--r--ports/renesas-ra/Makefile2
-rw-r--r--ports/samd/Makefile6
-rw-r--r--ports/stm32/Makefile2
-rwxr-xr-xports/stm32/mboot/Makefile6
-rw-r--r--ports/teensy/Makefile4
-rw-r--r--ports/windows/Makefile4
16 files changed, 34 insertions, 34 deletions
diff --git a/docs/develop/porting.rst b/docs/develop/porting.rst
index 0511f5d27..74974a39e 100644
--- a/docs/develop/porting.rst
+++ b/docs/develop/porting.rst
@@ -98,8 +98,8 @@ We also need a Makefile at this point for the port:
include $(TOP)/extmod/extmod.mk
# Set CFLAGS and libraries.
- CFLAGS = -I. -I$(BUILD) -I$(TOP)
- LIBS = -lm
+ CFLAGS += -I. -I$(BUILD) -I$(TOP)
+ LIBS += -lm
# Define the required source files.
SRC_C = \
diff --git a/examples/embedding/Makefile b/examples/embedding/Makefile
index 7de1219b2..edaa577f5 100644
--- a/examples/embedding/Makefile
+++ b/examples/embedding/Makefile
@@ -1,6 +1,6 @@
MPTOP = ../..
-CFLAGS = -std=c99 -I. -I$(MPTOP) -DNO_QSTR
-LDFLAGS = -L./build
+CFLAGS += -std=c99 -I. -I$(MPTOP) -DNO_QSTR
+LDFLAGS += -L./build
hello-embed: hello-embed.o -lmicropython
diff --git a/examples/embedding/Makefile.upylib b/examples/embedding/Makefile.upylib
index a8e2b91d5..99ce94b7a 100644
--- a/examples/embedding/Makefile.upylib
+++ b/examples/embedding/Makefile.upylib
@@ -20,7 +20,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) $(CFLAGS_EXTRA)
# Some systems (eg MacOS) need -fno-common so that mp_state_ctx is placed in the BSS.
CFLAGS += -fno-common
@@ -70,7 +70,7 @@ else
# Use gcc syntax for map file
LDFLAGS_ARCH = -Wl,-Map=$@.map,--cref
endif
-LDFLAGS = $(LDFLAGS_MOD) $(LDFLAGS_ARCH) -lm $(LDFLAGS_EXTRA)
+LDFLAGS += $(LDFLAGS_MOD) $(LDFLAGS_ARCH) -lm $(LDFLAGS_EXTRA)
ifeq ($(MICROPY_FORCE_32BIT),1)
# Note: you may need to install i386 versions of dependency packages,
diff --git a/ports/cc3200/Makefile b/ports/cc3200/Makefile
index b880ad646..6c034c586 100644
--- a/ports/cc3200/Makefile
+++ b/ports/cc3200/Makefile
@@ -20,7 +20,7 @@ include ../../py/mkenv.mk
CROSS_COMPILE ?= arm-none-eabi-
CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -march=armv7e-m -mabi=aapcs -mcpu=cortex-m4 -msoft-float -mfloat-abi=soft -fsingle-precision-constant -Wdouble-promotion
-CFLAGS = -Wall -Wpointer-arith -Werror -std=gnu99 -nostdlib $(CFLAGS_CORTEX_M4) -Os
+CFLAGS += -Wall -Wpointer-arith -Werror -std=gnu99 -nostdlib $(CFLAGS_CORTEX_M4) -Os
CFLAGS += -g -ffunction-sections -fdata-sections -fno-common -fsigned-char -mno-unaligned-access
CFLAGS += -Iboards/$(BOARD)
CFLAGS += $(CFLAGS_MOD)
@@ -28,7 +28,7 @@ CFLAGS += $(CFLAGS_MOD)
# Workaround gcc 12.1 bug.
CFLAGS += -Wno-array-bounds
-LDFLAGS = -Wl,-nostdlib -Wl,--gc-sections -Wl,-Map=$@.map
+LDFLAGS += -Wl,-nostdlib -Wl,--gc-sections -Wl,-Map=$@.map
FLASH_SIZE_WIPY = 2M
FLASH_SIZE_LAUNCHXL = 1M
diff --git a/ports/esp8266/Makefile b/ports/esp8266/Makefile
index c027f690f..6002dc5e5 100644
--- a/ports/esp8266/Makefile
+++ b/ports/esp8266/Makefile
@@ -57,12 +57,12 @@ CFLAGS_XTENSA = -fsingle-precision-constant -Wdouble-promotion \
-Wl,-EL -mlongcalls -mtext-section-literals -mforce-l32 \
-DLWIP_OPEN_SRC
-CFLAGS = $(INC) -Wall -Wpointer-arith -Werror -std=gnu99 -nostdlib -DUART_OS=$(UART_OS) \
+CFLAGS += $(INC) -Wall -Wpointer-arith -Werror -std=gnu99 -nostdlib -DUART_OS=$(UART_OS) \
$(CFLAGS_XTENSA) $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA) -I$(BOARD_DIR)
LD_FILES ?= boards/esp8266_2m.ld
-LDFLAGS = -nostdlib -T $(LD_FILES) -Map=$(@:.elf=.map) --cref
-LIBS = -L$(ESP_SDK)/lib -lmain -ljson -llwip_open -lpp -lnet80211 -lwpa -lphy -lnet80211 $(LDFLAGS_MOD)
+LDFLAGS += -nostdlib -T $(LD_FILES) -Map=$(@:.elf=.map) --cref
+LIBS += -L$(ESP_SDK)/lib -lmain -ljson -llwip_open -lpp -lnet80211 -lwpa -lphy -lnet80211 $(LDFLAGS_MOD)
LIBGCC_FILE_NAME = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
LIBS += -L$(dir $(LIBGCC_FILE_NAME)) -lgcc
diff --git a/ports/mimxrt/Makefile b/ports/mimxrt/Makefile
index 6a18879ac..8493c47a7 100644
--- a/ports/mimxrt/Makefile
+++ b/ports/mimxrt/Makefile
@@ -393,7 +393,7 @@ CFLAGS += $(CFLAGS_MOD) $(CFLAGS_EXTRA)
# Linker Flags
# =============================================================================
-LDFLAGS = \
+LDFLAGS += \
--cref \
--gc-sections \
--print-memory-usage \
diff --git a/ports/minimal/Makefile b/ports/minimal/Makefile
index 0e875cc24..2e85bd912 100644
--- a/ports/minimal/Makefile
+++ b/ports/minimal/Makefile
@@ -23,12 +23,12 @@ ifeq ($(CROSS), 1)
DFU = $(TOP)/tools/dfu.py
PYDFU = $(TOP)/tools/pydfu.py
CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mcpu=cortex-m4 -msoft-float -fsingle-precision-constant -Wdouble-promotion -Wfloat-conversion
-CFLAGS = $(INC) -Wall -Werror -std=c99 -nostdlib $(CFLAGS_CORTEX_M4) $(COPT)
-LDFLAGS = -nostdlib -T stm32f405.ld -Map=$@.map --cref --gc-sections
+CFLAGS += $(INC) -Wall -Werror -std=c99 -nostdlib $(CFLAGS_CORTEX_M4) $(COPT)
+LDFLAGS += -nostdlib -T stm32f405.ld -Map=$@.map --cref --gc-sections
else
LD = gcc
-CFLAGS = $(INC) -Wall -Werror -Wdouble-promotion -Wfloat-conversion -std=c99 $(COPT)
-LDFLAGS = -Wl,-Map=$@.map,--cref -Wl,--gc-sections
+CFLAGS += $(INC) -Wall -Werror -Wdouble-promotion -Wfloat-conversion -std=c99 $(COPT)
+LDFLAGS += -Wl,-Map=$@.map,--cref -Wl,--gc-sections
endif
CSUPEROPT = -Os # save some code space
diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile
index bc295cac8..38d0bd7fc 100644
--- a/ports/nrf/Makefile
+++ b/ports/nrf/Makefile
@@ -129,7 +129,7 @@ CFLAGS += -fno-strict-aliasing
CFLAGS += -Iboards/$(BOARD)
CFLAGS += -DNRF5_HAL_H='<$(MCU_VARIANT)_hal.h>'
-LDFLAGS = $(CFLAGS)
+LDFLAGS += $(CFLAGS)
LDFLAGS += -Xlinker -Map=$(@:.elf=.map)
LDFLAGS += -mthumb -mabi=aapcs $(addprefix -T,$(LD_FILES)) -L boards/
diff --git a/ports/pic16bit/Makefile b/ports/pic16bit/Makefile
index 392196cbc..d2c8df470 100644
--- a/ports/pic16bit/Makefile
+++ b/ports/pic16bit/Makefile
@@ -21,7 +21,7 @@ INC += -I$(XC16)/include
INC += -I$(XC16)/support/$(PARTFAMILY)/h
CFLAGS_PIC16BIT = -mcpu=$(PART) -mlarge-code
-CFLAGS = $(INC) -Wall -Werror -std=gnu99 -nostdlib $(CFLAGS_PIC16BIT) $(COPT)
+CFLAGS += $(INC) -Wall -Werror -std=gnu99 -nostdlib $(CFLAGS_PIC16BIT) $(COPT)
#Debugging/Optimization
ifeq ($(DEBUG), 1)
@@ -30,8 +30,8 @@ else
CFLAGS += -O1 -DNDEBUG
endif
-LDFLAGS = --heap=0 -nostdlib -T $(XC16)/support/$(PARTFAMILY)/gld/p$(PART).gld -Map=$@.map --cref -p$(PART)
-LIBS = -L$(XC16)/lib -L$(XC16)/lib/$(PARTFAMILY) -lc -lm -lpic30
+LDFLAGS += --heap=0 -nostdlib -T $(XC16)/support/$(PARTFAMILY)/gld/p$(PART).gld -Map=$@.map --cref -p$(PART)
+LIBS += -L$(XC16)/lib -L$(XC16)/lib/$(PARTFAMILY) -lc -lm -lpic30
SRC_C = \
main.c \
diff --git a/ports/powerpc/Makefile b/ports/powerpc/Makefile
index 0986fd13e..8fc9b1116 100644
--- a/ports/powerpc/Makefile
+++ b/ports/powerpc/Makefile
@@ -21,14 +21,14 @@ INC += -I.
INC += -I$(TOP)
INC += -I$(BUILD)
-CFLAGS = $(INC) -g -Wall -Wdouble-promotion -Wfloat-conversion -std=c99 $(COPT)
+CFLAGS += $(INC) -g -Wall -Wdouble-promotion -Wfloat-conversion -std=c99 $(COPT)
CFLAGS += -mno-string -mno-multiple -mno-vsx -mno-altivec -nostdlib
CFLAGS += -mlittle-endian -mstrict-align -msoft-float
CFLAGS += -Os
CFLAGS += -fdata-sections -ffunction-sections -fno-stack-protector -ffreestanding
CFLAGS += -U_FORTIFY_SOURCE
-LDFLAGS = -N -T powerpc.lds -nostdlib
+LDFLAGS += -N -T powerpc.lds -nostdlib
LIBS =
diff --git a/ports/renesas-ra/Makefile b/ports/renesas-ra/Makefile
index 92d8be069..6c37aeb1e 100644
--- a/ports/renesas-ra/Makefile
+++ b/ports/renesas-ra/Makefile
@@ -139,7 +139,7 @@ CFLAGS += -fsingle-precision-constant
endif
endif
-LDFLAGS = -nostdlib -L $(LD_DIR) $(addprefix -T,$(LD_FILES)) -Map=$(@:.elf=.map) --cref
+LDFLAGS += -nostdlib -L $(LD_DIR) $(addprefix -T,$(LD_FILES)) -Map=$(@:.elf=.map) --cref
LDFLAGS += --defsym=_estack_reserve=8
LIBS += "$(shell $(CC) $(CFLAGS) -print-libgcc-file-name)"
diff --git a/ports/samd/Makefile b/ports/samd/Makefile
index 5ff00f21f..512820088 100644
--- a/ports/samd/Makefile
+++ b/ports/samd/Makefile
@@ -58,15 +58,15 @@ GEN_PINS_HDR = $(BUILD)/pins.h
CFLAGS_MCU_SAMD21 = -mtune=cortex-m0plus -mcpu=cortex-m0plus -msoft-float
CFLAGS_MCU_SAMD51 = -mtune=cortex-m4 -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard
-CFLAGS = $(INC) -Wall -Werror -std=c99 -nostdlib -mthumb $(CFLAGS_MCU_$(MCU_SERIES)) -fsingle-precision-constant -Wdouble-promotion
+CFLAGS += $(INC) -Wall -Werror -std=c99 -nostdlib -mthumb $(CFLAGS_MCU_$(MCU_SERIES)) -fsingle-precision-constant -Wdouble-promotion
CFLAGS += -DMCU_$(MCU_SERIES) -D__$(CMSIS_MCU)__
CFLAGS += $(CFLAGS_MOD) $(CFLAGS_EXTRA)
CFLAGS += -DMPCONFIG_MCU_H='<boards/mpconfig_$(MCU_SERIES_LOWER).h>'
-LDFLAGS = -nostdlib $(addprefix -T,$(LD_FILES)) -Map=$@.map --cref
+LDFLAGS += -nostdlib $(addprefix -T,$(LD_FILES)) -Map=$@.map --cref
LDFLAGS += $(LDFLAGS_MOD)
-LIBS = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
+LIBS += $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
# Tune for Debugging or Optimization
CFLAGS += -g # always include debug info in the ELF
diff --git a/ports/stm32/Makefile b/ports/stm32/Makefile
index 4b4a9f0ce..903730982 100644
--- a/ports/stm32/Makefile
+++ b/ports/stm32/Makefile
@@ -99,7 +99,7 @@ CFLAGS += -fsingle-precision-constant
endif
endif
-LDFLAGS = -nostdlib -L $(LD_DIR) $(addprefix -T,$(LD_FILES)) -Wl,-Map=$(@:.elf=.map) -Wl,--cref
+LDFLAGS += -nostdlib -L $(LD_DIR) $(addprefix -T,$(LD_FILES)) -Wl,-Map=$(@:.elf=.map) -Wl,--cref
LDFLAGS += -Wl,--defsym=_estack_reserve=8
LIBS += "$(shell $(CC) $(CFLAGS) -print-libgcc-file-name)"
diff --git a/ports/stm32/mboot/Makefile b/ports/stm32/mboot/Makefile
index 4c903b4ff..176092f8c 100755
--- a/ports/stm32/mboot/Makefile
+++ b/ports/stm32/mboot/Makefile
@@ -58,7 +58,7 @@ INC += -I../$(USBDEV_DIR)/core/inc -I../$(USBDEV_DIR)/class/inc
# the compiler does not optimise these functions in terms of themselves.
CFLAGS_BUILTIN ?= -ffreestanding -fno-builtin -fno-lto
-CFLAGS = $(INC) -Wall -Wpointer-arith -Wdouble-promotion -Wfloat-conversion -Werror -std=gnu99 -nostdlib $(CFLAGS_MOD) $(CFLAGS_EXTRA)
+CFLAGS += $(INC) -Wall -Wpointer-arith -Wdouble-promotion -Wfloat-conversion -Werror -std=gnu99 -nostdlib $(CFLAGS_MOD) $(CFLAGS_EXTRA)
CFLAGS += -D$(CMSIS_MCU)
CFLAGS += $(CFLAGS_MCU_$(MCU_SERIES))
CFLAGS += $(COPT)
@@ -75,8 +75,8 @@ CFLAGS += -DMICROPY_HW_STM32WB_FLASH_SYNCRONISATION=0
CFLAGS += -DBOOTLOADER_DFU_USB_VID=$(BOOTLOADER_DFU_USB_VID) -DBOOTLOADER_DFU_USB_PID=$(BOOTLOADER_DFU_USB_PID)
MBOOT_LD_FILES ?= stm32_memory.ld stm32_sections.ld
-LDFLAGS = -nostdlib -L . $(addprefix -T,$(MBOOT_LD_FILES)) -Map=$(@:.elf=.map) --cref
-LIBS = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
+LDFLAGS += -nostdlib -L . $(addprefix -T,$(MBOOT_LD_FILES)) -Map=$(@:.elf=.map) --cref
+LIBS += $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
# Remove uncalled code from the final image.
CFLAGS += -fdata-sections -ffunction-sections
diff --git a/ports/teensy/Makefile b/ports/teensy/Makefile
index d7161fcbb..52fc812ad 100644
--- a/ports/teensy/Makefile
+++ b/ports/teensy/Makefile
@@ -75,8 +75,8 @@ INC += -I$(TOP)/ports/stm32
INC += -I$(BUILD)
INC += -Icore
-CFLAGS = $(INC) -Wall -Wpointer-arith -Werror -std=c99 -nostdlib $(CFLAGS_CORTEX_M4)
-LDFLAGS = -nostdlib -T mk20dx256.ld -msoft-float -mfloat-abi=soft
+CFLAGS += $(INC) -Wall -Wpointer-arith -Werror -std=c99 -nostdlib $(CFLAGS_CORTEX_M4)
+LDFLAGS += -nostdlib -T mk20dx256.ld -msoft-float -mfloat-abi=soft
ifeq ($(USE_ARDUINO_TOOLCHAIN),1)
diff --git a/ports/windows/Makefile b/ports/windows/Makefile
index 1e793800f..64334bc18 100644
--- a/ports/windows/Makefile
+++ b/ports/windows/Makefile
@@ -32,8 +32,8 @@ INC += -I$(BUILD)
INC += -I$(VARIANT_DIR)
# compiler settings
-CFLAGS = $(INC) -Wall -Wpointer-arith -Wdouble-promotion -Werror -std=gnu99 -DUNIX -D__USE_MINGW_ANSI_STDIO=1 $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA)
-LDFLAGS = $(LDFLAGS_MOD) -lm -lbcrypt $(LDFLAGS_EXTRA)
+CFLAGS += $(INC) -Wall -Wpointer-arith -Wdouble-promotion -Werror -std=gnu99 -DUNIX -D__USE_MINGW_ANSI_STDIO=1 $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA)
+LDFLAGS += -lm -lbcrypt $(LDFLAGS_EXTRA)
# Debugging/Optimization
ifdef DEBUG