From d1c166762aa8122c1134c5cbbd68083adc67e103 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Mon, 27 Feb 2023 02:27:03 +0200 Subject: [PATCH 19/19] Autotools: Disallow configuring source directory See osdn #45882 Signed-off-by: Marko Lindqvist --- INSTALL | 33 +++++++++++++++++---------------- autogen.sh | 4 ++-- configure.ac | 4 ++++ doc/INSTALL.Cygwin | 8 ++++---- doc/README.packaging | 2 ++ 5 files changed, 29 insertions(+), 22 deletions(-) diff --git a/INSTALL b/INSTALL index 498729e97e..67758cbc75 100644 --- a/INSTALL +++ b/INSTALL @@ -340,7 +340,7 @@ following order: pkg-config, Glib, Atk, Pango, Gdk-Pixbuf, Gtk. If configure does not find (correct) moc, you can give it with environment variable MOCCMD, e.g., - ./configure MOCCMD="/home/freeciv/local-qt/bin/moc" --enable-client=qt + ../src/configure MOCCMD="/home/freeciv/local-qt/bin/moc" --enable-client=qt - Qt6Core, Qt6Gui, and Qt6Widgets libraries and headers. At least version 6.0 is required. @@ -375,10 +375,11 @@ is configured to suit the features available on your machine. This configuration is done using the GNU "configure" script. -To use "configure", "cd" into the top directory containing the Freeciv -files, and type: +To use "configure", "cd" to directory where you want the build +to end, and run it from the top directory containing +the Freeciv files: - % ./configure + % ../src/configure This script will then attempt to determine the relevant features (and misfeatures!!) of your system. It should print a page or two of @@ -387,7 +388,7 @@ diagnostics about your machine, then stop gracefully. If you'd like help on the various options supported by the configure script, try the --help option, like this: - % ./configure --help + % ../src/configure --help By default the configure script will choose the Gtk+ client if the required libraries are found. If you prefer to override this default, @@ -396,12 +397,12 @@ you can give configure the "--enable-client=sdl2" option. If you want to change the compiler options, set the CFLAGS environment variable in your shell before running "configure". For example: - % CFLAGS="-O -g -pipe" ./configure [for people using Bourne shell or bash] + % CFLAGS="-O -g -pipe" ../src//configure [for people using Bourne shell or bash] or % setenv CFLAGS "-O -g -pipe" - % ./configure [for people using C shell or tcsh] + % ../src/configure [for people using C shell or tcsh] If you're tracking down a "core dump", we suggest that you use a value of "-g" for CFLAGS. @@ -410,7 +411,7 @@ When you install Freeciv (later), the game components will be copied into subdirectories of /usr/local by default. If you would like to use some other installation prefix besides /usr/local, you should specify it now: - % ./configure --prefix=/opt/freeciv + % ../src/configure --prefix=/opt/freeciv If for some reason using "configure" gives you trouble, follow these steps: @@ -501,9 +502,9 @@ If you experience problems with gettext in either configuring or compiling Freeciv, there are a few work-arounds you can try: 1. If you don't need Native Language Support, disable it using the - "--disable-nls" ./configure option: + "--disable-nls" configure option: - % ./configure --disable-nls + % ../src/configure --disable-nls % make 2. You can try to install the latest version of GNU gettext. @@ -535,7 +536,7 @@ without readline support. You can force configure to include readline or die trying by giving configure the --with-readline option: - % ./configure --with-readline + % ../src/configure --with-readline Some linux distributions (and possibly other operating systems) have readline version 4 incorrectly installed, so that readline is not @@ -552,16 +553,16 @@ Solaris (2.5 and up) has its own version of X in /usr/openwin, its own version of make in /usr/ccs/bin/make, and its own compiler (to be purchased separately) which, if you have it, is available in /opt/SUNWspro/bin. Solaris does not provide any of the stuff required for imlib, gdk and gtk, -either, which is required to build the GTK+ client. However, with some +either, which is required to build the GTK+ client. However, with some patience, everything can be compiled without problems. Make sure your environment variables, especially $PATH and $LD_LIBRARY_PATH, -and the ./configure options do not point to an inconsistent set of software, +and the configure options do not point to an inconsistent set of software, and compiling will be fine. -You can set up your $PATH and ./configure to use only GNU -tools. Furthermore, Freeciv is known to compile with MIT X, and with -certain combinations of GNU and Sun tools. The exact recipes depend on your +You can set up your $PATH and configure to use only GNU +tools. Furthermore, Freeciv is known to compile with MIT X, and with +certain combinations of GNU and Sun tools. The exact recipes depend on your local installation. diff --git a/autogen.sh b/autogen.sh index 5d3c5b484f..3611ac2416 100755 --- a/autogen.sh +++ b/autogen.sh @@ -322,7 +322,7 @@ fi echo "+ running configure ... " echo if [ -z "$FC_NEWARGLINE" ]; then - echo "I am going to run ./configure with no arguments - if you wish " + echo "I am going to run $SRCDIR/configure with no arguments - if you wish " echo "to pass any to it, please specify them on the $0 command line." else echo "using: $FC_NEWARGLINE" @@ -335,7 +335,7 @@ echo exit 1 } -# abort if we did --help +# Abort if we did --help if [ "$FC_HELP" = "yes" ]; then exit 1 fi diff --git a/configure.ac b/configure.ac index e722afa125..1f05fe0241 100644 --- a/configure.ac +++ b/configure.ac @@ -6,6 +6,10 @@ AC_INIT([Freeciv], m4_esyscmd([./fc_version | tr -d '\n']), [freeciv], [https://www.freeciv.org/]) AC_PREREQ(2.65) +if test "x$(pwd)" = "x$(cd $srcdir && pwd)" ; then + AC_MSG_ERROR([Attempted to configure source directory. You have to use separate build dir]) +fi + dnl Initialize with some random file to ensure the source is here. AC_CONFIG_SRCDIR([common/game.c]) AC_CONFIG_AUX_DIR(bootstrap) # This can't be quoted or automake will fail diff --git a/doc/INSTALL.Cygwin b/doc/INSTALL.Cygwin index f0af7d787d..226001be38 100644 --- a/doc/INSTALL.Cygwin +++ b/doc/INSTALL.Cygwin @@ -67,15 +67,15 @@ b) Get a Freeciv source tree (the doc/ directory this INSTALL.Cygwin is in, is a subdirectory of the source tree's root directory). Put it in a temporary place like /tmp. - ./configure --enable-client= [any other options e.g. --prefix=...] + ../src/configure --enable-client= [any other options e.g. --prefix=...] where is "gtk3.22", "qt", or list like "gtk3.22,qt". If you didn't install gettext-devel, you have to give also configure option --disable-nls to disable Native Language Support. If you are building directly from version control, and not from - tarball that has some files, including ./configure, pregenerated, - you need to run ./autogen.sh instead of ./configure. Use same options - as you would for directly running ./configure. + tarball that has some files, including configure, pregenerated, + you need to run ../src/autogen.sh instead of ../src/configure. + Use same options as you would for directly running configure. If you get messages of missing or outdated components, install them. diff --git a/doc/README.packaging b/doc/README.packaging index 44a462e258..fc61e8b9d2 100644 --- a/doc/README.packaging +++ b/doc/README.packaging @@ -18,6 +18,8 @@ Updating from 3.2 to 3.3 ~/.freeciv-client-rc-3.1 generated by Freeciv 3.1, or ~/.civclientrc generated by Freeciv version <= 2.1). * Minimum version of Qt is Qt-5.15, when building in Qt5-mode +* Configuring source directory is no longer allowed in autotools builds. + You have to use separate build dir(s) ---------------------------------------------------------------------- Compatibility of modified versions -- 2.39.2