Change build output dir structure and filenames
This commit is contained in:
parent
ab5d5ba33c
commit
f8ea68c3eb
@ -13,8 +13,6 @@ include $(CONTIKI)/Makefile.identify-target
|
|||||||
### Include Makefile.tools to pull in targets that allow us to build tools dir
|
### Include Makefile.tools to pull in targets that allow us to build tools dir
|
||||||
include $(CONTIKI)/Makefile.tools
|
include $(CONTIKI)/Makefile.tools
|
||||||
|
|
||||||
CONTIKI_NG_TARGET_LIB = contiki-ng-$(TARGET).a
|
|
||||||
|
|
||||||
ifeq ($(DEFINES),)
|
ifeq ($(DEFINES),)
|
||||||
-include Makefile.$(TARGET).defines
|
-include Makefile.$(TARGET).defines
|
||||||
ifneq ($(DEFINES),)
|
ifneq ($(DEFINES),)
|
||||||
@ -39,7 +37,12 @@ ifdef CI
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
OBJECTDIR = obj_$(TARGET)
|
BUILD_DIR = build
|
||||||
|
BUILD_DIR_TARGET = $(BUILD_DIR)/$(TARGET)
|
||||||
|
BUILD_DIR_BOARD = $(BUILD_DIR_TARGET)/$(BOARD)
|
||||||
|
OBJECTDIR = $(BUILD_DIR_BOARD)/obj
|
||||||
|
|
||||||
|
CONTIKI_NG_TARGET_LIB = $(BUILD_DIR_BOARD)/contiki-ng-$(TARGET).a
|
||||||
|
|
||||||
LOWERCASE = -abcdefghijklmnopqrstuvwxyz/
|
LOWERCASE = -abcdefghijklmnopqrstuvwxyz/
|
||||||
UPPERCASE = _ABCDEFGHIJKLMNOPQRSTUVWXYZ_
|
UPPERCASE = _ABCDEFGHIJKLMNOPQRSTUVWXYZ_
|
||||||
@ -75,11 +78,6 @@ endef
|
|||||||
CONTIKI_OBJECTFILES = ${addprefix $(OBJECTDIR)/,${call oname, $(CONTIKI_SOURCEFILES)}}
|
CONTIKI_OBJECTFILES = ${addprefix $(OBJECTDIR)/,${call oname, $(CONTIKI_SOURCEFILES)}}
|
||||||
PROJECT_OBJECTFILES = ${addprefix $(OBJECTDIR)/,${call oname, $(PROJECT_SOURCEFILES)}}
|
PROJECT_OBJECTFILES = ${addprefix $(OBJECTDIR)/,${call oname, $(PROJECT_SOURCEFILES)}}
|
||||||
|
|
||||||
# Provide way to create $(OBJECTDIR) if it has been removed by make clean
|
|
||||||
$(OBJECTDIR):
|
|
||||||
$(TRACE_MKDIR)
|
|
||||||
$(Q)mkdir $@
|
|
||||||
|
|
||||||
uniq = $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))
|
uniq = $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))
|
||||||
|
|
||||||
### Include target makefile (TODO Unsafe?)
|
### Include target makefile (TODO Unsafe?)
|
||||||
@ -125,6 +123,11 @@ endif # $(BOARD) not empty
|
|||||||
|
|
||||||
PLATFORM_ACTION ?= build
|
PLATFORM_ACTION ?= build
|
||||||
|
|
||||||
|
# Provide way to create $(OBJECTDIR) if it has been removed by make clean
|
||||||
|
$(OBJECTDIR):
|
||||||
|
$(TRACE_MKDIR)
|
||||||
|
$(Q)mkdir -p $@
|
||||||
|
|
||||||
ifneq ($(BOARD),)
|
ifneq ($(BOARD),)
|
||||||
TARGET_BOARD_UPPERCASE := ${strip ${shell echo $(BOARD) | sed y!$(LOWERCASE)!$(UPPERCASE)!}}
|
TARGET_BOARD_UPPERCASE := ${strip ${shell echo $(BOARD) | sed y!$(LOWERCASE)!$(UPPERCASE)!}}
|
||||||
CFLAGS += -DCONTIKI_BOARD_$(TARGET_BOARD_UPPERCASE)=1
|
CFLAGS += -DCONTIKI_BOARD_$(TARGET_BOARD_UPPERCASE)=1
|
||||||
@ -312,14 +315,13 @@ endef
|
|||||||
|
|
||||||
### Harmonize filename of a .map file, if the platform's build system wants
|
### Harmonize filename of a .map file, if the platform's build system wants
|
||||||
### to create one
|
### to create one
|
||||||
CONTIKI_NG_PROJECT_MAP = $(addsuffix -$(TARGET).map, $(basename $@))
|
CONTIKI_NG_PROJECT_MAP = $(BUILD_DIR_BOARD)/$(basename $(notdir $@)).map
|
||||||
|
|
||||||
.PHONY: clean distclean usage help targets boards savetarget savedefines viewconf
|
.PHONY: clean distclean usage help targets boards savetarget savedefines viewconf
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-$(Q)rm -f *.d *.e *.o $(CONTIKI_NG_TARGET_LIB) $(CLEAN)
|
-$(Q)rm -f *.d *.e *.o $(CLEAN)
|
||||||
-$(Q)rm -rf $(OBJECTDIR)
|
-$(Q)rm -rf $(BUILD_DIR_TARGET)
|
||||||
-$(Q)rm -f $(addsuffix -$(TARGET).map, $(CONTIKI_PROJECT))
|
|
||||||
-$(Q)rm -f $(addsuffix .$(TARGET), $(CONTIKI_PROJECT))
|
-$(Q)rm -f $(addsuffix .$(TARGET), $(CONTIKI_PROJECT))
|
||||||
@echo Target $(TARGET) cleaned
|
@echo Target $(TARGET) cleaned
|
||||||
|
|
||||||
@ -328,6 +330,7 @@ distclean:
|
|||||||
echo Running: $(MAKE) TARGET=$$TARG clean; \
|
echo Running: $(MAKE) TARGET=$$TARG clean; \
|
||||||
$(MAKE) TARGET=$$TARG clean; \
|
$(MAKE) TARGET=$$TARG clean; \
|
||||||
done
|
done
|
||||||
|
rmdir $(BUILD_DIR)
|
||||||
|
|
||||||
-include $(CONTIKI)/arch/platform/$(TARGET)/Makefile.customrules-$(TARGET)
|
-include $(CONTIKI)/arch/platform/$(TARGET)/Makefile.customrules-$(TARGET)
|
||||||
|
|
||||||
|
@ -51,27 +51,32 @@ endif
|
|||||||
### CPU-dependent cleanup files
|
### CPU-dependent cleanup files
|
||||||
CLEAN += *.elf *.bin *.lst *.hex *.i16hex
|
CLEAN += *.elf *.bin *.lst *.hex *.i16hex
|
||||||
|
|
||||||
### Don't treat the following files as intermediate
|
OUT_HEX = $(BUILD_DIR_BOARD)/%.hex
|
||||||
.PRECIOUS: %.elf %.hex %.bin
|
OUT_I16HEX = $(BUILD_DIR_BOARD)/%.i16hex
|
||||||
|
OUT_BIN = $(BUILD_DIR_BOARD)/%.bin
|
||||||
|
OUT_LST = $(BUILD_DIR_BOARD)/%.lst
|
||||||
|
|
||||||
%.i16hex: %.elf
|
### Don't treat the following files as intermediate
|
||||||
|
.PRECIOUS: $(OUT_ELF) $(OUT_HEX) $(OUT_BIN)
|
||||||
|
|
||||||
|
$(OUT_I16HEX): $(OUT_ELF)
|
||||||
$(TRACE_OBJCOPY)
|
$(TRACE_OBJCOPY)
|
||||||
$(Q)$(OBJCOPY) -O ihex $< $@
|
$(Q)$(OBJCOPY) -O ihex $< $@
|
||||||
|
|
||||||
%.hex: %.i16hex
|
$(OUT_HEX): $(OUT_I16HEX)
|
||||||
$(TRACE_SREC_CAT)
|
$(TRACE_SREC_CAT)
|
||||||
$(Q)$(SREC_CAT) $< -intel -o $@ -intel
|
$(Q)$(SREC_CAT) $< -intel -o $@ -intel
|
||||||
|
|
||||||
%.bin: %.elf
|
$(OUT_BIN): $(OUT_ELF)
|
||||||
$(TRACE_OBJCOPY)
|
$(TRACE_OBJCOPY)
|
||||||
$(Q)$(OBJCOPY) -O binary $(OBJCOPY_FLAGS) $< $@
|
$(Q)$(OBJCOPY) -O binary $(OBJCOPY_FLAGS) $< $@
|
||||||
|
|
||||||
%.lst: %.elf
|
$(OUT_LST): $(OUT_ELF)
|
||||||
$(TRACE_OBJDUMP)
|
$(TRACE_OBJDUMP)
|
||||||
$(Q)$(OBJDUMP) $(OBJDUMP_FLAGS) $< > $@
|
$(Q)$(OBJDUMP) $(OBJDUMP_FLAGS) $< > $@
|
||||||
|
|
||||||
### We don't really need the .hex and .bin for the .$(TARGET) but let's make
|
### We don't really need the .hex and .bin for the .$(TARGET) but let's make
|
||||||
### sure they get built
|
### sure they get built
|
||||||
%.$(TARGET): %.elf %.hex %.bin
|
%.$(TARGET): $(OUT_ELF) $(OUT_HEX) $(OUT_BIN)
|
||||||
$(TRACE_CP)
|
$(TRACE_CP)
|
||||||
$(Q)cp $< $@
|
$(Q)cp $< $@
|
||||||
|
@ -17,9 +17,11 @@ TARGET_LIBFLAGS := -Wl,--start-group $(TARGET_LIBFILES) -Wl,--end-group
|
|||||||
|
|
||||||
CUSTOM_RULE_LINK = 1
|
CUSTOM_RULE_LINK = 1
|
||||||
|
|
||||||
|
OUT_ELF = $(BUILD_DIR_BOARD)/%.elf
|
||||||
|
|
||||||
.SECONDEXPANSION:
|
.SECONDEXPANSION:
|
||||||
|
|
||||||
%.elf: $(CPU_STARTFILES) $$(CONTIKI_OBJECTFILES) %.o $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) $(LDSCRIPT) $(TARGET_LIBS)
|
$(OUT_ELF): $(CPU_STARTFILES) $$(CONTIKI_OBJECTFILES) %.o $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) $(LDSCRIPT) $(TARGET_LIBS)
|
||||||
$(TRACE_LD)
|
$(TRACE_LD)
|
||||||
$(Q)$(LD) $(LDFLAGS) ${filter-out $(LDSCRIPT) %.a,$^} ${filter %.a,$^} $(TARGET_LIBFLAGS) -o $@
|
$(Q)$(LD) $(LDFLAGS) ${filter-out $(LDSCRIPT) %.a,$^} ${filter %.a,$^} $(TARGET_LIBFLAGS) -o $@
|
||||||
|
|
||||||
|
@ -172,11 +172,11 @@ vpath %.s $(ASM_PATHS)
|
|||||||
|
|
||||||
OBJECTS = $(C_OBJECTS) $(ASM_OBJECTS)
|
OBJECTS = $(C_OBJECTS) $(ASM_OBJECTS)
|
||||||
|
|
||||||
CLEAN += nrf52832.a
|
NRFLIB = $(BUILD_DIR_BOARD)/nrf52832.a
|
||||||
|
|
||||||
TARGET_LIBS = nrf52832.a $(NRF52_SDK_ROOT)/components/iot/ble_6lowpan/lib/ble_6lowpan.a
|
TARGET_LIBS = $(NRFLIB) $(NRF52_SDK_ROOT)/components/iot/ble_6lowpan/lib/ble_6lowpan.a
|
||||||
|
|
||||||
nrf52832.a: $(OBJECTS)
|
$(NRFLIB): $(OBJECTS)
|
||||||
$(TRACE_AR)
|
$(TRACE_AR)
|
||||||
$(Q)$(AR) $(AROPTS) $@ $^
|
$(Q)$(AR) $(AROPTS) $@ $^
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user