xc-val-flgs.m4 6.8 KB

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