1 #---------------------------------------------------------------------------
5 # Copyright (c) 2013 Daniel Stenberg <daniel@haxx.se>
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.
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.
19 #---------------------------------------------------------------------------
24 dnl _XC_CHECK_VAR_LIBS
25 dnl -------------------------------------------------
28 AC_DEFUN([_XC_CHECK_VAR_LIBS], [
30 for xc_word in $LIBS; do
40 if test $xc_bad_var_libs = yes; then
41 AC_MSG_NOTICE([using LIBS: $LIBS])
42 AC_MSG_NOTICE([LIBS note: LIBS should only be used to specify libraries (-lname).])
47 dnl _XC_CHECK_VAR_LDFLAGS
48 dnl -------------------------------------------------
51 AC_DEFUN([_XC_CHECK_VAR_LDFLAGS], [
53 for xc_word in $LDFLAGS; do
56 xc_bad_var_ldflags=yes
59 xc_bad_var_ldflags=yes
62 xc_bad_var_ldflags=yes
65 xc_bad_var_ldflags=yes
69 if test $xc_bad_var_ldflags = yes; then
70 AC_MSG_NOTICE([using LDFLAGS: $LDFLAGS])
71 xc_bad_var_msg="LDFLAGS note: LDFLAGS should only be used to specify linker flags, not"
72 for xc_word in $LDFLAGS; do
75 AC_MSG_NOTICE([$xc_bad_var_msg macro definitions. Use CPPFLAGS for: $xc_word])
78 AC_MSG_NOTICE([$xc_bad_var_msg macro suppressions. Use CPPFLAGS for: $xc_word])
81 AC_MSG_NOTICE([$xc_bad_var_msg include directories. Use CPPFLAGS for: $xc_word])
84 AC_MSG_NOTICE([$xc_bad_var_msg libraries. Use LIBS for: $xc_word])
92 dnl _XC_CHECK_VAR_CPPFLAGS
93 dnl -------------------------------------------------
96 AC_DEFUN([_XC_CHECK_VAR_CPPFLAGS], [
97 xc_bad_var_cppflags=no
98 for xc_word in $CPPFLAGS; do
101 xc_bad_var_cppflags=yes
103 -L* | --library-path=*)
104 xc_bad_var_cppflags=yes
107 xc_bad_var_cppflags=yes
111 if test $xc_bad_var_cppflags = yes; then
112 AC_MSG_NOTICE([using CPPFLAGS: $CPPFLAGS])
113 xc_bad_var_msg="CPPFLAGS note: CPPFLAGS should only be used to specify C preprocessor flags, not"
114 for xc_word in $CPPFLAGS; do
117 AC_MSG_NOTICE([$xc_bad_var_msg library runtime directories. Use LDFLAGS for: $xc_word])
119 -L* | --library-path=*)
120 AC_MSG_NOTICE([$xc_bad_var_msg library directories. Use LDFLAGS for: $xc_word])
123 AC_MSG_NOTICE([$xc_bad_var_msg libraries. Use LIBS for: $xc_word])
131 dnl _XC_CHECK_VAR_CFLAGS
132 dnl -------------------------------------------------
135 AC_DEFUN([_XC_CHECK_VAR_CFLAGS], [
137 for xc_word in $CFLAGS; do
140 xc_bad_var_cflags=yes
143 xc_bad_var_cflags=yes
146 xc_bad_var_cflags=yes
149 xc_bad_var_cflags=yes
151 -L* | --library-path=*)
152 xc_bad_var_cflags=yes
155 xc_bad_var_cflags=yes
159 if test $xc_bad_var_cflags = yes; then
160 AC_MSG_NOTICE([using CFLAGS: $CFLAGS])
161 xc_bad_var_msg="CFLAGS note: CFLAGS should only be used to specify C compiler flags, not"
162 for xc_word in $CFLAGS; do
165 AC_MSG_NOTICE([$xc_bad_var_msg macro definitions. Use CPPFLAGS for: $xc_word])
168 AC_MSG_NOTICE([$xc_bad_var_msg macro suppressions. Use CPPFLAGS for: $xc_word])
171 AC_MSG_NOTICE([$xc_bad_var_msg include directories. Use CPPFLAGS for: $xc_word])
174 AC_MSG_NOTICE([$xc_bad_var_msg library runtime directories. Use LDFLAGS for: $xc_word])
176 -L* | --library-path=*)
177 AC_MSG_NOTICE([$xc_bad_var_msg library directories. Use LDFLAGS for: $xc_word])
180 AC_MSG_NOTICE([$xc_bad_var_msg libraries. Use LIBS for: $xc_word])
188 dnl XC_CHECK_USER_FLAGS
189 dnl -------------------------------------------------
192 dnl Performs some sanity checks for LIBS, LDFLAGS,
193 dnl CPPFLAGS and CFLAGS values that the user might
194 dnl have set. When checks fails, user is noticed
195 dnl about errors detected in all of them and script
196 dnl execution is halted.
198 dnl Intended to be used early in configure script.
200 AC_DEFUN([XC_CHECK_USER_FLAGS], [
202 AC_BEFORE([$0],[XC_CHECK_PROG_CC])dnl
203 dnl check order below matters
205 _XC_CHECK_VAR_LDFLAGS
206 _XC_CHECK_VAR_CPPFLAGS
208 if test $xc_bad_var_libs = yes ||
209 test $xc_bad_var_cflags = yes ||
210 test $xc_bad_var_ldflags = yes ||
211 test $xc_bad_var_cppflags = yes; then
212 AC_MSG_ERROR([Can not continue. Fix errors mentioned immediately above this line.])
217 dnl XC_CHECK_BUILD_FLAGS
218 dnl -------------------------------------------------
221 dnl Performs some sanity checks for LIBS, LDFLAGS,
222 dnl CPPFLAGS and CFLAGS values that the configure
223 dnl script might have set. When checks fails, user
224 dnl is noticed about errors detected in all of them
225 dnl but script continues execution.
227 dnl Intended to be used very late in configure script.
229 AC_DEFUN([XC_CHECK_BUILD_FLAGS], [
231 dnl check order below matters
233 _XC_CHECK_VAR_LDFLAGS
234 _XC_CHECK_VAR_CPPFLAGS
236 if test $xc_bad_var_libs = yes ||
237 test $xc_bad_var_cflags = yes ||
238 test $xc_bad_var_ldflags = yes ||
239 test $xc_bad_var_cppflags = yes; then
240 AC_MSG_WARN([Continuing even with errors mentioned immediately above this line.])