Search code examples
makefileifndef

Using ifndef in the makefile inside a variable defined by export


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

Solution

  • 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.