0

I want to insert ifndef in the makefile inside export And it seems that there is no possibility

export LINKER_INCLUDE_FILES:=$(BASE_PATH)/build/one/bmw/r4_0_cantata/Deploy/src/platform/one/r4/cr4_cpu.o \
                            $(BASE_PATH)/build/one/bmw/r4_0_cantata/Deploy/src/platform/one/r4/cr4_fpinit.o \
                            $(BASE_PATH)/build/one/bmw/r4_0_cantata/Deploy/src/platform/one/r4/cr4_startup.o \
                            $(BASE_PATH)/build/one/bmw/r4_0_cantata/Deploy/src/platform/one/r4/cr4_vfpinit.o \
                            $(BASE_PATH)/build/one/bmw/r4_0_cantata/Deploy/src/platform/one/r4_0/cr4_mpu.o \
                            $(BASE_PATH)/build/one/bmw/r4_0_cantata/Deploy/src/platform/one/r4_0/isr.o \
                            $(BASE_PATH)/build/one/bmw/r4_0_cantata/Deploy/src/config/one/bmw/r4_0/sys_resource_tables.o \
                            $(BASE_PATH)/build/one/bmw/r4_0_cantata/Deploy/src/app/unit_tests/cantata_infra/invz_printf.o \
                            $(BASE_PATH)/build/one/bmw/r4_0_cantata/Deploy/src/infra/hw/hw_access.o \
                            $(BASE_PATH)/build/one/bmw/r4_0_cantata/Deploy/src/infra/hw/regs.o \
                            $(BASE_PATH)/build/one/bmw/r4_0_cantata/Deploy/src/drivers/uart/uart_drv.o \

ifndef TEST_TIMER
                            $(BASE_PATH)/build/one/bmw/r4_0_cantata/Deploy/src/drivers/timers/timer.o \

endif

$(BASE_PATH)/build/one/bmw/r4_0_cantata/Deploy/src/drivers/vic/vic.o \
                            $(BASE_PATH)/build/one/bmw/r4_0_cantata/Deploy/src/drivers/clock_and_reset/clock_and_reset.o
John Bollinger
  • 160,171
  • 8
  • 81
  • 157
  • see https://www.gnu.org/software/make/manual/html_node/Conditional-Syntax.html – Bodo Nov 21 '22 at 13:04
  • Can't you conditionally add that extra line to the variable afterwards? The `\\` at the end of the line causes your `ifndef` to be part of that long assignment and is not recognized as a makefile instruction – Gerhardh Nov 21 '22 at 13:12
  • If something does not work, you should always show the error message or the actual and expected output/behavior. See also https://www.gnu.org/software/make/manual/html_node/Appending.html – Bodo Nov 21 '22 at 13:18

1 Answers1

1

Certainly that can't work.

You can just use:

export LINKER_INCLUDE_FILES :=  ... \

ifndef TEST_TIMER
LINKER_INCLUDE_FILES += $(BASE_PATH)/build/one/bmw/r4_0_cantata/Deploy/src/drivers/timers/timer.o
endif

E.g., put all the values into the variable, then use ifndef to += extra variables.

MadScientist
  • 92,819
  • 9
  • 109
  • 136