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