This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Solving the in-source build problem. Permanently.
- From: Phil Edwards <pedwards at disaster dot jaj dot com>
- To: gcc at gcc dot gnu dot org
- Cc: mark at codesourcery dot com
- Date: Thu, 3 Jan 2002 01:25:10 -0500
- Subject: Solving the in-source build problem. Permanently.
Mark once mentioned, offhand, that some time ago there was consensus that
an easy solution for trying to build in-source would be for configure to do
something like
mkdir foo
cd foo
../configure $*
and for make to do
cd foo
make whatever
Then all builds become separate-objdir builds, thus reducing the problem
to a well-known previously solved one.
(Yes, in-source builds work /now/, but they remain fragile, and they're
a PITA to maintain.)
Opinions on the following? It works for me, but it's only a rough cut.
Better comments and more possible makefile targets might be desirable.
Index: configure
===================================================================
RCS file: /home/pme/Repositories/GCC/gcc/configure,v
retrieving revision 1.40
diff -u -3 -p -r1.40 configure
--- configure 5 Dec 2001 12:40:39 -0000 1.40
+++ configure 3 Jan 2002 05:50:52 -0000
@@ -3,7 +3,7 @@
### WARNING: this file contains embedded tabs. Do not run untabify on this file.
# Configuration script
-# Copyright (C) 1988, 90, 91, 92, 93, 94, 95, 96, 97, 98, 1999, 2000, 2001
+# Copyright (C) 1988, 90, 91, 92, 93, 94, 95, 96, 97, 98, 1999, 2000, 2001, 2002
# Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
@@ -572,6 +572,15 @@ case "${srcdir}" in
srcdir=.
fi
esac
+
+# If it's an in-srcdir build, make a directory and configure there instead.
+if [ "${srcdir}" = "." ]; then
+ if [ ! -d builddir ]; then
+ mkdir builddir || exit 1
+ fi
+ cd builddir
+ exec ${config_shell} ../configure $arguments
+fi
### warn about some conflicting configurations.
Index: Makefile
===================================================================
RCS file: Makefile
diff -N Makefile
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Makefile 3 Jan 2002 06:07:42 -0000
@@ -0,0 +1,46 @@
+#
+# Redirecting Makefile.
+# Copyright (C) 2002 Free Software Foundation
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+
+# This Makefile is a red herring. It is not normally used and it is never
+# written by 'configure' from 'Makefile.in'. This Makefile is here to
+# support users who try to configure/build in the source directory. It
+# simply chdir's into a subdirectory created by configure and reinvokes
+# make. Few targets are listed because advanced users (who would use those
+# targets) are assumed to know that a separate build dir is recommended.
+
+SHELL = /bin/sh
+
+all:
+
+TARGETS = \
+ all \
+ bootstrap \
+ clean \
+ install
+
+
+.PHONY: $(TARGETS)
+$(TARGETS):
+ @if [ ! -d builddir ]; then \
+ echo 'You must configure before attempting to build.'; \
+ echo 'Please read the instructions in the INSTALL directory.'; \
+ exit 1; \
+ fi
+ (cd ./builddir; $(MAKE) $@)
+
Index: .cvsignore
===================================================================
RCS file: /home/pme/Repositories/GCC/gcc/.cvsignore,v
retrieving revision 1.5
diff -u -3 -p -r1.5 .cvsignore
--- .cvsignore 27 Jul 2001 06:00:45 -0000 1.5
+++ .cvsignore 3 Jan 2002 06:09:18 -0000
@@ -26,7 +26,6 @@ configure.tps
configure.vr
configure.vrs
dir.info
-Makefile
lost+found
update.out
LAST_UPDATED