configure.in 6.2 KB

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