]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Coverage and doc fixes for AC_LANG_SOURCE and AC_LANG_PROGRAM.
authorRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Tue, 8 Jun 2010 04:56:43 +0000 (06:56 +0200)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Tue, 8 Jun 2010 04:56:43 +0000 (06:56 +0200)
* tests/compile.at (AC_LANG_SOURCE, AC_LANG_SOURCE(C++))
(AC_LANG_SOURCE example, AC_LANG_PROGRAM example): New tests.
* doc/autoconf.texi (Generating Sources): Add markers for tested
examples; update quoting, and update AC_INIT usage to also set
optional URL arguments.  Mention that the examples require gcc.
Prompted by report from Brian J. Murrell.

Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
ChangeLog
doc/autoconf.texi
tests/compile.at

index dcb54a1c1afb6f878823e5e280c6605405f001ff..5150f4ff8129295011ed36844a339a012f234618 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2010-06-08  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
+       Coverage and doc fixes for AC_LANG_SOURCE and AC_LANG_PROGRAM.
+       * tests/compile.at (AC_LANG_SOURCE, AC_LANG_SOURCE(C++))
+       (AC_LANG_SOURCE example, AC_LANG_PROGRAM example): New tests.
+       * doc/autoconf.texi (Generating Sources): Add markers for tested
+       examples; update quoting, and update AC_INIT usage to also set
+       optional URL arguments.  Mention that the examples require gcc.
+       Prompted by report from Brian J. Murrell.
+
        Make AS_SET_CATFILE polymorphic, and add testsuite coverage.
        * lib/m4sugar/m4sh.m4 (AS_SET_CATFILE): Use AS_VAR_SET to set
        the variable.
index e99103dafcd67c5104545fe107965804bda2ec76..6be99aa20671d675d8708583ba5714e543c8a519 100644 (file)
@@ -8675,19 +8675,22 @@ all the @code{AC_DEFINE} performed so far.
 For instance executing (observe the double quotation!):
 
 @example
-AC_INIT([Hello], [1.0], [bug-hello@@example.org])
+@c If you change this example, adjust tests/compile.at:AC_LANG_SOURCE example.
+AC_INIT([Hello], [1.0], [bug-hello@@example.org], [],
+        [http://www.example.org/])
 AC_DEFINE([HELLO_WORLD], ["Hello, World\n"],
   [Greetings string.])
-AC_LANG(C)
+AC_LANG([C])
 AC_LANG_CONFTEST(
    [AC_LANG_SOURCE([[const char hw[] = "Hello, World\n";]])])
 gcc -E -dD -o - conftest.c
 @end example
 
 @noindent
-results in:
+on a system with @command{gcc} installed, results in:
 
 @example
+@c If you change this example, adjust tests/compile.at:AC_LANG_SOURCE example.
 @dots{}
 # 1 "conftest.c"
 
@@ -8696,6 +8699,7 @@ results in:
 #define PACKAGE_VERSION "1.0"
 #define PACKAGE_STRING "Hello 1.0"
 #define PACKAGE_BUGREPORT "bug-hello@@example.org"
+#define PACKAGE_URL "http://www.example.org/"
 #define HELLO_WORLD "Hello, World\n"
 
 const char hw[] = "Hello, World\n";
@@ -8716,7 +8720,9 @@ available.
 For instance:
 
 @example
-AC_INIT([Hello], [1.0], [bug-hello@@example.org])
+@c If you change this example, adjust tests/compile.at:AC_LANG_PROGRAM example.
+AC_INIT([Hello], [1.0], [bug-hello@@example.org], [],
+        [http://www.example.org/])
 AC_DEFINE([HELLO_WORLD], ["Hello, World\n"],
   [Greetings string.])
 AC_LANG_CONFTEST(
@@ -8726,9 +8732,10 @@ gcc -E -dD -o - conftest.c
 @end example
 
 @noindent
-results in:
+on a system with @command{gcc} installed, results in:
 
 @example
+@c If you change this example, adjust tests/compile.at:AC_LANG_PROGRAM example.
 @dots{}
 # 1 "conftest.c"
 
@@ -8737,6 +8744,7 @@ results in:
 #define PACKAGE_VERSION "1.0"
 #define PACKAGE_STRING "Hello 1.0"
 #define PACKAGE_BUGREPORT "bug-hello@@example.org"
+#define PACKAGE_URL "http://www.example.org/"
 #define HELLO_WORLD "Hello, World\n"
 
 const char hw[] = "Hello, World\n";
index bace001a4c090bf6e59254e4c53ab81572242b0c..129f3c696101afa52bb98cef61d32dae80aad182 100644 (file)
@@ -112,6 +112,146 @@ AT_CHECK_CONFIGURE
 AT_CLEANUP
 
 
+## ---------------- ##
+## AC_LANG_SOURCE.  ##
+## ---------------- ##
+
+AT_SETUP([AC_LANG_SOURCE])
+
+AT_DATA([configure.ac],
+[[AC_INIT([pkg], [1.0])
+AC_PROG_CC
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#ifndef PACKAGE_NAME
+choke me
+#endif
+int main ()
+{
+  return 0;
+}
+]], [], [AC_MSG_FAILURE([confdefs not included])])])
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+
+AT_CLEANUP
+
+
+## --------------------- ##
+## AC_LANG_SOURCE(C++).  ##
+## --------------------- ##
+
+AT_SETUP([AC_LANG_SOURCE(C++)])
+
+AT_DATA([configure.ac],
+[[AC_INIT([pkg], [1.0])
+AC_PROG_CXX
+AC_LANG([C++])
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#ifndef PACKAGE_NAME
+choke me
+#endif
+int main ()
+{
+  return 0;
+}
+]], [], [AC_MSG_FAILURE([confdefs not included])])])
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+
+AT_CLEANUP
+
+
+## ------------------------ ##
+## AC_LANG_SOURCE example.  ##
+## ------------------------ ##
+
+AT_SETUP([AC_LANG_SOURCE example])
+
+AT_DATA([configure.ac],
+[[# Taken from autoconf.texi:Generating Sources.
+# The only change is to not fail if gcc doesn't work.
+AC_INIT([Hello], [1.0], [bug-hello@example.org], [],
+        [http://www.example.org/])
+AC_DEFINE([HELLO_WORLD], ["Hello, World\n"],
+  [Greetings string.])
+AC_LANG([C])
+AC_LANG_CONFTEST(
+   [AC_LANG_SOURCE([[const char hw[] = "Hello, World\n";]])])
+gcc -E -dD -o - conftest.c || AS_EXIT([77])
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE([], [], [stdout])
+# Taken from autoconf.texi:Generating Sources.
+# Note that the output may contain more than one line matching
+#   # 1 "conftest.c"
+# so delete everything until the last one.
+AT_CHECK([sed  '1,/# 1 "conftest\.c"/d' stdout], [],
+[[
+#define PACKAGE_NAME "Hello"
+#define PACKAGE_TARNAME "hello"
+#define PACKAGE_VERSION "1.0"
+#define PACKAGE_STRING "Hello 1.0"
+#define PACKAGE_BUGREPORT "bug-hello@example.org"
+#define PACKAGE_URL "http://www.example.org/"
+#define HELLO_WORLD "Hello, World\n"
+
+const char hw[] = "Hello, World\n";
+]])
+
+AT_CLEANUP
+
+
+## ------------------------- ##
+## AC_LANG_PROGRAM example.  ##
+## ------------------------- ##
+
+AT_SETUP([AC_LANG_PROGRAM example])
+
+AT_DATA([configure.ac],
+[[# Taken from autoconf.texi:Generating Sources.
+# The only change is to not fail if gcc doesn't work.
+AC_INIT([Hello], [1.0], [bug-hello@example.org], [],
+        [http://www.example.org/])
+AC_DEFINE([HELLO_WORLD], ["Hello, World\n"],
+  [Greetings string.])
+AC_LANG_CONFTEST(
+[AC_LANG_PROGRAM([[const char hw[] = "Hello, World\n";]],
+                 [[fputs (hw, stdout);]])])
+gcc -E -dD -o - conftest.c || AS_EXIT([77])
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE([], [], [stdout])
+# Taken from autoconf.texi:Generating Sources.
+# Note that the output may contain more than one line matching
+#   # 1 "conftest.c"
+# so delete everything until the last one.
+AT_CHECK([sed  '1,/# 1 "conftest\.c"/d' stdout], [],
+[[
+#define PACKAGE_NAME "Hello"
+#define PACKAGE_TARNAME "hello"
+#define PACKAGE_VERSION "1.0"
+#define PACKAGE_STRING "Hello 1.0"
+#define PACKAGE_BUGREPORT "bug-hello@example.org"
+#define PACKAGE_URL "http://www.example.org/"
+#define HELLO_WORLD "Hello, World\n"
+
+const char hw[] = "Hello, World\n";
+int
+main ()
+{
+fputs (hw, stdout);
+  ;
+  return 0;
+}
+]])
+
+AT_CLEANUP
+
+
 ## --------------- ##
 ## AC_RUN_IFELSE.  ##
 ## --------------- ##