configure.in 5.7 KB

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