configure.ac 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. dnl Process this File with autoconf to produce a configure script.
  2. AC_PREREQ([2.69])
  3. AC_INIT([gsocket],[1.4.42dev2])
  4. AC_CONFIG_AUX_DIR(config)
  5. AC_CANONICAL_TARGET
  6. dnl we use automake
  7. AM_INIT_AUTOMAKE([foreign])
  8. AC_CONFIG_HEADERS(config.h)
  9. AM_PROG_AR
  10. dnl for --enable-maintainer-mode fun use:
  11. dnl AM_MAINTAINER_MODE
  12. dnl AC_DISABLE_STATIC
  13. dnl LT_INIT([disable-static])
  14. dnl AC_CONFIG_MACRO_DIRS([m4])
  15. dnl Checks for programs.
  16. AC_PROG_CC
  17. AC_PROG_INSTALL
  18. AC_PROG_RANLIB
  19. AC_CHECK_PROG([MAKE_CHECK], [make], [yes], [no])
  20. AS_IF([test x$MAKE_CHECK = xno], [AC_MSG_ERROR([make not found])])
  21. dnl
  22. dnl Use these compiler flags if we have gcc.
  23. dnl
  24. if test $ac_cv_c_compiler_gnu = yes; then
  25. CCOPTS='-O2 -Wall'
  26. CFLAGS="$CCOPTS $CFLAGS"
  27. fi
  28. test "x$prefix" != "xNONE" || prefix="/usr/local"
  29. test "x$exec_prefix" != "xNONE" || exec_prefix="${prefix}"
  30. dnl Do "gcc -xc -E -v -" to figure out default paths
  31. dnl Scenarios
  32. dnl --prefix=$HOME/usr => -I$HOME/usr/include /usr/include /usr/local/include
  33. dnl --prefix=/usr --includedir=$HOME/usr/include => -I$HOME/usr/include /usr/include /usr/local/include
  34. dnl --prefix=/usr/local --includedir=$HOME/usr/include => -I$HOME/usr/include /usr/local/include /usr/include
  35. dnl default: PREFIX/include unless --includedir=
  36. dnl Try include paths (especially on OSX)
  37. dnl Special consideration if openssl/srp.h exist in $HOME/usr/include
  38. dnl and also the /usr/include/openssl exists. GCC shall use
  39. dnl $HOME/usr/include/openssl/srp.h first but not if $prefix is /usr or any
  40. dnl of the default system paths
  41. dnl To make everyone happy we have to consider:
  42. dnl --prefix=$HOME/usr => Must _first_ add $HOME/usr/include
  43. dnl --prefix=/usr => Must _never_ add /usr/include (or _last_)
  44. test "x$prefix" != "x/usr" && test "x$prefix" != "x/usr/local" && trydir_i="${prefix}/include"
  45. trydir_i="${trydir_i} /usr/local/opt/openssl/include /opt/homebrew/opt/openssl/include"
  46. for xincdir in $includedir $trydir_i ; do
  47. if test ! -d "$xincdir" ; then
  48. continue;
  49. fi
  50. if test x"${INCLUDES}" = x; then
  51. INCLUDES="-I${xincdir}";
  52. else
  53. INCLUDES="$INCLUDES -I${xincdir}";
  54. fi
  55. done
  56. CPPFLAGS="-I${srcdir}/../include ${INCLUDES} $CPPFLAGS"
  57. dnl Try library paths...
  58. test "x$prefix" != "x/usr" && test "x$prefix" != "x/usr/local" && trydir_l="${prefix}/lib"
  59. trydir_l="${trydir_l} /usr/local/opt/openssl/lib /opt/homebrew/opt/openssl/lib"
  60. for xlibdir in $libdir $trydir_l ; do
  61. if test ! -d "$xlibdir" ; then
  62. continue;
  63. fi
  64. if test -f "${xlibdir}/libssl.a"; then
  65. STATIC_LIBSSLDIR="${xlibdir}"
  66. fi
  67. if test x"${LIBDIR}" = x; then
  68. LIBDIR="-L${xlibdir}";
  69. else
  70. LIBDIR="$LIBDIR -L${xlibdir}";
  71. fi
  72. done
  73. LDFLAGS="${LIBDIR} $LDFLAGS"
  74. dnl default perm of .so is 644 but on cygwin must be 755.
  75. PERM_DSO="644"
  76. case "$host" in
  77. *-cygwin*)
  78. PERM_DSO="755"
  79. ;;
  80. mips-sony-bsd|mips-sony-newsos4)
  81. AC_DEFINE([NEED_SETPGRP], [1], [Need setpgrp to acquire controlling tty])
  82. ;;
  83. *-*-ultrix*)
  84. AC_DEFINE([NEED_SETPGRP], [1], [Need setpgrp to acquire controlling tty])
  85. ;;
  86. *-*-darwin*|*-*-*bsd*)
  87. AC_DEFINE([BSD_SCRIPT], [1], [/usr/bin/script is the bsd variant])
  88. if test x"$(which ar)" != x'/usr/bin/ar'; then
  89. ARDIRWARN=1
  90. fi
  91. ;;
  92. esac
  93. dnl debian packaging requires -soname for LD_PRELOAD libs
  94. dnl OSX's linker does not allow -soname.
  95. SONAME_GSOCKET_DSO="-Wl,-soname=gsocket_dso.so.0"
  96. SONAME_GSOCKET_UCHROOT_DSO="-Wl,-soname=gsocket_uchroot_dso.so.0"
  97. case "$host" in
  98. *-*-darwin*)
  99. SONAME_GSOCKET_DSO=""
  100. SONAME_GSOCKET_UCHROOT_DSO=""
  101. ;;
  102. esac
  103. dnl Checks for header files.
  104. AC_HEADER_SYS_WAIT
  105. AC_CHECK_HEADERS(sys/time.h sys/endian.h sys/param.h unistd.h fnmatch.h string.h utmp.h utmpx.h pty.h openssl/srp.h util.h libutil.h netinet/in_systm.h sys/loadavg.h libproc.h wordexp.h)
  106. AC_CHECK_HEADER(openssl/srp.h, [], [AC_MSG_ERROR([openssl/srp.h not found. Update OpenSSL or apt install libssl-dev?])])
  107. dnl Checks for typedefs, structures, and compiler characteristics.
  108. AC_C_CONST
  109. AC_TYPE_PID_T
  110. dnl Checks for library functions.
  111. AC_FUNC_MEMCMP
  112. dnl If size_t is not defined, define size_t to be unsigned.
  113. AC_TYPE_SIZE_T
  114. dnl If uid_t is not defined, define uid_t to be int and gid_t to be int.
  115. AC_TYPE_UID_T
  116. AC_ARG_ENABLE(static,
  117. [ --enable-static Compile static binary],
  118. [STATIC="yes"], [STATIC="no"]
  119. )
  120. dnl OSX does not support static binaries.
  121. dnl At least staticly include OpenSSL libs
  122. if test x"${STATIC}" = xyes; then
  123. case "$host" in
  124. *-*-darwin*)
  125. LDADD_STATIC="${STATIC_LIBSSLDIR}/libssl.a ${STATIC_LIBSSLDIR}/libcrypto.a"
  126. AC_DEFINE(HAVE_LIBSSL, 1, [Define to 1 if you have the `ssl' library (-lssl)])
  127. AC_DEFINE(HAVE_LIBCRYPTO, 1, [Define to 1 if you have the `crypto' library (-lcrypto)])
  128. STATIC_SSL="yes"
  129. ;;
  130. *)
  131. CFLAGS_STATIC="-static "
  132. ;;
  133. esac
  134. fi
  135. AC_CHECK_LIB(util, forkpty)
  136. AC_CHECK_LIB(socket, socket)
  137. if test x"${STATIC}" = xno; then
  138. AC_CHECK_LIB(nsl, gethostbyname)
  139. fi
  140. dnl AC_CHECK_LIB([net], [libnet_name_resolve], [AC_MSG_ERROR([libnet 1.0.x found. Requires libnet 1.1 or newer])])
  141. dnl AC_CHECK_LIB([net], [libnet_init], ,[AC_MSG_ERROR([libnet 1.1.x not found])])
  142. if test x"$STATIC" = xno; then
  143. AC_CHECK_LIB(dl, dlopen)
  144. fi
  145. AC_CHECK_LIB(dl, dlopen, LDADD_LIBDL="-ldl")
  146. AC_CHECK_LIB(procstat, procstat_close)
  147. dnl
  148. if test x"$STATIC_SSL" != xyes; then
  149. AC_CHECK_LIB([crypto], [ENGINE_init], [], [AC_MSG_ERROR([libcrypto not found])])
  150. AC_CHECK_LIB([ssl], [SRP_VBASE_get1_by_user], [], [AC_MSG_ERROR([SRP not supported. Please upgrade OpenSSL lib])])
  151. fi
  152. AC_CHECK_FUNCS(gettimeofday memcpy strchr strlcat forkpty openpty getline stat64 open64 statvfs64 accept4 connectx)
  153. AC_ARG_ENABLE([31337],
  154. AS_HELP_STRING([--enable-31337], [Enable experimental features.]),
  155. AC_DEFINE(D31337, 1, [Expermental feature])
  156. )
  157. AC_ARG_ENABLE([stealth],
  158. AS_HELP_STRING([--enable-stealth], [Stip -h and -m strings.]),
  159. AC_DEFINE(STEALTH, 1, [Stealth Mode])
  160. )
  161. AC_ARG_ENABLE([debug],
  162. AS_HELP_STRING([--enable-debug], [Enable debug information.]),
  163. [debug=true AC_DEFINE(DEBUG, 1, [Debug infos])]
  164. )
  165. AC_ARG_ENABLE([tests],
  166. AS_HELP_STRING([--enable-tests], [Enable self-tests.]),
  167. [selftests=true]
  168. )
  169. AS_IF([test x$enable_debug = xyes], AC_DEFINE(D31337, 1, [Expermental feature]))
  170. AS_IF([test x$enable_debug = xyes], [selftests=true])
  171. AS_IF([test x$selftests = xtrue], AC_DEFINE(SELFTESTS, 1, [Self Tests]))
  172. AC_ARG_ENABLE(dist,
  173. [ --enable-dist Enable distribution mode, Use own libraries.],
  174. [DIST="yes"], [DIST="no"]
  175. )
  176. AC_ARG_ENABLE(realprefix,
  177. [ --enable-realprefix Set real prefix (for dpkg packaging)],
  178. [REALPREFIX="${enableval}"], [REALPREFIX="${prefix}"]
  179. )
  180. AS_IF([test x$selftests = xtrue], AC_SUBST(PROGRAMS_TEST_LIB, "list-test${EXEEXT} event-test${EXEEXT}"))
  181. AS_IF([test x$selftests = xtrue], AC_SUBST(PROGRAMS_TEST_TOOLS, "packet-test${EXEEXT} readline-test${EXEEXT} console_display-test${EXEEXT} filetransfer-test${EXEEXT}"))
  182. AC_SUBST(LDADD_STATIC, "${LDADD_STATIC}")
  183. AC_SUBST(LDADD_LIBDL, "${LDADD_LIBDL}")
  184. AC_SUBST(CFLAGS_STATIC, "${CFLAGS_STATIC}")
  185. AC_SUBST(PERM_DSO, "${PERM_DSO}")
  186. AC_SUBST(SONAME_GSOCKET_DSO, "${SONAME_GSOCKET_DSO}")
  187. AC_SUBST(SONAME_GSOCKET_UCHROOT_DSO, "${SONAME_GSOCKET_UCHROOT_DSO}")
  188. AC_SUBST(REALPREFIX, "${REALPREFIX}")
  189. AC_CONFIG_FILES([Makefile lib/Makefile tools/Makefile include/Makefile include/gsocket/Makefile tools/gsocket.conf man/Makefile examples/Makefile])
  190. AC_OUTPUT
  191. echo "
  192. \"If netcat is a swiss army knife then
  193. gs-netcat is a germanic battle axe\"
  194. --acpizer/United Cracking Force
  195. "
  196. if test x"${STATIC}" = xyes; then
  197. case "$host" in
  198. *-*-darwin*)
  199. echo "
  200. *** OSX does not support static binaries. Creating dynamic binaries ***
  201. *** instead and trying our best to included OpenSSL statically. ***
  202. "
  203. ;;
  204. *)
  205. echo "
  206. ********************************** WARNING ***********************************
  207. * Your MUST compile OpenSSL like this: *
  208. * openssl-src> *
  209. * ./Configure --prefix=\$HOME/usr no-dso no-threads no-shared linux-generic64 *
  210. * mkdir -p \$HOME/usr && make install_sw *
  211. * Only then compile gsocket \(using the same --prefix=\): *
  212. * gsocket-src> ./configure --prefix=\$HOME/usr --enable-static *
  213. * gsocket-src> make all install *
  214. * gsocket-src> export PATH=\$HOME/usr/bin:\$PATH *
  215. ******************************************************************************
  216. "
  217. ;;
  218. esac
  219. fi
  220. echo "
  221. ${PACKAGE_NAME}-${PACKAGE_VERSION} has been configured:
  222. Host..............: ${host}
  223. Prefix............: ${prefix}
  224. Compiler..........: ${CC}
  225. Compiler flags....: ${CFLAGS_STATIC}${CFLAGS}
  226. Preprocessor flags: ${CPPFLAGS}
  227. Linker flags......: ${LDFLAGS}
  228. Libraries.........: ${LIBS}
  229. Configuration complete. Now type: make all install"
  230. if test x"${ARDIRWARN}" = x1; then
  231. AC_MSG_WARN([Build tools seem to be a mix of GNU and Apple.])
  232. AC_MSG_WARN([Alex, try 'PATH=/usr/bin:\$PATH ./configure'.])
  233. fi