2005-04-08 17:01:17 +02:00
# -*- makefile -*- : Force emacs to use Makefile mode
2008-10-08 00:18:15 +02:00
#
2005-04-08 17:01:17 +02:00
# This file contains various boring housekeeping functions that would
# otherwise seriously clutter up the main Makefile.
2008-10-08 00:18:15 +02:00
###############################################################################
2005-04-08 17:01:17 +02:00
#
2007-12-08 01:50:57 +01:00
# Find a usable "echo -e" substitute.
#
2007-12-07 21:25:02 +01:00
TAB := $( shell $( PRINTF) '\t' )
ECHO_E_ECHO := $( ECHO)
ECHO_E_ECHO_E := $( ECHO) -e
ECHO_E_BIN_ECHO := /bin/echo
ECHO_E_BIN_ECHO_E := /bin/echo -e
ECHO_E_ECHO_TAB := $( shell $( ECHO_E_ECHO) '\t' | cat)
ECHO_E_ECHO_E_TAB := $( shell $( ECHO_E_ECHO_E) '\t' | cat)
ECHO_E_BIN_ECHO_TAB := $( shell $( ECHO_E_BIN_ECHO) '\t' )
ECHO_E_BIN_ECHO_E_TAB := $( shell $( ECHO_E_BIN_ECHO_E) '\t' )
i f e q ( $( ECHO_E_ECHO_TAB ) , $( TAB ) )
2008-09-29 22:48:51 +02:00
ECHO_E := $( ECHO_E_ECHO)
2007-12-08 01:50:57 +01:00
e n d i f
2007-12-07 21:25:02 +01:00
i f e q ( $( ECHO_E_ECHO_E_TAB ) , $( TAB ) )
2008-09-29 22:48:51 +02:00
ECHO_E := $( ECHO_E_ECHO_E)
2007-12-08 01:50:57 +01:00
e n d i f
2007-12-07 21:25:02 +01:00
i f e q ( $( ECHO_E_BIN_ECHO_TAB ) , $( TAB ) )
2008-09-29 22:48:51 +02:00
ECHO_E := $( ECHO_E_BIN_ECHO)
2007-12-08 01:50:57 +01:00
e n d i f
2007-12-07 21:25:02 +01:00
i f e q ( $( ECHO_E_BIN_ECHO_E_TAB ) , $( TAB ) )
2008-09-29 22:48:51 +02:00
ECHO_E := $( ECHO_E_BIN_ECHO_E)
2007-12-08 01:50:57 +01:00
e n d i f
2007-12-07 21:25:02 +01:00
2007-12-08 01:50:57 +01:00
.echocheck :
i f d e f E C H O _ E
2007-12-07 21:25:02 +01:00
@$( TOUCH) $@
2007-12-08 01:50:57 +01:00
e l s e
2007-12-07 21:25:02 +01:00
@$( PRINTF) '%24s : x%sx\n' 'tab' '$(TAB)'
@$( PRINTF) '%24s : x%sx\n' '"$(ECHO_E_ECHO) \t"' \
'$(ECHO_E_ECHO_TAB)'
@$( PRINTF) '%24s : x%sx\n' '"$(ECHO_E_ECHO_E) \t"' \
'$(ECHO_E_ECHO_E_TAB)'
@$( PRINTF) '%24s : x%sx\n' '"$(ECHO_E_BIN_ECHO) \t"' \
'$(ECHO_E_BIN_ECHO_TAB)'
@$( PRINTF) '%24s : x%sx\n' '"$(ECHO_E_BIN_ECHO_E) \t"' \
'$(ECHO_E_BIN_ECHO_E_TAB)'
@$( ECHO) "No usable \"echo -e\" substitute found"
2007-12-08 01:50:57 +01:00
@exit 1
e n d i f
2008-10-08 00:18:15 +02:00
MAKEDEPS += .echocheck
2007-12-08 01:50:57 +01:00
VERYCLEANUP += .echocheck
2007-12-07 21:25:02 +01:00
2007-12-08 01:50:57 +01:00
echo :
@$( ECHO) " Using \" $( ECHO_E) \" for \"echo -e\" "
2009-03-31 12:06:35 +02:00
###############################################################################
#
# Generate a usable "seq" substitute
#
d e f i n e s e q
$( shell awk 'BEGIN { for ( i = $(1) ; i <= $(2) ; i++ ) print i }' )
e n d e f
2008-10-17 19:24:04 +02:00
###############################################################################
#
# Determine host OS
#
HOST_OS := $( shell uname -s)
hostos :
@$( ECHO) $( HOST_OS)
2009-03-10 18:50:01 +01:00
###############################################################################
#
# Determine compiler
CCDEFS := $( shell $( CC) -E -x c -c /dev/null -dM | cut -d" " -f2)
ccdefs :
@$( ECHO) $( CCDEFS)
i f e q ( $( filter __ICC ,$ ( CCDEFS ) ) , _ _ I C C )
CCTYPE := icc
e l s e
CCTYPE := gcc
e n d i f
cctype :
@$( ECHO) $( CCTYPE)
2008-10-08 00:18:15 +02:00
###############################################################################
#
# Check for tools that can cause failed builds
#
.toolcheck :
@if $( CC) -v 2>& 1 | grep -is 'gcc version 2\.96' > /dev/null; then \
$( ECHO) 'gcc 2.96 is unsuitable for compiling Etherboot' ; \
$( ECHO) 'Use gcc 2.95 or gcc 3.x instead' ; \
exit 1; \
fi
@if [ ` perl -e 'use bytes; print chr(255)' | wc -c` = 2 ] ; then \
$( ECHO) 'Your Perl version has a Unicode handling bug' ; \
$( ECHO) 'Execute this command before compiling Etherboot:' ; \
$( ECHO) 'export LANG=$${LANG%.UTF-8}' ; \
exit 1; \
fi
@$( TOUCH) $@
MAKEDEPS += .toolcheck
VERYCLEANUP += .toolcheck
###############################################################################
#
# Check for various tool workarounds
2007-01-31 12:06:36 +01:00
#
2009-02-16 01:28:30 +01:00
# Make syntax does not allow use of comma or space in certain places.
# This ugly workaround is suggested in the manual.
#
COMMA := ,
EMPTY :=
SPACE := $( EMPTY) $( EMPTY)
2005-04-08 17:01:17 +02:00
# Check for an old version of gas (binutils 2.9.1)
#
2007-09-09 00:38:17 +02:00
OLDGAS := $( shell $( AS) --version | grep -q '2\.9\.1' && $( ECHO) -DGAS291)
2005-04-08 17:01:17 +02:00
CFLAGS += $( OLDGAS)
oldgas :
2007-09-09 00:38:17 +02:00
@$( ECHO) $( oldgas)
2005-04-08 17:01:17 +02:00
2007-12-15 20:37:21 +01:00
# Some widespread patched versions of gcc include -fstack-protector by
# default, even when -ffreestanding is specified. We therefore need
# to disable -fstack-protector if the compiler supports it.
#
2009-03-10 18:50:01 +01:00
i f e q ( $( CCTYPE ) , g c c )
2008-10-01 20:05:39 +02:00
SP_TEST = $( CC) -fno-stack-protector -x c -c /dev/null \
-o /dev/null >/dev/null 2>& 1
2007-12-15 20:37:21 +01:00
SP_FLAGS := $( shell $( SP_TEST) && $( ECHO) '-fno-stack-protector' )
CFLAGS += $( SP_FLAGS)
2009-03-10 18:50:01 +01:00
e n d i f
2007-12-15 20:37:21 +01:00
2009-05-27 03:21:45 +02:00
# gcc 4.4 generates .eh_frame sections by default, which distort the
# output of "size". Inhibit this.
#
i f e q ( $( CCTYPE ) , g c c )
CFI_TEST = $( CC) -fno-dwarf2-cfi-asm -x c -c /dev/null \
-o /dev/null >/dev/null 2>& 1
CFI_FLAGS := $( shell $( CFI_TEST) && $( ECHO) '-fno-dwarf2-cfi-asm' )
CFLAGS += $( CFI_FLAGS)
e n d i f
2009-03-31 08:01:06 +02:00
# Some versions of gas choke on division operators, treating them as
# comment markers. Specifying --divide will work around this problem,
# but isn't available on older gas versions.
#
DIVIDE_TEST = $( AS) --divide /dev/null -o /dev/null 2>/dev/null
DIVIDE_FLAGS := $( shell $( DIVIDE_TEST) && $( ECHO) '--divide' )
ASFLAGS += $( DIVIDE_FLAGS)
2008-10-08 00:18:15 +02:00
###############################################################################
#
# Build verbosity
#
i f e q ( $( V ) , 1 )
Q :=
QM := @\#
e l s e
Q := @
QM := @
e n d i f
###############################################################################
#
# Set BIN according to whatever was specified on the command line as
# the build target.
2005-04-14 13:45:37 +02:00
#
2008-10-08 00:18:15 +02:00
# Determine how many different BIN directories are mentioned in the
# make goals.
#
BIN_GOALS := $( filter bin/% bin-%,$( MAKECMDGOALS) )
BIN_GOAL_BINS := $( foreach BG,$( BIN_GOALS) ,$( firstword $( subst /, ,$( BG) ) ) )
NUM_BINS := $( words $( sort $( BIN_GOAL_BINS) ) )
i f e q ( $( NUM_BINS ) , 0 )
# No BIN directory was specified. Set BIN to "bin" as a sensible
# default.
BIN := bin
e l s e # NUM_BINS == 0
i f e q ( $( NUM_BINS ) , 1 )
# If exactly one BIN directory was specified, set BIN to match this
# directory.
#
BIN := $( firstword $( BIN_GOAL_BINS) )
e l s e # NUM_BINS == 1
# More than one BIN directory was specified. We cannot handle the
# latter case within a single make invocation, so set up recursive
# targets for each BIN directory.
#
# Leave $(BIN) undefined. This has implications for any target that
# depends on $(BIN); such targets should be made conditional upon the
# existence of $(BIN).
#
$(BIN_GOALS) : % : BIN_RECURSE
$( Q) $( MAKE) --no-print-directory BIN = $( firstword $( subst /, ,$@ ) ) $@
.PHONY : BIN_RECURSE
e n d i f # NUM_BINS == 1
e n d i f # NUM_BINS == 0
i f d e f B I N
# Create $(BIN) directory if it doesn't exist yet
#
i f e q ( $( wildcard $ ( BIN ) ) , )
$( shell $ ( MKDIR ) -p $ ( BIN ) )
e n d i f
# Target to allow e.g. "make bin-efi arch"
#
$(BIN) :
@# Do nothing, silently
.PHONY : $( BIN )
# Remove everything in $(BIN) for a "make clean"
#
CLEANUP += $( BIN) /*.* # Avoid picking up directories
e n d i f # defined(BIN)
# Determine whether or not we need to include the dependency files
#
NO_DEP_TARGETS := $( BIN) clean veryclean
i f e q ( $( MAKECMDGOALS ) , )
NEED_DEPS := 1
e n d i f
i f n e q ( $( strip $ ( filter -out $ ( NO_DEP_TARGETS ) ,$ ( MAKECMDGOALS ) ) ) , )
NEED_DEPS := 1
e n d i f
###############################################################################
#
# Select build architecture and platform based on $(BIN)
#
# BIN has the form bin[-[arch-]platform]
ARCHS := $( patsubst arch/%,%,$( wildcard arch/*) )
PLATFORMS := $( patsubst config/defaults/%.h,%,\
$( wildcard config/defaults/*.h) )
archs :
@$( ECHO) $( ARCHS)
platforms :
@$( ECHO) $( PLATFORMS)
i f d e f B I N
# Determine architecture portion of $(BIN), if present
BIN_ARCH := $( strip $( foreach A,$( ARCHS) ,\
$( patsubst bin-$( A) -%,$( A) ,\
$( filter bin-$( A) -%,$( BIN) ) ) ) )
# Determine platform portion of $(BIN), if present
i f e q ( $( BIN_ARCH ) , )
BIN_PLATFORM := $( patsubst bin-%,%,$( filter bin-%,$( BIN) ) )
e l s e
BIN_PLATFORM := $( patsubst bin-$( BIN_ARCH) -%,%,$( BIN) )
e n d i f
# Determine build architecture
DEFAULT_ARCH := i386
ARCH := $( firstword $( BIN_ARCH) $( DEFAULT_ARCH) )
CFLAGS += -DARCH= $( ARCH)
arch :
@$( ECHO) $( ARCH)
.PHONY : arch
# Determine build platform
DEFAULT_PLATFORM := pcbios
PLATFORM := $( firstword $( BIN_PLATFORM) $( DEFAULT_PLATFORM) )
CFLAGS += -DPLATFORM= $( PLATFORM)
platform :
@$( ECHO) $( PLATFORM)
e n d i f # defined(BIN)
# Include architecture-specific Makefile
i f d e f A R C H
2008-10-10 03:08:31 +02:00
MAKEDEPS += arch/$( ARCH) /Makefile
2008-10-08 00:18:15 +02:00
i n c l u d e a r c h / $( ARCH ) / M a k e f i l e
e n d i f
2009-08-11 16:14:36 +02:00
# Include architecture-specific include path
i f d e f A R C H
INCDIRS += arch/$( ARCH) /include
e n d i f
2008-10-08 00:18:15 +02:00
###############################################################################
#
# Source file handling
2005-04-08 17:01:17 +02:00
# SRCDIRS lists all directories containing source files.
srcdirs :
2007-09-09 00:38:17 +02:00
@$( ECHO) $( SRCDIRS)
2005-04-08 17:01:17 +02:00
# SRCS lists all .c or .S files found in any SRCDIR
#
SRCS += $( wildcard $( patsubst %,%/*.c,$( SRCDIRS) ) )
SRCS += $( wildcard $( patsubst %,%/*.S,$( SRCDIRS) ) )
srcs :
2007-09-09 00:38:17 +02:00
@$( ECHO) $( SRCS)
2005-04-08 17:01:17 +02:00
# AUTO_SRCS lists all files in SRCS that are not mentioned in
# NON_AUTO_SRCS. Files should be added to NON_AUTO_SRCS if they
# cannot be built using the standard build template.
#
AUTO_SRCS = $( filter-out $( NON_AUTO_SRCS) ,$( SRCS) )
autosrcs :
2007-09-09 00:38:17 +02:00
@$( ECHO) $( AUTO_SRCS)
2005-04-08 17:01:17 +02:00
2008-10-08 00:18:15 +02:00
# Just about everything else in this section depends upon having
# $(BIN) set
i f d e f B I N
2009-08-11 16:14:36 +02:00
# INCDIRS lists the include path
incdirs :
@$( ECHO) $( INCDIRS)
2008-10-08 00:18:15 +02:00
# Common flags
#
2009-08-11 16:14:36 +02:00
CFLAGS += $( foreach INC,$( INCDIRS) ,-I$( INC) )
2009-03-10 18:50:01 +01:00
CFLAGS += -Os
2008-10-08 00:18:15 +02:00
CFLAGS += -g
2009-03-10 18:50:01 +01:00
i f e q ( $( CCTYPE ) , g c c )
CFLAGS += -ffreestanding
CFLAGS += -Wall -W -Wformat-nonliteral
e n d i f
i f e q ( $( CCTYPE ) , i c c )
CFLAGS += -fno-builtin
CFLAGS += -no-ip
CFLAGS += -no-gcc
CFLAGS += -diag-disable 111 # Unreachable code
CFLAGS += -diag-disable 128 # Unreachable loop
CFLAGS += -diag-disable 170 # Array boundary checks
CFLAGS += -diag-disable 177 # Unused functions
CFLAGS += -diag-disable 181 # printf() format checks
CFLAGS += -diag-disable 188 # enum strictness
CFLAGS += -diag-disable 193 # Undefined preprocessor identifiers
CFLAGS += -diag-disable 280 # switch ( constant )
CFLAGS += -diag-disable 310 # K&R parameter lists
CFLAGS += -diag-disable 424 # Extra semicolon
CFLAGS += -diag-disable 589 # Declarations mid-code
CFLAGS += -diag-disable 593 # Unused variables
CFLAGS += -diag-disable 810 # Casting ints to smaller ints
CFLAGS += -diag-disable 981 # Sequence point violations
CFLAGS += -diag-disable 1292 # Ignored attributes
CFLAGS += -diag-disable 1338 # void pointer arithmetic
CFLAGS += -diag-disable 1361 # Variable-length arrays
CFLAGS += -diag-disable 1418 # Missing prototypes
CFLAGS += -diag-disable 1419 # Missing prototypes
CFLAGS += -diag-disable 1599 # Hidden variables
CFLAGS += -Wall -Wmissing-declarations
e n d i f
2008-10-08 00:18:15 +02:00
CFLAGS += $( EXTRA_CFLAGS)
ASFLAGS += $( EXTRA_ASFLAGS)
LDFLAGS += $( EXTRA_LDFLAGS)
# Inhibit -Werror if NO_WERROR is specified on make command line
#
i f n e q ( $( NO_WERROR ) , 1 )
CFLAGS += -Werror
2009-02-16 02:06:40 +01:00
ASFLAGS += --fatal-warnings
2008-10-08 00:18:15 +02:00
e n d i f
2010-02-05 23:15:18 +01:00
# Function trace recorder state in the last build. This is needed
# in order to correctly rebuild whenever the function recorder is
# enabled/disabled.
#
FNREC_STATE := $( BIN) /.fnrec.state
i f e q ( $( wildcard $ ( FNREC_STATE ) ) , )
FNREC_STATE_OLD := <invalid>
e l s e
FNREC_STATE_OLD := $( shell cat $( FNREC_STATE) )
e n d i f
i f e q ( $( FNREC_STATE_OLD ) , $( FNREC ) )
$(FNREC_STATE) :
e l s e
$(FNREC_STATE) : clean
$( shell $ ( ECHO ) "$ ( FNREC ) " > $ ( FNREC_STATE ) )
e n d i f
VERYCLEANUP += $( FNREC_STATE)
MAKEDEPS += $( FNREC_STATE)
i f e q ( $( FNREC ) , 1 )
# Enabling -finstrument-functions affects gcc's analysis and leads to spurious
# warnings about use of uninitialised variables.
#
CFLAGS += -Wno-uninitialized
CFLAGS += -finstrument-functions
CFLAGS += -finstrument-functions-exclude-file-list= core/fnrec.c
e n d i f
2008-10-08 00:18:15 +02:00
# compiler.h is needed for our linking and debugging system
#
CFLAGS += -include compiler.h
# CFLAGS for specific object types
#
CFLAGS_c +=
CFLAGS_S += -DASSEMBLY
# Base object name of the current target
#
OBJECT = $( firstword $( subst ., ,$( @F) ) )
# CFLAGS for specific object files. You can define
# e.g. CFLAGS_rtl8139, and have those flags automatically used when
# compiling bin/rtl8139.o.
#
OBJ_CFLAGS = $( CFLAGS_$( OBJECT) ) -DOBJECT= $( subst -,_,$( OBJECT) )
$(BIN)/%.flags :
@$( ECHO) $( OBJ_CFLAGS)
2009-03-10 18:50:01 +01:00
# ICC requires postprocessing objects to fix up table alignments
#
i f e q ( $( CCTYPE ) , i c c )
POST_O = && $( ICCFIX) $@
POST_O_DEPS := $( ICCFIX)
e l s e
POST_O :=
POST_O_DEPS :=
e n d i f
2008-10-08 00:18:15 +02:00
# Rules for specific object types.
#
COMPILE_c = $( CC) $( CFLAGS) $( CFLAGS_c) $( OBJ_CFLAGS)
2009-03-10 18:50:01 +01:00
RULE_c = $( Q) $( COMPILE_c) -c $< -o $@ $( POST_O)
2009-10-15 20:07:20 +02:00
R U L E _ c _ t o _ d b g % .o = $( Q) $( COMPILE_c) -Ddebug_$( subst -,_,$( OBJECT) ) = $* -c $< -o $@ $( POST_O)
2008-10-08 00:18:15 +02:00
RULE_c_to_c = $( Q) $( COMPILE_c) -E -c $< > $@
RULE_c_to_s = $( Q) $( COMPILE_c) -S -g0 -c $< -o $@
PREPROCESS_S = $( CPP) $( CFLAGS) $( CFLAGS_S) $( OBJ_CFLAGS)
ASSEMBLE_S = $( AS) $( ASFLAGS)
RULE_S = $( Q) $( PREPROCESS_S) $< | $( ASSEMBLE_S) -o $@
RULE_S_to_s = $( Q) $( PREPROCESS_S) $< > $@
DEBUG_TARGETS += dbg%.o c s
2005-04-08 17:01:17 +02:00
# We automatically generate rules for any file mentioned in AUTO_SRCS
# using the following set of templates. It would be cleaner to use
# $(eval ...), but this function exists only in GNU make >= 3.80.
# src_template : generate Makefile rules for a given source file
#
# $(1) is the full path to the source file (e.g. "drivers/net/rtl8139.c")
# $(2) is the full path to the .d file (e.g. "bin/deps/drivers/net/rtl8139.d")
# $(3) is the source type (e.g. "c")
# $(4) is the source base name (e.g. "rtl8139")
#
d e f i n e s r c _ t e m p l a t e
2008-10-08 00:18:15 +02:00
@$( ECHO) " [DEPS] $( 1) "
2005-04-08 17:01:17 +02:00
@$( MKDIR) -p $( dir $( 2) )
@$( RM) $( 2)
@$( TOUCH) $( 2)
2007-07-24 16:19:09 +02:00
@$( CPP) $( CFLAGS) $( CFLAGS_$( 3) ) $( CFLAGS_$( 4) ) -DOBJECT= $( 4) \
2010-03-22 23:19:00 +01:00
-Wno-error -M $( 1) -MG -MP | \
2009-03-10 18:50:01 +01:00
sed 's/\.o\s*:/_DEPS =/' >> $( 2)
@$( ECHO_E) '\n$$(BIN)/$(4).o :' \
'$(1) $$(MAKEDEPS) $$(POST_O_DEPS) $$($(4)_DEPS)' \
2008-10-08 00:18:15 +02:00
'\n\t$$(QM)$(ECHO) " [BUILD] $$@"' \
2005-04-08 17:01:17 +02:00
'\n\t$$(RULE_$(3))\n' \
'\nBOBJS += $$(BIN)/$(4).o\n' \
$( foreach TGT,$( DEBUG_TARGETS) , \
$( if $( RULE_$( 3) _to_$( TGT) ) , \
2009-03-10 18:50:01 +01:00
'\n$$(BIN)/$(4).$(TGT) :' \
'$(1) $$(MAKEDEPS) $$(POST_O_DEPS) $$($(4)_DEPS)' \
2008-10-08 00:18:15 +02:00
'\n\t$$(QM)$(ECHO) " [BUILD] $$@"' \
2005-04-17 01:28:36 +02:00
'\n\t$$(RULE_$(3)_to_$(TGT))\n' \
'\n$(TGT)_OBJS += $$(BIN)/$(4).$(TGT)\n' ) ) \
2005-04-08 17:01:17 +02:00
'\n$(2) : $$($(4)_DEPS)\n' \
'\nTAGS : $$($(4)_DEPS)\n' \
>> $( 2)
2009-04-17 14:43:35 +02:00
@$( PARSEROM) $( 1) >> $( 2)
2005-04-08 17:01:17 +02:00
e n d e f
# Rule to generate the Makefile rules files to be included
#
$(BIN)/deps/%.d : % $( MAKEDEPS ) $( PARSEROM )
2007-09-09 00:38:17 +02:00
$( if $( filter $( AUTO_SRCS) ,$<) ,$( call src_template,$<,$@ ,$( subst .,,$( suffix $<) ) ,$( basename $( notdir $<) ) ) ,@$( ECHO) 'ERROR: $< is not an AUTO_SRC' ; exit 1)
2005-04-08 17:01:17 +02:00
# Calculate and include the list of Makefile rules files
#
AUTO_DEPS = $( patsubst %,$( BIN) /deps/%.d,$( AUTO_SRCS) )
2008-10-08 00:18:15 +02:00
i f d e f N E E D _ D E P S
2008-10-10 03:09:55 +02:00
i f n e q ( $( AUTO_DEPS ) , )
2008-07-24 20:45:35 +02:00
- i n c l u d e $( AUTO_DEPS )
2008-10-08 00:18:15 +02:00
e n d i f
2008-10-10 03:09:55 +02:00
e n d i f
2005-04-08 17:01:17 +02:00
autodeps :
2007-09-09 00:38:17 +02:00
@$( ECHO) $( AUTO_DEPS)
2005-04-08 17:01:17 +02:00
VERYCLEANUP += $( BIN) /deps
# The following variables are created by the Makefile rules files
#
bobjs :
2007-09-09 00:38:17 +02:00
@$( ECHO) $( BOBJS)
2005-04-08 17:01:17 +02:00
drivers :
2007-09-09 00:38:17 +02:00
@$( ECHO) $( DRIVERS)
2005-04-08 17:01:17 +02:00
.PHONY : drivers
roms :
2007-09-09 00:38:17 +02:00
@$( ECHO) $( ROMS)
2005-04-08 17:01:17 +02:00
2009-02-16 01:28:30 +01:00
# List of embedded images included in the last build of embedded.o.
# This is needed in order to correctly rebuild embedded.o whenever the
# list of objects changes.
#
EMBEDDED_LIST := $( BIN) /.embedded.list
i f e q ( $( wildcard $ ( EMBEDDED_LIST ) ) , )
2009-03-27 05:47:08 +01:00
EMBEDDED_LIST_IMAGE := <invalid>
2009-02-16 01:28:30 +01:00
e l s e
EMBEDDED_LIST_IMAGE := $( shell cat $( EMBEDDED_LIST) )
e n d i f
i f n e q ( $( EMBEDDED_LIST_IMAGE ) , $( EMBEDDED_IMAGE ) )
$( shell $ ( ECHO ) "$ ( EMBEDDED_IMAGE ) " > $ ( EMBEDDED_LIST ) )
e n d i f
$(EMBEDDED_LIST) :
VERYCLEANUP += $( EMBEDDED_LIST)
EMBEDDED_FILES := $( subst $( COMMA) , ,$( EMBEDDED_IMAGE) )
2009-03-31 12:06:35 +02:00
EMBED_ALL := $( foreach i,$( call seq,1,$( words $( EMBEDDED_FILES) ) ) ,\
2009-02-16 01:28:30 +01:00
EMBED ( $( i) , \" $( word $( i) , $( EMBEDDED_FILES) ) \" ,\
\" $( notdir $( word $( i) ,$( EMBEDDED_FILES) ) ) \" ) )
2008-01-08 16:51:36 +01:00
2009-02-16 01:28:30 +01:00
$(BIN)/embedded.o : $( EMBEDDED_FILES ) $( EMBEDDED_LIST )
2010-03-01 21:34:47 +01:00
# This file uses .incbin inline assembly to include a binary file.
# Unfortunately ccache does not detect this dependency and caches builds even
# when the binary file has changed.
#
$(BIN)/embedded.o : override CC := env CCACHE_DISABLE =1 $( CC )
2009-02-16 01:28:30 +01:00
CFLAGS_embedded = -DEMBED_ALL= " $( EMBED_ALL) "
2008-01-08 16:51:36 +01:00
2005-04-08 17:01:17 +02:00
# Generate the NIC file from the parsed source files. The NIC file is
# only for rom-o-matic.
#
$(BIN)/NIC : $( AUTO_DEPS )
2007-09-09 00:38:17 +02:00
@$( ECHO) '# This is an automatically generated file, do not edit' > $@
@$( ECHO) '# It does not affect anything in the build, ' \
2005-04-08 17:01:17 +02:00
'it is only for rom-o-matic' >> $@
2007-09-09 00:38:17 +02:00
@$( ECHO) >> $@
2005-04-08 17:01:17 +02:00
@perl -ne 'chomp; print "$$1\n" if /\# NIC\t(.*)$$/' $^ >> $@
2008-10-08 00:18:15 +02:00
CLEANUP += $( BIN) /NIC # Doesn't match the $(BIN)/*.* pattern
2005-04-08 17:01:17 +02:00
# Analyse a target name (e.g. "bin/dfe538--prism2_pci.zrom.tmp") and
# derive the variables:
#
# TGT_ELEMENTS : the elements of the target (e.g. "dfe538 prism2_pci")
# TGT_PREFIX : the prefix type (e.g. "zrom")
# TGT_DRIVERS : the driver for each element (e.g. "rtl8139 prism2_pci")
# TGT_ROM_NAME : the ROM name (e.g. "dfe538")
# TGT_MEDIA : the media type (e.g. "rom")
#
2010-04-19 21:16:01 +02:00
DRIVERS_ipxe = $( DRIVERS)
2005-05-03 13:51:19 +02:00
CARD_DRIVER = $( firstword $( DRIVER_$( 1) ) $( 1) )
2005-04-08 17:01:17 +02:00
TGT_ELEMENTS = $( subst --, ,$( firstword $( subst ., ,$( notdir $@ ) ) ) )
TGT_PREFIX = $( word 2,$( subst ., ,$( notdir $@ ) ) )
TGT_ROM_NAME = $( firstword $( TGT_ELEMENTS) )
2005-05-03 13:51:19 +02:00
TGT_DRIVERS = $( strip $( if $( DRIVERS_$( TGT_ROM_NAME) ) , \
$( DRIVERS_$( TGT_ROM_NAME) ) , \
$( foreach TGT_ELEMENT,$( TGT_ELEMENTS) , \
$( call CARD_DRIVER,$( TGT_ELEMENT) ) ) ) )
2005-04-08 17:01:17 +02:00
TGT_MEDIA = $( subst z,,$( TGT_PREFIX) )
2006-06-06 17:41:21 +02:00
# Look up ROM IDs for the current target
2005-04-08 17:01:17 +02:00
# (e.g. "bin/dfe538--prism2_pci.zrom.tmp") and derive the variables:
#
# TGT_PCI_VENDOR : the PCI vendor ID (e.g. "0x1186")
# TGT_PCI_DEVICE : the PCI device ID (e.g. "0x1300")
#
TGT_PCI_VENDOR = $( PCI_VENDOR_$( TGT_ROM_NAME) )
TGT_PCI_DEVICE = $( PCI_DEVICE_$( TGT_ROM_NAME) )
# Calculate link-time options for the current target
# (e.g. "bin/dfe538--prism2_pci.zrom.tmp") and derive the variables:
#
# TGT_LD_DRIVERS : symbols to require in order to drag in the relevant drivers
# (e.g. "obj_rtl8139 obj_prism2_pci")
# TGT_LD_IDS : symbols to define in order to fill in ID structures in the
2005-04-12 19:56:23 +02:00
# ROM header (e.g."pci_vendor_id=0x1186 pci_device_id=0x1300")
2005-04-08 17:01:17 +02:00
#
TGT_LD_DRIVERS = $( subst -,_,$( patsubst %,obj_%,$( TGT_DRIVERS) ) )
2006-06-06 17:41:21 +02:00
TGT_LD_PREFIX = obj_$( TGT_PREFIX) prefix
2008-04-23 17:24:00 +02:00
TGT_LD_IDS = pci_vendor_id = $( firstword $( TGT_PCI_VENDOR) 0) \
pci_device_id = $( firstword $( TGT_PCI_DEVICE) 0)
2005-04-08 17:01:17 +02:00
# Calculate linker flags based on link-time options for the current
# target type (e.g. "bin/dfe538--prism2_pci.zrom.tmp") and derive the
# variables:
#
# TGT_LD_FLAGS : target-specific flags to pass to linker (e.g.
# "-u obj_zpciprefix -u obj_rtl8139 -u obj_prism2_pci
# --defsym pci_vendor=0x1186 --defsym pci_device=0x1300")
#
TGT_LD_FLAGS = $( foreach SYM,$( TGT_LD_PREFIX) $( TGT_LD_DRIVERS) obj_config,\
-u $( SYM) --defsym check_$( SYM) = $( SYM) ) \
$( patsubst %,--defsym %,$( TGT_LD_IDS) )
# Calculate makerom flags for the specific target
# (e.g. "bin/dfe538--prism2_pci.zrom.tmp") and derive the variables:
#
# TGT_MAKEROM_FLAGS : target-specific flags for makerom (e.g.
# "-p 0x1186,0x1300")
#
TGT_MAKEROM_FLAGS = $( strip $( MAKEROM_FLAGS_$( TGT_ROM_NAME) ) \
$( if $( TGT_PCI_VENDOR) ,$( strip -p $( TGT_PCI_VENDOR) ,$( TGT_PCI_DEVICE) ) ) )
2005-04-17 01:28:36 +02:00
# Calculate list of debugging versions of objects to be included in
# the target.
#
2005-04-25 21:25:45 +02:00
DEBUG_LIST = $( subst $( COMMA) , ,$( DEBUG) )
2007-01-18 20:00:09 +01:00
DEBUG_OBJ_LEVEL = $( firstword $( word 2,$( subst :, ,$( 1) ) ) 1)
DEBUG_OBJ_BASE = $( word 1,$( subst :, ,$( 1) ) ) .dbg$( call DEBUG_OBJ_LEVEL,$( 1) )
2005-04-25 21:25:45 +02:00
DEBUG_OBJ = $( BIN) /$( call DEBUG_OBJ_BASE,$( 1) ) .o
DEBUG_ORIG_OBJ = $( BIN) /$( word 1,$( subst :, ,$( 1) ) ) .o
DEBUG_OBJS = $( foreach D,$( DEBUG_LIST) ,$( call DEBUG_OBJ,$( D) ) )
DEBUG_ORIG_OBJS = $( foreach D,$( DEBUG_LIST) ,$( call DEBUG_ORIG_OBJ,$( D) ) )
BLIB_OBJS = $( DEBUG_OBJS) $( filter-out $( DEBUG_ORIG_OBJS) ,$( BOBJS) )
2005-04-17 01:28:36 +02:00
2005-04-08 17:01:17 +02:00
# Print out all derived information for a given target.
#
$(BIN)/%.info :
2007-09-09 00:38:17 +02:00
@$( ECHO) 'Elements : $(TGT_ELEMENTS)'
@$( ECHO) 'Prefix : $(TGT_PREFIX)'
@$( ECHO) 'Drivers : $(TGT_DRIVERS)'
@$( ECHO) 'ROM name : $(TGT_ROM_NAME)'
@$( ECHO) 'Media : $(TGT_MEDIA)'
@$( ECHO)
@$( ECHO) 'PCI vendor : $(TGT_PCI_VENDOR)'
@$( ECHO) 'PCI device : $(TGT_PCI_DEVICE)'
@$( ECHO)
@$( ECHO) 'LD driver symbols : $(TGT_LD_DRIVERS)'
@$( ECHO) 'LD prefix symbols : $(TGT_LD_PREFIX)'
@$( ECHO) 'LD ID symbols : $(TGT_LD_IDS)'
@$( ECHO)
@$( ECHO) 'LD target flags : $(TGT_LD_FLAGS)'
@$( ECHO)
@$( ECHO) 'makerom target flags : $(TGT_MAKEROM_FLAGS)'
@$( ECHO)
@$( ECHO) 'Debugging objects : $(DEBUG_OBJS)'
@$( ECHO) 'Replaced objects : $(DEBUG_ORIG_OBJS)'
2007-07-07 18:49:07 +02:00
# List of objects included in the last build of blib. This is needed
# in order to correctly rebuild blib whenever the list of objects
# changes.
#
2008-10-08 00:18:15 +02:00
BLIB_LIST := $( BIN) /.blib.list
i f e q ( $( wildcard $ ( BLIB_LIST ) ) , )
2009-03-27 05:47:08 +01:00
BLIB_LIST_OBJS := <invalid>
2008-10-08 00:18:15 +02:00
e l s e
BLIB_LIST_OBJS := $( shell cat $( BLIB_LIST) )
e n d i f
i f n e q ( $( BLIB_LIST_OBJS ) , $( BLIB_OBJS ) )
2007-09-09 00:38:17 +02:00
$( shell $ ( ECHO ) "$ ( BLIB_OBJS ) " > $ ( BLIB_LIST ) )
2007-07-07 18:49:07 +02:00
e n d i f
$(BLIB_LIST) :
VERYCLEANUP += $( BLIB_LIST)
2006-06-29 19:58:48 +02:00
2005-04-18 15:55:57 +02:00
# Library of all objects
#
2007-07-07 18:49:07 +02:00
BLIB = $( BIN) /blib.a
$(BLIB) : $( BLIB_OBJS ) $( BLIB_LIST ) $( MAKEDEPS )
2007-01-31 12:06:36 +01:00
$( Q) $( RM) $( BLIB)
2007-09-09 00:38:17 +02:00
$( QM) $( ECHO) " [AR] $@ "
2007-01-31 12:06:36 +01:00
$( Q) $( AR) r $@ $( BLIB_OBJS)
$( Q) $( RANLIB) $@
2005-04-18 15:55:57 +02:00
blib : $( BLIB )
2005-04-08 17:01:17 +02:00
2010-04-24 20:15:51 +02:00
# Command to generate build ID. Must be unique for each $(BIN)/%.tmp,
# even within the same build run.
#
BUILD_ID_CMD := perl -e 'printf "0x%08x", int ( rand ( 0xffffffff ) );'
2005-04-08 17:01:17 +02:00
# Build an intermediate object file from the objects required for the
# specified target.
2005-04-17 01:28:36 +02:00
#
2010-04-24 20:15:51 +02:00
$(BIN)/%.tmp : $( BLIB ) $( MAKEDEPS ) $( LDSCRIPT )
2007-09-09 00:38:17 +02:00
$( QM) $( ECHO) " [LD] $@ "
2007-01-31 12:06:36 +01:00
$( Q) $( LD) $( LDFLAGS) -T $( LDSCRIPT) $( TGT_LD_FLAGS) $( BLIB) -o $@ \
2010-04-24 20:15:51 +02:00
--defsym _build_id = ` $( BUILD_ID_CMD) ` -Map $( BIN) /$* .tmp.map
2007-01-31 12:06:36 +01:00
$( Q) $( OBJDUMP) -ht $@ | $( SORTOBJDUMP) >> $( BIN) /$* .tmp.map
2005-04-08 17:01:17 +02:00
2007-12-28 20:33:11 +01:00
# Keep intermediate object file (useful for debugging)
2008-06-06 15:25:25 +02:00
.PRECIOUS : $( BIN ) /%.tmp
2007-12-28 20:33:11 +01:00
2005-04-08 17:01:17 +02:00
# Show a linker map for the specified target
#
$(BIN)/%.map : $( BIN ) /%.tmp
@less $( BIN) /$* .tmp.map
2009-04-17 13:38:44 +02:00
# Get objects list for the specified target
#
d e f i n e o b j s _ l i s t
$( sort $( foreach OBJ_SYMBOL,\
$( filter obj_%,$( shell $( NM) $( 1) | cut -d" " -f3) ) ,\
$( patsubst obj_%,%,$( OBJ_SYMBOL) ) ) )
e n d e f
$(BIN)/%.objs : $( BIN ) /%.tmp
$( Q) $( ECHO) $( call objs_list,$<)
2009-04-18 16:55:01 +02:00
$(BIN)/%.sizes : $( BIN ) /%.tmp
2009-12-30 02:28:34 +01:00
$( Q) $( SIZE) -t $( foreach OBJ,$( call objs_list,$<) ,$( wildcard $( BIN) /$( subst _,?,$( OBJ) ) .o) ) | \
2009-04-18 17:19:29 +02:00
sort -g
2009-04-17 13:38:44 +02:00
# Get dependency list for the specified target
#
d e f i n e d e p s _ l i s t
$( sort $( foreach OBJ,$( call objs_list,$( 1) ) ,$( $( OBJ) _DEPS) ) )
e n d e f
$(BIN)/%.deps : $( BIN ) /%.tmp
$( Q) $( ECHO) $( call deps_list,$<)
# Get unneeded source files for the specified target
#
d e f i n e n o d e p s _ l i s t
2009-04-29 09:51:27 +02:00
$( sort $( filter-out $( call deps_list,$( 1) ) ,\
2009-04-17 13:38:44 +02:00
$( foreach BOBJ,$( BOBJS) ,\
$( $( basename $( notdir $( BOBJ) ) ) _DEPS) ) ) )
e n d e f
$(BIN)/%.nodeps : $( BIN ) /%.tmp
$( Q) $( ECHO) $( call nodeps_list,$<)
2009-04-29 09:51:27 +02:00
# Get licensing verdict for the specified target
#
d e f i n e u n l i c e n s e d _ d e p s _ l i s t
$( shell grep -L FILE_LICENCE $( call deps_list,$( 1) ) )
e n d e f
d e f i n e l i c e n c e _ l i s t
$( patsubst __licence_%,%,\
$( filter __licence_%,$( shell $( NM) $( 1) | cut -d" " -f3) ) )
e n d e f
$(BIN)/%.licence : $( BIN ) /%.tmp
$( QM) $( ECHO) " [LICENCE] $@ "
$( Q) $( if $( strip $( call unlicensed_deps_list,$<) ) ,\
echo -n "Unable to determine licence because the following " ; \
echo "files are missing a licence declaration:" ; \
echo $( call unlicensed_deps_list,$<) ; \
exit 1,\
$( LICENCE) $( call licence_list,$<) )
2007-07-16 17:58:38 +02:00
# Extract compression information from intermediate object file
#
$(BIN)/%.zinfo : $( BIN ) /%.tmp
2007-09-09 00:38:17 +02:00
$( QM) $( ECHO) " [ZINFO] $@ "
2007-07-16 17:58:38 +02:00
$( Q) $( OBJCOPY) -O binary -j .zinfo $< $@
2007-07-16 14:41:27 +02:00
# Build raw binary file from intermediate object file
#
$(BIN)/%.bin : $( BIN ) /%.tmp
2007-09-09 00:38:17 +02:00
$( QM) $( ECHO) " [BIN] $@ "
2007-07-16 17:58:38 +02:00
$( Q) $( OBJCOPY) -O binary -R .zinfo $< $@
# Compress raw binary file
#
$(BIN)/%.zbin : $( BIN ) /%.bin $( BIN ) /%.zinfo $( ZBIN )
2007-09-09 00:38:17 +02:00
$( QM) $( ECHO) " [ZBIN] $@ "
2007-07-16 17:58:38 +02:00
$( Q) $( ZBIN) $( BIN) /$* .bin $( BIN) /$* .zinfo > $@
2007-07-16 14:41:27 +02:00
2005-04-08 17:01:17 +02:00
# Rules for each media format. These are generated and placed in an
# external Makefile fragment. We could do this via $(eval ...), but
# that would require make >= 3.80.
#
# Note that there's an alternative way to generate most .rom images:
# they can be copied from their 'master' ROM image using cp and
# reprocessed with makerom to add the PCI IDs and ident string. The
# relevant rule would look something like:
#
# $(BIN)/dfe538%rom : $(BIN)/rtl8139%rom
# cat $< $@
# $(FINALISE_rom)
#
# You can derive the ROM/driver relationships using the variables
# DRIVER_<rom> and/or ROMS_<driver>.
#
# We don't currently do this, because (a) it would require generating
# yet more Makefile fragments (since you need a rule for each ROM in
# ROMS), and (b) the linker is so fast that it probably wouldn't make
# much difference to the overall build time.
media :
2007-09-09 00:38:17 +02:00
@$( ECHO) $( MEDIA)
2005-04-08 17:01:17 +02:00
AUTO_MEDIA = $( filter-out $( NON_AUTO_MEDIA) ,$( MEDIA) )
automedia :
2007-09-09 00:38:17 +02:00
@$( ECHO) $( AUTO_MEDIA)
2005-04-08 17:01:17 +02:00
# media_template : create Makefile rules for specified media
#
# $(1) is the media name (e.g. "rom")
# $(2) is the full path to the .d file (e.g. "bin/deps/rom.media.d")
#
d e f i n e m e d i a _ t e m p l a t e
2008-10-08 00:18:15 +02:00
@$( ECHO) " [MEDIADEPS] $( 1) "
2005-04-08 17:01:17 +02:00
@$( MKDIR) -p $( dir $( 2) )
@$( RM) $( 2)
@$( TOUCH) $( 2)
2007-12-08 01:50:57 +01:00
@$( ECHO_E) '$$(BIN)/%.$(1) : $$(BIN)/%.$(1).zbin' \
2007-09-09 00:38:17 +02:00
'\n\t$$(QM)$(ECHO) " [FINISH] $$@"' \
2007-07-16 14:41:27 +02:00
'\n\t$$(Q)$$(CP) $$< $$@' \
2009-04-16 04:15:08 +02:00
'\n\t$$(Q)$$(PAD_$(1))' \
2007-07-16 14:41:27 +02:00
'\n\t$$(Q)$$(FINALISE_$(1))' \
2005-04-08 17:01:17 +02:00
> $( 2)
e n d e f
# Rule to generate the Makefile rules to be included
#
$(BIN)/deps/%.media.d : $( MAKEDEPS )
$( if $( filter $( AUTO_MEDIA) ,$* ) , \
$( call media_template,$* ,$@ ) , \
2007-09-09 00:38:17 +02:00
@$( ECHO) 'ERROR: $* is not an AUTO_MEDIA' ; exit 1)
2005-04-08 17:01:17 +02:00
# Calculate and include the list of Makefile rules files
#
MEDIA_DEPS = $( patsubst %,$( BIN) /deps/%.media.d,$( AUTO_MEDIA) )
mediadeps :
2007-09-09 00:38:17 +02:00
@$( ECHO) $( MEDIA_DEPS)
2008-10-08 00:18:15 +02:00
i f d e f N E E D _ D E P S
2008-10-10 03:09:55 +02:00
i f n e q ( $( MEDIA_DEPS ) , )
2008-07-24 20:45:35 +02:00
- i n c l u d e $( MEDIA_DEPS )
2008-10-08 00:18:15 +02:00
e n d i f
2008-10-10 03:09:55 +02:00
e n d i f
2008-10-08 00:18:15 +02:00
# Wrap up binary blobs (for embedded images)
#
$(BIN)/%.o : payload /%.img
$( QM) echo " [WRAP] $@ "
$( Q) $( LD) -b binary -r -o $@ $< --undefined obj_payload \
--defsym obj_$* = 0
BOBJS += $( patsubst payload/%.img,$( BIN) /%.o,$( wildcard payload/*.img) )
2005-04-08 17:01:17 +02:00
# The "allXXXs" targets for each suffix
#
2007-08-30 19:08:46 +02:00
allall : allroms allzroms allpxes allisos alldsks
2005-04-08 17:01:17 +02:00
allroms allzroms : all %s : $( foreach ROM ,$ ( ROMS ) ,$ ( BIN ) /$ ( ROM ) .%)
2007-08-30 19:08:46 +02:00
allpxes allisos alldsks : all %s : $( foreach DRIVER ,$ ( DRIVERS ) ,$ ( BIN ) /$ ( DRIVER ) .%)
2005-04-08 17:01:17 +02:00
2010-04-19 21:16:01 +02:00
# Alias for ipxe.%
2007-08-23 00:10:00 +02:00
#
2010-04-19 21:16:01 +02:00
$(BIN)/etherboot.% : $( BIN ) /ipxe .%
2007-08-23 00:10:00 +02:00
ln -sf $( notdir $<) $@
2008-10-08 00:18:15 +02:00
e n d i f # defined(BIN)
###############################################################################
2007-09-06 16:11:09 +02:00
#
2008-10-08 00:18:15 +02:00
# Rules for finalising files. TGT_MAKEROM_FLAGS is defined as part of
# the automatic build system and varies by target; it includes the
# "-p 0x1234,0x5678" string to set the PCI IDs.
#
FINALISE_rom = $( MAKEROM) $( MAKEROM_FLAGS) $( TGT_MAKEROM_FLAGS) \
-i$( IDENT) -s 0 $@
2007-09-06 16:11:09 +02:00
2008-10-08 00:18:15 +02:00
# Some ROMs require specific flags to be passed to makerom.pl
#
MAKEROM_FLAGS_3c503 = -3
2007-09-06 16:11:09 +02:00
2008-10-08 00:18:15 +02:00
###############################################################################
#
2007-07-16 17:58:38 +02:00
# The compression utilities
2005-04-08 17:01:17 +02:00
#
$(NRV2B) : util /nrv 2b .c $( MAKEDEPS )
2007-09-09 00:38:17 +02:00
$( QM) $( ECHO) " [HOSTCC] $@ "
2007-07-16 17:58:38 +02:00
$( Q) $( HOST_CC) -O2 -DENCODE -DDECODE -DMAIN -DVERBOSE -DNDEBUG \
2005-04-08 17:01:17 +02:00
-DBITSIZE= 32 -DENDIAN= 0 -o $@ $<
CLEANUP += $( NRV2B)
2007-07-16 17:58:38 +02:00
$(ZBIN) : util /zbin .c util /nrv 2b .c $( MAKEDEPS )
2007-09-09 00:38:17 +02:00
$( QM) $( ECHO) " [HOSTCC] $@ "
2007-07-16 17:58:38 +02:00
$( Q) $( HOST_CC) -O2 -o $@ $<
CLEANUP += $( ZBIN)
2008-10-12 02:55:55 +02:00
###############################################################################
#
2009-01-07 03:05:51 +01:00
# The EFI image converter
2008-10-12 02:55:55 +02:00
#
2009-03-31 10:36:08 +02:00
ELF2EFI_CFLAGS := -I$( BINUTILS_DIR) /include -I$( BFD_DIR) /include \
-idirafter include -L$( BINUTILS_DIR) /lib -L$( BFD_DIR) /lib \
-lbfd -liberty -lz
2009-01-07 03:05:51 +01:00
$(ELF2EFI32) : util /elf 2efi .c $( MAKEDEPS )
2008-10-12 02:55:55 +02:00
$( QM) $( ECHO) " [HOSTCC] $@ "
2009-03-31 10:36:08 +02:00
$( Q) $( HOST_CC) $( ELF2EFI_CFLAGS) -DMDE_CPU_IA32 -O2 -o $@ $<
2009-01-07 03:05:51 +01:00
CLEANUP += $( ELF2EFI32)
$(ELF2EFI64) : util /elf 2efi .c $( MAKEDEPS )
$( QM) $( ECHO) " [HOSTCC] $@ "
2009-03-31 10:36:08 +02:00
$( Q) $( HOST_CC) $( ELF2EFI_CFLAGS) -DMDE_CPU_X64 -O2 -o $@ $<
2009-01-07 03:05:51 +01:00
CLEANUP += $( ELF2EFI64)
2008-10-12 02:55:55 +02:00
2009-01-08 03:19:18 +01:00
$(EFIROM) : util /efirom .c $( MAKEDEPS )
$( QM) $( ECHO) " [HOSTCC] $@ "
$( Q) $( HOST_CC) -idirafter include -O2 -o $@ $<
CLEANUP += $( EFIROM)
2009-03-10 18:50:01 +01:00
###############################################################################
#
# The ICC fixup utility
#
$(ICCFIX) : util /iccfix .c $( MAKEDEPS )
$( QM) $( ECHO) " [HOSTCC] $@ "
$( Q) $( HOST_CC) -idirafter include -O2 -o $@ $<
CLEANUP += $( ICCFIX)
2010-03-22 23:19:00 +01:00
###############################################################################
#
# Local configs
#
config/local/%.h :
$( Q) touch $@
2008-10-08 00:18:15 +02:00
###############################################################################
#
2005-04-08 17:01:17 +02:00
# Auto-incrementing build serial number. Append "bs" to your list of
# build targets to get a serial number printed at the end of the
# build. Enable -DBUILD_SERIAL in order to see it when the code runs.
#
2005-04-18 14:43:18 +02:00
BUILDSERIAL_H = config/.buildserial.h
BUILDSERIAL_NOW = config/.buildserial.now
BUILDSERIAL_NEXT = config/.buildserial.next
2005-04-08 17:01:17 +02:00
2005-04-18 14:43:18 +02:00
$(BUILDSERIAL_NOW) $(BUILDSERIAL_NEXT) :
2007-09-09 00:38:17 +02:00
$( ECHO) 1 > $@
2005-04-08 17:01:17 +02:00
2005-04-18 14:43:18 +02:00
$(BUILDSERIAL_H) : $( BUILDSERIAL_NOW ) $( BUILDSERIAL_NEXT )
2007-09-09 00:38:17 +02:00
$( ECHO) '#define BUILD_SERIAL_NUM $(shell cat $<)' > $@
2005-04-08 17:01:17 +02:00
i f e q ( $( filter bs ,$ ( MAKECMDGOALS ) ) , b s )
2005-04-18 14:43:18 +02:00
$( shell diff -q $ ( BUILDSERIAL_NOW ) $ ( BUILDSERIAL_NEXT ) > /dev /null || \
cp -f $( BUILDSERIAL_NEXT) $( BUILDSERIAL_NOW) )
2005-04-08 17:01:17 +02:00
e n d i f
2005-04-18 14:43:18 +02:00
bs : $( BUILDSERIAL_NOW )
2007-09-09 00:38:17 +02:00
@$( ECHO) $$ ( ( $( shell cat $<) + 1 ) ) > $( BUILDSERIAL_NEXT)
@$( ECHO) " Build serial number is $( shell cat $<) "
2005-04-08 17:01:17 +02:00
2008-10-08 00:18:15 +02:00
###############################################################################
2005-04-08 17:01:17 +02:00
#
2008-10-08 00:18:15 +02:00
# Build the TAGS file(s) for emacs
#
TAGS :
ctags -e -R -f $@ --exclude= bin
2005-04-08 17:01:17 +02:00
2008-10-08 00:18:15 +02:00
CLEANUP += TAGS
2005-04-08 17:01:17 +02:00
2008-10-08 00:18:15 +02:00
###############################################################################
2005-04-08 17:01:17 +02:00
#
2008-10-08 00:18:15 +02:00
# Force rebuild for any given target
#
%.rebuild :
rm -f $*
$( Q) $( MAKE) $*
2005-04-08 17:01:17 +02:00
2008-10-08 00:18:15 +02:00
###############################################################################
#
2005-04-23 16:41:38 +02:00
# Symbol table checks
#
2008-10-08 00:18:15 +02:00
i f d e f B I N
2005-04-23 16:41:38 +02:00
SYMTAB = $( BIN) /symtab
$(SYMTAB) : $( BLIB )
2007-07-17 02:15:39 +02:00
$( OBJDUMP) -w -t $< > $@
2005-04-23 16:41:38 +02:00
2007-07-07 18:49:59 +02:00
CLEANUP += $( BIN) /symtab
2005-04-23 16:41:38 +02:00
symcheck : $( SYMTAB )
$( SYMCHECK) $<
2008-10-08 00:18:15 +02:00
e n d i f # defined(BIN)
###############################################################################
2005-04-14 13:45:37 +02:00
#
2008-10-08 00:18:15 +02:00
# Build bochs symbol table
#
i f d e f B I N
2005-04-14 13:45:37 +02:00
2008-10-08 00:18:15 +02:00
$(BIN)/%.bxs : $( BIN ) /%.tmp
$( NM) $< | cut -d" " -f1,3 > $@
e n d i f # defined(BIN)
###############################################################################
#
2005-05-18 13:13:34 +02:00
# Documentation
#
2008-10-08 00:18:15 +02:00
i f d e f B I N
2005-05-18 13:13:34 +02:00
$(BIN)/doxygen.cfg : doxygen .cfg $( MAKEDEPS )
2009-08-11 16:14:36 +02:00
$( Q) $( PERL) -pe 's{\@SRCDIRS\@}{$(SRCDIRS)}; ' \
-e 's{\@INCDIRS\@}{$(filter-out .,$(INCDIRS))}; ' \
2005-05-18 16:39:31 +02:00
-e 's{\@BIN\@}{$(BIN)}; ' \
-e 's{\@ARCH\@}{$(ARCH)}; ' \
$< > $@
2005-05-18 13:13:34 +02:00
$(BIN)/doc : $( BIN ) /doxygen .cfg
2009-08-11 16:14:36 +02:00
$( Q) $( DOXYGEN) $<
2005-05-18 13:13:34 +02:00
.PHONY : $( BIN ) /doc
doc : $( BIN ) /doc
2009-08-11 16:14:36 +02:00
doc-clean :
$( Q) $( RM) -r $( BIN) /doc
VERYCLEANUP += $( BIN) /doc
2005-05-18 13:13:34 +02:00
docview :
@[ -f $( BIN) /doc/html/index.html ] || $( MAKE) $( BIN) /doc
@if [ -n " $$ BROWSER " ] ; then \
( $$ BROWSER $( BIN) /doc/html/index.html & ) ; \
else \
2007-09-09 00:38:17 +02:00
$( ECHO) " Documentation index in $( BIN) /doc/html/index.html " ; \
2005-05-18 13:13:34 +02:00
fi
2008-10-08 00:18:15 +02:00
e n d i f # defined(BIN)
###############################################################################
#
2005-04-08 17:01:17 +02:00
# Clean-up
#
clean :
$( RM) $( CLEANUP)
veryclean : clean
$( RM) -r $( VERYCLEANUP)