Skip to content

Commit 17f2783

Browse files
jimmodpgeorge
authored andcommittedOct 11, 2022
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 <[email protected]>
1 parent 8e912a5 commit 17f2783

File tree

16 files changed

+34
-34
lines changed

16 files changed

+34
-34
lines changed
 

‎docs/develop/porting.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ We also need a Makefile at this point for the port:
9898
include $(TOP)/extmod/extmod.mk
9999
100100
# Set CFLAGS and libraries.
101-
CFLAGS = -I. -I$(BUILD) -I$(TOP)
102-
LIBS = -lm
101+
CFLAGS += -I. -I$(BUILD) -I$(TOP)
102+
LIBS += -lm
103103
104104
# Define the required source files.
105105
SRC_C = \

‎examples/embedding/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MPTOP = ../..
2-
CFLAGS = -std=c99 -I. -I$(MPTOP) -DNO_QSTR
3-
LDFLAGS = -L./build
2+
CFLAGS += -std=c99 -I. -I$(MPTOP) -DNO_QSTR
3+
LDFLAGS += -L./build
44

55
hello-embed: hello-embed.o -lmicropython
66

‎examples/embedding/Makefile.upylib

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ INC += -I$(BUILD)
2020
# compiler settings
2121
CWARN = -Wall -Werror
2222
CWARN += -Wpointer-arith -Wuninitialized
23-
CFLAGS = $(INC) $(CWARN) -std=gnu99 -DUNIX $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA)
23+
CFLAGS += $(INC) $(CWARN) -std=gnu99 -DUNIX $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA)
2424

2525
# Some systems (eg MacOS) need -fno-common so that mp_state_ctx is placed in the BSS.
2626
CFLAGS += -fno-common
@@ -70,7 +70,7 @@ else
7070
# Use gcc syntax for map file
7171
LDFLAGS_ARCH = -Wl,-Map=$@.map,--cref
7272
endif
73-
LDFLAGS = $(LDFLAGS_MOD) $(LDFLAGS_ARCH) -lm $(LDFLAGS_EXTRA)
73+
LDFLAGS += $(LDFLAGS_MOD) $(LDFLAGS_ARCH) -lm $(LDFLAGS_EXTRA)
7474

7575
ifeq ($(MICROPY_FORCE_32BIT),1)
7676
# Note: you may need to install i386 versions of dependency packages,

‎ports/cc3200/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ include ../../py/mkenv.mk
2020
CROSS_COMPILE ?= arm-none-eabi-
2121

2222
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
23-
CFLAGS = -Wall -Wpointer-arith -Werror -std=gnu99 -nostdlib $(CFLAGS_CORTEX_M4) -Os
23+
CFLAGS += -Wall -Wpointer-arith -Werror -std=gnu99 -nostdlib $(CFLAGS_CORTEX_M4) -Os
2424
CFLAGS += -g -ffunction-sections -fdata-sections -fno-common -fsigned-char -mno-unaligned-access
2525
CFLAGS += -Iboards/$(BOARD)
2626
CFLAGS += $(CFLAGS_MOD)
2727

2828
# Workaround gcc 12.1 bug.
2929
CFLAGS += -Wno-array-bounds
3030

31-
LDFLAGS = -Wl,-nostdlib -Wl,--gc-sections -Wl,-Map=$@.map
31+
LDFLAGS += -Wl,-nostdlib -Wl,--gc-sections -Wl,-Map=$@.map
3232

3333
FLASH_SIZE_WIPY = 2M
3434
FLASH_SIZE_LAUNCHXL = 1M

‎ports/esp8266/Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ CFLAGS_XTENSA = -fsingle-precision-constant -Wdouble-promotion \
5757
-Wl,-EL -mlongcalls -mtext-section-literals -mforce-l32 \
5858
-DLWIP_OPEN_SRC
5959

60-
CFLAGS = $(INC) -Wall -Wpointer-arith -Werror -std=gnu99 -nostdlib -DUART_OS=$(UART_OS) \
60+
CFLAGS += $(INC) -Wall -Wpointer-arith -Werror -std=gnu99 -nostdlib -DUART_OS=$(UART_OS) \
6161
$(CFLAGS_XTENSA) $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA) -I$(BOARD_DIR)
6262

6363
LD_FILES ?= boards/esp8266_2m.ld
64-
LDFLAGS = -nostdlib -T $(LD_FILES) -Map=$(@:.elf=.map) --cref
65-
LIBS = -L$(ESP_SDK)/lib -lmain -ljson -llwip_open -lpp -lnet80211 -lwpa -lphy -lnet80211 $(LDFLAGS_MOD)
64+
LDFLAGS += -nostdlib -T $(LD_FILES) -Map=$(@:.elf=.map) --cref
65+
LIBS += -L$(ESP_SDK)/lib -lmain -ljson -llwip_open -lpp -lnet80211 -lwpa -lphy -lnet80211 $(LDFLAGS_MOD)
6666

6767
LIBGCC_FILE_NAME = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
6868
LIBS += -L$(dir $(LIBGCC_FILE_NAME)) -lgcc

‎ports/mimxrt/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ CFLAGS += $(CFLAGS_MOD) $(CFLAGS_EXTRA)
393393
# Linker Flags
394394
# =============================================================================
395395

396-
LDFLAGS = \
396+
LDFLAGS += \
397397
--cref \
398398
--gc-sections \
399399
--print-memory-usage \

‎ports/minimal/Makefile

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ ifeq ($(CROSS), 1)
2323
DFU = $(TOP)/tools/dfu.py
2424
PYDFU = $(TOP)/tools/pydfu.py
2525
CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mcpu=cortex-m4 -msoft-float -fsingle-precision-constant -Wdouble-promotion -Wfloat-conversion
26-
CFLAGS = $(INC) -Wall -Werror -std=c99 -nostdlib $(CFLAGS_CORTEX_M4) $(COPT)
27-
LDFLAGS = -nostdlib -T stm32f405.ld -Map=$@.map --cref --gc-sections
26+
CFLAGS += $(INC) -Wall -Werror -std=c99 -nostdlib $(CFLAGS_CORTEX_M4) $(COPT)
27+
LDFLAGS += -nostdlib -T stm32f405.ld -Map=$@.map --cref --gc-sections
2828
else
2929
LD = gcc
30-
CFLAGS = $(INC) -Wall -Werror -Wdouble-promotion -Wfloat-conversion -std=c99 $(COPT)
31-
LDFLAGS = -Wl,-Map=$@.map,--cref -Wl,--gc-sections
30+
CFLAGS += $(INC) -Wall -Werror -Wdouble-promotion -Wfloat-conversion -std=c99 $(COPT)
31+
LDFLAGS += -Wl,-Map=$@.map,--cref -Wl,--gc-sections
3232
endif
3333

3434
CSUPEROPT = -Os # save some code space

‎ports/nrf/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ CFLAGS += -fno-strict-aliasing
129129
CFLAGS += -Iboards/$(BOARD)
130130
CFLAGS += -DNRF5_HAL_H='<$(MCU_VARIANT)_hal.h>'
131131

132-
LDFLAGS = $(CFLAGS)
132+
LDFLAGS += $(CFLAGS)
133133
LDFLAGS += -Xlinker -Map=$(@:.elf=.map)
134134
LDFLAGS += -mthumb -mabi=aapcs $(addprefix -T,$(LD_FILES)) -L boards/
135135

‎ports/pic16bit/Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ INC += -I$(XC16)/include
2121
INC += -I$(XC16)/support/$(PARTFAMILY)/h
2222

2323
CFLAGS_PIC16BIT = -mcpu=$(PART) -mlarge-code
24-
CFLAGS = $(INC) -Wall -Werror -std=gnu99 -nostdlib $(CFLAGS_PIC16BIT) $(COPT)
24+
CFLAGS += $(INC) -Wall -Werror -std=gnu99 -nostdlib $(CFLAGS_PIC16BIT) $(COPT)
2525

2626
#Debugging/Optimization
2727
ifeq ($(DEBUG), 1)
@@ -30,8 +30,8 @@ else
3030
CFLAGS += -O1 -DNDEBUG
3131
endif
3232

33-
LDFLAGS = --heap=0 -nostdlib -T $(XC16)/support/$(PARTFAMILY)/gld/p$(PART).gld -Map=$@.map --cref -p$(PART)
34-
LIBS = -L$(XC16)/lib -L$(XC16)/lib/$(PARTFAMILY) -lc -lm -lpic30
33+
LDFLAGS += --heap=0 -nostdlib -T $(XC16)/support/$(PARTFAMILY)/gld/p$(PART).gld -Map=$@.map --cref -p$(PART)
34+
LIBS += -L$(XC16)/lib -L$(XC16)/lib/$(PARTFAMILY) -lc -lm -lpic30
3535

3636
SRC_C = \
3737
main.c \

‎ports/powerpc/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ INC += -I.
2121
INC += -I$(TOP)
2222
INC += -I$(BUILD)
2323

24-
CFLAGS = $(INC) -g -Wall -Wdouble-promotion -Wfloat-conversion -std=c99 $(COPT)
24+
CFLAGS += $(INC) -g -Wall -Wdouble-promotion -Wfloat-conversion -std=c99 $(COPT)
2525
CFLAGS += -mno-string -mno-multiple -mno-vsx -mno-altivec -nostdlib
2626
CFLAGS += -mlittle-endian -mstrict-align -msoft-float
2727
CFLAGS += -Os
2828
CFLAGS += -fdata-sections -ffunction-sections -fno-stack-protector -ffreestanding
2929
CFLAGS += -U_FORTIFY_SOURCE
3030

31-
LDFLAGS = -N -T powerpc.lds -nostdlib
31+
LDFLAGS += -N -T powerpc.lds -nostdlib
3232

3333
LIBS =
3434

‎ports/renesas-ra/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ CFLAGS += -fsingle-precision-constant
139139
endif
140140
endif
141141

142-
LDFLAGS = -nostdlib -L $(LD_DIR) $(addprefix -T,$(LD_FILES)) -Map=$(@:.elf=.map) --cref
142+
LDFLAGS += -nostdlib -L $(LD_DIR) $(addprefix -T,$(LD_FILES)) -Map=$(@:.elf=.map) --cref
143143
LDFLAGS += --defsym=_estack_reserve=8
144144
LIBS += "$(shell $(CC) $(CFLAGS) -print-libgcc-file-name)"
145145

‎ports/samd/Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ GEN_PINS_HDR = $(BUILD)/pins.h
5858

5959
CFLAGS_MCU_SAMD21 = -mtune=cortex-m0plus -mcpu=cortex-m0plus -msoft-float
6060
CFLAGS_MCU_SAMD51 = -mtune=cortex-m4 -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard
61-
CFLAGS = $(INC) -Wall -Werror -std=c99 -nostdlib -mthumb $(CFLAGS_MCU_$(MCU_SERIES)) -fsingle-precision-constant -Wdouble-promotion
61+
CFLAGS += $(INC) -Wall -Werror -std=c99 -nostdlib -mthumb $(CFLAGS_MCU_$(MCU_SERIES)) -fsingle-precision-constant -Wdouble-promotion
6262
CFLAGS += -DMCU_$(MCU_SERIES) -D__$(CMSIS_MCU)__
6363
CFLAGS += $(CFLAGS_MOD) $(CFLAGS_EXTRA)
6464
CFLAGS += -DMPCONFIG_MCU_H='<boards/mpconfig_$(MCU_SERIES_LOWER).h>'
6565

66-
LDFLAGS = -nostdlib $(addprefix -T,$(LD_FILES)) -Map=$@.map --cref
66+
LDFLAGS += -nostdlib $(addprefix -T,$(LD_FILES)) -Map=$@.map --cref
6767
LDFLAGS += $(LDFLAGS_MOD)
6868

69-
LIBS = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
69+
LIBS += $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
7070

7171
# Tune for Debugging or Optimization
7272
CFLAGS += -g # always include debug info in the ELF

‎ports/stm32/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ CFLAGS += -fsingle-precision-constant
9999
endif
100100
endif
101101

102-
LDFLAGS = -nostdlib -L $(LD_DIR) $(addprefix -T,$(LD_FILES)) -Wl,-Map=$(@:.elf=.map) -Wl,--cref
102+
LDFLAGS += -nostdlib -L $(LD_DIR) $(addprefix -T,$(LD_FILES)) -Wl,-Map=$(@:.elf=.map) -Wl,--cref
103103
LDFLAGS += -Wl,--defsym=_estack_reserve=8
104104
LIBS += "$(shell $(CC) $(CFLAGS) -print-libgcc-file-name)"
105105

‎ports/stm32/mboot/Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ INC += -I../$(USBDEV_DIR)/core/inc -I../$(USBDEV_DIR)/class/inc
5858
# the compiler does not optimise these functions in terms of themselves.
5959
CFLAGS_BUILTIN ?= -ffreestanding -fno-builtin -fno-lto
6060

61-
CFLAGS = $(INC) -Wall -Wpointer-arith -Wdouble-promotion -Wfloat-conversion -Werror -std=gnu99 -nostdlib $(CFLAGS_MOD) $(CFLAGS_EXTRA)
61+
CFLAGS += $(INC) -Wall -Wpointer-arith -Wdouble-promotion -Wfloat-conversion -Werror -std=gnu99 -nostdlib $(CFLAGS_MOD) $(CFLAGS_EXTRA)
6262
CFLAGS += -D$(CMSIS_MCU)
6363
CFLAGS += $(CFLAGS_MCU_$(MCU_SERIES))
6464
CFLAGS += $(COPT)
@@ -75,8 +75,8 @@ CFLAGS += -DMICROPY_HW_STM32WB_FLASH_SYNCRONISATION=0
7575
CFLAGS += -DBOOTLOADER_DFU_USB_VID=$(BOOTLOADER_DFU_USB_VID) -DBOOTLOADER_DFU_USB_PID=$(BOOTLOADER_DFU_USB_PID)
7676

7777
MBOOT_LD_FILES ?= stm32_memory.ld stm32_sections.ld
78-
LDFLAGS = -nostdlib -L . $(addprefix -T,$(MBOOT_LD_FILES)) -Map=$(@:.elf=.map) --cref
79-
LIBS = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
78+
LDFLAGS += -nostdlib -L . $(addprefix -T,$(MBOOT_LD_FILES)) -Map=$(@:.elf=.map) --cref
79+
LIBS += $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
8080

8181
# Remove uncalled code from the final image.
8282
CFLAGS += -fdata-sections -ffunction-sections

‎ports/teensy/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ INC += -I$(TOP)/ports/stm32
7575
INC += -I$(BUILD)
7676
INC += -Icore
7777

78-
CFLAGS = $(INC) -Wall -Wpointer-arith -Werror -std=c99 -nostdlib $(CFLAGS_CORTEX_M4)
79-
LDFLAGS = -nostdlib -T mk20dx256.ld -msoft-float -mfloat-abi=soft
78+
CFLAGS += $(INC) -Wall -Wpointer-arith -Werror -std=c99 -nostdlib $(CFLAGS_CORTEX_M4)
79+
LDFLAGS += -nostdlib -T mk20dx256.ld -msoft-float -mfloat-abi=soft
8080

8181
ifeq ($(USE_ARDUINO_TOOLCHAIN),1)
8282

‎ports/windows/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ INC += -I$(BUILD)
3232
INC += -I$(VARIANT_DIR)
3333

3434
# compiler settings
35-
CFLAGS = $(INC) -Wall -Wpointer-arith -Wdouble-promotion -Werror -std=gnu99 -DUNIX -D__USE_MINGW_ANSI_STDIO=1 $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA)
36-
LDFLAGS = $(LDFLAGS_MOD) -lm -lbcrypt $(LDFLAGS_EXTRA)
35+
CFLAGS += $(INC) -Wall -Wpointer-arith -Wdouble-promotion -Werror -std=gnu99 -DUNIX -D__USE_MINGW_ANSI_STDIO=1 $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA)
36+
LDFLAGS += -lm -lbcrypt $(LDFLAGS_EXTRA)
3737

3838
# Debugging/Optimization
3939
ifdef DEBUG

0 commit comments

Comments
 (0)
Please sign in to comment.