From: Ralf Wildenhues Date: Tue, 8 Jun 2010 04:56:43 +0000 (+0200) Subject: Coverage and doc fixes for AC_LANG_SOURCE and AC_LANG_PROGRAM. X-Git-Tag: v2.66~40 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c106e61216c5b339c093dcf01ae42635759166db;p=thirdparty%2Fautoconf.git 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. Signed-off-by: Ralf Wildenhues --- diff --git a/ChangeLog b/ChangeLog index dcb54a1c..5150f4ff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2010-06-08 Ralf Wildenhues + 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. diff --git a/doc/autoconf.texi b/doc/autoconf.texi index e99103da..6be99aa2 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -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"; diff --git a/tests/compile.at b/tests/compile.at index bace001a..129f3c69 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], [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. ## ## --------------- ##