From 3e4a9d60a9419621b08c647a306843d76c47c2cb Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 9 Mar 2011 15:02:42 -0800 Subject: build: Add support for non-source-directory builds. Such as: mkdir build cd build ../configure make This is implemented by having the configure script set a srcdir variable in Makefile.config, and then sprinkling $(srcdir) into various make rules. We also use vpath directives to convince GNU make to find the source files from the original source directory. --- configure | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) (limited to 'configure') diff --git a/configure b/configure index 3d1efb0b..157ecf39 100755 --- a/configure +++ b/configure @@ -1,5 +1,26 @@ #! /bin/sh +srcdir=$(dirname "$0") + +# For a non-srcdir configure invocation (such as ../configure), create +# the directory structure and copy Makefiles. +if [ "$srcdir" != "." ]; then + + for dir in . $(grep "^subdirs *=" "$srcdir"/Makefile | sed -e "s/subdirs *= *//"); do + mkdir -p "$dir" + cp "$srcdir"/"$dir"/Makefile.local "$dir" + cp "$srcdir"/"$dir"/Makefile "$dir" + done + + # Easiest way to get the test suite to work is to just copy the + # whole thing into the build directory. + cp -a "$srcdir"/test/* test + + # Emacs only likes to generate compiled files next to the .el files + # by default so copy these as well (which is not ideal0. + cp -a "$srcdir"/emacs/*.el emacs +fi + # Set several defaults (optionally specified by the user in # environemnt variables) CC=${CC:-gcc} @@ -424,7 +445,7 @@ EOF fi printf "Checking for getline... " -if ${CC} -o compat/have_getline compat/have_getline.c > /dev/null 2>&1 +if ${CC} -o compat/have_getline "$srcdir"/compat/have_getline.c > /dev/null 2>&1 then printf "Yes.\n" have_getline=1 @@ -435,7 +456,7 @@ fi rm -f compat/have_getline printf "Checking for strcasestr... " -if ${CC} -o compat/have_strcasestr compat/have_strcasestr.c > /dev/null 2>&1 +if ${CC} -o compat/have_strcasestr "$srcdir"/compat/have_strcasestr.c > /dev/null 2>&1 then printf "Yes.\n" have_strcasestr=1 @@ -508,6 +529,24 @@ cat > Makefile.config <