From 8e12285f665b0fdc3e2af61dc6023b4cf468732b Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Thu, 21 May 2020 19:28:42 +0200 Subject: [PATCH] introduce CROSS_*FLAGS for cross-compilation --- armsrc/Makefile | 6 ++---- bootrom/Makefile | 2 +- common_arm/Makefile.common | 16 ++++++++-------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/armsrc/Makefile b/armsrc/Makefile index 60b23c9f7..18d36a1b7 100644 --- a/armsrc/Makefile +++ b/armsrc/Makefile @@ -132,8 +132,6 @@ VERSIONSRC = version.c \ # Do not move this inclusion before the definition of {THUMB,ASM,ARM}SRC include ../common_arm/Makefile.common -COMMON_FLAGS = -Os - INSTALLFW = $(OBJDIR)/fullimage.elf ifneq (,$(FWTAG)) INSTALLFWTAG = $(notdir $(INSTALLFW:%.elf=%-$(FWTAG).elf)) @@ -178,7 +176,7 @@ $(FPGA_COMPRESSOR): $(OBJDIR)/fullimage.stage1.elf: $(VERSIONOBJ) $(OBJDIR)/fpga_all.o $(THUMBOBJ) $(ARMOBJ) $(info [=] LD $@) - $(Q)$(CC) $(LDFLAGS) -Wl,-T,ldscript,-Map,$(patsubst %.elf,%.map,$@) -o $@ $^ $(LIBS) + $(Q)$(CC) $(CROSS_LDFLAGS) -Wl,-T,ldscript,-Map,$(patsubst %.elf,%.map,$@) -o $@ $^ $(LIBS) $(OBJDIR)/fullimage.nodata.bin: $(OBJDIR)/fullimage.stage1.elf $(info [-] GEN $@) @@ -206,7 +204,7 @@ $(OBJDIR)/fullimage.data.o: $(OBJDIR)/fullimage.data.bin.z $(OBJDIR)/fullimage.elf: $(OBJDIR)/fullimage.nodata.o $(OBJDIR)/fullimage.data.o $(info [=] LD $@) - $(Q)$(CC) $(LDFLAGS) -Wl,-T,ldscript,-e,_osimage_entry,-Map,$(patsubst %.elf,%.map,$@) -o $@ $^ + $(Q)$(CC) $(CROSS_LDFLAGS) -Wl,-T,ldscript,-e,_osimage_entry,-Map,$(patsubst %.elf,%.map,$@) -o $@ $^ tarbin: $(OBJS) $(info TAR $@) diff --git a/bootrom/Makefile b/bootrom/Makefile index f6cf18174..68597aa22 100644 --- a/bootrom/Makefile +++ b/bootrom/Makefile @@ -52,7 +52,7 @@ tarbin: $(OBJS) $(OBJDIR)/bootrom.elf: $(VERSIONOBJ) $(ASMOBJ) $(ARMOBJ) $(THUMBOBJ) $(info [=] LD $@) - $(Q)$(CC) $(LDFLAGS) -Wl,-T,ldscript-flash,-Map,$(patsubst %.elf,%.map,$@) -o $@ $^ $(LIBS) + $(Q)$(CC) $(CROSS_LDFLAGS) -Wl,-T,ldscript-flash,-Map,$(patsubst %.elf,%.map,$@) -o $@ $^ $(LIBS) clean: $(Q)$(RM) $(OBJDIR)$(PATHSEP)*.o diff --git a/common_arm/Makefile.common b/common_arm/Makefile.common index e2c3ae3bc..c8dceead5 100644 --- a/common_arm/Makefile.common +++ b/common_arm/Makefile.common @@ -89,10 +89,10 @@ ifeq ($(NOERROR),1) DEFCFLAGS += -Wno-error endif -CFLAGS ?= $(DEFCFLAGS) -CFLAGS += $(ARMCFLAGS) -c $(INCLUDE) -std=c99 -DON_DEVICE $(APP_CFLAGS) +CROSS_CFLAGS ?= $(DEFCFLAGS) +CROSS_CFLAGS += $(ARMCFLAGS) -c $(INCLUDE) -std=c99 -DON_DEVICE $(APP_CFLAGS) -LDFLAGS += -nostartfiles -nodefaultlibs -Wl,-gc-sections -Wl,--build-id=none -n +CROSS_LDFLAGS += -nostartfiles -nodefaultlibs -Wl,-gc-sections -Wl,--build-id=none -n LIBS = -lgcc # Flags to generate temporary dependency files @@ -107,21 +107,21 @@ VERSIONOBJ = $(patsubst %.c,$(OBJDIR)/%.o,$(notdir $(VERSIONSRC))) $(THUMBOBJ): $(OBJDIR)/%.o: %.c $(INCLUDES) $(info [-] CC $<) - $(Q)$(CC) $(CFLAGS) $(DEPFLAGS) -mthumb -o $@ $< + $(Q)$(CC) $(CROSS_CFLAGS) $(DEPFLAGS) -mthumb -o $@ $< $(Q)$(POSTCOMPILE) $(ARMOBJ): $(OBJDIR)/%.o: %.c $(INCLUDES) $(info [-] CC $<) - $(Q)$(CC) $(CFLAGS) $(DEPFLAGS) -o $@ $< + $(Q)$(CC) $(CROSS_CFLAGS) $(DEPFLAGS) -o $@ $< $(Q)$(POSTCOMPILE) $(ASMOBJ): $(OBJDIR)/%.o: %.s $(info [-] CC $<) - $(Q)$(CC) $(CFLAGS) -o $@ $< + $(Q)$(CC) $(CROSS_CFLAGS) -o $@ $< $(VERSIONOBJ): $(OBJDIR)/%.o: %.c $(INCLUDES) $(info [-] CC $<) - $(Q)$(CC) $(CFLAGS) -mthumb -o $@ $< + $(Q)$(CC) $(CROSS_CFLAGS) -mthumb -o $@ $< # This objcopy call translates physical flash addresses to logical addresses # without touching start address or RAM addresses (.bss and .data sections) @@ -135,7 +135,7 @@ $(OBJDIR)/%.s19: $(OBJDIR)/%.elf $(Q)$(OBJCOPY) -Osrec --srec-forceS3 --strip-debug $(OBJCOPY_TRANSLATIONS) $^ $@ # easy printing of MAKE VARIABLES -print-%: ; @echo $* = $($*) +print-%: ; @echo $* = $($*) # Automatic dependency generation DEPENDENCY_FILES = $(patsubst %.c,$(OBJDIR)/%.d,$(notdir $(THUMBSRC))) \