xc-val-flgs.m4 6.9 KB

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