123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360 |
- #
- # configure.in -- autoconf source to configure newsd
- #
- # Copyright 2003-2013 Michael Sweet
- # Copyright 2002 Greg Ercolano
- #
- # This program is free software; you can redistribute it and/or modify
- # it under the terms of the GNU General Public Licensse as published by
- # the Free Software Foundation; either version 2 of the License, or
- # (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- #
- AC_INIT(newsd.C)
- AC_CONFIG_HEADER(config.h)
- dnl Version number...
- VERSION=2.0
- AC_SUBST(VERSION)
- AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
- dnl Get the operating system...
- uname=`uname`
- uversion=`uname -r | sed -e '1,$s/[[^0-9]]//g'`
- if test "$uname" = "IRIX64"; then
- uname="IRIX"
- fi
- dnl Clear default debugging options and set normal optimization by
- dnl default unless the user asks for debugging specifically.
- CFLAGS="${CFLAGS:=}"
- CXXFLAGS="${CXXFLAGS:=}"
- LDFLAGS="${LDFLAGS:=}"
- OPTIM=""
- PIEFLAGS=""
- RELROFLAGS=""
- AC_SUBST(LDFLAGS)
- AC_SUBST(OPTIM)
- AC_SUBST(PIEFLAGS)
- AC_SUBST(RELROFLAGS)
- AC_ARG_ENABLE(debug, [ --enable-debug turn on debugging, default=no])
- AC_ARG_ENABLE(relro, [ --enable-relro use GCC relro option, default=no])
- AC_ARG_WITH(archflags, [ --with-archflags="flags"
- set default architecture flags ])
- AC_ARG_WITH(docdir, [ --with-docdir set directory for documentation],
- docdir="$withval",
- docdir="NONE")
- AC_SUBST(docdir)
- AC_ARG_WITH(optim, [ --with-optim="flags" set optimization flags ])
- AC_ARG_WITH(sendmail, [ --with-sendmail set default sendmail program],
- sendmail="$withval",
- sendmail="NONE")
- AC_SUBST(sendmail)
- AC_ARG_WITH(spooldir, [ --with-spooldir set default directory for article files],
- spooldir="$withval",
- spooldir="NONE")
- AC_SUBST(spooldir)
- dnl For debugging, use "-g" for optimizer settings...
- if test x$enable_debug = xyes; then
- OPTIM="-g"
- fi
- dnl Setup general architecture flags...
- if test -z "$with_archflags"; then
- ARCHFLAGS=""
- else
- ARCHFLAGS="$with_archflags"
- fi
- AC_SUBST(ARCHFLAGS)
- dnl Check for libraries with socket stuff...
- AC_SEARCH_LIBS(socket, socket)
- AC_SEARCH_LIBS(getaddrinfo, nsl)
- AC_SEARCH_LIBS(getnameinfo, nsl)
- dnl Check for largefile support...
- AC_SYS_LARGEFILE
- dnl Check for POSIX threading support...
- have_pthread=no
- AC_CHECK_HEADER(pthread.h)
- if test x$ac_cv_header_pthread_h = xyes; then
- for flag in -lpthreads -lpthread -pthread; do
- AC_MSG_CHECKING([for pthread_create using $flag])
- SAVELIBS="$LIBS"
- LIBS="$flag $LIBS"
- AC_TRY_LINK([#include <pthread.h>],
- [pthread_create(0, 0, 0, 0);],
- have_pthread=yes,
- LIBS="$SAVELIBS")
- AC_MSG_RESULT([$have_pthread])
- done
- fi
- if test $have_pthread = no; then
- AC_MSG_ERROR(Sorry, newsd requires POSIX threads.)
- fi
- dnl Define largefile options as needed...
- LARGEFILE=""
- if test x$enable_largefile != xno; then
- LARGEFILE="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE"
- if test x$ac_cv_sys_large_files = x1; then
- LARGEFILE="$LARGEFILE -D_LARGE_FILES"
- fi
- if test x$ac_cv_sys_file_offset_bits = x64; then
- LARGEFILE="$LARGEFILE -D_FILE_OFFSET_BITS=64"
- fi
- fi
- AC_SUBST(LARGEFILE)
- if test -n "$GCC"; then
- # Add GCC-specific compiler options...
- if test -z "$OPTIM"; then
- if test -z "$with_optim"; then
- # Default to optimize-for-size and debug
- OPTIM="-Os -g"
- else
- OPTIM="$with_optim $OPTIM"
- fi
- fi
- # The -fstack-protector option is available with some versions of
- # GCC and adds "stack canaries" which detect when the return address
- # has been overwritten, preventing many types of exploit attacks.
- AC_MSG_CHECKING(if GCC supports -fstack-protector)
- OLDCFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -fstack-protector"
- AC_TRY_COMPILE(,,
- OPTIM="$OPTIM -fstack-protector"
- AC_MSG_RESULT(yes),
- AC_MSG_RESULT(no))
- CFLAGS="$OLDCFLAGS"
- # The -pie option is available with some versions of GCC and adds
- # randomization of addresses, which avoids another class of exploits
- # that depend on a fixed address for common functions.
- AC_MSG_CHECKING(if GCC supports -fPIE)
- OLDCFLAGS="$CFLAGS"
- case "$uname" in
- Darwin*)
- CFLAGS="$CFLAGS -fPIE -Wl,-pie"
- AC_TRY_COMPILE(,,[
- OPTIM="-fPIC $OPTIM"
- PIEFLAGS="-fPIE -Wl,-pie"
- AC_MSG_RESULT(yes)],
- AC_MSG_RESULT(no))
- ;;
- *)
- CFLAGS="$CFLAGS -fPIE -pie"
- AC_TRY_COMPILE(,,[
- OPTIM="-fPIC $OPTIM"
- PIEFLAGS="-fPIE -pie"
- AC_MSG_RESULT(yes)],
- AC_MSG_RESULT(no))
- ;;
- esac
- CFLAGS="$OLDCFLAGS"
- if test -z "$with_optim"; then
- # Add useful warning options for tracking down problems...
- OPTIM="-Wall -Wno-format-y2k $OPTIM"
- # Additional warning options for development testing...
- if test -d .svn; then
- OPTIM="-Wshadow -Wunused $OPTIM"
- fi
- fi
- case "$uname" in
- Darwin*)
- # -D_FORTIFY_SOURCE=2 adds additional object size
- # checking, basically wrapping all string functions
- # with buffer-limited ones. Not strictly needed for
- # newsd since we already use buffer-limited calls, but
- # this will catch any additions that are broken.
- CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
- CXXFLAGS="$CXXFLAGS -D_FORTIFY_SOURCE=2"
- if test x$enable_pie = xyes; then
- # GCC 4 on Mac OS X needs -Wl,-pie as well
- LDFLAGS="$LDFLAGS -Wl,-pie"
- fi
- ;;
- Linux*)
- # The -z relro option is provided by the Linux linker
- # command to make relocatable data read-only.
- if test x$enable_relro = xyes; then
- RELROFLAGS="-Wl,-z,relro"
- fi
- ;;
- esac
- elif test ! -z "$OPTIM"; then
- OPTIM="$with_optim $OPTIM"
- fi
- dnl Checks for programs...
- AC_PROG_CC
- AC_PROG_CXX
- AC_PROG_INSTALL
- if test "$INSTALL" = "$ac_install_sh"; then
- # Use full path to install-sh script...
- INSTALL="`pwd`/install-sh"
- fi
- AC_PATH_PROG(HTMLDOC,htmldoc)
- AC_PATH_PROG(MKDIR,mkdir)
- AC_PATH_PROG(MV,mv)
- AC_PATH_PROG(POD2MAN,pod2man)
- AC_PATH_PROG(POD2HTML,pod2html)
- AC_PATH_PROG(NROFF,nroff)
- if test x$NROFF = x; then
- AC_PATH_PROG(GROFF,groff)
- if test x$GROFF = x; then
- NROFF="echo"
- else
- NROFF="$GROFF -T ascii"
- fi
- fi
- AC_PATH_PROG(RM,rm)
- dnl Architecture checks...
- AC_C_CONST
- AC_C_CHAR_UNSIGNED
- dnl Checks for header files.
- AC_HEADER_STDC
- dnl Fix "prefix" variable if it hasn't been specified...
- if test "x$prefix" = xNONE; then
- prefix="/usr"
- fi
- dnl Fix "exec_prefix" variable if it hasn't been specified...
- if test "x$exec_prefix" = NONE; then
- exec_prefix="$prefix"
- fi
- dnl Fix "localstatedir" variable if it hasn't been specified...
- if test "$localstatedir" = "\${prefix}/var"; then
- if test "$prefix" = "/usr"; then
- if test $uname = Darwin; then
- localstatedir="/private/var"
- else
- localstatedir="/var"
- fi
- else
- localstatedir="$prefix/var"
- fi
- fi
- dnl Fix "sysconfdir" variable if it hasn't been specified...
- if test "$sysconfdir" = "\${prefix}/etc"; then
- if test "$prefix" = "/"; then
- if test "$uname" = Darwin; then
- sysconfdir="/private/etc"
- else
- sysconfdir="/etc"
- fi
- else
- sysconfdir="$prefix/etc"
- fi
- fi
- AC_DEFINE_UNQUOTED(CONFIG_FILE, "$sysconfdir/newsd.conf")
- dnl Fix "datarootdir" variable if it hasn't been specified...
- if test "$datarootdir" = "\${prefix}/share"; then
- if test "$prefix" = "/"; then
- datarootdir="/usr/share"
- else
- datarootdir="$prefix/share"
- fi
- fi
- dnl Fix "datadir" variable if it hasn't been specified...
- if test "x$datadir" = "x\${prefix}/share"; then
- datadir="$prefix/share"
- fi
- dnl Fix "docdir" variable if it hasn't been specified...
- if test "x$docdir" = xNONE; then
- docdir="$datadir/doc/newsd"
- fi
- dnl Domain socket is in $(localstatedir)...
- DOMAIN_SOCKET="$localstatedir/run/newsd"
- AC_DEFINE_UNQUOTED(DOMAIN_SOCKET, "$DOMAIN_SOCKET")
- dnl Fix "sendmail" variable if it hasn't been specified...
- if test "x$sendmail" = xNONE; then
- for dir in /usr/sbin /usr/lib /usr/bin /usr/local/sbin; do
- if test -x $dir/sendmail; then
- sendmail="$dir/sendmail"
- fi
- done
- fi
- AC_DEFINE_UNQUOTED(SENDMAIL, "$sendmail")
- dnl Fix "spooldir" variable if it hasn't been specified...
- if test "x$spooldir" = xNONE; then
- spooldir="$localstatedir/spool/newsd"
- fi
- AC_DEFINE_UNQUOTED(SPOOL_DIR, "$spooldir")
- dnl Fix "mandir" variable if it hasn't been specified...
- if test "$mandir" = "\${prefix}/man" -a "$prefix" = "/usr"; then
- mandir="/usr/share/man"
- fi
- dnl More manpage stuff...
- MAN5EXT="5.gz"
- MAN8EXT="8.gz"
- AC_SUBST(MAN5EXT)
- AC_SUBST(MAN8EXT)
- dnl Setup init.d locations...
- init_target="init"
- init_dir=""
- if test x$rcdir = x; then
- case "$uname" in
- NetBSD*)
- # NetBSD
- init_dir="/etc/rc.d"
- ;;
- Darwin*)
- # Darwin and Mac OS X...
- init_target="launchd"
- ;;
- Linux*)
- init_dir="/etc/init.d"
- ;;
- esac
- fi
- AC_SUBST(init_dir)
- AC_SUBST(init_target)
- dnl Output the makefile, list file, and config header...
- AC_OUTPUT(Makefile newsd.sh newsd.conf newsd.list newsd.pod newsd.conf.pod)
|