configure.ac 6.5 KB

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