1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374
|
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.58)
dnl OK, autoconf stuff first
AC_INIT(dancer-ircd, 1.0.36, asuffield@suffields.me.uk)
AC_COPYRIGHT([Copyright Andrew Suffield <asuffield@suffields.me.uk>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
See README.license for more details])
dnl Define where to find the input files
dnl This one should be pretty unique (the files in main/ are fairly generic)
AC_CONFIG_SRCDIR(include/config.h.fn)
AC_CONFIG_AUX_DIR(build-misc)
AC_CONFIG_MACRO_DIR(autoconf)
dnl Find the canonical names right away
AC_CANONICAL_HOST
dnl Now the automake init bit
AM_INIT_AUTOMAKE(1.8)
AM_MAINTAINER_MODE
AC_CONFIG_HEADERS(include/setup.h)
orig_CFLAGS="$CFLAGS"
dnl Checks for programs.
AC_PROG_CC
AC_ISC_POSIX
AC_PROG_INSTALL
debug_syms=""
AC_ARG_ENABLE(debug-syms,
[ --disable-debug-syms Do not include debug symbols in executables ],
[if test "$enableval" = "yes"
then
debug_syms='-g3 '
fi], debug_syms='-g3 ')
AC_ARG_ENABLE(tc-syms,
[ --enable-tc-syms Enable test coverage data ],
[if test "$enableval" = "yes"
then
debug_syms="${debug_syms}-ftest-coverage -fprofile-arcs "
fi])
AC_ARG_ENABLE(profile,
[ --enable-profile Enable profiling data ],
[if test "$enableval" = "yes"
then
debug_syms="${debug_syms}-pg "
fi])
AC_MSG_CHECKING(for suitable optimisation flags)
AC_ARG_ENABLE(optimise,
[ --enable-optimise Enable optimisation ],
[if test "$enableval" = "yes"
then
if test "$GCC" = "yes"
then
optimise='-Os '
else
optimise='-O '
fi
else
if test "$GCC" = "yes"
then
optimise='-O0 '
else
optimise=''
fi
fi],[
if test -f "$srcdir/development"
then
if test "$GCC" = "yes"
then
optimise='-O0 '
else
optimise=''
fi
else
if test "$GCC" = "yes"
then
optimise='-O2 '
else
optimise='-O '
fi
fi
])
if test -z "${optimise}"
then
AC_MSG_RESULT(none)
else
AC_MSG_RESULT(${optimise})
fi
# Have to run this one after PROG_CC, because it uses CHECK_LIB and we
# want to pass arguments to PROG_CC
AC_ARG_ENABLE(profile-libc,
[ --enable-profile-libc Try to link with profiling libc ],
[if test "$enableval" = "yes"
then
AC_CHECK_LIB(c_p, open)
fi])
dnl This is the list of all system headers that are included in dancer. If libc can
dnl compile with all these included and errors on, then it is considered to be safe
dnl to use errors
AC_MSG_CHECKING([for system headers used])
dancer_headers_used=`(find ${srcdir}/src -name '*.c'; find ${srcdir}/include -name '*.h') | xargs grep -r -h '^\# *include <' | sed 's/>.*/>/' | sed 's/\# */\#/' | sed 's/include *</include </' | sort | uniq`
count_dancer_headers_used=`printf "$dancer_headers_used" | wc -l | sed -e 's/^ *//'`
AC_MSG_RESULT([found $count_dancer_headers_used])
dnl OK, get the simple list to check for existance
dancer_headers_list=`printf "$dancer_headers_used" | sed 's/\#include <\(.*\)>/\1/'`
AC_CHECK_HEADERS($dancer_headers_list)
dnl Now compose the working list of guarded headers...
dancer_headers_guarded=`printf "$dancer_headers_list\n" | sed "h;y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%;s/\(.*\)/\#ifdef HAVE_\1/;x;s/\(.*\)/\#include <\1>/;x;G;a\\\\
\#endif
"`
dnl Checks for libraries.
AC_CHECK_LIB(z, inflate)
dnl Replace `main' with a function in -lnsl:
AC_CHECK_LIB(nsl, gethostbyname)
AC_CHECK_FUNC(res_mkquery,, AC_CHECK_LIB(resolv, res_mkquery,, AC_CHECK_LIB(resolv, __res_mkquery)))
dnl Pop quiz: what systems is this used on? Does dancer build on any of them?
AC_CHECK_LIB(socket, socket)
dnl Checks for header files.
AC_HEADER_STDC
dnl Check for stdarg.h - if we can't find it, halt configure
AC_CHECK_HEADER(stdarg.h,, AC_MSG_ERROR(stdarg.h could not be found))
dnl Checks for library functions.
AC_PROG_GCC_TRADITIONAL
dnl check for poll() call
AC_CHECK_FUNC(poll, AC_DEFINE(USE_POLL,,[poll() system call is available]),)
dnl check for u_int32_t
AC_CHECK_TYPE(u_int32_t, unsigned long)
AC_C_BIGENDIAN
DANCER_CHECK_C_PRINTF_ZD
DANCER_VA_COPY
dnl This should be a little easier to grok than the prior mess
dnl But only a little
dnl Basically, try POSIX, then BSD, then SysV
AC_MSG_CHECKING(for non-blocking socket implementation)
DANCER_CHECK_NBLOCK_SOCKET_POSIX(
nblock='POSIX'
AC_DEFINE(NBLOCK_POSIX,,[Using POSIX non-blocking sockets (O_NONBLOCK)])
AC_MSG_RESULT(O_NONBLOCK),
nblock='UNKNOWN',
nblock='CROSS')
if test "$nblock" = "UNKNOWN"
then
dnl Not POSIX...
DANCER_CHECK_NBLOCK_SOCKET_BSD(
nblock='BSD'
AC_DEFINE(NBLOCK_BSD,,[Using BSD non-blocking sockets (O_NDELAY)])
AC_MSG_RESULT(O_NDELAY),
nblock='UNKNOWN',
nblock='CROSS')
fi
if test "$nblock" = "UNKNOWN"
then
dnl Not BSD either...
DANCER_CHECK_NBLOCK_SOCKET_SYSV(
nblock='SYSV'
AC_DEFINE(NBLOCK_SYSV,,[Using SysV non-blocking sockets (FIONBIO)])
AC_MSG_RESULT(FIONBIO),
nblock='UNKNOWN',
nblock='CROSS')
fi
case "$nblock" in
UNKNOWN) AC_MSG_ERROR("could not find a non-blocking socket implementation") ;;
CROSS) AC_MSG_ERROR("cross-compiling") ;;
esac
AC_FUNC_MMAP
dnl OK, efence?
AC_ARG_WITH(efence, [ --with-efence Link with electric fence ])
if test "$with_efence" = "yes"
then
AC_CHECK_LIB(efence, EF_ALIGNMENT, LIBS="${LIBS} -lefence", AC_MSG_ERROR(libefence not found))
fi
dnl See what warnings we can get away with
DANCER_C_GCC_TRY_FLAGS([-Wall], dancer_cv_c_gcc_w_all)
DANCER_C_GCC_TRY_FLAGS([-Wwrite-strings], dancer_cv_c_gcc_w_strings)
DANCER_C_GCC_TRY_FLAGS([-Wpointer-arith], dancer_cv_c_gcc_w_pointer_arith)
DANCER_C_GCC_TRY_FLAGS([-Wcast-qual], dancer_cv_c_gcc_w_cast_qual)
DANCER_C_GCC_TRY_FLAGS([-Wimplicit -Wnested-externs], dancer_cv_c_gcc_w_implicit)
DANCER_C_GCC_TRY_FLAGS([-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations], dancer_cv_c_gcc_prototypes)
DANCER_C_GCC_TRY_FLAGS([-W -Wno-unused], dancer_cv_c_gcc_w)
dnl For a day when I'm very very bored...
dnl DANCER_C_GCC_TRY_FLAGS([-Wshadow], dancer_cv_c_gcc_w_shadow)
dnl DANCER_C_GCC_TRY_FLAGS([-Wconversion], dancer_cv_c_gcc_w_conversion)
DANCER_C_GCC_TRY_FLAGS([-Wmissing-noreturn], dancer_cv_c_gcc_w_missing_noreturn)
DANCER_C_GCC_TRY_FLAGS([-Wundef], dancer_cv_c_gcc_w_undef)
DANCER_C_GCC_TRY_FLAGS([-Wpacked], dancer_cv_c_gcc_w_packed)
DANCER_C_GCC_TRY_FLAGS([-Wnested-externs], dancer_cv_c_gcc_w_nested_externs)
dnl Not yet good enough to be useful (gcc 3.1.0)
dnl DANCER_C_GCC_TRY_FLAGS([-Wunreachable-code], dancer_cv_c_gcc_w_unreachable_code)
DANCER_C_GCC_TRY_FLAGS([-Wbad-function-cast], dancer_cv_c_gcc_w_bad_function_cast)
DANCER_C_GCC_TRY_FLAGS([-Wunused-function -Wunused-label -Wunused-value -Wunused-variable], dancer_cv_c_gcc_w_unused)
DANCER_C_GCC_TRY_FLAGS([-Wredundant-decls], dancer_cv_c_gcc_w_redundant_decls)
DANCER_C_GCC_TRY_FLAGS([-Wfloat-equal], dancer_cv_c_gcc_w_float_equal)
DANCER_C_GCC_TRY_FLAGS([-std=gnu9x], dancer_cv_c_gcc_std_gnu9x)
ac_save_CFLAGS="${debug_syms}${optimise}${CWARNS}${orig_CFLAGS}"
CFLAGS=${ac_save_CFLAGS}
AC_MSG_CHECKING([for pedantry])
warn='no'
AC_ARG_ENABLE(pedantic,
[ --disable-pedantic=type Do not compile with -pedantic (for those with broken libc)
If present, type can be "warn" or "err" ],
[case "$enableval" in
yes) pedantic='-pedantic-errors ' ;;
no) pedantic='' ;;
warn*) pedantic='-pedantic ' ;;
err*) pedantic='-pedantic-errors ' ;;
esac],
dnl OK, can we compile with -pedantic-errors, or is libc broken?
dancer_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -pedantic-errors"
AC_TRY_COMPILE([
$dancer_headers_guarded
int main(void);
],[
return 0;
], pedantic='-pedantic-errors ',
warn='yes'
pedantic='-pedantic ')
CFLAGS="$dancer_save_CFLAGS $pedantic")
if test -z "$pedantic"
then
AC_MSG_RESULT(none)
else
AC_MSG_RESULT($pedantic)
fi
if test "$warn" = "yes"
then
AC_MSG_WARN([Can't use -pedantic-errors, is libc buggy?])
fi
ac_save_CFLAGS="${debug_syms}${optimise}${pedantic}${CWARNS}${orig_CFLAGS}"
CFLAGS=${ac_save_CFLAGS}
AC_MSG_CHECKING([-Werror])
warn='no'
AC_ARG_ENABLE(errors,
[ --disable-errors Do not compile with -Werror (for those with broken headers) ],
[case "$enableval" in
yes) errors='-Werror ' ;;
no) errors='' ;;
esac],
dnl <sigh> Can we compile with -Werror, or is libc broken?
dancer_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Werror"
AC_TRY_COMPILE([
$dancer_headers_guarded
int main(void);
],[
return 0;
],errors='-Werror ',
warn='yes'
errors='')
CFLAGS="$dancer_save_CFLAGS")
if test -z "$errors"
then
AC_MSG_RESULT([not used])
else
AC_MSG_RESULT([used])
fi
if test "$warn" = "yes"
then
AC_MSG_WARN([Can't use -Werror, is libc buggy?])
fi
ac_save_CFLAGS="${debug_syms}${optimise}${pedantic}${CWARNS}${errors}${orig_CFLAGS}"
CFLAGS=${ac_save_CFLAGS}
dnl Check this _after_ warning flags are determined
DANCER_CHECK_LONG_LONG
DANCER_CHECK_C_ATTRIBUTE_PRINTF_ZD
DANCER_CHECK_C_ATTRIBUTE(malloc)
DANCER_CHECK_C_ATTRIBUTE(pure)
DANCER_CHECK_C_ATTRIBUTE(noreturn)
dnl These bits are used to store build-time information in version.c for
dnl display in m_info()
BUILD_UNAME=`uname -a`
BUILD_TIME=`date -u`
AC_DEFINE_UNQUOTED(BUILD_UNAME, "$BUILD_UNAME", [uname of build system])
AC_DEFINE_UNQUOTED(BUILD_TIME, "$BUILD_TIME", [./configure run time])
short_time=`date -u +%Y/%m/%d_%T`
AC_ARG_WITH(serno,
[ --with-serno="..." Add a serial number (shows in date field) ],
SERIAL="${short_time}_$withval",
SERIAL="$short_time")
AC_DEFINE_UNQUOTED(SERIAL, "$SERIAL", [Serial number and date of build])
AC_ARG_WITH(config,
[ --with-config=type Select a default configuration to use
Currently available configurations:
dist - default distribution
fn - as used on the Freenode Network ],
[case "$withval" in
dist) config="config.h.dist" ;;
debian) config="config.h.debian" ;;
fn-large|freenode-large) config="config.h.fn-large" ;;
fn|freenode) config="config.h.fn" ;;
fn-small|freenode-small) config="config.h.fn-small" ;;
opn) config="config.h.fn" ;;
opn-small) config="config.h.fn-small" ;;
esac
cp "include/$config" include/config.h],
[test -f include/config.h || cp include/config.h.dist include/config.h]
)
AC_ARG_ENABLE(documentation,
[ --enable-documentation Build the documentation ],
[case "$enableval" in
yes) documentation="yes" ;;
no) documentation="no" ;;
esac],
[documentation="no"])
AM_CONDITIONAL(DOCUMENTATION, test "$documentation" = "yes")
AC_CONFIG_FILES(
Makefile
autoconf/Makefile
build-misc/Makefile
doc/Makefile
doc/sgml/Makefile
doc/sgml/dancer-oper-guide/Makefile
doc/sgml/dancer-user-guide/Makefile
include/Makefile
lib/Dancer/Makefile
lib/Dancer/Proxy/Makefile
lib/Makefile
src/Makefile
tools/Makefile
)
AC_OUTPUT
echo "
Configuration:
Detected OS: ${host_os}
Dancer version: ${VERSION}
Install prefix: ${prefix}
CFLAGS: ${CFLAGS}
"
|