automake-patches
[Top][All Lists]
Advanced

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

Patch: FYI: PR 220 change


From: Tom Tromey
Subject: Patch: FYI: PR 220 change
Date: 30 Dec 2001 13:17:59 -0700

This changes AM_CONDITIONAL so that it gives an error at configure
time if it was only run conditionally.

It would be better if we could generate this error at autoconf-time,
but I don't think that is possible.

I like this patch since this problem is hard to debug unless you've
already encountered it before.  With this change it becomes much
easier to figure out what is wrong.

Tom

Index: ChangeLog
from  Tom Tromey  <address@hidden>
        For PR automake/220:
        * tests/Makefile.am (TESTS): Added pr220.test.
        * tests/pr220.test: New file.
        * m4/cond.m4 (AM_CONDITIONAL): Cause config.status to fail if
        conditional was never run.

Index: m4/cond.m4
===================================================================
RCS file: /cvs/automake/automake/m4/cond.m4,v
retrieving revision 1.7
diff -u -r1.7 cond.m4
--- m4/cond.m4 2001/10/08 11:53:44 1.7
+++ m4/cond.m4 2001/12/30 20:05:39
@@ -35,4 +35,9 @@
 else
   $1_TRUE='#'
   $1_FALSE=
-fi])
+fi
+AC_CONFIG_COMMANDS_PRE(
+[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
+  AC_MSG_ERROR([conditional \"$1\" was never defined.
+Usually this means the macro was only invoked conditionally.])
+fi])])
Index: tests/Makefile.am
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.am,v
retrieving revision 1.359
diff -u -r1.359 Makefile.am
--- tests/Makefile.am 2001/12/30 00:19:42 1.359
+++ tests/Makefile.am 2001/12/30 20:05:40
@@ -239,6 +239,7 @@
 pluseq8.test \
 ppf77.test \
 pr2.test \
+pr220.test \
 pr266.test \
 pr279.test \
 pr279-2.test \
Index: tests/Makefile.in
===================================================================
RCS file: /cvs/automake/automake/tests/Makefile.in,v
retrieving revision 1.466
diff -u -r1.466 Makefile.in
--- tests/Makefile.in 2001/12/30 00:19:42 1.466
+++ tests/Makefile.in 2001/12/30 20:05:40
@@ -312,6 +312,7 @@
 pluseq8.test \
 ppf77.test \
 pr2.test \
+pr220.test \
 pr266.test \
 pr279.test \
 pr279-2.test \
Index: tests/pr220.test
===================================================================
RCS file: pr220.test
diff -N pr220.test
--- /dev/null   Tue May  5 13:32:27 1998
+++ tests/pr220.test Sun Dec 30 12:05:40 2001
@@ -0,0 +1,49 @@
+#! /bin/sh
+
+# Test for PR automake/220.
+ 
+. $srcdir/defs || exit 1
+
+cat >main.c <<EOF
+int main() { return 0; }
+EOF
+
+cat > Makefile.am << 'EOF'
+if NEVER_TRUE
+NEVER_DEFINED = missingfile.c
+endif
+
+bin_PROGRAMS = main
+main_SOURCES = main.c $(NEVER_DEFINED)
+EOF
+
+cat > configure.in << 'EOF'
+AC_INIT(main.c)
+AM_INIT_AUTOMAKE(test_am, 1.0)
+AC_PROG_CC
+AC_ARG_ENABLE(foo,
+[  --enanble-foo          Enable foo],
+[ if test "foo" = "bar" ; then
+    AM_CONDITIONAL(NEVER_TRUE, true)
+  else
+    AM_CONDITIONAL(NEVER_TRUE, false)
+  fi
+])
+AC_OUTPUT(Makefile)
+EOF
+
+# Fail gracefully if no gcc.
+(gcc -v) > /dev/null 2>&1 || exit 77
+
+touch README NEWS AUTHORS ChangeLog
+
+mkdir build
+
+$ACLOCAL \
+   && $AUTOCONF \
+   && $AUTOMAKE -a || exit 1
+
+cd build
+# configure should fail since we've done something invalid.
+CC='gcc' ../configure && exit 1
+exit 0



reply via email to

[Prev in Thread] Current Thread [Next in Thread]