[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: problems with autoreconf



On Fri, 2010-10-29 at 07:20:42 +0200, Guillem Jover wrote:
> On Wed, 2010-10-27 at 20:43:17 -0500, Michael Schmidt wrote:
> > then i tried running the configure script and it broke like this
> 
> > checking for bcopy... yes
> > checking for memcpy... yes
> > checking for setsid... yes
> > checking for getdtablesize... yes
> > checking for posix_fadvise... yes
> > ./configure: line 13869: syntax error near unexpected token `fi'
> > ./configure: line 13869: `fi'
> 
> Most probably that's due to some m4 missquoting.

It was due to an empty 'else fi'.

> > I tried investigating why this happens, but I can't find the reason.
> > I checked the configure script at that line, and from what I can
> > tell this problem is that the if statement never was opened, but
> > there is a closing else en fi.Maybe you guys can try and reproduce
> > this error, just so that I know that it definitely is a problem on
> > my system.

> What version of automake are you using? Can you post your configure
> script somewhere? Or send it to me privately if that's not possible
> (as it's quite huge).

He is using automake 1.10.1, and autoconf 2.61 from lenny, and he sent
me the failing configure off-list.

I tried to reproduce it with automake 1.10.3 but it works with that.
I'm guessing though it's a problem with autoconf. Current autoconf
fills the empty 'else fi' body with a colon (null command).

> Most of the time the if is there, it's just concatenated with some
> other text.

I queued the attached patch which should fix this bug (you'll need to
apply the dpkg-m4-quotes.patch first), please let me know if there's
something else. They will be in my next push, today or tomorrow.

Sorry for now having come back to you earlier.

thanks,
guillem
commit 28bd5ea3ff451181657e32211300a57398e14c23
Author: Guillem Jover <guillem@debian.org>
Date:   Sat Oct 30 09:00:24 2010 +0200

    build: Add missing m4 quotes to sed regex
    
    This was making the regex non-functional, as the square brackets
    were being removed when generating the output file, thus making the
    --disable-compiler-optimisations and --disable-linker-optimisations
    non-functional.

diff --git a/m4/dpkg-compiler.m4 b/m4/dpkg-compiler.m4
index 5a0f791..e885af4 100644
--- a/m4/dpkg-compiler.m4
+++ b/m4/dpkg-compiler.m4
@@ -36,7 +36,7 @@ AC_DEFUN([DPKG_COMPILER_OPTIMISATIONS],
 	AS_HELP_STRING([--disable-compiler-optimisations],
 		       [Disable compiler optimisations]),
 [if test "x$enable_compiler_optimisations" = "xno"; then
-	[CFLAGS=$(echo "$CFLAGS" | sed -e "s/ -O[1-9]*\b/ -O0/g")]
+	[CFLAGS=$(echo "$CFLAGS" | sed -e "s/ -O[[1-9]]*\b/ -O0/g")]
 fi])dnl
 ])
 
diff --git a/m4/dpkg-linker.m4 b/m4/dpkg-linker.m4
index 9bd98f0..bff4d22 100644
--- a/m4/dpkg-linker.m4
+++ b/m4/dpkg-linker.m4
@@ -8,7 +8,7 @@ AC_DEFUN([DPKG_LINKER_OPTIMISATIONS],
 	AS_HELP_STRING([--disable-linker-optimisations],
 		       [Disable linker optimisations]),
 [if test "x$enable_linker_optimisations" = "xno"; then
-	[LDFLAGS=$(echo "$LDFLAGS" | sed -e "s/ -Wl,-O[0-9]*\b//g")]
+	[LDFLAGS=$(echo "$LDFLAGS" | sed -e "s/ -Wl,-O[[0-9]]*\b//g")]
 else
 	[LDFLAGS="$LDFLAGS -Wl,-O1"]
 fi], [LDFLAGS="$LDFLAGS -Wl,-O1"])dnl
commit 2f6287298b00a194539d93452d8c192de0d8d30c
Author: Guillem Jover <guillem@debian.org>
Date:   Sun Oct 31 03:27:29 2010 +0100

    build: Unify and fix AC_ARG_ENABLE usage
    
    The current code was executing code in the action arguments, instead
    of just setting boolean flags and processing them afterwards. This
    poses several problems, it implies jugling code around in case the the
    default changes, it might also duplicate code, and it might leave the
    ACTION-IF-NOT-GIVEN argument empty which could turn into an empty
    “then fi” shell block which is a syntax error on POSIX shell. Leaving
    the ACTION-IF-GIVEN argument empty is fine as it's always used by
    autoconf to set $enableval to the specific enable variable, and setting
    that variable from $enableval is redundant and might be wrong depending
    on the order they are set, which could empty it.
    
    Reported-by: Michael Schmidt <michael.schmidt.dangel@gmail.com>
    Signed-off-by: Guillem Jover <guillem@debian.org>

diff --git a/m4/dpkg-compiler.m4 b/m4/dpkg-compiler.m4
index e885af4..3a38601 100644
--- a/m4/dpkg-compiler.m4
+++ b/m4/dpkg-compiler.m4
@@ -8,7 +8,7 @@ AC_DEFUN([DPKG_COMPILER_WARNINGS],
 [AC_ARG_ENABLE(compiler-warnings,
 	AS_HELP_STRING([--disable-compiler-warnings],
 	               [Disable additional compiler warnings]),
-	[enable_compiler_warnings=$enableval],
+	[],
 	[enable_compiler_warnings=yes])
 
 WFLAGS="-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers \
@@ -35,9 +35,12 @@ AC_DEFUN([DPKG_COMPILER_OPTIMISATIONS],
 [AC_ARG_ENABLE(compiler-optimisations,
 	AS_HELP_STRING([--disable-compiler-optimisations],
 		       [Disable compiler optimisations]),
-[if test "x$enable_compiler_optimisations" = "xno"; then
-	[CFLAGS=$(echo "$CFLAGS" | sed -e "s/ -O[[1-9]]*\b/ -O0/g")]
-fi])dnl
+	[],
+	[enable_compiler_optimisations=yes])
+
+  AS_IF([test "x$enable_compiler_optimisations" = "xno"], [
+    CFLAGS=$(echo "$CFLAGS" | sed -e "s/ -O[[1-9]]*\b/ -O0/g")
+  ])
 ])
 
 # DPKG_TRY_C99([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
diff --git a/m4/dpkg-funcs.m4 b/m4/dpkg-funcs.m4
index d374986..45c0e3c 100644
--- a/m4/dpkg-funcs.m4
+++ b/m4/dpkg-funcs.m4
@@ -76,12 +76,13 @@ AC_DEFUN([DPKG_MMAP],
   AC_ARG_ENABLE([mmap],
     AS_HELP_STRING([--enable-mmap],
                    [enable usage of unrealiable mmap if available]),
-    [
-      AC_CHECK_FUNCS([mmap])
-      AC_DEFINE(USE_MMAP, 1, [Use unreliable mmap support])
-    ],
-    []
-  )
+    [],
+    [enable_mmap=no])
+
+  AS_IF([test "x$enable_mmap" = "xyes"], [
+    AC_CHECK_FUNCS([mmap])
+    AC_DEFINE(USE_MMAP, 1, [Use unreliable mmap support])
+  ])
 ])
 
 # DPKG_FUNC_ASYNC_SYNC
diff --git a/m4/dpkg-linker.m4 b/m4/dpkg-linker.m4
index bff4d22..2fdaae5 100644
--- a/m4/dpkg-linker.m4
+++ b/m4/dpkg-linker.m4
@@ -7,9 +7,12 @@ AC_DEFUN([DPKG_LINKER_OPTIMISATIONS],
 [AC_ARG_ENABLE(linker-optimisations,
 	AS_HELP_STRING([--disable-linker-optimisations],
 		       [Disable linker optimisations]),
-[if test "x$enable_linker_optimisations" = "xno"; then
-	[LDFLAGS=$(echo "$LDFLAGS" | sed -e "s/ -Wl,-O[[0-9]]*\b//g")]
-else
-	[LDFLAGS="$LDFLAGS -Wl,-O1"]
-fi], [LDFLAGS="$LDFLAGS -Wl,-O1"])dnl
+    [],
+    [enable_linker_optimisations=yes])
+
+  AS_IF([test "x$enable_linker_optimisations" = "xno"], [
+    LDFLAGS=$(echo "$LDFLAGS" | sed -e "s/ -Wl,-O[[0-9]]*\b//g")
+  ], [
+    LDFLAGS="$LDFLAGS -Wl,-O1"
+  ])
 ])

Reply to: