xref: /curl/m4/xc-cc-check.m4 (revision b2696ac3)
1#---------------------------------------------------------------------------
2#
3# xc-cc-check.m4
4#
5# Copyright (C) Daniel Stenberg, <daniel@haxx.se>
6#
7# Permission to use, copy, modify, and distribute this software for any
8# purpose with or without fee is hereby granted, provided that the above
9# copyright notice and this permission notice appear in all copies.
10#
11# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18#
19# SPDX-License-Identifier: ISC
20#
21#---------------------------------------------------------------------------
22
23# serial 1
24
25
26dnl _XC_PROG_CC_PREAMBLE
27dnl -------------------------------------------------
28dnl Private macro.
29
30AC_DEFUN([_XC_PROG_CC_PREAMBLE], [
31  xc_prog_cc_prev_IFS=$IFS
32  xc_prog_cc_prev_LIBS=$LIBS
33  xc_prog_cc_prev_CFLAGS=$CFLAGS
34  xc_prog_cc_prev_LDFLAGS=$LDFLAGS
35  xc_prog_cc_prev_CPPFLAGS=$CPPFLAGS
36])
37
38
39dnl _XC_PROG_CC_POSTLUDE
40dnl -------------------------------------------------
41dnl Private macro.
42
43AC_DEFUN([_XC_PROG_CC_POSTLUDE], [
44  IFS=$xc_prog_cc_prev_IFS
45  LIBS=$xc_prog_cc_prev_LIBS
46  CFLAGS=$xc_prog_cc_prev_CFLAGS
47  LDFLAGS=$xc_prog_cc_prev_LDFLAGS
48  CPPFLAGS=$xc_prog_cc_prev_CPPFLAGS
49  AC_SUBST([CC])dnl
50  AC_SUBST([CPP])dnl
51  AC_SUBST([LIBS])dnl
52  AC_SUBST([CFLAGS])dnl
53  AC_SUBST([LDFLAGS])dnl
54  AC_SUBST([CPPFLAGS])dnl
55])
56
57
58dnl _XC_PROG_CC
59dnl -------------------------------------------------
60dnl Private macro.
61
62AC_DEFUN([_XC_PROG_CC], [
63  AC_REQUIRE([_XC_PROG_CC_PREAMBLE])dnl
64  AC_REQUIRE([XC_CHECK_BUILD_FLAGS])dnl
65  AC_REQUIRE([AC_PROG_INSTALL])dnl
66  AC_REQUIRE([AC_PROG_CC])dnl
67  AC_REQUIRE([AM_PROG_CC_C_O])dnl
68  AC_REQUIRE([AC_PROG_CPP])dnl
69  AC_REQUIRE([_XC_PROG_CC_POSTLUDE])dnl
70])
71
72
73dnl XC_CHECK_PROG_CC
74dnl -------------------------------------------------
75dnl Public macro.
76dnl
77dnl Checks for C compiler and C preprocessor programs,
78dnl while doing some previous sanity validation on user
79dnl provided LIBS, LDFLAGS, CPPFLAGS and CFLAGS values
80dnl that must succeed in order to continue execution.
81dnl
82dnl This sets variables CC and CPP, while preventing
83dnl LIBS, LDFLAGS, CFLAGS, CPPFLAGS and IFS from being
84dnl unexpectedly changed by underlying macros.
85
86AC_DEFUN([XC_CHECK_PROG_CC], [
87  AC_PREREQ([2.50])dnl
88  AC_BEFORE([$0],[_XC_PROG_CC_PREAMBLE])dnl
89  AC_BEFORE([$0],[AC_PROG_INSTALL])dnl
90  AC_BEFORE([$0],[AC_PROG_CC])dnl
91  AC_BEFORE([$0],[AM_PROG_CC_C_O])dnl
92  AC_BEFORE([$0],[AC_PROG_CPP])dnl
93  AC_BEFORE([$0],[AC_PROG_LIBTOOL])dnl
94  AC_BEFORE([$0],[AM_INIT_AUTOMAKE])dnl
95  AC_BEFORE([$0],[_XC_PROG_CC_POSTLUDE])dnl
96  AC_REQUIRE([_XC_PROG_CC])dnl
97])
98