Author: blueswirl Date: Sat Feb 16 13:08:33 2013 New Revision: 1099 URL: http://tracker.coreboot.org/trac/openbios/changeset/1099
Log: build: support disjoint build directory
Support building in any directory, not just in-tree build.
Use VPATH for non-Forth files.
Forth compiler does not support explicit paths, so drop source path prefixes added by XML and rely on directories passed with -I flag.
Signed-off-by: Blue Swirl blauwirbel@gmail.com
Modified: trunk/openbios-devel/.gitignore trunk/openbios-devel/Makefile trunk/openbios-devel/Makefile.target trunk/openbios-devel/config/scripts/switch-arch trunk/openbios-devel/config/xml/dictionary.xsl trunk/openbios-devel/config/xml/object.xsl
Modified: trunk/openbios-devel/.gitignore ============================================================================== --- trunk/openbios-devel/.gitignore Sun Feb 3 17:50:11 2013 (r1098) +++ trunk/openbios-devel/.gitignore Sat Feb 16 13:08:33 2013 (r1099) @@ -1,2 +1,3 @@ obj-* .stgit-* +config-host.mak
Modified: trunk/openbios-devel/Makefile ============================================================================== --- trunk/openbios-devel/Makefile Sun Feb 3 17:50:11 2013 (r1098) +++ trunk/openbios-devel/Makefile Sat Feb 16 13:08:33 2013 (r1099) @@ -1,5 +1,4 @@ -ODIRS=$(wildcard obj-*) -TARGETS=$(subst obj-,,$(ODIRS)) +include config-host.mak
all: requirements info build
Modified: trunk/openbios-devel/Makefile.target ============================================================================== --- trunk/openbios-devel/Makefile.target Sun Feb 3 17:50:11 2013 (r1098) +++ trunk/openbios-devel/Makefile.target Sat Feb 16 13:08:33 2013 (r1099) @@ -6,7 +6,6 @@ include config.mak
ODIR := . -SRCDIR := .. HOSTCC := gcc
HOSTCFLAGS+= -O2 -g -DFCOMPILER -DBOOTSTRAP $(CROSSCFLAGS) @@ -38,6 +37,10 @@
quiet-command = $(if $(V),$1,$(if $(2),@echo $2 && $1, @$1))
+VPATH_SUFFIXES = %.c %.h %.S %.fs +set-vpath = $(if $1,$(foreach PATTERN,$(VPATH_SUFFIXES),$(eval vpath $(PATTERN) $1))) +$(call set-vpath, $(SRCDIR)) + # # pre rules #
Modified: trunk/openbios-devel/config/scripts/switch-arch ============================================================================== --- trunk/openbios-devel/config/scripts/switch-arch Sun Feb 3 17:50:11 2013 (r1098) +++ trunk/openbios-devel/config/scripts/switch-arch Sat Feb 16 13:08:33 2013 (r1099) @@ -117,21 +117,18 @@ echo "<option name="$option" type="boolean" value="true" />" }
-if ! test -f utils/dist/debian/rules; then - echo "switch-arch must be run from the top-level source directory" >&2 - exit 1 -fi
-# This is needed because viewvc messes with the permissions of executables: -chmod 755 utils/dist/debian/rules -chmod 755 config/scripts/switch-arch -chmod 755 config/scripts/reldir +SRCDIR=`dirname "$0"`/../.. +BUILDDIR=`pwd` + +# make source path absolute +SRCDIR=`cd "$SRCDIR"; pwd`
if test "x$HOSTARCH" = "x"; then archname fi
-VERSION=`head VERSION` +VERSION=`head $SRCDIR/VERSION`
echo "Configuring OpenBIOS on $HOSTARCH for $*"
@@ -156,8 +153,8 @@ arch_list="" for target in $target_list; do arch=`echo $target | sed s/.*-//g` - if ! test -f config/examples/${arch}_config.xml; then - echo "Cannot find config/examples/${arch}_config.xml" >&2 + if ! test -f $SRCDIR/config/examples/${arch}_config.xml; then + echo "Cannot find $SRCDIR/config/examples/${arch}_config.xml" >&2 exit 1 fi if ! echo $arch_list | grep -q "$arch"; then @@ -269,7 +266,8 @@ cross="yes" fi crosscflags $HOSTARCH $ARCH - OBJDIR=obj-$ARCH + OBJDIR=$BUILDDIR/obj-$ARCH + ODIRS="$ODIRS $OBJDIR"
printf "Initializing build tree $OBJDIR..." rm -rf "$OBJDIR" @@ -294,9 +292,9 @@ mkdir -p $OBJDIR/host/include mkdir -p $OBJDIR/host/kernel mkdir -p $OBJDIR/forth - ln -s ../../../include/arch/$BASEARCH $OBJDIR/target/include/asm + ln -s $SRCDIR/include/arch/$BASEARCH $OBJDIR/target/include/asm #compile the host binary with target settings instead - #ln -s ../../../include/arch/$HOSTARCH $OBJDIR/host/include/asm + #ln -s $SRCDIR/include/arch/$HOSTARCH $OBJDIR/host/include/asm if [ "$mol" = "yes" ]; then printf "\nUsing MOL path $MOLPATH...\n" mkdir -p $OBJDIR/target/arch/ppc/mol @@ -324,11 +322,9 @@ fi echo "ok."
- cd $OBJDIR - SRCDIR=.. - ODIR=. + ODIR=$OBJDIR
- printf "Creating target Makefile..." + printf "Creating target config.mak..." echo "ARCH=$ARCH" > $ODIR/config.mak if [ "$cross" = "yes" ]; then echo "TARGET=$TARGET" >> $ODIR/config.mak @@ -338,7 +334,10 @@ echo "HOSTARCH?=$HOSTARCH" >> $ODIR/config.mak echo "CROSSCFLAGS=$CROSSCFLAGS" >> $ODIR/config.mak echo "VERSION="$VERSION"" >> $ODIR/config.mak + echo "SRCDIR=$SRCDIR" >> $ODIR/config.mak + echo "ok."
+ printf "Creating target rules.mak..." ln -s $SRCDIR/config/xml/rules.xml $ODIR/rules.xml echo "<?xml version=\"1.0\"?><config>" > $ODIR/config.xml # Generic @@ -381,8 +380,9 @@ fi cat $SRCDIR/config/examples/${ARCH}_config.xml >> $ODIR/config.xml
+ cd $ODIR echo "</config>" >> $ODIR/config.xml - ln -s ../Makefile.target $ODIR/Makefile + ln -s $SRCDIR/Makefile.target $ODIR/Makefile xsltproc $SRCDIR/config/xml/xinclude.xsl $SRCDIR/build.xml > $ODIR/build-full.xml xsltproc $SRCDIR/config/xml/makefile.xsl $ODIR/build-full.xml > $ODIR/rules.mak echo "ok." @@ -392,5 +392,12 @@ xsltproc $SRCDIR/config/xml/config-forth.xsl $ODIR/config.xml > $ODIR/forth/config.fs echo "ok."
- cd $SRCDIR + cd $BUILDDIR done + +if [ "$SRCDIR" != "$BUILDDIR" ]; then + ln -s $SRCDIR/Makefile $BUILDDIR +fi + +echo "ODIRS=$ODIRS" >> $BUILDDIR/config-host.mak +echo "TARGETS=$arch_list" >> $BUILDDIR/config-host.mak
Modified: trunk/openbios-devel/config/xml/dictionary.xsl ============================================================================== --- trunk/openbios-devel/config/xml/dictionary.xsl Sun Feb 3 17:50:11 2013 (r1098) +++ trunk/openbios-devel/config/xml/dictionary.xsl Sat Feb 16 13:08:33 2013 (r1099) @@ -56,7 +56,6 @@ <xsl:value-of select="$dictname"/>xsl:text-DICTIONARY:=$(</xsl:text> <xsl:value-of select="$dictname"/>xsl:text-DICTIONARY) </xsl:text>
- xsl:text$(SRCDIR)/</xsl:text> <xsl:value-of select="$path"/> <xsl:value-of select="@source"/> xsl:text </xsl:text> @@ -122,6 +121,8 @@ </xsl:if> </xsl:for-each>
+ <!-- needed to locate files with full path --> + xsl:text -I$(SRCDIR)</xsl:text> <!-- needed to include config and build date --> xsl:text -I$(ODIR)/forth</xsl:text>
Modified: trunk/openbios-devel/config/xml/object.xsl ============================================================================== --- trunk/openbios-devel/config/xml/object.xsl Sun Feb 3 17:50:11 2013 (r1098) +++ trunk/openbios-devel/config/xml/object.xsl Sat Feb 16 13:08:33 2013 (r1099) @@ -52,7 +52,6 @@ xsl:text.o: </xsl:text>
<!-- path of source file --> - xsl:text$(SRCDIR)/</xsl:text> <xsl:value-of select="$path"/> <xsl:value-of select="@source"/>