X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=rules.mk;h=1289740f2471f30d4b225310cd8b4b88bed0be65;hb=941529ddc4cddd04f69d38c0929ec00fe93aadef;hp=990fc39d25c4d1453872986cd6c70d9c5a39bef1;hpb=8f410de98a38da826788f2b5a2c5581b2231041b;p=bertos.git diff --git a/rules.mk b/rules.mk old mode 100755 new mode 100644 index 990fc39d..1289740f --- a/rules.mk +++ b/rules.mk @@ -24,6 +24,15 @@ Q := @ L := @echo endif +# Select Bourne Again SHell as default make shell +SHELL := bash + +# Checker build +ifeq ($(C),1) +CC = $(CHECKER) +CFLAGS += -Wundef -D__x86_64__=1 -D__unix__=1 -D__linux__=1 -D__STDC_VERSION__=199901L +endif + # Initialize $(top_srcdir) with current directory, unless it was already initialized top_srcdir ?= $(shell pwd) @@ -34,13 +43,18 @@ TRG_HEX = $(TRG:%=$(OUTDIR)/%.hex) TRG_BIN = $(TRG:%=$(OUTDIR)/%.bin) TRG_ROM = $(TRG:%=$(OUTDIR)/%.rom) TRG_COF = $(TRG:%=$(OUTDIR)/%.cof) +TRG_EXE = $(TRG:%=$(OUTDIR)/%) RECURSIVE_TARGETS = all-recursive install-recursive clean-recursive # The default target .PHONY: all -all:: all-recursive $(TRG_S19) $(TRG_HEX) +ifeq ($(EMBEDDED_TARGET),1) +all:: all-recursive $(TRG_S19) $(TRG_HEX) $(TRG_BIN) +else +all:: all-recursive $(TRG_EXE) +endif # Generate project documentation .PHONY: docs @@ -57,6 +71,14 @@ $(1)_ASFLAGS += -mmcu=$$($(1)_MCU) $(1)_CPPAFLAGS += -mmcu=$$($(1)_MCU) $(1)_LDFLAGS += -mmcu=$$($(1)_MCU) endif +ifneq ($$(strip $$($(1)_CPU)),) +# Define all project specific object files +$(1)_CFLAGS += -mcpu=$$($(1)_CPU) +$(1)_CXXFLAGS += -mcpu=$$($(1)_CPU) +$(1)_ASFLAGS += -mcpu=$$($(1)_CPU) +$(1)_CPPAFLAGS += -mcpu=$$($(1)_CPU) +$(1)_LDFLAGS += -mcpu=$$($(1)_CPU) +endif ifneq ($$(strip $$($(1)_LDSCRIPT)),) $(1)_LDFLAGS += -Wl,-T$$($(1)_LDSCRIPT) endif @@ -104,14 +126,19 @@ $$($(1)_CPPAOBJ): $$(OBJDIR)/$(1)/%.o : %.S $L "$(1): Assembling with CPP $$<" @$$(MKDIR_P) $$(dir $$@) $Q $$(CC) -c $$(CPPAFLAGS) $$($(1)_CPPAFLAGS) $$($(1)_CPPFLAGS) $$(CPPFLAGS) $$< -o $$@ + # Link: instructions to create elf output file from object files -$$(OUTDIR)/$(1).elf: bumprev $$($(1)_OBJ) $$($(1)_LDSCRIPT) - $L "$(1): Linking $$(OUTDIR)/$(1)" +$$(OUTDIR)/$(1).elf $$(OUTDIR)/$(1)_nostrip: bumprev $$($(1)_OBJ) $$($(1)_LDSCRIPT) + $L "$(1): Linking $$@" @$$(MKDIR_P) $$(dir $$@) - $Q $$(LD) $$($(1)_OBJ) $$(LIB) $$(LDFLAGS) $$($(1)_LDFLAGS) -o $$(OUTDIR)/$(1)_nostrip - $Q $$(STRIP) -o $$(OUTDIR)/$(1) $$(OUTDIR)/$(1)_nostrip + $Q $$(LD) $$($(1)_OBJ) $$(LIB) $$(LDFLAGS) $$($(1)_LDFLAGS) -o $$@ +# Strip debug info +$$(OUTDIR)/$(1): $$(OUTDIR)/$(1)_nostrip + $L "$(1): Generating stripped executable $$@" + $Q $$(STRIP) -o $$@ $$^ + # Compile and link (program-at-a-time) $$(OUTDIR)/$(1)_whole.elf: bumprev $$($(1)_SRC) $$($(1)_LDSCRIPT) $L "$(1): Compiling and Linking whole program $$@"