Skip to content

Commit

Permalink
Makefile: use normal conditionals
Browse files Browse the repository at this point in the history
  • Loading branch information
fjmolinas committed Jun 29, 2020
1 parent 8c7b677 commit e98341d
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 35 deletions.
7 changes: 4 additions & 3 deletions boards/native/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@ endif
EEPROM_FILE ?= $(BINDIR)/native.eeprom

# set the eeprom file flags only when the periph_eeprom feature is used.
# NOTE: This can be turned into normal conditional syntax once #9913 is fixed
EEPROM_FILE_FLAGS = $(if $(filter periph_eeprom,$(FEATURES_USED)),--eeprom $(EEPROM_FILE),)
TERMFLAGS += $(EEPROM_FILE_FLAGS)
ifneq (,$(filter periph_eeprom,$(FEATURES_USED)))
EEPROM_FILE_FLAGS = --eeprom $(EEPROM_FILE)
TERMFLAGS += $(EEPROM_FILE_FLAGS)
endif

TERMFLAGS += $(PORT)

Expand Down
26 changes: 15 additions & 11 deletions cpu/esp32/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ INCLUDES += -I$(ESP32_SDK_DIR)/components/soc/esp32/include
INCLUDES += -I$(ESP32_SDK_DIR)/components/soc/include
INCLUDES += -I$(RIOTCPU)/$(CPU)

INCLUDES += $(if $(filter esp_eth,$(USEMODULE)),-I$(RIOTCPU)/$(CPU)/vendor/esp-idf/include/ethernet)
INCLUDES += $(if $(filter esp_eth,$(USEMODULE)),-I$(ESP32_SDK_DIR)/components/ethernet/include)
ifneq (,$(filter esp_eth,$(USEMODULE)))
INCLUDES += -I$(RIOTCPU)/$(CPU)/vendor/esp-idf/include/ethernet
INCLUDES += -I$(ESP32_SDK_DIR)/components/ethernet/include
endif

CFLAGS += -DSDK_NOT_USED -DCONFIG_FREERTOS_UNICORE=1 -DESP_PLATFORM
CFLAGS += -DLOG_TAG_IN_BRACKETS
Expand All @@ -58,18 +60,20 @@ LINKFLAGS += -T$(RIOTCPU)/$(CPU)/ld/esp32.rom.nanofmt.ld
LINKFLAGS += -nostdlib -lgcc -Wl,-gc-sections

# Baselibs needed when using esp_wifi_any pseudomodule
_ESP_WIFI_ANY_BASELIBS = -lcore -lrtc -lnet80211 -lpp -lcoexist -lwps -lwpa -lwpa2
_ESP_WIFI_ANY_BASELIBS += -lphy -lstdc++
ifneq (,$(filter esp_wifi_any,$(USEMODULE)))
BASELIBS += -lcore -lrtc -lnet80211 -lpp -lcoexist -lwps -lwpa -lwpa2
BASELIBS += -lphy -lstdc++
endif

# Baselibs needed when using esp_now module
_ESP_NOW_BASELIBS = -lespnow -lmesh

# NOTE: These checks can be turned into a normal conditional when #9913 is fixed
BASELIBS += $(if $(filter esp_wifi_any,$(USEMODULE)),$(_ESP_WIFI_ANY_BASELIBS))
BASELIBS += $(if $(filter esp_now,$(USEMODULE)),$(_ESP_NOW_BASELIBS))
ifneq (,$(filter esp_now,$(USEMODULE)))
BASELIBS += -lespnow -lmesh
endif

UNDEF += $(if $(filter cpp,$(FEATURES_USED)),$(BINDIR)/esp_cxx/cxa_guard.o)
BASELIBS += $(if $(filter cpp,$(FEATURES_USED)),-lstdc++)
ifneq (,$(filter cpp,$(FEATURES_USED)))
UNDEF += $(BINDIR)/esp_cxx/cxa_guard.o
BASELIBS += -lstdc++
endif

# additional flasher configuration for ESP32 QEMU
ifneq (,$(filter esp_qemu,$(USEMODULE)))
Expand Down
14 changes: 9 additions & 5 deletions cpu/esp8266/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,15 @@ INCLUDES += -I$(ESP8266_RTOS_SDK_DIR)/components/spi_flash/include

CFLAGS += -D__ESP_FILE__=__FILE__

# NOTE: These can be turned into normal conditionals after #9913 is fixed
GDBSTUB_DIR ?= $(if $(filter esp_gdbstub,$(USEMODULE)),$(RIOTCPU)/$(CPU)/vendor/esp-gdbstub)
CFLAGS += $(if $(filter esp_gdbstub,$(USEMODULE)),-DGDBSTUB_BREAK_ON_INIT=1)
INCLUDES += $(if $(filter esp_gdbstub,$(USEMODULE)),-I$(GDBSTUB_DIR))
BASELIBS += $(if $(filter esp_now, $(USEMODULE)), -lespnow)
ifneq (,$(filter esp_gdbstub,$(USEMODULE)))
GDBSTUB_DIR ?= $(RIOTCPU)/$(CPU)/vendor/esp-gdbstub
CFLAGS += -DGDBSTUB_BREAK_ON_INIT=1)
INCLUDES += -I$(GDBSTUB_DIR)
endif

ifneq (,$(filter esp_now,$(USEMODULE)))
BASELIBS += -lespnow
endif

BASELIBS += -lgcc -lwpa -lcore -lnet80211 -lphy -lpp -lstdc++

Expand Down
34 changes: 23 additions & 11 deletions cpu/esp_common/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ ARFLAGS = rcs
CFLAGS_DBG ?= -ggdb -g3

# override default CFLAGS_OPT in case module esp_gdb is enabled
CFLAGS_OPT ?= $(if $(filter esp_gdb,$(USEMODULE)),-Og,-Os)
ifneq (,$(filter esp_gdb,$(USEMODULE)))
CFLAGS_OPT ?= -Og
else
CFLAGS_OPT ?= -Os
endif

CFLAGS += $(CFLAGS_OPT) $(CFLAGS_DBG)

Expand All @@ -51,9 +55,10 @@ ifneq (,$(filter esp_qemu,$(USEMODULE)))
CFLAGS += -DQEMU
endif

# NOTE: These checks can be turned into normal conditionals when #9913 is fixed
# use 32 priority levels if any WiFi interface or the ETH interface is used
CFLAGS += $(if $(filter esp_wifi_any esp_eth,$(USEMODULE)),-DSCHED_PRIO_LEVELS=32)
ifneq (,$(filter esp_wifi_any esp_eth,$(USEMODULE)))
CFLAGS += -DSCHED_PRIO_LEVELS=32
endif

# The threads for handling the ESP hardware have the priorities from 2 to 4.
# The priority of lwIP TCPIP thread should be lower than these priorities.
Expand All @@ -62,9 +67,12 @@ ifneq (,$(filter lwip,$(USEMODULE)))
endif

# if SPI RAM is enabled, the qout flash mode has to be used
# NOTE: These checks can be turned into normal conditionals when #9913 is fixed
_FLASH_MODE_PREV := $(FLASH_MODE)
FLASH_MODE = $(if $(filter esp_spi_ram,$(USEMODULE)),qout,$(_FLASH_MODE_PREV))
ifneq (,$(filter esp_spi_ram,$(USEMODULE)))
FLASH_MODE = qout
else
FLASH_MODE = $(_FLASH_MODE_PREV)
endif

# set CFLAG for the correspondant FLASH_MODE
CFLAGS += $(if $(findstring qout,$(FLASH_MODE)),-DFLASH_MODE_QOUT=1)
Expand All @@ -82,9 +90,12 @@ LINKFLAGS += -nostdlib -Wl,-gc-sections -Wl,-static
# LINKFLAGS += -Wl,--verbose
# LINKFLAGS += -Wl,--print-gc-sections

# NOTE: These checks can be turned into normal conditionals when #9913 is fixed
BOOTLOADER_COLOR = $(if $(filter esp_log_colored,$(USEMODULE)),_colors)
BOOTLOADER_INFO = $(if $(filter esp_log_startup,$(USEMODULE)),_info)
ifneq (,$(filter esp_log_colored,$(USEMODULE)))
BOOTLOADER_COLOR = _colors
endif
ifneq (,$(filter esp_log_startup,$(USEMODULE)))
BOOTLOADER_INFO = _info
endif

BOOTLOADER_BIN = bootloader$(BOOTLOADER_COLOR)$(BOOTLOADER_INFO).bin

Expand Down Expand Up @@ -132,7 +143,8 @@ else
FFLAGS += 0x10000 $(FLASHFILE).bin
endif

# NOTE: These checks can be turned into normal conditionals when #9913 is fixed
# increase the test timeout for file system tests that use the SPI flash drive
RIOT_TEST_TIMEOUT = $(if $(filter spiffs littlefs,$(USEMODULE)),120)
$(call target-export-variables,test,RIOT_TEST_TIMEOUT)
ifneq (,$(filter spiffs littlefs,$(USEMODULE)))
RIOT_TEST_TIMEOUT = 20
$(call target-export-variables,test,RIOT_TEST_TIMEOUT)
endif
7 changes: 4 additions & 3 deletions cpu/mips32r2_common/Makefile.include
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
INCLUDES += -I$(RIOTCPU)/mips32r2_common/include

# NOTE: This can be turned into normal conditional syntax once #9913 is fixed
CFLAGS += $(if $(filter newlib_syscalls_mips_uhi,$(USEMODULE)),-DHAVE_HEAP_STATS,)
LINKFLAGS += $(if $(filter newlib_syscalls_mips_uhi,$(USEMODULE)),-luhi,)
ifneq (,$(filter newlib_syscalls_mips_uhi,$(USEMODULE)))
CFLAGS += -DHAVE_HEAP_STATS
LINKFLAGS += -luhi
endif
7 changes: 5 additions & 2 deletions makefiles/arch/cortexm.inc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,11 @@ ifneq (llvm, $(TOOLCHAIN))
endif
endif
# Add soft or hard FPU CFLAGS depending on the module
# NOTE: This can be turned into normal conditional syntax once #9913 is fixed
CFLAGS_FPU ?= $(if $(filter cortexm_fpu,$(USEMODULE)),$(_CORTEX_HW_FPU_CFLAGS),-mfloat-abi=soft)
ifneq (,$(filter cortexm_fpu,$(USEMODULE)))
CFLAGS_FPU ?= $(_CORTEX_HW_FPU_CFLAGS)
else
CFLAGS_FPU ?= -mfloat-abi=soft
endif

ifeq ($(CPU_CORE),cortex-m4f)
MCPU = cortex-m4
Expand Down

0 comments on commit e98341d

Please sign in to comment.