configure.ac 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. AC_INIT([docsis], [0.9.9-dev])
  2. AC_CONFIG_SRCDIR([src/docsis.c])
  3. AC_CONFIG_HEADERS([config.h])
  4. AM_INIT_AUTOMAKE([dist-bzip2])
  5. AC_CANONICAL_HOST
  6. AC_LANG([C])
  7. LT_INIT
  8. dnl AC_PROG_YACC
  9. AC_PROG_LEX
  10. if test "x$LEX" != xflex; then
  11. AC_MSG_ERROR([flex not found])
  12. fi
  13. AC_CHECK_LIB(resolv, inet_aton)
  14. LT_LIB_M
  15. AC_SUBST(LIBM)
  16. AC_PATH_PROGS([M4], [gm4 gnum4 m4], [notfound],[/usr/local/bin:/usr/freeware/bin:/usr/gnu/bin:${prefix}/bin:${exec_prefix}/bin:$PATH] )
  17. if test "x$M4" = "xnotfound"; then
  18. AC_MSG_ERROR([M4 is required])
  19. else
  20. ac_m4_vers=`$M4 --version 2>/dev/null | head -1` ;
  21. if echo "$ac_m4_vers" | grep -q GNU; then
  22. AC_MSG_RESULT([ found $ac_m4_vers at $M4 ])
  23. else
  24. AC_MSG_ERROR([ GNU M4 is needed ])
  25. fi
  26. fi
  27. dnl check for bison, yacc won't help;
  28. AC_PATH_PROG([BISON], [bison], [notfound],
  29. [$PATH:${prefix}/bin:${exec_prefix}/bin:/usr/freeware/bin:/usr/gnu/bin:/usr/local/bin:/usr/bin])
  30. if test "x$BISON" != "xnotfound" ; then
  31. ac_bison_vers=`$BISON --version 2>/dev/null | head -1 | cut -d' ' -f4| awk 'BEGIN { FS = "."; } { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
  32. if test -n "$ac_bison_vers" && test "$ac_bison_vers" -ge 1028000
  33. then
  34. YACC="${BISON} -t -d -y"
  35. BISON="${YACC}"
  36. AC_MSG_RESULT([ found bison version $ac_bison_vers, using $YACC])
  37. AC_DEFINE_UNQUOTED(HAVE_BISON, 1, [Defines if your system has GNU bison])
  38. else
  39. AC_MSG_ERROR([bison version >= 1.28 not found])
  40. fi
  41. else
  42. AC_MSG_ERROR([bison not found])
  43. fi
  44. AC_SUBST(YACC)
  45. AC_SUBST(BISON)
  46. dnl NET-SNMP check by Cornel Ciocirlan.
  47. AC_PATH_PROG([NETSNMP_CONFIG], [net-snmp-config], [/usr/libexec/net-snmp-config],
  48. [$PATH:${prefix}/bin:${exec_prefix}/bin:/opt/net-snmp/bin:/usr/local/bin:/usr/bin])
  49. if test -n "$NETSNMP_CONFIG"; then
  50. vers=`$NETSNMP_CONFIG --version 2>/dev/null | awk 'BEGIN { FS = "."; } { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
  51. if test -n "$vers" && test "$vers" -ge 5000007
  52. then
  53. NETSNMP_LIBS="`$NETSNMP_CONFIG --libs`"
  54. NETSNMP_PREFIX="`$NETSNMP_CONFIG --prefix`"
  55. # Hack to allow distcheck to succeed.
  56. if test "x$prefix" = "xNONE" || echo "$NETSNMP_PREFIX" | grep -q "^$prefix"; then
  57. NETSNMP_MIBPATH="$NETSNMP_PREFIX/share/snmp/mibs"
  58. else
  59. NETSNMP_MIBPATH="${prefix}${NETSNMP_PREFIX}/share/snmp/mibs"
  60. fi
  61. NETSNMP_RPATH=
  62. for args in $NETSNMP_LIBS; do
  63. case $args in
  64. -L*)
  65. NETSNMP_RPATH="$NETSNMP_CONFIG $args"
  66. ;;
  67. esac
  68. done
  69. NETSNMP_RPATH=`echo $NETSNMP_RPATH | sed -e "s/-L/-R/g"`
  70. NETSNMP_CFLAGS="`$NETSNMP_CONFIG --cflags`"
  71. # AC_CHECK_HEADERS(net-snmp/net-snmp-config.h, [
  72. AC_MSG_RESULT([ found net-snmp version $vers])
  73. AC_DEFINE_UNQUOTED(HAVE_NETSNMP, 1, [Defines if your system has the net-snmp library])
  74. # ], [
  75. # AC_MSG_ERROR([You need at least net-snmp 5.0.7, get it at http://www.net-snmp.org])
  76. # ])
  77. else
  78. AC_MSG_ERROR([You need at least net-snmp 5.0.7, get it at http://www.net-snmp.org])
  79. fi
  80. fi
  81. AC_SUBST(NETSNMP_LIBS)
  82. AC_SUBST(NETSNMP_CFLAGS)
  83. AC_SUBST(NETSNMP_RPATH)
  84. AC_SUBST(NETSNMP_PREFIX)
  85. AC_MSG_CHECKING([for netsnmp_init_mib])
  86. orig_CFLAGS="$CFLAGS"
  87. orig_LIBS="$LIBS"
  88. CFLAGS="$CFLAGS $NETSNMP_CFLAGS"
  89. LIBS="$LIBS $NETSNMP_LIBS"
  90. AC_LINK_IFELSE(
  91. [AC_LANG_PROGRAM([[#include <net-snmp/net-snmp-config.h>
  92. #include <net-snmp/net-snmp-includes.h>]],
  93. [[netsnmp_init_mib();]])],
  94. [AC_MSG_RESULT(yes)
  95. AC_DEFINE_UNQUOTED(HAVE_NETSNMP_INIT_MIB, 1, [Defines if your net-snmp has the netsnmp_init_mib function])],
  96. [AC_MSG_RESULT(no)]
  97. )
  98. CFLAGS="$orig_CFLAGS"
  99. LIBS="$orig_LIBS"
  100. dnl end libnetsnmp check
  101. dnl check for Cygwin & NSIS to build docsis_setup.exe
  102. AC_MSG_CHECKING([for Cygwin])
  103. if test "x$host_os" = "xcygwin" ; then
  104. AC_MSG_RESULT([ found Cygwin, trying to use NSIS to build setup.exe ])
  105. dnl save current path in DOS format so we can substitute it in in NSIS setup script
  106. CYGWIN_BUILDROOT=`cygpath -w $PWD`
  107. NETSNMP_MIBPATH="`cygpath -d ${NETSNMP_PREFIX}/share/snmp/mibs`"
  108. AC_MSG_RESULT([ using build root $CYGWIN_BUILDROOT])
  109. AC_SUBST(CYGWIN_BUILDROOT)
  110. AC_SUBST(NETSNMP_MIBPATH)
  111. AC_PATH_PROG([MAKENSIS], [makensis], [notfound],[$PATH:$prefix/bin:/cygdrive/c/Program Files/NSIS])
  112. if test "x$MAKENSIS" = "xnotfound"; then
  113. AC_MSG_RESULT([makensis not found, no setup.exe...])
  114. else
  115. AC_MSG_RESULT([found makensis at $MAKENSIS ... ])
  116. fi
  117. else
  118. AC_MSG_RESULT([no])
  119. fi
  120. AM_CONDITIONAL(CYGWIN_BUILD, test "x$host_os" = "xcygwin")
  121. AM_CONDITIONAL(CYGWIN_BUILD_SETUP_EXE, test "x$host_os" = "xcygwin" -a "x$MAKENSIS" != "xnotfound" )
  122. dnl end check for NSIS
  123. AC_PATH_PROG(sedpath, sed)
  124. if test "x$GCC" = "xyes"; then
  125. dnl We enable -Wall later.
  126. dnl If it's set after the warning CFLAGS in the compiler invocation, it counteracts the -Wno... flags.
  127. dnl This leads to warnings we don't want.
  128. CFLAGS=`echo $CFLAGS |$sedpath 's/-Wall//'`
  129. dnl ENABLE WARNINGS SUPPORTED BY THE VERSION OF GCC IN USE
  130. for newflag in \
  131. "-Waggregate-return" \
  132. "-Wbad-function-cast" \
  133. "-Wcast-align" \
  134. "-Wdeclaration-after-statement" \
  135. "-Wendif-labels" \
  136. "-Werror-implicit-function-declaration" \
  137. "-Wextra -Wno-unused-parameter" \
  138. "-Wfloat-equal" \
  139. "-Wformat-security" \
  140. "-Werror=format-security" \
  141. "-Winit-self" \
  142. "-Wmissing-declarations" \
  143. "-Wmissing-noreturn" \
  144. "-Wmissing-prototypes" \
  145. "-Wpointer-arith" \
  146. "-Wundef" \
  147. ; do
  148. orig_CFLAGS="$CFLAGS"
  149. CFLAGS="$CFLAGS $newflag"
  150. AC_MSG_CHECKING(for $newflag option to gcc)
  151. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
  152. int main() {return 0;}
  153. ]])], [
  154. AC_MSG_RESULT(yes)
  155. CFLAGS="$orig_CFLAGS"
  156. DEBUG_CFLAGS="$DEBUG_CFLAGS $newflag"
  157. ], [
  158. AC_MSG_RESULT(no)
  159. CFLAGS="$orig_CFLAGS"
  160. ])
  161. done
  162. if test "x$enable_fortify" = "xyes"; then
  163. AC_MSG_CHECKING(for FORTIFY_SOURCE support)
  164. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <features.h>]], [[
  165. int main() {
  166. #if !(__GNUC_PREREQ (4, 1) \
  167. || (defined __GNUC_RH_RELEASE__ && __GNUC_PREREQ (4, 0)) \
  168. || (defined __GNUC_RH_RELEASE__ && __GNUC_PREREQ (3, 4) \
  169. && __GNUC_MINOR__ == 4 \
  170. && (__GNUC_PATCHLEVEL__ > 2 \
  171. || (__GNUC_PATCHLEVEL__ == 2 && __GNUC_RH_RELEASE__ >= 8))))
  172. #error No FORTIFY_SOURCE support
  173. #endif
  174. return 0;
  175. }
  176. ]])], [
  177. AC_MSG_RESULT(yes)
  178. DEBUG_CFLAGS="$DEBUG_CFLAGS -Wp,-D_FORTIFY_SOURCE=2"
  179. ], [
  180. AC_MSG_RESULT(no)
  181. ])
  182. fi
  183. case $host in
  184. *cygwin*)
  185. CFLAGS="$CFLAGS -fno-stack-protector"
  186. ;;
  187. esac
  188. CFLAGS="-Wall $DEBUG_CFLAGS -g $CFLAGS"
  189. fi
  190. AC_CONFIG_FILES([build_setup.nsi Makefile src/Makefile doc/Makefile examples/Makefile mibs/Makefile])
  191. AC_OUTPUT