repo: ngircd
action: commit
revision: 
path_from: 
revision_from: 192e304b94f239de13b0f10ca01f6694fe6eea40:
path_to: 
revision_to: 
git.thebackupbox.net
ngircd
git clone git://git.thebackupbox.net/ngircd
commit 192e304b94f239de13b0f10ca01f6694fe6eea40
Author: Alexander Barton 
Date:   Sun Sep 23 17:55:48 2012 +0200

    Change build system to support new and old GNU automake

    Starting with GNU automake 1.12, the "de-ANSI-fication support" has been
    removed, which ngIRCd used to enable building itself on very old systems.

    Now the problem is, that using automake >= 1.12 isn't working because of
    the now unsupported M4 macros. Therefore the solution that this patch
    implements is to dynamically generate the automake input files with our
    own ./autogen.sh script:

      configure.ng => configure.in
      Makefile.ng => Makefile.am

    This is quite an ugly approach, but it works and enables us to:

      1. use current automake >= 1.12 for development and "private builds",
      2. still build distribution archives using automake 1.11.x that have
         "de-ANSI-fication support" enabled in the generated Makefile's.

    And if you are using Makefile's generated with a automake version newer
    than 1.11.x (without "de-ANSI-fication support"), the ./configure script
    warns you not to use this generated build system to generate distribution
    archives.

    Drawback of this patch: you MUST use our autogen.sh script, you can't call
    the autoconf/automake commands directly any more; but autoreconf should
    still work ...

diff --git a/.gitignore b/.gitignore
index 19900414b6c60c2f68888aba8dfe734a26aefc01..
index ..bfa35421089ad977c92f055da2def29d86ae8d62 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,6 +9,7 @@ build-stamp-ngircd*
 config.log
 config.status
 configure
+configure.in
 configure.lineno
 cscope.out
 debian
diff --git a/autogen.sh b/autogen.sh
index cca200b2a452d02478224566f135fdf0b8ca4eed..
index ..d47d7504b68268ab3de7bf49b73a8b716307b8b5 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -16,6 +16,11 @@
 # GNU autoconf. It tries to be smart in finding the correct/usable/available
 # installed versions of these tools on your system.
 #
+# In addition, it enables or disables the "de-ANSI-fication" support of GNU
+# automake, which is supported up to autoconf 1.11.x an has been removed
+# in automake 1.12 -- make sure to use a version of automake supporting it
+# when generating distribution archives!
+#
 # The following strategy is used for each of aclocal, autoheader, automake,
 # and autoconf: first, "tool" (the regular name of the tool, e. g. "autoconf"
 # or "automake") is checked. If this fails, "tool" (for example
@@ -129,7 +134,7 @@ fi

 # Try to detect the needed tools when no environment variable already
 # specifies one:
-echo "Searching tools ..."
+echo "Searching for required tools ..."
 [ -z "$ACLOCAL" ] && ACLOCAL=`Search aclocal 1`
 [ "$VERBOSE" = "1" ] && echo " - ACLOCAL=$ACLOCAL"
 [ -z "$AUTOHEADER" ] && AUTOHEADER=`Search autoheader 2`
@@ -139,9 +144,8 @@ echo "Searching tools ..."
 [ -z "$AUTOCONF" ] && AUTOCONF=`Search autoconf 2`
 [ "$VERBOSE" = "1" ] && echo " - AUTOCONF=$AUTOCONF"

-# Call ./configure when parameters have been passed to this script and
-# GO isn't already defined.
-[ -z "$GO" -a $# -gt 0 ] && GO=1
+[ $# -gt 0 ] && CONFIGURE_ARGS=" $@" || CONFIGURE_ARGS=""
+[ -z "$GO" -a -n "$CONFIGURE_ARGS" ] && GO=1

 # Verify that all tools have been found
 [ -z "$ACLOCAL" ] && Notfound aclocal
@@ -149,10 +153,37 @@ echo "Searching tools ..."
 [ -z "$AUTOMAKE" ] && Notfound automake
 [ -z "$AUTOCONF" ] && Notfound autoconf

+AM_VERSION=`$AUTOMAKE --version | egrep -o "([0-9]+\.[0-9]+\.[0-9]+)"`
+ifs=$IFS; IFS="."; set $AM_VERSION; IFS=$ifs
+AM_MAJOR="$1"; AM_MINOR="$2"; AM_PATCHLEVEL="$3"
+
+AM_MAKEFILES="src/ipaddr/Makefile.ng src/ngircd/Makefile.ng src/testsuite/Makefile.ng src/tool/Makefile.ng"
+
+if [ "$AM_MAJOR" -eq "1" -a "$AM_MINOR" -lt "12" ]; then
+	# automake < 1.12 => automatic de-ANSI-fication support available
+	echo "Enabling de-ANSI-fication support (automake $AM_VERSION) ..."
+	sed -e "s|^__ng_PROTOTYPES__|AM_C_PROTOTYPES|g" configure.ng >configure.in
+	DEANSI_START=""
+	DEANSI_END=""
+else
+	# automake >= 1.12 => no de-ANSI-fication support available
+	echo "Disabling de-ANSI-fication support (automake $AM_VERSION) ..."
+	sed -e "s|^__ng_PROTOTYPES__|AC_C_PROTOTYPES|g" configure.ng >configure.in
+	DEANSI_START="#"
+	DEANSI_END="	# disabled by ./autogen.sh script"
+fi
+sed -e "s|^__ng_Makefile_am_template__|${DEANSI_START}AUTOMAKE_OPTIONS = ansi2knr${DEANSI_END}|g" \
+	src/portab/Makefile.ng >src/portab/Makefile.am
+for makefile_ng in $AM_MAKEFILES; do
+	makefile_am=`echo "$makefile_ng" | sed -e "s|\.ng\$|\.am|g"`
+	sed -e "s|^__ng_Makefile_am_template__|${DEANSI_START}AUTOMAKE_OPTIONS = ../portab/ansi2knr${DEANSI_END}|g" \
+		$makefile_ng >$makefile_am
+done
+
 export ACLOCAL AUTOHEADER AUTOMAKE AUTOCONF

 # Generate files
-echo "Generating files ..."
+echo "Generating files using GNU $AUTOCONF and $AUTOMAKE ..."
 Run $ACLOCAL && \
 	Run $AUTOCONF && \
 	Run $AUTOHEADER && \
@@ -164,8 +195,7 @@ if [ $? -eq 0 -a -x ./configure ]; then
 	NAME=`grep PACKAGE_STRING= configure | cut -d"'" -f2`
 	if [ "$GO" = "1" ]; then
 		[ -n "$PREFIX" ] && p=" --prefix=$PREFIX" || p=""
-		[ -n "$*" ] && a=" $*" || a=""
-		c="./configure${p}${a}"
+		c="./configure${p}${CONFIGURE_ARGS}"
 		echo "Okay, autogen.sh for $NAME done."
 		echo "Calling \"$c\" ..."
 		$c
diff --git a/configure.in b/configure.ng
similarity index 97%
rename from configure.in
rename to configure.ng
index 949a383a5089104c0f283fffa9cb050dd1746b8a..
index ..25654f9cfbdfc78d2ef74de059a64cfeeb8e355f 100644
--- a/configure.in
+++ b/configure.ng
@@ -61,7 +61,7 @@ AC_PROG_RANLIB

 AC_C_CONST
 AC_C_INLINE
-AM_C_PROTOTYPES
+__ng_PROTOTYPES__

 # -- Hard coded system and compiler dependencies/features/options ... --

@@ -674,4 +674,12 @@ echo "$x_ssl_lib"

 echo

+if ! grep "^AUTOMAKE_OPTIONS = ../portab/ansi2knr" src/ngircd/Makefile.am >/dev/null 2>&1; then
+	echo "WARNING:"
+	echo "This GNU automake generated build system does not support \"de-ANSI-fication\","
+	echo "therefore don't use it to generate \"official\" distribution archives!"
+	echo "(Most probably you want to use GNU automake 1.11.x for this purpose ...)"
+	echo
+fi
+
 # -eof-
diff --git a/src/ipaddr/.gitignore b/src/ipaddr/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..08a6d725b51930d1162342705fb6b5444f68a980
--- /dev/null
+++ b/src/ipaddr/.gitignore
@@ -0,0 +1 @@
+Makefile.am
diff --git a/src/ipaddr/Makefile.am b/src/ipaddr/Makefile.ng
similarity index 88%
rename from src/ipaddr/Makefile.am
rename to src/ipaddr/Makefile.ng
index 6ce299f2c9afc0b65edfcafd4b27cfc807b317ed..
index ..3d5a5db9ca19a9d531c4e314bfd4ef21cc4846ce 100644
--- a/src/ipaddr/Makefile.am
+++ b/src/ipaddr/Makefile.ng
@@ -3,7 +3,7 @@
 # (c) 2008 Florian Westphal , public domain.
 #

-AUTOMAKE_OPTIONS = ../portab/ansi2knr
+__ng_Makefile_am_template__

 INCLUDES = -I$(srcdir)/../portab

diff --git a/src/ngircd/.gitignore b/src/ngircd/.gitignore
index c25ba5e3426f430c39c09bf4ca00cafb9294ade6..
index ..d1148bfb7adb9d19931b22b39fbcd81584ee7859 100644
--- a/src/ngircd/.gitignore
+++ b/src/ngircd/.gitignore
@@ -1,3 +1,4 @@
+Makefile.am
 check-help
 check-version
 ngircd
diff --git a/src/ngircd/Makefile.am b/src/ngircd/Makefile.ng
similarity index 98%
rename from src/ngircd/Makefile.am
rename to src/ngircd/Makefile.ng
index 3a411a964b266a2ab9874342ee618018c953ba86..
index ..db3ecfe9ec7072ed1a6d9c44075893a16f9a2b3e 100644
--- a/src/ngircd/Makefile.am
+++ b/src/ngircd/Makefile.ng
@@ -9,7 +9,7 @@
 # Please read the file COPYING, README and AUTHORS for more information.
 #

-AUTOMAKE_OPTIONS = ../portab/ansi2knr
+__ng_Makefile_am_template__

 INCLUDES = -I$(srcdir)/../portab -I$(srcdir)/../tool -I$(srcdir)/../ipaddr

diff --git a/src/portab/.gitignore b/src/portab/.gitignore
index 839a69fd918df3588412d3fb4bd767b566305603..
index ..9bac6ac1ad6c587487b2bd74aeff82e166af178f 100644
--- a/src/portab/.gitignore
+++ b/src/portab/.gitignore
@@ -1 +1,2 @@
+Makefile.am
 portabtest
diff --git a/src/portab/Makefile.am b/src/portab/Makefile.ng
similarity index 97%
rename from src/portab/Makefile.am
rename to src/portab/Makefile.ng
index a57ea4959803aa160013f5f9c56020d8f0eab8a8..
index ..5681a5304293a27473fb32b61950a7abcf0c4eea 100644
--- a/src/portab/Makefile.am
+++ b/src/portab/Makefile.ng
@@ -10,7 +10,7 @@
 # der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
 #

-AUTOMAKE_OPTIONS = ansi2knr
+__ng_Makefile_am_template__

 noinst_LIBRARIES = libngportab.a

diff --git a/src/testsuite/.gitignore b/src/testsuite/.gitignore
index 5884a486590f98b275cb7b52a1187349b377035e..
index ..b33a08f4be74918b6160bf726acfa496d820561d 100644
--- a/src/testsuite/.gitignore
+++ b/src/testsuite/.gitignore
@@ -1,3 +1,4 @@
+Makefile.am
 T-ngircd1
 T-ngircd2
 channel-test
diff --git a/src/testsuite/Makefile.am b/src/testsuite/Makefile.ng
similarity index 98%
rename from src/testsuite/Makefile.am
rename to src/testsuite/Makefile.ng
index 9dc76a7d90f47e5a8b8c79b7d22d8fbdd52b6ca2..
index ..fe642e8954a3d35d52c880f467310b9beacd38ef 100644
--- a/src/testsuite/Makefile.am
+++ b/src/testsuite/Makefile.ng
@@ -10,7 +10,7 @@
 # der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
 #

-AUTOMAKE_OPTIONS = ../portab/ansi2knr
+__ng_Makefile_am_template__

 INCLUDES = -I$(srcdir)/../portab

diff --git a/src/tool/.gitignore b/src/tool/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..08a6d725b51930d1162342705fb6b5444f68a980
--- /dev/null
+++ b/src/tool/.gitignore
@@ -0,0 +1 @@
+Makefile.am
diff --git a/src/tool/Makefile.am b/src/tool/Makefile.ng
similarity index 94%
rename from src/tool/Makefile.am
rename to src/tool/Makefile.ng
index 8d6cda46656b5d67a6bc8244e6fadd8544b876e9..
index ..807f24bc852162bfe7a51eed8251cf69f9134775 100644
--- a/src/tool/Makefile.am
+++ b/src/tool/Makefile.ng
@@ -9,7 +9,7 @@
 # Please read the file COPYING, README and AUTHORS for more information.
 #

-AUTOMAKE_OPTIONS = ../portab/ansi2knr
+__ng_Makefile_am_template__

 INCLUDES = -I$(srcdir)/../portab

-----END OF PAGE-----