configure.in 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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. AM_PROG_LIBTOOL
  7. dnl AC_PROG_YACC
  8. AC_PROG_LEX
  9. AC_CHECK_LIB(resolv, inet_aton)
  10. AC_CHECK_LIBM
  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. dnl end libnetsnmp check
  82. dnl check for Cygwin & NSIS to build docsis_setup.exe
  83. AC_MSG_CHECKING([for Cygwin])
  84. if test "x$host_os" = "xcygwin" ; then
  85. AC_MSG_RESULT([ found Cygwin, trying to use NSIS to build setup.exe ])
  86. dnl save current path in DOS format so we can substitute it in in NSIS setup script
  87. CYGWIN_BUILDROOT=`cygpath -w $PWD`
  88. NETSNMP_MIBPATH="`cygpath -d ${NETSNMP_PREFIX}/share/snmp/mibs`"
  89. AC_MSG_RESULT([ using build root $CYGWIN_BUILDROOT])
  90. AC_SUBST(CYGWIN_BUILDROOT)
  91. AC_SUBST(NETSNMP_MIBPATH)
  92. AC_PATH_PROG([MAKENSIS], [makensis], [notfound],[$PATH:$prefix/bin:/cygdrive/c/Program Files/NSIS])
  93. if test "x$MAKENSIS" = "xnotfound"; then
  94. AC_MSG_RESULT([makensis not found, no setup.exe...])
  95. else
  96. AC_MSG_RESULT([found makensis at $MAKENSIS ... ])
  97. fi
  98. else
  99. AC_MSG_RESULT([no])
  100. fi
  101. AM_CONDITIONAL(CYGWIN_BUILD, test "x$host_os" = "xcygwin")
  102. AM_CONDITIONAL(CYGWIN_BUILD_SETUP_EXE, test "x$host_os" = "xcygwin" -a "x$MAKENSIS" != "xnotfound" )
  103. dnl end check for NSIS
  104. AC_PATH_PROG(sedpath, sed)
  105. if test "x$GCC" = "xyes"; then
  106. dnl We enable -Wall later.
  107. dnl If it's set after the warning CFLAGS in the compiler invocation, it counteracts the -Wno... flags.
  108. dnl This leads to warnings we don't want.
  109. CFLAGS=`echo $CFLAGS |$sedpath 's/-Wall//'`
  110. dnl ENABLE WARNINGS SUPPORTED BY THE VERSION OF GCC IN USE
  111. for newflag in \
  112. "-Waggregate-return" \
  113. "-Wbad-function-cast" \
  114. "-Wcast-align" \
  115. "-Wdeclaration-after-statement" \
  116. "-Wendif-labels" \
  117. "-Werror-implicit-function-declaration" \
  118. "-Wextra -Wno-unused-parameter" \
  119. "-Wfloat-equal" \
  120. "-Wformat-security" \
  121. "-Werror=format-security" \
  122. "-Winit-self" \
  123. "-Wmissing-declarations" \
  124. "-Wmissing-noreturn" \
  125. "-Wmissing-prototypes" \
  126. "-Wpointer-arith" \
  127. "-Wundef" \
  128. ; do
  129. orig_CFLAGS="$CFLAGS"
  130. CFLAGS="$CFLAGS $newflag"
  131. AC_MSG_CHECKING(for $newflag option to gcc)
  132. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
  133. int main() {return 0;}
  134. ]])], [
  135. AC_MSG_RESULT(yes)
  136. CFLAGS="$orig_CFLAGS"
  137. DEBUG_CFLAGS="$DEBUG_CFLAGS $newflag"
  138. ], [
  139. AC_MSG_RESULT(no)
  140. CFLAGS="$orig_CFLAGS"
  141. ])
  142. done
  143. if test "x$enable_fortify" = "xyes"; then
  144. AC_MSG_CHECKING(for FORTIFY_SOURCE support)
  145. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <features.h>]], [[
  146. int main() {
  147. #if !(__GNUC_PREREQ (4, 1) \
  148. || (defined __GNUC_RH_RELEASE__ && __GNUC_PREREQ (4, 0)) \
  149. || (defined __GNUC_RH_RELEASE__ && __GNUC_PREREQ (3, 4) \
  150. && __GNUC_MINOR__ == 4 \
  151. && (__GNUC_PATCHLEVEL__ > 2 \
  152. || (__GNUC_PATCHLEVEL__ == 2 && __GNUC_RH_RELEASE__ >= 8))))
  153. #error No FORTIFY_SOURCE support
  154. #endif
  155. return 0;
  156. }
  157. ]])], [
  158. AC_MSG_RESULT(yes)
  159. DEBUG_CFLAGS="$DEBUG_CFLAGS -Wp,-D_FORTIFY_SOURCE=2"
  160. ], [
  161. AC_MSG_RESULT(no)
  162. ])
  163. fi
  164. CFLAGS="-Wall $DEBUG_CFLAGS -g $CFLAGS"
  165. fi
  166. AC_OUTPUT(build_setup.nsi Makefile src/Makefile doc/Makefile examples/Makefile mibs/Makefile)