1 #--------------------------------------------------------------------------- 2 # 3 # xc-val-flgs.m4 4 # 5 # Copyright (c) 2013 Daniel Stenberg <daniel (a] 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 #--------------------------------------------------------------------------- 20 21 # serial 1 22 23 24 dnl _XC_CHECK_VAR_LIBS 25 dnl ------------------------------------------------- 26 dnl Private macro. 27 28 AC_DEFUN([_XC_CHECK_VAR_LIBS], [ 29 xc_bad_var_libs=no 30 for xc_word in $LIBS; do 31 case "$xc_word" in 32 -l* | --library=*) 33 : 34 ;; 35 *) 36 xc_bad_var_libs=yes 37 ;; 38 esac 39 done 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).]) 43 fi 44 ]) 45 46 47 dnl _XC_CHECK_VAR_LDFLAGS 48 dnl ------------------------------------------------- 49 dnl Private macro. 50 51 AC_DEFUN([_XC_CHECK_VAR_LDFLAGS], [ 52 xc_bad_var_ldflags=no 53 for xc_word in $LDFLAGS; do 54 case "$xc_word" in 55 -D*) 56 xc_bad_var_ldflags=yes 57 ;; 58 -U*) 59 xc_bad_var_ldflags=yes 60 ;; 61 -I*) 62 xc_bad_var_ldflags=yes 63 ;; 64 -l* | --library=*) 65 xc_bad_var_ldflags=yes 66 ;; 67 esac 68 done 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 73 case "$xc_word" in 74 -D*) 75 AC_MSG_NOTICE([$xc_bad_var_msg macro definitions. Use CPPFLAGS for: $xc_word]) 76 ;; 77 -U*) 78 AC_MSG_NOTICE([$xc_bad_var_msg macro suppressions. Use CPPFLAGS for: $xc_word]) 79 ;; 80 -I*) 81 AC_MSG_NOTICE([$xc_bad_var_msg include directories. Use CPPFLAGS for: $xc_word]) 82 ;; 83 -l* | --library=*) 84 AC_MSG_NOTICE([$xc_bad_var_msg libraries. Use LIBS for: $xc_word]) 85 ;; 86 esac 87 done 88 fi 89 ]) 90 91 92 dnl _XC_CHECK_VAR_CPPFLAGS 93 dnl ------------------------------------------------- 94 dnl Private macro. 95 96 AC_DEFUN([_XC_CHECK_VAR_CPPFLAGS], [ 97 xc_bad_var_cppflags=no 98 for xc_word in $CPPFLAGS; do 99 case "$xc_word" in 100 -rpath*) 101 xc_bad_var_cppflags=yes 102 ;; 103 -L* | --library-path=*) 104 xc_bad_var_cppflags=yes 105 ;; 106 -l* | --library=*) 107 xc_bad_var_cppflags=yes 108 ;; 109 esac 110 done 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 115 case "$xc_word" in 116 -rpath*) 117 AC_MSG_NOTICE([$xc_bad_var_msg library runtime directories. Use LDFLAGS for: $xc_word]) 118 ;; 119 -L* | --library-path=*) 120 AC_MSG_NOTICE([$xc_bad_var_msg library directories. Use LDFLAGS for: $xc_word]) 121 ;; 122 -l* | --library=*) 123 AC_MSG_NOTICE([$xc_bad_var_msg libraries. Use LIBS for: $xc_word]) 124 ;; 125 esac 126 done 127 fi 128 ]) 129 130 131 dnl _XC_CHECK_VAR_CFLAGS 132 dnl ------------------------------------------------- 133 dnl Private macro. 134 135 AC_DEFUN([_XC_CHECK_VAR_CFLAGS], [ 136 xc_bad_var_cflags=no 137 for xc_word in $CFLAGS; do 138 case "$xc_word" in 139 -D*) 140 xc_bad_var_cflags=yes 141 ;; 142 -U*) 143 xc_bad_var_cflags=yes 144 ;; 145 -I*) 146 xc_bad_var_cflags=yes 147 ;; 148 -rpath*) 149 xc_bad_var_cflags=yes 150 ;; 151 -L* | --library-path=*) 152 xc_bad_var_cflags=yes 153 ;; 154 -l* | --library=*) 155 xc_bad_var_cflags=yes 156 ;; 157 esac 158 done 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 163 case "$xc_word" in 164 -D*) 165 AC_MSG_NOTICE([$xc_bad_var_msg macro definitions. Use CPPFLAGS for: $xc_word]) 166 ;; 167 -U*) 168 AC_MSG_NOTICE([$xc_bad_var_msg macro suppressions. Use CPPFLAGS for: $xc_word]) 169 ;; 170 -I*) 171 AC_MSG_NOTICE([$xc_bad_var_msg include directories. Use CPPFLAGS for: $xc_word]) 172 ;; 173 -rpath*) 174 AC_MSG_NOTICE([$xc_bad_var_msg library runtime directories. Use LDFLAGS for: $xc_word]) 175 ;; 176 -L* | --library-path=*) 177 AC_MSG_NOTICE([$xc_bad_var_msg library directories. Use LDFLAGS for: $xc_word]) 178 ;; 179 -l* | --library=*) 180 AC_MSG_NOTICE([$xc_bad_var_msg libraries. Use LIBS for: $xc_word]) 181 ;; 182 esac 183 done 184 fi 185 ]) 186 187 188 dnl XC_CHECK_USER_FLAGS 189 dnl ------------------------------------------------- 190 dnl Public macro. 191 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. 197 dnl 198 dnl Intended to be used early in configure script. 199 200 AC_DEFUN([XC_CHECK_USER_FLAGS], [ 201 AC_PREREQ([2.50])dnl 202 AC_BEFORE([$0],[XC_CHECK_PROG_CC])dnl 203 dnl check order below matters 204 _XC_CHECK_VAR_LIBS 205 _XC_CHECK_VAR_LDFLAGS 206 _XC_CHECK_VAR_CPPFLAGS 207 _XC_CHECK_VAR_CFLAGS 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.]) 213 fi 214 ]) 215 216 217 dnl XC_CHECK_BUILD_FLAGS 218 dnl ------------------------------------------------- 219 dnl Public macro. 220 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. 226 dnl 227 dnl Intended to be used very late in configure script. 228 229 AC_DEFUN([XC_CHECK_BUILD_FLAGS], [ 230 AC_PREREQ([2.50])dnl 231 dnl check order below matters 232 _XC_CHECK_VAR_LIBS 233 _XC_CHECK_VAR_LDFLAGS 234 _XC_CHECK_VAR_CPPFLAGS 235 _XC_CHECK_VAR_CFLAGS 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.]) 241 fi 242 ]) 243 244