@ -189,6 +189,24 @@ GZIP_SUFFIX := .gz
MAKE_DEP = -Wp,-MD,$( DEP) -MT $$ @ -MP
# MAKE_C_LIB builds a C source file and generates the dependency file
# $(1) = output directory
# $(2) = source file (%.c)
# $(3) = library name
d e f i n e M A K E _ C _ L I B
$(eval OBJ : = $( 1) /$( patsubst %.c ,%.o ,$ ( notdir $ ( 2) ) ) )
$(eval DEP : = $( patsubst %.o ,%.d ,$ ( OBJ ) ) )
$(OBJ) : $( 2) $( filter -out %.d ,$ ( MAKEFILE_LIST ) ) | lib $( 3) _dirs
@echo " CC $$ < "
$$ ( Q) $$ ( CC) $$ ( TF_CFLAGS) $$ ( CFLAGS) $( MAKE_DEP) -c $$ < -o $$ @
- i n c l u d e $( DEP )
e n d e f
# MAKE_C builds a C source file and generates the dependency file
# $(1) = output directory
# $(2) = source file (%.c)
@ -243,6 +261,18 @@ $(1): $(2) $(filter-out %.d,$(MAKEFILE_LIST)) | bl$(3)_dirs
e n d e f
# MAKE_LIB_OBJS builds both C source files
# $(1) = output directory
# $(2) = list of source files
# $(3) = name of the library
d e f i n e M A K E _ L I B _ O B J S
$( eval C_OBJS := $( filter %.c,$( 2) ) )
$( eval REMAIN := $( filter-out %.c,$( 2) ) )
$( eval $( foreach obj,$( C_OBJS) ,$( call MAKE_C_LIB,$( 1) ,$( obj) ,$( 3) ) ) )
$( and $( REMAIN) ,$( error Unexpected source files present: $( REMAIN) ) )
e n d e f
# MAKE_OBJS builds both C and assembly source files
# $(1) = output directory
@ -274,6 +304,41 @@ endef
# This must be set to a C string (including quotes where applicable).
BUILD_MESSAGE_TIMESTAMP ?= __TIME__", " __DATE__
.PHONY : libraries
# MAKE_LIB_DIR macro defines the target for the directory where
# libraries are created
d e f i n e M A K E _ L I B _ D I R
$( eval LIB_DIR := ${ BUILD_PLAT } /lib)
$( eval $( call MAKE_PREREQ_DIR,${ LIB_DIR } ,${ BUILD_PLAT } ) )
e n d e f
# MAKE_LIB macro defines the targets and options to build each BL image.
# Arguments:
# $(1) = Library name
d e f i n e M A K E _ L I B
$( eval BUILD_DIR := ${ BUILD_PLAT } /lib$( 1) )
$( eval LIB_DIR := ${ BUILD_PLAT } /lib)
$( eval SOURCES := $( LIB$( call uppercase,$( 1) ) _SRCS) )
$( eval OBJS := $( addprefix $( BUILD_DIR) /,$( call SOURCES_TO_OBJS,$( SOURCES) ) ) )
$( eval $ ( call MAKE_PREREQ_DIR ,$ {BUILD_DIR },$ {BUILD_PLAT }) )
$( eval $ ( call MAKE_LIB_OBJS ,$ ( BUILD_DIR ) ,$ ( SOURCES ) ,$ ( 1) ) )
.PHONY : lib ${1}_dirs
lib${1}_dirs : | ${BUILD_DIR } ${LIB_DIR }
libraries : ${LIB_DIR }/lib $( 1) .a
LDPATHS = -L${ LIB_DIR }
LDLIBS += -l$( 1)
all : ${LIB_DIR }/lib $( 1) .a
${LIB_DIR}/lib$(1).a : $( OBJS )
@echo " AR $$ @ "
$$ ( Q) $$ ( AR) cr $$ @ $$ ?
e n d e f
# MAKE_BL macro defines the targets and options to build each BL image.
# Arguments:
# $(1) = BL stage (2, 2u, 30, 31, 32, 33)
@ -313,7 +378,7 @@ bl${1}_dirs: | ${OBJ_DIRS}
$( eval $ ( call MAKE_OBJS ,$ ( BUILD_DIR ) ,$ ( SOURCES ) ,$ ( 1) ) )
$( eval $ ( call MAKE_LD ,$ ( LINKERFILE ) ,$ ( BL_LINKERFILE ) ,$ ( 1) ) )
$(ELF) : $( OBJS ) $( LINKERFILE ) | bl $( 1) _dirs $( BL_LIBS )
$(ELF) : $( OBJS ) $( LINKERFILE ) | bl $( 1) _dirs libraries $( BL_LIBS )
@echo " LD $$ @ "
i f d e f M A K E _ B U I L D _ S T R I N G S
$( call MAKE_BUILD_STRINGS, $( BUILD_DIR) /build_message.o)
@ -323,7 +388,8 @@ else
$$ ( CC) $$ ( TF_CFLAGS) $$ ( CFLAGS) -xc -c - -o $( BUILD_DIR) /build_message.o
e n d i f
$$ ( Q) $$ ( LD) -o $$ @ $$ ( TF_LDFLAGS) $$ ( LDFLAGS) -Map= $( MAPFILE) \
--script $( LINKERFILE) $( BUILD_DIR) /build_message.o $( OBJS) $( LDLIBS) $( BL_LIBS)
--script $( LINKERFILE) $( BUILD_DIR) /build_message.o \
$( OBJS) $( LDPATHS) $( LDLIBS) $( BL_LIBS)
$(DUMP) : $( ELF )
@echo " OD $$ @ "