blob: b721c315572babbe467f8988de13f4a4d2db1d55 [file] [log] [blame]
xf.li6c8fc1e2023-08-12 00:11:09 -07001#---------------------------------------------------------------------------
2#
3# xc-val-flgs.m4
4#
5# Copyright (c) 2013 - 2022, 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_CHECK_VAR_LIBS
27dnl -------------------------------------------------
28dnl Private macro.
29
30AC_DEFUN([_XC_CHECK_VAR_LIBS], [
31 xc_bad_var_libs=no
32 for xc_word in $LIBS; do
33 case "$xc_word" in
34 -l* | --library=*)
35 :
36 ;;
37 *)
38 xc_bad_var_libs=yes
39 ;;
40 esac
41 done
42 if test $xc_bad_var_libs = yes; then
43 AC_MSG_NOTICE([using LIBS: $LIBS])
44 AC_MSG_NOTICE([LIBS note: LIBS should only be used to specify libraries (-lname).])
45 fi
46])
47
48
49dnl _XC_CHECK_VAR_LDFLAGS
50dnl -------------------------------------------------
51dnl Private macro.
52
53AC_DEFUN([_XC_CHECK_VAR_LDFLAGS], [
54 xc_bad_var_ldflags=no
55 for xc_word in $LDFLAGS; do
56 case "$xc_word" in
57 -D*)
58 xc_bad_var_ldflags=yes
59 ;;
60 -U*)
61 xc_bad_var_ldflags=yes
62 ;;
63 -I*)
64 xc_bad_var_ldflags=yes
65 ;;
66 -l* | --library=*)
67 xc_bad_var_ldflags=yes
68 ;;
69 esac
70 done
71 if test $xc_bad_var_ldflags = yes; then
72 AC_MSG_NOTICE([using LDFLAGS: $LDFLAGS])
73 xc_bad_var_msg="LDFLAGS note: LDFLAGS should only be used to specify linker flags, not"
74 for xc_word in $LDFLAGS; do
75 case "$xc_word" in
76 -D*)
77 AC_MSG_NOTICE([$xc_bad_var_msg macro definitions. Use CPPFLAGS for: $xc_word])
78 ;;
79 -U*)
80 AC_MSG_NOTICE([$xc_bad_var_msg macro suppressions. Use CPPFLAGS for: $xc_word])
81 ;;
82 -I*)
83 AC_MSG_NOTICE([$xc_bad_var_msg include directories. Use CPPFLAGS for: $xc_word])
84 ;;
85 -l* | --library=*)
86 AC_MSG_NOTICE([$xc_bad_var_msg libraries. Use LIBS for: $xc_word])
87 ;;
88 esac
89 done
90 fi
91])
92
93
94dnl _XC_CHECK_VAR_CPPFLAGS
95dnl -------------------------------------------------
96dnl Private macro.
97
98AC_DEFUN([_XC_CHECK_VAR_CPPFLAGS], [
99 xc_bad_var_cppflags=no
100 for xc_word in $CPPFLAGS; do
101 case "$xc_word" in
102 -rpath*)
103 xc_bad_var_cppflags=yes
104 ;;
105 -L* | --library-path=*)
106 xc_bad_var_cppflags=yes
107 ;;
108 -l* | --library=*)
109 xc_bad_var_cppflags=yes
110 ;;
111 esac
112 done
113 if test $xc_bad_var_cppflags = yes; then
114 AC_MSG_NOTICE([using CPPFLAGS: $CPPFLAGS])
115 xc_bad_var_msg="CPPFLAGS note: CPPFLAGS should only be used to specify C preprocessor flags, not"
116 for xc_word in $CPPFLAGS; do
117 case "$xc_word" in
118 -rpath*)
119 AC_MSG_NOTICE([$xc_bad_var_msg library runtime directories. Use LDFLAGS for: $xc_word])
120 ;;
121 -L* | --library-path=*)
122 AC_MSG_NOTICE([$xc_bad_var_msg library directories. Use LDFLAGS for: $xc_word])
123 ;;
124 -l* | --library=*)
125 AC_MSG_NOTICE([$xc_bad_var_msg libraries. Use LIBS for: $xc_word])
126 ;;
127 esac
128 done
129 fi
130])
131
132
133dnl _XC_CHECK_VAR_CFLAGS
134dnl -------------------------------------------------
135dnl Private macro.
136
137AC_DEFUN([_XC_CHECK_VAR_CFLAGS], [
138 xc_bad_var_cflags=no
139 for xc_word in $CFLAGS; do
140 case "$xc_word" in
141 -D*)
142 xc_bad_var_cflags=yes
143 ;;
144 -U*)
145 xc_bad_var_cflags=yes
146 ;;
147 -I*)
148 xc_bad_var_cflags=yes
149 ;;
150 -rpath*)
151 xc_bad_var_cflags=yes
152 ;;
153 -L* | --library-path=*)
154 xc_bad_var_cflags=yes
155 ;;
156 -l* | --library=*)
157 xc_bad_var_cflags=yes
158 ;;
159 esac
160 done
161 if test $xc_bad_var_cflags = yes; then
162 AC_MSG_NOTICE([using CFLAGS: $CFLAGS])
163 xc_bad_var_msg="CFLAGS note: CFLAGS should only be used to specify C compiler flags, not"
164 for xc_word in $CFLAGS; do
165 case "$xc_word" in
166 -D*)
167 AC_MSG_NOTICE([$xc_bad_var_msg macro definitions. Use CPPFLAGS for: $xc_word])
168 ;;
169 -U*)
170 AC_MSG_NOTICE([$xc_bad_var_msg macro suppressions. Use CPPFLAGS for: $xc_word])
171 ;;
172 -I*)
173 AC_MSG_NOTICE([$xc_bad_var_msg include directories. Use CPPFLAGS for: $xc_word])
174 ;;
175 -rpath*)
176 AC_MSG_NOTICE([$xc_bad_var_msg library runtime directories. Use LDFLAGS for: $xc_word])
177 ;;
178 -L* | --library-path=*)
179 AC_MSG_NOTICE([$xc_bad_var_msg library directories. Use LDFLAGS for: $xc_word])
180 ;;
181 -l* | --library=*)
182 AC_MSG_NOTICE([$xc_bad_var_msg libraries. Use LIBS for: $xc_word])
183 ;;
184 esac
185 done
186 fi
187])
188
189
190dnl XC_CHECK_USER_FLAGS
191dnl -------------------------------------------------
192dnl Public macro.
193dnl
194dnl Performs some sanity checks for LIBS, LDFLAGS,
195dnl CPPFLAGS and CFLAGS values that the user might
196dnl have set. When checks fails, user is noticed
197dnl about errors detected in all of them and script
198dnl execution is halted.
199dnl
200dnl Intended to be used early in configure script.
201
202AC_DEFUN([XC_CHECK_USER_FLAGS], [
203 AC_PREREQ([2.50])dnl
204 AC_BEFORE([$0],[XC_CHECK_PROG_CC])dnl
205 dnl check order below matters
206 _XC_CHECK_VAR_LIBS
207 _XC_CHECK_VAR_LDFLAGS
208 _XC_CHECK_VAR_CPPFLAGS
209 _XC_CHECK_VAR_CFLAGS
210 if test $xc_bad_var_libs = yes ||
211 test $xc_bad_var_cflags = yes ||
212 test $xc_bad_var_ldflags = yes ||
213 test $xc_bad_var_cppflags = yes; then
214 AC_MSG_ERROR([Can not continue. Fix errors mentioned immediately above this line.])
215 fi
216])
217
218
219dnl XC_CHECK_BUILD_FLAGS
220dnl -------------------------------------------------
221dnl Public macro.
222dnl
223dnl Performs some sanity checks for LIBS, LDFLAGS,
224dnl CPPFLAGS and CFLAGS values that the configure
225dnl script might have set. When checks fails, user
226dnl is noticed about errors detected in all of them
227dnl but script continues execution.
228dnl
229dnl Intended to be used very late in configure script.
230
231AC_DEFUN([XC_CHECK_BUILD_FLAGS], [
232 AC_PREREQ([2.50])dnl
233 dnl check order below matters
234 _XC_CHECK_VAR_LIBS
235 _XC_CHECK_VAR_LDFLAGS
236 _XC_CHECK_VAR_CPPFLAGS
237 _XC_CHECK_VAR_CFLAGS
238 if test $xc_bad_var_libs = yes ||
239 test $xc_bad_var_cflags = yes ||
240 test $xc_bad_var_ldflags = yes ||
241 test $xc_bad_var_cppflags = yes; then
242 AC_MSG_WARN([Continuing even with errors mentioned immediately above this line.])
243 fi
244])