test harness: improve catching of usage errors in script 'test-driver'
[platform/upstream/automake.git] / m4 / init.m4
1 # Do all the work for Automake.                             -*- Autoconf -*-
2
3 # Copyright (C) 1996-2013 Free Software Foundation, Inc.
4 #
5 # This file is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This macro actually does too much.  Some checks are only needed if
10 # your package does certain things.  But this isn't really a big deal.
11
12 dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O.
13 m4_define([AC_PROG_CC],
14 m4_defn([AC_PROG_CC])
15 [_AM_PROG_CC_C_O
16 ])
17
18 # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
19 # AM_INIT_AUTOMAKE([OPTIONS])
20 # -----------------------------------------------
21 # The call with PACKAGE and VERSION arguments is the old style
22 # call (pre autoconf-2.50), which is being phased out.  PACKAGE
23 # and VERSION should now be passed to AC_INIT and removed from
24 # the call to AM_INIT_AUTOMAKE.
25 # We support both call styles for the transition.  After
26 # the next Automake release, Autoconf can make the AC_INIT
27 # arguments mandatory, and then we can depend on a new Autoconf
28 # release and drop the old call support.
29 AC_DEFUN([AM_INIT_AUTOMAKE],
30 [AC_PREREQ([2.65])dnl
31 dnl Autoconf wants to disallow AM_ names.  We explicitly allow
32 dnl the ones we care about.
33 m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
34 AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
35 AC_REQUIRE([AC_PROG_INSTALL])dnl
36 if test "`cd $srcdir && pwd`" != "`pwd`"; then
37   # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
38   # is not polluted with repeated "-I."
39   AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
40   # test to see if srcdir already configured
41   if test -f $srcdir/config.status; then
42     AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
43   fi
44 fi
45
46 # test whether we have cygpath
47 if test -z "$CYGPATH_W"; then
48   if (cygpath --version) >/dev/null 2>/dev/null; then
49     CYGPATH_W='cygpath -w'
50   else
51     CYGPATH_W=echo
52   fi
53 fi
54 AC_SUBST([CYGPATH_W])
55
56 # Define the identity of the package.
57 dnl Distinguish between old-style and new-style calls.
58 m4_ifval([$2],
59 [AC_DIAGNOSE([obsolete],
60              [$0: two- and three-arguments forms are deprecated.])
61 m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
62  AC_SUBST([PACKAGE], [$1])dnl
63  AC_SUBST([VERSION], [$2])],
64 [_AM_SET_OPTIONS([$1])dnl
65 dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
66 m4_if(
67   m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]),
68   [ok:ok],,
69   [m4_fatal([AC_INIT should be called with package and version arguments])])dnl
70  AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
71  AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
72
73 _AM_IF_OPTION([no-define],,
74 [AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package])
75  AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl
76
77 # Some tools Automake needs.
78 AC_REQUIRE([AM_SANITY_CHECK])dnl
79 AC_REQUIRE([AC_ARG_PROGRAM])dnl
80 AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}])
81 AM_MISSING_PROG([AUTOCONF], [autoconf])
82 AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}])
83 AM_MISSING_PROG([AUTOHEADER], [autoheader])
84 AM_MISSING_PROG([MAKEINFO], [makeinfo])
85 AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
86 AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
87 AC_REQUIRE([AC_PROG_MKDIR_P])dnl
88 # For better backward compatibility.  To be removed once Automake 1.9.x
89 # dies out for good.  For more background, see:
90 # <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
91 # <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
92 AC_SUBST([mkdir_p], ['$(MKDIR_P)'])
93 # We need awk for the "check" target.  The system "awk" is bad on
94 # some platforms.
95 AC_REQUIRE([AC_PROG_AWK])dnl
96 AC_REQUIRE([AC_PROG_MAKE_SET])dnl
97 AC_REQUIRE([AM_SET_LEADING_DOT])dnl
98 _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
99               [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
100                              [_AM_PROG_TAR([v7])])])
101 _AM_IF_OPTION([no-dependencies],,
102 [AC_PROVIDE_IFELSE([AC_PROG_CC],
103                   [_AM_DEPENDENCIES([CC])],
104                   [m4_define([AC_PROG_CC],
105                              m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl
106 AC_PROVIDE_IFELSE([AC_PROG_CXX],
107                   [_AM_DEPENDENCIES([CXX])],
108                   [m4_define([AC_PROG_CXX],
109                              m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl
110 AC_PROVIDE_IFELSE([AC_PROG_OBJC],
111                   [_AM_DEPENDENCIES([OBJC])],
112                   [m4_define([AC_PROG_OBJC],
113                              m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl
114 AC_PROVIDE_IFELSE([AC_PROG_OBJCXX],
115                   [_AM_DEPENDENCIES([OBJCXX])],
116                   [m4_define([AC_PROG_OBJCXX],
117                              m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl
118 ])
119 AC_REQUIRE([AM_SILENT_RULES])dnl
120 dnl The testsuite driver may need to know about EXEEXT, so add the
121 dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen.  This
122 dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below.
123 AC_CONFIG_COMMANDS_PRE(dnl
124 [m4_provide_if([_AM_COMPILER_EXEEXT],
125   [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
126
127 # POSIX will say in a future version that running "rm -f" with no argument
128 # is OK; and we want to be able to make that assumption in our Makefile
129 # recipes.  So use an aggressive probe to check that the usage we want is
130 # actually supported "in the wild" to an acceptable degree.
131 # See automake bug#10828.
132 # To make any issue more visible, cause the running configure to be aborted
133 # by default if the 'rm' program in use doesn't match our expectations; the
134 # user can still override this though.
135 if rm -f && rm -fr && rm -rf; then : OK; else
136   cat >&2 <<'END'
137 Oops!
138
139 Your 'rm' program seems unable to run without file operands specified
140 on the command line, even when the '-f' option is present.  This is contrary
141 to the behaviour of most rm programs out there, and not conforming with
142 the upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542>
143
144 Please tell bug-automake@gnu.org about your system, including the value
145 of your $PATH and any error possibly output before this message.  This
146 can help us improve future automake versions.
147
148 END
149   if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then
150     echo 'Configuration will proceed anyway, since you have set the' >&2
151     echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2
152     echo >&2
153   else
154     cat >&2 <<'END'
155 Aborting the configuration process, to ensure you take notice of the issue.
156
157 You can download and install GNU coreutils to get an 'rm' implementation
158 that behaves properly: <http://www.gnu.org/software/coreutils/>.
159
160 If you want to complete the configuration process using your problematic
161 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
162 to "yes", and re-run configure.
163
164 END
165     AC_MSG_ERROR([Your 'rm' program is bad, sorry.])
166   fi
167 fi])
168
169 dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion.  Do not
170 dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
171 dnl mangled by Autoconf and run in a shell conditional statement.
172 m4_define([_AC_COMPILER_EXEEXT],
173 m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
174
175 # When config.status generates a header, we must update the stamp-h file.
176 # This file resides in the same directory as the config header
177 # that is generated.  The stamp files are numbered to have different names.
178
179 # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
180 # loop where config.status creates the headers, so we can generate
181 # our stamp files there.
182 AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
183 [# Compute $1's index in $config_headers.
184 _am_arg=$1
185 _am_stamp_count=1
186 for _am_header in $config_headers :; do
187   case $_am_header in
188     $_am_arg | $_am_arg:* )
189       break ;;
190     * )
191       _am_stamp_count=`expr $_am_stamp_count + 1` ;;
192   esac
193 done
194 echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])