autoconf-patches
[Top][All Lists]
Advanced

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

Coverage and doc fixes for AC_LANG_SOURCE and AC_LANG_PROGRAM.


From: Ralf Wildenhues
Subject: Coverage and doc fixes for AC_LANG_SOURCE and AC_LANG_PROGRAM.
Date: Sun, 6 Jun 2010 13:56:04 +0200
User-agent: Mutt/1.5.20 (2009-10-28)

Without the URL change, the results are documented wrongly in the
manual, missing
  #define PACKAGE_URL ""

so this might be nice before 2.66.  OK?

The second patch has the downside of requiring maintenance should the
formatting of the source contents change.

Thanks,
Ralf

    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.

diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 08fa929..18aef12 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -8685,19 +8685,22 @@ Generating Sources
 For instance executing (observe the double quotation!):
 
 @example
-AC_INIT([Hello], [1.0], [bug-hello@@example.org])
address@hidden 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
address@hidden If you change this example, adjust 
tests/compile.at:AC_LANG_SOURCE example.
 @dots{}
 # 1 "conftest.c"
 
@@ -8706,6 +8709,7 @@ Generating Sources
 #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";
@@ -8726,7 +8730,9 @@ Generating Sources
 For instance:
 
 @example
-AC_INIT([Hello], [1.0], [bug-hello@@example.org])
address@hidden 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(
@@ -8736,9 +8742,10 @@ Generating Sources
 @end example
 
 @noindent
-results in:
+on a system with @command{gcc} installed, results in:
 
 @example
address@hidden If you change this example, adjust 
tests/compile.at:AC_LANG_PROGRAM example.
 @dots{}
 # 1 "conftest.c"
 
@@ -8747,6 +8754,7 @@ Generating Sources
 #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";
diff --git a/tests/compile.at b/tests/compile.at
index bace001..129f3c6 100644
--- a/tests/compile.at
+++ b/tests/compile.at
@@ -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], address@hidden, [],
+        [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 "address@hidden"
+#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], address@hidden, [],
+        [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 "address@hidden"
+#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.  ##
 ## --------------- ##



reply via email to

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