From 3f09b90d211a86c1d002a786a5ffc34b72fba780 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Fri, 14 Dec 2012 17:18:03 +0100 Subject: build: fix VPATH builds * configure (fn_dirname): New. Use it to ensure the creation of proper symlinks to Makefiles. (config.mak): Define top_builddir and top_srcdir. (CPPFLAGS): Be sure to find the headers. * Makefile, lib/Makefile, tests/Makefile, tests2/Makefile: Adjust to set VPATH properly. Fix confusion between top_builddir and top_srcdir. --- configure | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) (limited to 'configure') diff --git a/configure b/configure index a400524..b4ac328 100755 --- a/configure +++ b/configure @@ -2,6 +2,14 @@ # # tcc configure script (c) 2003 Fabrice Bellard +fn_dirname() +{ + case $1 in + */*) echo "$1" | sed -e 's,/[^/]*,,';; + *) echo '.' + esac +} + # set temporary file name if test ! -z "$TMPDIR" ; then TMPDIR1="${TMPDIR}" @@ -411,10 +419,13 @@ echo "#define GCC_MAJOR $gcc_major" >> $TMPH echo "HOST_CC=$host_cc" >> config.mak echo "AR=$ar" >> config.mak echo "STRIP=$strip -s -R .comment -R .note" >> config.mak -echo "CFLAGS=$CFLAGS" >> config.mak -echo "LDFLAGS=$LDFLAGS" >> config.mak -echo "LIBSUF=$LIBSUF" >> config.mak -echo "EXESUF=$EXESUF" >> config.mak +cat >> config.mak <> config.mak @@ -491,16 +502,23 @@ echo "@set VERSION $version" > config.texi # build tree in object directory if source path is different from current one if test "$source_path_used" = "yes" ; then - DIRS="tests" - FILES="Makefile tests/Makefile" - for dir in $DIRS ; do - mkdir -p $dir - done + FILES="Makefile lib/Makefile tests/Makefile tests2/Makefile" for f in $FILES ; do - ln -sf $source_path/$f $f + dir=`fn_dirname "$f"` + test -d "$dir" || mkdir -p "$dir" + back=`echo "$source_path/$dir/" | sed 's,/\./,/,g;s,[^/]*/,../,g'` + back=$back$f + ln -sf $back $f done fi -echo "SRC_PATH=$source_path" >> config.mak +cat >>config.mak <>config.mak diff $TMPH config.h >/dev/null 2>&1 if test $? -ne 0 ; then -- cgit v1.3.1