configure.ac 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. dnl Process this file with autoconf to produce a configure script.
  2. dnl
  3. dnl
  4. AC_PREREQ(2.59)
  5. AC_INIT([wraith],[],[wraith@botpack.net])
  6. AC_CONFIG_SRCDIR(src/eggdrop.h)
  7. AC_CONFIG_HEADER(src/config.h)
  8. AC_CONFIG_AUX_DIR([build/autotools])
  9. AC_COPYRIGHT([Copyright (c) Bryan Drewery])
  10. AC_REVISION($Revision$)
  11. EGG_SAVE_PARAMETERS
  12. # Setup build environment
  13. dnl Search for newer gcc versions before older
  14. #AC_REQUIRE_CPP
  15. AC_LANG([C++])
  16. AC_PROG_CXX([g++6 g++5 g++49 g++-4.9 g++48 g++-4.8 g++47 g++-4.7 g++46 g++-4.6 g++ c++ CC cxx cc++])
  17. CC="${CXX} -x c"
  18. AC_SUBST(CC)
  19. AC_REQUIRE_CPP
  20. AX_CXX_COMPILE_STDCXX_11([noext], [mandatory])
  21. EGG_CHECK_CC
  22. #CXX_RPATH_CHECK
  23. #checkpoint
  24. AC_CACHE_SAVE
  25. # Speedup compile
  26. EGG_CHECK_CCWALL
  27. EGG_CHECK_CCPIPE
  28. CXX_FLAG_CHECK([CXXFLAGS], [-fcolor-diagnostics], [colordiagnostics])
  29. #CXX_FLAG_CHECK([CXXFLAGS], [-Qunused-arguments], [unusedarguments])
  30. CXX_FLAG_CHECK_NO([CXXFLAGS], [-Winvalid-source-encoding], [-Wno-invalid-source-encoding], [invalid_source_encoding])
  31. CXX_FLAG_CHECK_NO([CXXFLAGS], [-Wnarrowing], [-Wno-narrowing], [nonarrowing])
  32. CXX_FLAG_CHECK_NO([CXXFLAGS], [-Wcast-function-type], [-Wno-cast-function-type], [no_cast_function_type])
  33. CXX_FLAG_CHECK([CXXFLAGS], [-fstack-protector], [stackprotector])
  34. CXX_FLAG_CHECK([CXXFLAGS], [-fstack-protector-strong], [stackprotectorstrong])
  35. if [[ "${ax_cv_prog_cc_stackprotectorstrong}" = "yes" ]]; then
  36. LDFLAGS="${LDFLAGS} -fstack-protector-strong"
  37. elif [[ "${ax_cv_prog_cc_stackprotector}" = "yes" ]]; then
  38. LDFLAGS="${LDFLAGS} -fstack-protector"
  39. fi
  40. CXX_FLAG_CHECK([DEBCXXFLAGS], [-Og], [Og])
  41. if [[ "${ax_cv_prog_cc_Og}" = "no" ]]; then
  42. DEBCXXFLAGS="${DEBCXXFLAGS} -O0"
  43. fi
  44. CXX_FLAG_CHECK_LINK([DEBCXXFLAGS], [-fsanitize=address], [fsanitize_address])
  45. if [[ "${ax_cv_prog_cc_fsanitize_address}" = "yes" ]]; then
  46. DEBLDFLAGS="${DEBLDFLAGS} -fsanitize=address"
  47. fi
  48. CXX_FLAG_CHECK([DEBCXXFLAGS], [-fstack-protector-all], [stackprotectorall])
  49. CXX_FLAG_CHECK([DEBCXXFLAGS], [-Wconditional-uninitialized], [w_conditional_uninitialized])
  50. CXX_FLAG_CHECK([LDFLAGS], [-static-libstdc++], [static_libstdcxx])
  51. #CXX_FLAG_CHECK([LDFLAGS], [-static-libgcc], [static_libgcc])
  52. if [[ "${ax_cv_prog_cc_static_libstdcxx}" = "yes" ]]; then
  53. AC_MSG_CHECKING([for static libstdc++])
  54. AC_TRY_LINK([], [], [AC_MSG_RESULT(OK)],
  55. [
  56. AC_MSG_RESULT([not found.])
  57. AC_MSG_ERROR([Static libstdc++ is rquired to build.], 1)
  58. ]
  59. )
  60. fi
  61. EGG_CHECK_DEPMODE
  62. #checkpoint
  63. AC_CACHE_SAVE
  64. # Checks for programs
  65. AC_PROG_MAKE_SET
  66. AC_PROG_SED
  67. EGG_PROG_HEAD_1
  68. EGG_PROG_AWK
  69. EGG_PROG_BASENAME
  70. AC_CHECK_PROG(OBJCOPY, objcopy, [objcopy --remove-section=.note --remove-section=.comment], touch)
  71. AC_CHECK_PROG(STRIP, strip, strip, touch)
  72. AC_CHECK_PROG(DIFF, gdiff, gdiff, diff)
  73. AC_CHECK_PROG(UNAME, uname, uname)
  74. # Test the os and set the module linking settings
  75. EGG_CHECK_OS
  76. # Check for IPv6 support
  77. #EGG_IPV6_SUPPORTED
  78. EGG_IPV6_OPTIONS
  79. EGG_CHECK_SOCKLEN_T
  80. # Check for inconsistent random() functions
  81. EGG_CHECK_RANDOM_MAX
  82. # Create static binaries
  83. EGG_CHECK_CCSTATIC
  84. AC_SUBST(DEBCXXFLAGS)
  85. AC_SUBST(DEBLDFLAGS)
  86. #checkpoint
  87. AC_CACHE_SAVE
  88. # Checks for system libraries
  89. EGG_CHECK_LIBS
  90. CHECK_LIBELF
  91. # Checks for header files
  92. AC_HEADER_DIRENT
  93. AC_HEADER_SYS_WAIT
  94. AC_HEADER_TIME
  95. AC_HEADER_STAT
  96. #checkpoint
  97. AC_CACHE_SAVE
  98. AC_CHECK_HEADERS([stdarg.h arpa/inet.h fcntl.h limits.h locale.h netdb.h netinet/in.h])
  99. AC_CHECK_HEADERS([sys/file.h sys/ioctl.h sys/param.h sys/socket.h wchar.h])
  100. AC_CHECK_HEADERS([sys/ptrace.h paths.h sys/prctl.h sys/procctl.h])
  101. #checkpoint
  102. AC_CACHE_SAVE
  103. #AC_CHECK_HEADERS(openssl/ssl.h openssl/crypto.h)
  104. #AC_CHECK_HEADERS(zlib.h)
  105. CHECK_SSL
  106. # TCL checks
  107. # Tcl version to recommend if no Tcl is found, and the site where it can be
  108. # found for download.
  109. tclrecommendver="8.5.X"
  110. tclrecommendsite="ftp://tcl.activestate.com/pub/tcl/tcl8_5/"
  111. # Tcl library filename prefixes, suffixes, and search paths.
  112. tcllibnames="tcl8.6 tcl86 tcl8.5 tcl85 tcl8.4 tcl84 tcl8.3 tcl83 tcl8.2 tcl82 \
  113. tcl8.1 tcl81 tcl8.0 tcl80 tcl tcl7.6 tcl76 tcl7.5 tcl75 \
  114. tcl7.4 tcl74 tcl7.3 tcl73 tcl7.2 tcl72 tcl7.1 tcl71 \
  115. tcl7.0 tcl70"
  116. tcllibextensions=".so .so.1 .so.1.0 .so.1.1 .so.1.2 .dll .dylib .sl .a"
  117. tcllibpaths="$HOME/lib $HOME/tcl/lib \
  118. /usr/local/lib /usr/lib /lib /lib64 /usr/lib64 \
  119. /usr/local/lib/tcl8.6 /usr/lib/tcl8.6 \
  120. /usr/local/lib/tcl8.5 /usr/lib/tcl8.5 \
  121. /usr/local/lib/tcl8.4 /usr/lib/tcl8.4 \
  122. /usr/local/lib/tcl8.3 /usr/lib/tcl8.3 \
  123. /usr/local/pkgs/tcl/lib /sys/lib /usr/pkg/lib \
  124. /usr/i486-linuxaout/lib /beos/system/lib $HOME"
  125. # Tcl header filenames and search paths.
  126. tclheadernames="tcl.h"
  127. tclheaderpaths="$HOME/include $HOME/tcl/include \
  128. /usr/local/include /usr/include \
  129. /usr/local/include/tcl8.6 /usr/include/tcl8.6 \
  130. /usr/local/include/tcl8.5 /usr/include/tcl8.5 \
  131. /usr/local/include/tcl8.4 /usr/include/tcl8.4 \
  132. /usr/local/include/tcl8.3 /usr/include/tcl8.3 \
  133. /usr/local/pkgs/tcl/include /sys/include \
  134. /usr/pkg/lib /beos/system/include /beos/devel/include $HOME"
  135. # Misc Tcl checks.
  136. EGG_TCL_OPTIONS
  137. EGG_TCL_ENV
  138. EGG_TCL_WITH_TCLLIB
  139. EGG_TCL_WITH_TCLINC
  140. EGG_TCL_FIND_LIBRARY
  141. EGG_TCL_FIND_HEADER
  142. EGG_TCL_CHECK_LIBRARY
  143. EGG_TCL_CHECK_HEADER
  144. EGG_TCL_DETECT_CHANGE
  145. EGG_TCL_CHECK_VERSION
  146. EGG_TCL_CHECK_PRE70
  147. EGG_TCL_TESTLIBS
  148. EGG_TCL_CHECK_FREE
  149. #EGG_TCL_CHECK_GETCURRENTTHREAD
  150. #EGG_TCL_CHECK_GETTHREADDATA
  151. EGG_TCL_CHECK_SETNOTIFIER
  152. EGG_TCL_LIB_REQS
  153. AC_CACHE_SAVE
  154. # Checks for typedefs, structures, and compiler characteristics
  155. AC_TYPE_PID_T
  156. AC_TYPE_SIZE_T
  157. AC_TYPE_UID_T
  158. #AC_C_CONST
  159. AC_C_VOLATILE
  160. AC_C_BIGENDIAN(AC_DEFINE(B_ENDIAN, 1, [big endian]),AC_DEFINE(L_ENDIAN, 1, [little endian]))
  161. #AC_C_INLINE
  162. AC_C_CHAR_UNSIGNED
  163. #AC_C_STRINGIZE
  164. #AC_C_PROTOTYPES
  165. #checkpoint
  166. AC_CACHE_SAVE
  167. # Checks for typedefs, structures, and compiler characteristics
  168. AC_TYPE_PID_T
  169. AC_TYPE_SIZE_T
  170. AC_TYPE_UID_T
  171. AC_TYPE_LONG_LONG_INT
  172. AC_TYPE_INT8_T
  173. AC_TYPE_UINT8_T
  174. AC_TYPE_INT16_T
  175. AC_TYPE_UINT16_T
  176. AC_TYPE_INT32_T
  177. AC_TYPE_UINT32_T
  178. AC_TYPE_INT64_T
  179. AC_TYPE_UINT64_T
  180. AC_STRUCT_TIMEZONE
  181. AC_STRUCT_TM
  182. # Checks for library functions
  183. AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
  184. AC_FUNC_MMAP
  185. EGG_FUNC_TIMESPEC
  186. #checkpoint
  187. AC_CACHE_SAVE
  188. AC_CHECK_FUNCS([getrusage getpassphrase posix_madvise madvise])
  189. AC_CHECK_FUNCS([memmem random snprintf srandom gettime])
  190. #checkpoint
  191. AC_CACHE_SAVE
  192. AC_CHECK_FUNCS([vsnprintf prctl procctl closefrom])
  193. #autoscan suggested this....
  194. #These are recommended by autoscan, but no code supports it currently
  195. #AC_CHECK_FUNCS([alarm bzero dup2 getcwd gethostbyaddr gethostname getpass gettimeofday mbrlen
  196. #mkdir munmap realpath select setlocale socket strchr strerror strpbrk strrchr strstr strtol tzset])
  197. EGG_CHECK_FUNC_VSPRINTF
  198. EGG_CHECK_FUNC_UNAME
  199. # Make sure we have stdc headers, since we can't compile without them
  200. EGG_HEADER_STDC
  201. #checkpoint
  202. AC_CACHE_SAVE
  203. EGG_SUBST_VERSION
  204. #FIND_WRAPS
  205. DO_DEPS
  206. AC_CONFIG_FILES([Makefile lib/Makefile src/Makefile src/buildinfo.h])
  207. AH_TEMPLATE(HAVE_ST_MTIM, [Define to 1 if your struct stat has an st_mtim member])
  208. AH_TEMPLATE(HAVE_ST_MTIMESPEC, [Define to 1 if your struct stat has an st_mtimespec member])
  209. AH_TEMPLATE(HAVE_TIMESPEC, [Define to 1 if you have struct timespec in sys/time.h])
  210. AH_TEMPLATE(HAVE_TIMESPECSUB2, [Define to 1 if you have a timespecsub macro or function that takes two arguments (not three)])
  211. AH_BOTTOM([#include "config-sanity.h"])
  212. [
  213. GIT_REQUIRED=1
  214. if [ "$GIT_REQUIRED" = "1" ]; then
  215. if ! test -d .git; then
  216. echo ""
  217. echo ""
  218. echo "You have downloaded a GIT version of wraith."
  219. echo "Either 'git clone' from a git repository or download a source tarball"
  220. echo "A distribution version can be found at http://wraith.botpack.net/wiki/Download"
  221. echo ""
  222. echo ""
  223. exit 1
  224. fi
  225. fi
  226. ]
  227. [
  228. if test -d .git; then
  229. git submodule init
  230. git submodule update
  231. git submodule foreach --recursive git clean -fdx
  232. # Restore as it may have been removed by an older 'make distclean'
  233. if ! test -f src/response.h; then
  234. git checkout src/response.h
  235. fi
  236. fi
  237. ]
  238. export CC CXX
  239. if [[ -f lib/bdlib/configure ]]; then
  240. AC_CONFIG_SUBDIRS([lib/bdlib])
  241. fi
  242. if [[ -n "${LIBELF_BUNDLED}" ]] && [[ -f lib/libelf/configure ]]; then
  243. AC_CONFIG_SUBDIRS([lib/libelf])
  244. fi
  245. AC_OUTPUT
  246. CXX="$CXX" CXXFLAGS="$CXXFLAGS" TCL_INCLUDES="$TCL_INCLUDES" SSL_INCLUDES="$SSL_INCLUDES" \
  247. SED="$SED" src/generate_defs.sh || exit 1