@ -28,12 +28,13 @@ VPATH :=
# Convert all SRC to OBJ
d e f i n e O B J _ F R O M _ S R C
$( patsubst %.c ,$ 1/%.o ,$ ( patsubst %.cpp ,$ 1/%.o ,$ ( patsubst %.cc ,$ 1/%.o ,$ ( patsubst %.S ,$ 1/%.o ,$ ( $ 1_SRC ) ) ) ) )
$( patsubst %.c ,$ 1/%.o ,$ ( patsubst %.cpp ,$ 1/%.o ,$ ( patsubst %.cc ,$ 1/%.o ,$ ( patsubst %.S ,$ 1/%.o ,$ ( patsubst %.clib ,$ 1/%.a ,$ ( $ 1_SRC ) ) ) ) ) )
e n d e f
$( foreach OUTPUT ,$ ( OUTPUTS ) ,$ ( eval $ ( OUTPUT ) _OBJ +=$ ( call OBJ_FROM_SRC ,$ ( OUTPUT ) ) ) )
# Define a list of all objects
OBJ := $( foreach OUTPUT,$( OUTPUTS) ,$( $( OUTPUT) _OBJ) )
NO_LTO_OBJ := $( filter %.a,$( OBJ) )
MASTER_OUTPUT := $( firstword $( OUTPUTS) )
@ -81,7 +82,9 @@ CSTANDARD = -std=gnu99
# -Wall...: warning level
# -Wa,...: tell GCC to pass this to the assembler.
# -adhlns...: create assembler listing
CFLAGS += -g$( DEBUG)
i f n d e f S K I P _ D E B U G _ I N F O
CFLAGS += -g$( DEBUG)
e n d i f
CFLAGS += $( CDEFS)
CFLAGS += -O$( OPT)
# add color
@ -110,7 +113,9 @@ CFLAGS += $(CSTANDARD)
# -Wall...: warning level
# -Wa,...: tell GCC to pass this to the assembler.
# -adhlns...: create assembler listing
CPPFLAGS += -g$( DEBUG)
i f n d e f S K I P _ D E B U G _ I N F O
CPPFLAGS += -g$( DEBUG)
e n d i f
CPPFLAGS += $( CPPDEFS)
CPPFLAGS += -O$( OPT)
# to supress "warning: only initialized variables can be placed into program memory area"
@ -138,7 +143,11 @@ CPPFLAGS += -Wa,-adhlns=$(@:%.o=%.lst)
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
# dump that will be displayed for a given single line of source input.
ASFLAGS += $( ADEFS)
ASFLAGS += -Wa,-adhlns= $( @:%.o= %.lst) ,-gstabs,--listing-cont-lines= 100
i f n d e f S K I P _ D E B U G _ I N F O
ASFLAGS += -Wa,-adhlns= $( @:%.o= %.lst) ,-gstabs,--listing-cont-lines= 100
e l s e
ASFLAGS += -Wa,-adhlns= $( @:%.o= %.lst) ,--listing-cont-lines= 100
e n d i f
#---------------- Library Options ----------------
# Minimalistic printf version
@ -210,6 +219,11 @@ ALL_CFLAGS = $(MCUFLAGS) $(CFLAGS) $(EXTRAFLAGS)
ALL_CPPFLAGS = $( MCUFLAGS) -x c++ $( CPPFLAGS) $( EXTRAFLAGS)
ALL_ASFLAGS = $( MCUFLAGS) -x assembler-with-cpp $( ASFLAGS) $( EXTRAFLAGS)
d e f i n e N O _ L T O
$(patsubst %.a,%.o,$1) : NOLTO_CFLAGS += -fno -lto
e n d e f
$( foreach LOBJ , $ ( NO_LTO_OBJ ) , $ ( eval $ ( call NO_LTO ,$ ( LOBJ ) ) ) )
MOVE_DEP = mv -f $( patsubst %.o,%.td,$@ ) $( patsubst %.o,%.d,$@ )
@ -290,8 +304,8 @@ $1_INCFLAGS := $$(patsubst %,-I%,$$($1_INC))
i f d e f $ 1 _ C O N F I G
$1_CONFIG_FLAGS += $$ ( patsubst %,-include %,$$ ( $1 _CONFIG) )
e n d i f
$1_CFLAGS = $$ ( ALL_CFLAGS) $$ ( $1 _DEFS) $$ ( $1 _INCFLAGS) $$ ( $1 _CONFIG_FLAGS)
$1_CPPFLAGS = $$ ( ALL_CPPFLAGS) $$ ( $1 _DEFS) $$ ( $1 _INCFLAGS) $$ ( $1 _CONFIG_FLAGS)
$1_CFLAGS = $$ ( ALL_CFLAGS) $$ ( $1 _DEFS) $$ ( $1 _INCFLAGS) $$ ( $1 _CONFIG_FLAGS) $$ ( NOLTO_CFLAGS)
$1_CPPFLAGS = $$ ( ALL_CPPFLAGS) $$ ( $1 _DEFS) $$ ( $1 _INCFLAGS) $$ ( $1 _CONFIG_FLAGS) $$ ( NOLTO_CFLAGS)
$1_ASFLAGS = $$ ( ALL_ASFLAGS) $$ ( $1 _DEFS) $$ ( $1 _INCFLAGS) $$ ( $1 _CONFIG_FLAGS)
# Compile: create object files from C source files.
@ -321,6 +335,12 @@ $1/%.o : %.S $1/asflags.txt $1/compiler.txt | $(BEGIN)
$$ ( eval CMD = $$ ( CC) -c $$ ( $1 _ASFLAGS) $$ < -o $$ @)
@$$ ( BUILD_CMD)
$1/%.a : $1/%.o
@mkdir -p $$ ( @D)
@$( SILENT) || printf " Archiving: $$ < " | $$ ( AWK_CMD)
$$ ( eval CMD = $$ ( AR) $$ @ $$ <)
@$$ ( BUILD_CMD)
$1/force :
$1/cflags.txt : $1/force
@ -346,7 +366,7 @@ $(MASTER_OUTPUT)/ldflags.txt: $(MASTER_OUTPUT)/force
# We have to use static rules for the .d files for some reason
DEPS = $( patsubst %.o,%.d,$( OBJ) )
DEPS = $( patsubst %.o,%.d,$( patsubst %.a,%.o,$( OBJ) ) )
# Keep the .d files
.PRECIOUS : $( DEPS )
# Empty rule to force recompilation if the .d file is missing
@ -391,7 +411,7 @@ $(shell mkdir -p $(BUILD_DIR) 2>/dev/null)
$( eval $ ( foreach OUTPUT ,$ ( OUTPUTS ) ,$ ( shell mkdir -p $ ( OUTPUT ) 2>/dev /null ) ) )
# Include the dependency files.
- i n c l u d e $( patsubst %.o ,%.d ,$ ( OBJ) )
- i n c l u d e $( patsubst %.o ,%.d ,$ ( patsubst %.a ,%.o ,$ ( OBJ) ) )
# Listing of phony targets.