mirror of
https://github.com/andreili/klipper.git
synced 2025-08-23 19:34:06 +02:00
Makefile: Fix lpc176x and stm32f1 builds
Commit e18501d0 broke the build for targets that added objects to klipper.elf via adding dependencies. Rework the build so that it is possible to add objects to klipper.elf via a new OBJS_klipper.elf makefile variable. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
309a47c781
commit
9430fea2c5
6
Makefile
6
Makefile
@ -37,6 +37,8 @@ CFLAGS := -I$(OUT) -Isrc -I$(OUT)board-generic/ -std=gnu11 -O2 -MD -g \
|
||||
-ffunction-sections -fdata-sections
|
||||
CFLAGS += -flto -fwhole-program -fno-use-linker-plugin
|
||||
|
||||
OBJS_klipper.elf = $(patsubst %.c, $(OUT)src/%.o,$(src-y))
|
||||
OBJS_klipper.elf += $(OUT)compile_time_request.o
|
||||
CFLAGS_klipper.elf = $(CFLAGS) -Wl,--gc-sections
|
||||
|
||||
CPPFLAGS = -I$(OUT) -P -MD -MT $@
|
||||
@ -83,9 +85,9 @@ $(OUT)compile_time_request.o: $(patsubst %.c, $(OUT)src/%.o.ctr,$(src-y)) ./scri
|
||||
$(Q)$(PYTHON) ./scripts/buildcommands.py -d $(OUT)klipper.dict -t "$(CC);$(AS);$(LD);$(OBJCOPY);$(OBJDUMP);$(STRIP)" $(OUT)klipper.compile_time_request $(OUT)compile_time_request.c
|
||||
$(Q)$(CC) $(CFLAGS) -c $(OUT)compile_time_request.c -o $@
|
||||
|
||||
$(OUT)klipper.elf: $(patsubst %.c, $(OUT)src/%.o,$(src-y)) $(OUT)compile_time_request.o
|
||||
$(OUT)klipper.elf: $(OBJS_klipper.elf)
|
||||
@echo " Linking $@"
|
||||
$(Q)$(CC) $(patsubst %.c, $(OUT)src/%.o,$(src-y)) $(OUT)compile_time_request.o $(CFLAGS_klipper.elf) -o $@
|
||||
$(Q)$(CC) $(OBJS_klipper.elf) $(CFLAGS_klipper.elf) -o $@
|
||||
$(Q)scripts/check-gcc.sh $@ $(OUT)compile_time_request.o
|
||||
|
||||
################ Kconfig rules
|
||||
|
@ -9,9 +9,6 @@ dirs-y += lib/lpc176x/device/TOOLCHAIN_GCC_ARM
|
||||
CFLAGS += -mthumb -mcpu=cortex-m3
|
||||
CFLAGS += -Ilib/lpc176x/device -Ilib/cmsis-core
|
||||
|
||||
CFLAGS_klipper.elf += -T $(OUT)LPC1768.ld
|
||||
CFLAGS_klipper.elf += --specs=nano.specs --specs=nosys.specs
|
||||
|
||||
# Add source files
|
||||
src-y += lpc176x/main.c lpc176x/gpio.c
|
||||
src-$(CONFIG_HAVE_GPIO_ADC) += lpc176x/adc.c
|
||||
@ -23,21 +20,23 @@ src-y += ../lib/lpc176x/device/system_LPC17xx.c
|
||||
src-$(CONFIG_USBSERIAL) += lpc176x/usbserial.c generic/usb_cdc.c
|
||||
src-$(CONFIG_SERIAL) += lpc176x/serial.c generic/serial_irq.c
|
||||
|
||||
# Add the TOOLCHAIN_GCC_ARM files to the build
|
||||
# Add assembler build rules
|
||||
$(OUT)%.o: %.S
|
||||
@echo " Assembling $@"
|
||||
$(Q)$(AS) $< -o $@
|
||||
|
||||
asmsrc-y := ../lib/lpc176x/device/TOOLCHAIN_GCC_ARM/startup_LPC17xx.S
|
||||
OBJS_klipper.elf += $(patsubst %.S, $(OUT)src/%.o,$(asmsrc-y))
|
||||
|
||||
$(OUT)klipper.elf: $(patsubst %.S, $(OUT)src/%.o,$(asmsrc-y))
|
||||
|
||||
target-y := $(OUT)LPC1768.ld $(target-y)
|
||||
|
||||
# Build the linker script
|
||||
$(OUT)LPC1768.ld: lib/lpc176x/device/TOOLCHAIN_GCC_ARM/LPC1768.ld $(OUT)board-link
|
||||
@echo " Preprocessing $@"
|
||||
$(Q)$(CPP) -P -MD -MT $@ -DMBED_APP_START=$(CONFIG_FLASH_START) -DMBED_APP_SIZE="(512K - $(CONFIG_FLASH_START))" $< -o $@
|
||||
|
||||
CFLAGS_klipper.elf += -T $(OUT)LPC1768.ld
|
||||
CFLAGS_klipper.elf += --specs=nano.specs --specs=nosys.specs
|
||||
$(OUT)klipper.elf : $(OUT)LPC1768.ld
|
||||
|
||||
# Build the additional bin output file
|
||||
target-y += $(OUT)klipper.bin
|
||||
|
||||
|
@ -12,9 +12,6 @@ CFLAGS += -Ilib/cmsis-core
|
||||
CFLAGS += -Ilib/cmsis-stm32f1/include -Ilib/hal-stm32f1/include
|
||||
CFLAGS += -DSTM32F103xB
|
||||
|
||||
CFLAGS_klipper.elf += -T $(OUT)stm32f1.ld
|
||||
CFLAGS_klipper.elf += --specs=nano.specs --specs=nosys.specs
|
||||
|
||||
# Add source files
|
||||
src-y += stm32f1/main.c stm32f1/gpio.c
|
||||
src-$(CONFIG_HAVE_GPIO_ADC) += stm32f1/adc.c
|
||||
@ -24,22 +21,24 @@ src-y += generic/crc16_ccitt.c generic/armcm_irq.c generic/armcm_timer.c
|
||||
src-y += ../lib/cmsis-stm32f1/source/system_stm32f1xx.c
|
||||
src-$(CONFIG_USBSERIAL) += stm32f1/usbserial.c generic/usb_cdc.c
|
||||
src-$(CONFIG_SERIAL) += stm32f1/serial.c generic/serial_irq.c
|
||||
asmsrc-y = ../lib/cmsis-stm32f1/source/startup_stm32f103xb.s
|
||||
|
||||
# Add assembler build rules
|
||||
$(OUT)%.o: %.s $(OUT)autoconf.h $(OUT)board-link
|
||||
@echo " Assembling $@"
|
||||
$(Q)$(AS) $< -o $@
|
||||
|
||||
$(OUT)klipper.elf: $(patsubst %.s, $(OUT)src/%.o,$(asmsrc-y))
|
||||
asmsrc-y = ../lib/cmsis-stm32f1/source/startup_stm32f103xb.s
|
||||
OBJS_klipper.elf += $(patsubst %.s, $(OUT)src/%.o,$(asmsrc-y))
|
||||
|
||||
# Build the linker script
|
||||
target-y := $(OUT)stm32f1.ld $(target-y)
|
||||
|
||||
$(OUT)stm32f1.ld: src/stm32f1/stm32f1.ld $(OUT)board-link
|
||||
@echo " Preprocessing $@"
|
||||
$(Q)$(CPP) -P -MD -MT $@ -DFLASH_START=$(CONFIG_FLASH_START) $< -o $@
|
||||
|
||||
CFLAGS_klipper.elf += -T $(OUT)stm32f1.ld
|
||||
CFLAGS_klipper.elf += --specs=nano.specs --specs=nosys.specs
|
||||
$(OUT)klipper.elf : $(OUT)stm32f1.ld
|
||||
|
||||
# Binary output file rules
|
||||
target-y += $(OUT)klipper.bin
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user