| 1 |
# -*- Autoconf -*- |
|---|
| 2 |
# Process this file with autoconf to produce a configure script. |
|---|
| 3 |
|
|---|
| 4 |
AC_PREREQ(2.56) |
|---|
| 5 |
AC_INIT(hydranode, 0.1.1, madcat@hydranode.com) |
|---|
| 6 |
AC_CANONICAL_TARGET |
|---|
| 7 |
AM_INIT_AUTOMAKE(hydranode, 0.1.1) |
|---|
| 8 |
AC_CONFIG_SRCDIR([src/hydranode.cpp]) |
|---|
| 9 |
AM_CONFIG_HEADER([config.h]) |
|---|
| 10 |
|
|---|
| 11 |
with_pic="no"; |
|---|
| 12 |
|
|---|
| 13 |
CXXFLAGS=`echo $CXXFLAGS | sed s/-O2//`; # Gets rid of default -O2 |
|---|
| 14 |
|
|---|
| 15 |
# Enable all default warnings |
|---|
| 16 |
CXXFLAGS="$CXXFLAGS -W -Wall -Wno-return-type -Wno-long-long -Wpointer-arith -pedantic" |
|---|
| 17 |
|
|---|
| 18 |
# 64-bit file I/O please |
|---|
| 19 |
CPPFLAGS="$CPPFLAGS -D_LARGE_FILES -D_FILE_OFFSET_BITS=64" |
|---|
| 20 |
|
|---|
| 21 |
# Checks for programs. |
|---|
| 22 |
AC_PROG_CXX |
|---|
| 23 |
AC_PROG_MAKE_SET |
|---|
| 24 |
AC_DISABLE_STATIC |
|---|
| 25 |
AC_PROG_LIBTOOL |
|---|
| 26 |
AC_LANG(C++) |
|---|
| 27 |
AC_PREFIX_DEFAULT(/opt/hydranode) |
|---|
| 28 |
_AC_SRCPATHS(["."]) |
|---|
| 29 |
|
|---|
| 30 |
AC_MSG_CHECKING([compiler version]) |
|---|
| 31 |
AC_PREPROC_IFELSE( |
|---|
| 32 |
[AC_LANG_PROGRAM([[#if !defined __GNUC__ |
|---|
| 33 |
#error Not GNU compiler |
|---|
| 34 |
#elif __GNUC__ < 3 |
|---|
| 35 |
#error Need GCC 3 or newer |
|---|
| 36 |
#elif __GNUC__ == 3 && __GNUC_MINOR__ < 2 |
|---|
| 37 |
#error Need GCC 3.2 or newer, found __GNUC__ __GNU__MINOR__ |
|---|
| 38 |
#endif ]])], |
|---|
| 39 |
[AC_MSG_RESULT([ok])], |
|---|
| 40 |
[AC_MSG_FAILURE([hydranode requires g++ 3.2 or newer])]) |
|---|
| 41 |
|
|---|
| 42 |
trace_dflt="yes" |
|---|
| 43 |
|
|---|
| 44 |
AC_ARG_ENABLE(,,) |
|---|
| 45 |
AC_ARG_ENABLE(, [Customization:],) |
|---|
| 46 |
AC_ARG_ENABLE(debug, |
|---|
| 47 |
[ --enable-debug Enable code debugging [[default=yes]] ], |
|---|
| 48 |
debug="$enableval", debug="yes" ) |
|---|
| 49 |
AC_ARG_ENABLE(trace, |
|---|
| 50 |
[ --enable-trace Enable trace logging [[default=no ]] ], |
|---|
| 51 |
[trace="$enableval" && trace_dflt="no"], trace="no" ) |
|---|
| 52 |
AC_ARG_ENABLE(optimize, |
|---|
| 53 |
[ --enable-optimize Enable code optimizations [[default=no ]] ], |
|---|
| 54 |
optimize="$enableval", optimize="no") |
|---|
| 55 |
AC_ARG_ENABLE(some_optimize, |
|---|
| 56 |
[ --enable-some_optimize Enable some optimizations [[default=no ]] ], |
|---|
| 57 |
some_optimize="$enableval", some_optimize="no") |
|---|
| 58 |
AC_ARG_ENABLE(colors, |
|---|
| 59 |
[ --enable-colors Enable coloured output [[default=yes]] ], |
|---|
| 60 |
colors="$enableval", colors="yes" ) |
|---|
| 61 |
AC_ARG_ENABLE(profile, |
|---|
| 62 |
[ --enable-profile Enable code profiling [[default=no ]] ], |
|---|
| 63 |
profile="$enableval", profile="no" ) |
|---|
| 64 |
AC_ARG_ENABLE(hexdumps, |
|---|
| 65 |
[ --enable-hexdumps Enable packet hexdumps [[default=no ]] ], |
|---|
| 66 |
hexdumps="$enableval", hexdumps="no") |
|---|
| 67 |
AC_ARG_WITH(builtin_boost, |
|---|
| 68 |
[ --with-builtin_boost Use built-in Boost library [[default=no]]], |
|---|
| 69 |
[builtin_boost=$withval], [builtin_boost=false] |
|---|
| 70 |
) |
|---|
| 71 |
dnl This is here and not in boost.m4 'cos otherwise it breaks when both |
|---|
| 72 |
dnl builtin_boost and with-boost args are specified. |
|---|
| 73 |
AC_ARG_WITH(boost, |
|---|
| 74 |
AC_HELP_STRING( |
|---|
| 75 |
[--with-boost=PATH], |
|---|
| 76 |
[Absolute path name where the Boost C++ libraries reside]), |
|---|
| 77 |
[BOOST_ROOT=$withval], [BOOST_ROOT="/usr"] |
|---|
| 78 |
) |
|---|
| 79 |
|
|---|
| 80 |
AC_ARG_WITH(builtin, |
|---|
| 81 |
[ --with-builtin=MODULES Modules that shall be built-in ], |
|---|
| 82 |
builtin="$builtin $withval", builtin="") |
|---|
| 83 |
AC_ARG_ENABLE(static, |
|---|
| 84 |
[ --enable-static Enable static linking [[default=no ]] ], |
|---|
| 85 |
static="$enableval", static="no") |
|---|
| 86 |
|
|---|
| 87 |
AC_MSG_CHECKING([for --enable-optimize]) |
|---|
| 88 |
AC_MSG_RESULT($optimize) |
|---|
| 89 |
if test $optimize == yes; then CPPFLAGS="$CPPFLAGS -O3"; fi; |
|---|
| 90 |
|
|---|
| 91 |
AC_MSG_CHECKING([for --enable-some_optimize]) |
|---|
| 92 |
AC_MSG_RESULT($some_optimize) |
|---|
| 93 |
if test $some_optimize == yes; then CPPFLAGS="$CPPFLAGS -O0"; fi |
|---|
| 94 |
|
|---|
| 95 |
AC_MSG_CHECKING([for --enable-debug]) |
|---|
| 96 |
AC_MSG_RESULT([$debug]) |
|---|
| 97 |
if test $debug == yes; then |
|---|
| 98 |
CXXFLAGS="$CXXFLAGS -g -ggdb"; |
|---|
| 99 |
else |
|---|
| 100 |
CXXFLAGS="$CXXFLAGS -DNDEBUG"; |
|---|
| 101 |
fi |
|---|
| 102 |
|
|---|
| 103 |
AC_MSG_CHECKING([for --enable-trace]) |
|---|
| 104 |
AC_MSG_RESULT([$trace]) |
|---|
| 105 |
if test $trace == no; then CXXFLAGS="$CXXFLAGS -DNTRACE"; fi |
|---|
| 106 |
|
|---|
| 107 |
AC_MSG_CHECKING([for --enable-profile]) |
|---|
| 108 |
AC_MSG_RESULT($profile) |
|---|
| 109 |
if test $profile == yes; then CXXFLAGS="$CXXFLAGS -p -pg"; fi |
|---|
| 110 |
|
|---|
| 111 |
AC_MSG_CHECKING([for --enable-colors]) |
|---|
| 112 |
AC_MSG_RESULT($colors) |
|---|
| 113 |
if test $colors == yes; then |
|---|
| 114 |
AC_DEFINE([__ANSI_COLORS__], [], [Define if you want coloured runtime output]) |
|---|
| 115 |
fi |
|---|
| 116 |
|
|---|
| 117 |
AC_MSG_CHECKING([for --enable-static]) |
|---|
| 118 |
AC_MSG_RESULT($static) |
|---|
| 119 |
if test $static == yes; then |
|---|
| 120 |
LDFLAGS="$LDFLAGS -static"; |
|---|
| 121 |
AC_DEFINE([STATIC_BUILD], [], [Define when making a static build]) |
|---|
| 122 |
fi |
|---|
| 123 |
|
|---|
| 124 |
AC_MSG_CHECKING([for --enable-hexdumps]) |
|---|
| 125 |
AC_MSG_RESULT($hexdumps) |
|---|
| 126 |
if test $hexdumps == yes; then |
|---|
| 127 |
AC_DEFINE([HEXDUMPS], [], [Define to get packet hexdumps]) |
|---|
| 128 |
fi |
|---|
| 129 |
|
|---|
| 130 |
AM_CONDITIONAL([STATIC_BUILD], test x$static = xyes) |
|---|
| 131 |
|
|---|
| 132 |
dnl Check Boost C++ libs |
|---|
| 133 |
if test x$builtin_boost != xyes; then |
|---|
| 134 |
RS_BOOST([1.32.0],[],[AC_MSG_ERROR(Boost C++ libraries not found)]) |
|---|
| 135 |
fi |
|---|
| 136 |
if test x$builtin_boost != xyes; then |
|---|
| 137 |
RS_BOOST_THREAD([], [builtin_boost=yes]) |
|---|
| 138 |
RS_BOOST_DATETIME([], [builtin_boost=yes]) |
|---|
| 139 |
RS_BOOST_SIGNALS([], [builtin_boost=yes]) |
|---|
| 140 |
RS_BOOST_FILESYSTEM([], [builtin_boost=yes]) |
|---|
| 141 |
RS_BOOST_PROGRAM_OPTIONS([], [builtin_boost=yes]) |
|---|
| 142 |
fi |
|---|
| 143 |
if test -z $BOOST_ROOT || test $BOOST_ROOT = "/usr"; then |
|---|
| 144 |
boost_path="$HOME/boost_1_32_0"; |
|---|
| 145 |
else |
|---|
| 146 |
boost_path=$BOOST_ROOT |
|---|
| 147 |
fi |
|---|
| 148 |
if test x$builtin_boost = xyes; then |
|---|
| 149 |
BOOST_CPPFLAGS="-I$boost_path" |
|---|
| 150 |
fi |
|---|
| 151 |
|
|---|
| 152 |
AM_CONDITIONAL(BUILTIN_BOOST, test x$builtin_boost = xyes) |
|---|
| 153 |
AC_SUBST(boost_path, $boost_path) |
|---|
| 154 |
|
|---|
| 155 |
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" |
|---|
| 156 |
LDFLAGS="$LDFLAGS $BOOST_LIBS_R"; |
|---|
| 157 |
|
|---|
| 158 |
dnl Checks for libraries. |
|---|
| 159 |
case $target_os in |
|---|
| 160 |
*bsd*) |
|---|
| 161 |
AC_CHECK_LIB([c], [dlopen], [LIBS="-lc"; |
|---|
| 162 |
AC_DEFINE(HAVE_LIBDL, 1, Define if you have libdl)]) |
|---|
| 163 |
;; |
|---|
| 164 |
*) |
|---|
| 165 |
AC_CHECK_LIB([dl], [dlopen], [LIBS="-ldl"; |
|---|
| 166 |
AC_DEFINE(HAVE_LIBDL, 1, Define if you have libdl)]) |
|---|
| 167 |
;; |
|---|
| 168 |
esac |
|---|
| 169 |
dnl AC_CHECK_LIB([pthread], [pthread_create]) |
|---|
| 170 |
AC_CHECK_LIB([z], [compress2], [], [ |
|---|
| 171 |
builtin_modules="$builtin_modules ../zlib/built-in.o" |
|---|
| 172 |
builtin_dirs="$builtin_dirs ../zlib" |
|---|
| 173 |
builtin_zlib=true |
|---|
| 174 |
CPPFLAGS="$CPPFLAGS -I$ac_abs_top_srcdir/zlib" |
|---|
| 175 |
]) |
|---|
| 176 |
|
|---|
| 177 |
# Checks for header files. |
|---|
| 178 |
AC_CHECK_HEADERS([stdint.h inttypes.h]) |
|---|
| 179 |
AC_CHECK_HEADERS([arpa/inet.h fcntl.h netinet/in.h sys/socket.h sys/time.h sys/timeb.h]) |
|---|
| 180 |
AC_CHECK_HEADERS([signal.h execinfo.h]) |
|---|
| 181 |
AC_CHECK_HEADERS([byteswap.h libkern/OSByteOrder.h]) |
|---|
| 182 |
|
|---|
| 183 |
# Checks for library functions. |
|---|
| 184 |
AC_CHECK_FUNCS([gettimeofday ftime memset sigaction setsid fork]) |
|---|
| 185 |
|
|---|
| 186 |
AC_SUBST(module_cpp, "-D__MODULE__") |
|---|
| 187 |
|
|---|
| 188 |
# Adjust compiler/linker flags as neccesery for platform |
|---|
| 189 |
case $target_os in |
|---|
| 190 |
darwin*) |
|---|
| 191 |
CPPFLAGS="$CPPFLAGS -D__MAC__ -Wno-long-double" |
|---|
| 192 |
LDFLAGS="$LDFLAGS -framework Carbon" |
|---|
| 193 |
AC_SUBST(core_ld, "$LIBS") |
|---|
| 194 |
AC_SUBST(module_ld, "-bundle -bundle_loader $ac_abs_top_builddir/src/hydranode") |
|---|
| 195 |
;; |
|---|
| 196 |
mingw32* | cygwin) |
|---|
| 197 |
CPPFLAGS="$CPPFLAGS -mthreads -DBOOST_THREAD_BUILD_LIB" |
|---|
| 198 |
LDFLAGS="$LDFLAGS" |
|---|
| 199 |
AC_SUBST(core_ld, "/mingw/lib/libws2_32.a") |
|---|
| 200 |
;; |
|---|
| 201 |
linux* | *bsd*) |
|---|
| 202 |
CPPFLAGS="$CPPFLAGS -pthread" |
|---|
| 203 |
LDFLAGS="$LDFLAGS $LIBS -lpthread"; |
|---|
| 204 |
if test $static != yes; then |
|---|
| 205 |
core_ldflags="$core_ldflags -rdynamic"; |
|---|
| 206 |
fi |
|---|
| 207 |
AC_SUBST(core_ld, $core_ldflags) |
|---|
| 208 |
AC_SUBST(module_ld, "-shared") |
|---|
| 209 |
;; |
|---|
| 210 |
solaris*) |
|---|
| 211 |
CPPFLAGS="$CPPFLAGS -pthreads" |
|---|
| 212 |
LDFLAGS="$LDFLAGS -pthreads" |
|---|
| 213 |
core_ldflags="$LIBS -lsocket -lrt -lnsl" |
|---|
| 214 |
if test x$with_gnu_ld = xtrue; then |
|---|
| 215 |
core_ldflags="$core_ldflags -Wl,-export-dynamic"; |
|---|
| 216 |
fi |
|---|
| 217 |
AC_SUBST(core_ld, $core_ldflags) |
|---|
| 218 |
AC_SUBST(module_cpp, "-fPIC") |
|---|
| 219 |
AC_SUBST(module_ld, "-shared") |
|---|
| 220 |
;; |
|---|
| 221 |
*) |
|---|
| 222 |
AC_MSG_ERROR([Unsupported platform $target_os, please report this.]) |
|---|
| 223 |
;; |
|---|
| 224 |
esac |
|---|
| 225 |
|
|---|
| 226 |
build_modules="ed2k hnsh" # Default modules |
|---|
| 227 |
case $with_ed2k in no) build_modules=`echo $build_modules | sed s/ed2k//`;; esac |
|---|
| 228 |
case $with_hnsh in no) build_modules=`echo $build_modules | sed s/hnsh//`;; esac |
|---|
| 229 |
case $with_minimal in yes) build_modules="$build_modules minimal";; esac |
|---|
| 230 |
case $with_ftp in yes) build_modules="$build_modules ftp";; esac |
|---|
| 231 |
case $with_dc in yes) build_modules="$build_modules dc";; esac |
|---|
| 232 |
case $with_http in yes) build_modules="$build_modules http";; esac |
|---|
| 233 |
case $with_cgcomm in yes) build_modules="$build_modules cgcomm";; esac |
|---|
| 234 |
case $with_mailnotify in yes) build_modules="$build_modules mailnotify";; esac |
|---|
| 235 |
|
|---|
| 236 |
builtin=`echo $builtin | sed 's/,/\ /'` # Replace commas with spaces |
|---|
| 237 |
for i in $builtin; do |
|---|
| 238 |
builtin_modules="$builtin_modules $ac_abs_top_builddir/modules/$i/built-in.o"; |
|---|
| 239 |
builtin_dirs="$builtin_dirs $ac_abs_top_builddir/modules/$i"; |
|---|
| 240 |
|
|---|
| 241 |
# If built-in, don't build dynamic version anymore |
|---|
| 242 |
build_modules=`echo $build_modules | sed s/$i//` |
|---|
| 243 |
|
|---|
| 244 |
case $i in |
|---|
| 245 |
ed2k) AC_SUBST(ed2k_cpp, [-DBUILT_IN]);; |
|---|
| 246 |
hnsh) AC_SUBST(hnsh_cpp, [-DBUILT_IN]);; |
|---|
| 247 |
minimal) AC_SUBST(minimal_cpp, [-DBUILT_IN]);; |
|---|
| 248 |
ftp) AC_SUBST(ftp_cpp, [-DBUILT_IN]);; |
|---|
| 249 |
dc) AC_SUBST(dc_cpp, [-DBUILT_IN]);; |
|---|
| 250 |
cgcomm) AC_SUBST(cgcomm_cpp, [-DBUILT_IN]);; |
|---|
| 251 |
http) AC_SUBST(http_cpp, [-DBUILT_IN]);; |
|---|
| 252 |
mailnotify) AC_SUBST(mailnotify_cpp, [-DBUILT_IN]);; |
|---|
| 253 |
esac |
|---|
| 254 |
builtin_flag=built-in.o |
|---|
| 255 |
done; |
|---|
| 256 |
builtin_modules_names=$builtin # Cache it here before it gets overwritten |
|---|
| 257 |
|
|---|
| 258 |
AC_SUBST(build_modules, $build_modules) |
|---|
| 259 |
AC_SUBST(builtin_modules, $builtin_modules) |
|---|
| 260 |
AC_SUBST(builtin_module_dirs, $builtin_dirs) |
|---|
| 261 |
AC_SUBST(builtin, $builtin_flag) |
|---|
| 262 |
|
|---|
| 263 |
test "x$prefix" = xNONE && prefix=$ac_default_prefix |
|---|
| 264 |
AC_DEFINE_UNQUOTED([MODULE_DIR], "$prefix/lib", [Path to modules]) |
|---|
| 265 |
|
|---|
| 266 |
# Due to the design of Autoconf, all modules must be listed here, as well as |
|---|
| 267 |
# in modules/Makefile.am, under EXTRA_SUBDIRS |
|---|
| 268 |
AC_CONFIG_FILES([Makefile |
|---|
| 269 |
modules/Makefile |
|---|
| 270 |
modules/ed2k/Makefile |
|---|
| 271 |
modules/hnsh/Makefile |
|---|
| 272 |
modules/minimal/Makefile |
|---|
| 273 |
modules/mailnotify/Makefile |
|---|
| 274 |
zlib/Makefile |
|---|
| 275 |
src/Makefile |
|---|
| 276 |
tests/Makefile |
|---|
| 277 |
tests/test-workthread/Makefile |
|---|
| 278 |
tests/test-range/Makefile |
|---|
| 279 |
tests/test-ipfilter/Makefile |
|---|
| 280 |
tests/test-partdata/Makefile |
|---|
| 281 |
tests/test-hasher/Makefile |
|---|
| 282 |
tests/test-hash/Makefile |
|---|
| 283 |
tests/test-config/Makefile |
|---|
| 284 |
tests/test-metadata/Makefile |
|---|
| 285 |
]) |
|---|
| 286 |
AC_OUTPUT |
|---|
| 287 |
|
|---|
| 288 |
echo |
|---|
| 289 |
echo "Configured Hydranode $VERSION for \`$target'" |
|---|
| 290 |
echo |
|---|
| 291 |
echo -e " Should optimizations be enabled? $optimize" |
|---|
| 292 |
echo -e " Should debugging be enabled? $debug" |
|---|
| 293 |
echo -e " Should trace code be enabled? $trace" |
|---|
| 294 |
echo -e " Which dynamic modules should be built? $build_modules" |
|---|
| 295 |
echo -e " Which modules should be built-in? $builtin_modules_names" |
|---|
| 296 |
echo -e " Which libraries should be used?" |
|---|
| 297 |
if test x$builtin_boost = xyes; then |
|---|
| 298 |
echo -e " Boost (built-in)" |
|---|
| 299 |
else |
|---|
| 300 |
echo -e " Boost (system)" |
|---|
| 301 |
fi |
|---|
| 302 |
if test x$builtin_zlib = xtrue; then |
|---|
| 303 |
echo -e " Zlib (built-in)" |
|---|
| 304 |
else |
|---|
| 305 |
echo -e " Zlib (system)" |
|---|
| 306 |
fi |
|---|
| 307 |
|
|---|
| 308 |
if test x$builtin_boost = xyes; then |
|---|
| 309 |
if ! test -d $boost_path ; then |
|---|
| 310 |
echo "" |
|---|
| 311 |
echo "ERROR: Boost libraries not detected on system." |
|---|
| 312 |
echo "ERROR: Boost libraries source not found at '$boost_path'." |
|---|
| 313 |
echo -n "Unable to continue; " |
|---|
| 314 |
echo "Boost libraries are available from http://www.boost.org/." |
|---|
| 315 |
echo "" |
|---|
| 316 |
exit 1; |
|---|
| 317 |
else |
|---|
| 318 |
echo " Where are Boost library sources? $boost_path" |
|---|
| 319 |
fi |
|---|
| 320 |
fi |
|---|
| 321 |
echo |
|---|