dnl $Id$ dnl Copyright (C) 2002 Olafur Osvaldsson dnl dnl This program is free software; you can redistribute it and/or dnl modify it under the terms of the GNU General Public License dnl as published by the Free Software Foundation; either version 2 dnl of the License, or (at your option) any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. define([m4_chop], [m4_substr($1, 0, m4_decr(m4_len($1)))]) m4_define([noattach_version], m4_chop(m4_include(VERSION))) AC_INIT(noattach, [noattach_version], [oli@isnic.is]) AC_REVISION($Revision$) AC_CONFIG_SRCDIR([noattach.c]) dnl Lets just start by adding default paths to the include and lib paths CPPFLAGS="$CPPFLAGS -I/usr/include -I/usr/local/include" LDFLAGS="$LDFLAGS -L/usr/lib -L/usr/local/lib" AH_TOP([/* * Copyright (C) 2002 Olafur Osvaldsson * * 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. * * 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. */]) dnl *** prefix *** if test "x$prefix" = "xNONE" then prefix=$ac_default_prefix fi if test "x$exec_prefix" = "xNONE" then exec_prefix=$prefix fi AC_PROG_MAKE_SET AM_INIT_AUTOMAKE AM_CONFIG_HEADER(config.h) dnl Checks for programs. AC_PROG_CC AC_PROG_INSTALL AC_PROG_AWK AC_PROG_CXX dnl What is our target OS TARGET=`$ac_config_guess` AC_SUBST(TARGET) AC_ARG_ENABLE(header,[ --enable-header Enable addition of X-Filter header to messages],ADD_HEADER=true) if test "$ADD_HEADER" = "true" then CFLAGS="$CFLAGS -DADD_HEADER" fi AC_ARG_ENABLE(log-envfrom,[ --enable-log-envfrom When a mail msg is rejected, log the envelope from address],LOG_ENVFROM=true) if test "$LOG_ENVFROM" = "true" then CFLAGS="$CFLAGS -DLOG_ENVFROM" fi AC_ARG_ENABLE(DEBUG,[ --enable-DEBUG leave debug info in executables],DEBUG=true) if test "$DEBUG" = "true" then CFLAGS="$CFLAGS -g -Wall -DDEBUG" fi AC_ARG_ENABLE(dmalloc,[ --enable-dmalloc Enable malloc debug with dmalloc],DMALLOC=true) if test "$DMALLOC" = "true" then DEBUG=true fi AC_ARG_ENABLE(efence,[ --enable-efence Enable malloc debug with ElectricFence],EFENCE=true) if test "$EFENCE" = "true" then DEBUG=true fi dnl Checks for libraries. AC_MSG_CHECKING([for pthread_detach in -lpthread]) ac_save_LIBS="$LIBS" LIBS="$LIBS -lpthread" AC_TRY_LINK( [#include ], [ (void) pthread_detach(0); ], with_posix_threads=yes, with_posix_threads=no) AC_MSG_RESULT([$with_posix_threads]) if test "$with_posix_threads" = "no" then LIBS=" $ac_save_LIBS -lpthreads" AC_MSG_CHECKING([for pthread_detach in -lpthreads]) AC_TRY_LINK( [#include ], [ (void) pthread_detach(0); ], with_posix_threads=yes, with_posix_threads=no) AC_MSG_RESULT([$with_posix_threads]) if test "$with_posix_threads" = "no" then # This is for FreeBSD LIBS="$ac_save_LIBS -pthread" AC_MSG_CHECKING([for pthread_detach in -pthread]) AC_TRY_LINK( [#include ], [ (void) pthread_detach(0); ], with_posix_threads=yes, with_posix_threads=no) AC_MSG_RESULT([$with_posix_threads]) if test "$with_posix_threads" = "no" then AC_MSG_ERROR([Unable to find pthread]) fi fi fi AC_CHECK_LIB(resolv,inet_aton,result=yes,result=no) if test "$result" = "yes" then LIBS="$LIBS -lresolv" fi AC_CHECK_LIB(socket,socket,result=yes,result=no) if test "$result" = "yes"; then LIBS="$LIBS -lsocket" fi AC_CHECK_LIB(nsl,inet_addr,result=yes,result=no) if test "$result" = "yes"; then LIBS="$LIBS -lnsl" fi dnl Checks for header files. AC_HEADER_STDC AC_HEADER_STDBOOL AC_CHECK_HEADERS([stdlib.h string.h unistd.h syslog.h]) dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_TYPE_PID_T AC_TYPE_SIZE_T dnl Checks for library functions. AC_FUNC_FORK AC_FUNC_MALLOC AC_FUNC_REALLOC AC_CHECK_FUNCS([regcomp strchr strdup strcasestr strncasecmp memset gethostname strerror strrchr]) dnl *** options in config.h *** AC_MSG_CHECKING(for PID_FILE) AC_ARG_WITH(pid-file, [[ --with-pid-file=FILE set the name of the pid file [/var/run/noattach.pid]]], [PID_FILE=$withval], [PID_FILE=/var/run/noattach.pid]) AC_DEFINE_UNQUOTED(PID_FILE, "$PID_FILE") AC_MSG_RESULT($PID_FILE) AC_SUBST(PID_FILE) AC_MSG_CHECKING(for PAT_FILE) AC_ARG_WITH(pat-file, [[ --with-pat-file=FILE set the name of the pattern file [PREFIX/etc/noattach.patterns]]], [PAT_FILE=$withval], [PAT_FILE=$prefix/etc/noattach.patterns]) AC_DEFINE_UNQUOTED(PAT_FILE, "$PAT_FILE") AC_MSG_RESULT($PAT_FILE) AC_SUBST(PAT_FILE) AC_MSG_CHECKING(for SENDMAIL_INCLUDE) AC_ARG_WITH(sendmail-include, [[ --with-sendmail-include=DIR set the sendmail include dir [/usr/local/include]]], [SENDMAIL_INCLUDE=$withval], [SENDMAIL_INCLUDE=/usr/local/include]) AC_DEFINE_UNQUOTED(SENDMAIL_INCLUDE, "$SENDMAIL_INCLUDE") AC_MSG_RESULT($SENDMAIL_INCLUDE) AC_SUBST(SENDMAIL_INCLUDE) CPPFLAGS="$CPPFLAGS -I$SENDMAIL_INCLUDE" AC_MSG_CHECKING(for SENDMAIL_LIB) AC_ARG_WITH(sendmail-lib, [[ --with-sendmail-lib=DIR set the sendmail lib dir [/usr/local/lib]]], [SENDMAIL_LIB=$withval], [SENDMAIL_LIB=/usr/local/lib]) AC_DEFINE_UNQUOTED(SENDMAIL_LIB, "$SENDMAIL_LIB") AC_MSG_RESULT($SENDMAIL_LIB) AC_SUBST(SENDMAIL_LIB) LDFLAGS="$LDFLAGS -L$SENDMAIL_LIB" dnl If sendmail has been compiled with LDAP support we need to link libldap and libber also AC_ARG_ENABLE(ldap,[ --enable-ldap Link with ldap library],LDAP=true) if test "$LDAP" = "true" then AC_CHECK_LIB(ldap,ldap_init,result=yes,result=no,-llber) if test "$result" = "yes" then LIBS="$LIBS -lldap -llber" else AC_MSG_ERROR([Unable to find libldap or libber]) fi fi dnl Needed libmilter include and lib files from the sendmail include/lib dirs AC_CHECK_HEADER(mfapi.h, ac_have_mfapi=yes \ AC_DEFINE(MFAPI_H, 1, [We have mfapi.h]), ac_have_mfapi=no) if test "$ac_have_mfapi" = "no" then AC_CHECK_HEADER(libmilter/mfapi.h, ac_have_mfapi=yes, AC_MSG_ERROR([Unable to find mfapi.h])) fi AC_CHECK_LIB(milter,smfi_main,result=yes,result=no) if test "$result" = "yes"; then LIBS="$LIBS -lmilter" else AC_MSG_ERROR([Unable to find libmilter]) fi dnl DEBUG stuff if test "$DMALLOC" = "true" then AC_MSG_CHECKING([for dmalloc]) ac_save_LIBS="$LIBS" LIBS="$LIBS -ldmalloc" AC_TRY_LINK( [#include ], [ (void) malloc(1); ], with_dmalloc=yes,with_dmalloc=no) AC_MSG_RESULT([$with_dmalloc]) if test "$with_dmalloc" = "no" then LIBS="$ac_save_LIBS" else CFLAGS="$CFLAGS -DDMALLOC" fi if test "$EFENCE" = "true" then AC_MSG_ERROR([Unable to use both dmalloc and efence at the same time]) fi else if test "$EFENCE" = "true" then AC_CHECK_LIB(efence,malloc,result=yes,result=no) if test "$result" = "yes" then LIBS="$LIBS -lefence" fi fi fi dnl Define symbols AC_DEFINE(PID_FILE, $PID_FILE, [Our pid file]) AC_DEFINE(PAT_FILE, $PAT_FILE, [Our pattern file]) AC_DEFINE(SENDMAIL_INCLUDE, $SENDMAIL_INCLUDE, [Sendmail include dir]) AC_DEFINE(SENDMAIL_LIB, $SENDMAIL_LIB, [Sendmail lib dir]) AC_CONFIG_FILES([Makefile]) AC_OUTPUT(fedora/noattach.spec) AC_OUTPUT(fedora/noattach.sh)