1dnl $Id$ 2dnl Copyright (C) 2002 Olafur Osvaldsson 3dnl 4dnl This program is free software; you can redistribute it and/or 5dnl modify it under the terms of the GNU General Public License 6dnl as published by the Free Software Foundation; either version 2 7dnl of the License, or (at your option) any later version. 8dnl 9dnl This program is distributed in the hope that it will be useful, 10dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 11dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12dnl GNU General Public License for more details. 13dnl 14dnl You should have received a copy of the GNU General Public License 15dnl along with this program; if not, write to the Free Software 16dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 18define([m4_chop], [m4_substr($1, 0, m4_decr(m4_len($1)))]) 19m4_define([noattach_version], m4_chop(m4_include(VERSION))) 20 21AC_INIT(noattach, [noattach_version], [oli@isnic.is]) 22AC_REVISION($Revision$) 23AC_CONFIG_SRCDIR([noattach.c]) 24 25dnl Lets just start by adding default paths to the include and lib paths 26CPPFLAGS="$CPPFLAGS -I/usr/include -I/usr/local/include" 27LDFLAGS="$LDFLAGS -L/usr/lib -L/usr/local/lib" 28 29AH_TOP([/* 30 * Copyright (C) 2002 Olafur Osvaldsson 31 * 32 * This program is free software; you can redistribute it and/or 33 * modify it under the terms of the GNU General Public License 34 * as published by the Free Software Foundation; either version 2 35 * of the License, or (at your option) any later version. 36 * 37 * This program is distributed in the hope that it will be useful, 38 * but WITHOUT ANY WARRANTY; without even the implied warranty of 39 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 40 * GNU General Public License for more details. 41 * 42 * You should have received a copy of the GNU General Public License 43 * along with this program; if not, write to the Free Software 44 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 45 */]) 46 47dnl *** prefix *** 48 49if test "x$prefix" = "xNONE" 50then 51 prefix=$ac_default_prefix 52fi 53if test "x$exec_prefix" = "xNONE" 54then 55 exec_prefix=$prefix 56fi 57 58AC_PROG_MAKE_SET 59 60AM_INIT_AUTOMAKE 61AM_CONFIG_HEADER(config.h) 62 63dnl Checks for programs. 64AC_PROG_CC 65AC_PROG_INSTALL 66AC_PROG_AWK 67AC_PROG_CXX 68 69dnl What is our target OS 70TARGET=`$ac_config_guess` 71AC_SUBST(TARGET) 72 73 74AC_ARG_ENABLE(header,[ --enable-header Enable addition of X-Filter header to messages],ADD_HEADER=true) 75if test "$ADD_HEADER" = "true" 76then 77 CFLAGS="$CFLAGS -DADD_HEADER" 78fi 79 80AC_ARG_ENABLE(log-envfrom,[ --enable-log-envfrom When a mail msg is rejected, log the envelope from address],LOG_ENVFROM=true) 81if test "$LOG_ENVFROM" = "true" 82then 83 CFLAGS="$CFLAGS -DLOG_ENVFROM" 84fi 85 86AC_ARG_ENABLE(DEBUG,[ --enable-DEBUG leave debug info in executables],DEBUG=true) 87if test "$DEBUG" = "true" 88then 89 CFLAGS="$CFLAGS -g -Wall -DDEBUG" 90fi 91 92AC_ARG_ENABLE(dmalloc,[ --enable-dmalloc Enable malloc debug with dmalloc],DMALLOC=true) 93if test "$DMALLOC" = "true" 94then 95 DEBUG=true 96fi 97 98AC_ARG_ENABLE(efence,[ --enable-efence Enable malloc debug with ElectricFence],EFENCE=true) 99if test "$EFENCE" = "true" 100then 101 DEBUG=true 102fi 103 104 105dnl Checks for libraries. 106AC_MSG_CHECKING([for pthread_detach in -lpthread]) 107ac_save_LIBS="$LIBS" 108LIBS="$LIBS -lpthread" 109AC_TRY_LINK( 110[#include <pthread.h>], 111[ (void) pthread_detach(0); ], 112with_posix_threads=yes, with_posix_threads=no) 113AC_MSG_RESULT([$with_posix_threads]) 114if test "$with_posix_threads" = "no" 115then 116 LIBS=" $ac_save_LIBS -lpthreads" 117 AC_MSG_CHECKING([for pthread_detach in -lpthreads]) 118 AC_TRY_LINK( 119 [#include <pthread.h>], 120 [ (void) pthread_detach(0); ], 121 with_posix_threads=yes, with_posix_threads=no) 122 AC_MSG_RESULT([$with_posix_threads]) 123 if test "$with_posix_threads" = "no" 124 then 125 # This is for FreeBSD 126 LIBS="$ac_save_LIBS -pthread" 127 AC_MSG_CHECKING([for pthread_detach in -pthread]) 128 AC_TRY_LINK( 129 [#include <pthread.h>], 130 [ (void) pthread_detach(0); ], 131 with_posix_threads=yes, with_posix_threads=no) 132 AC_MSG_RESULT([$with_posix_threads]) 133 if test "$with_posix_threads" = "no" 134 then 135 AC_MSG_ERROR([Unable to find pthread]) 136 fi 137 fi 138fi 139 140AC_CHECK_LIB(resolv,inet_aton,result=yes,result=no) 141if test "$result" = "yes" 142then 143 LIBS="$LIBS -lresolv" 144fi 145 146AC_CHECK_LIB(socket,socket,result=yes,result=no) 147if test "$result" = "yes"; then 148 LIBS="$LIBS -lsocket" 149fi 150 151AC_CHECK_LIB(nsl,inet_addr,result=yes,result=no) 152if test "$result" = "yes"; then 153 LIBS="$LIBS -lnsl" 154fi 155 156dnl Checks for header files. 157AC_HEADER_STDC 158AC_HEADER_STDBOOL 159AC_CHECK_HEADERS([stdlib.h string.h unistd.h syslog.h]) 160 161 162dnl Checks for typedefs, structures, and compiler characteristics. 163AC_C_CONST 164AC_TYPE_PID_T 165AC_TYPE_SIZE_T 166 167dnl Checks for library functions. 168AC_FUNC_FORK 169AC_FUNC_MALLOC 170AC_FUNC_REALLOC 171AC_CHECK_FUNCS([regcomp strchr strdup strcasestr strncasecmp memset gethostname strerror strrchr]) 172 173 174 175dnl *** options in config.h *** 176 177AC_MSG_CHECKING(for PID_FILE) 178AC_ARG_WITH(pid-file, [[ --with-pid-file=FILE set the name of the pid file [/var/run/noattach.pid]]], 179 [PID_FILE=$withval], [PID_FILE=/var/run/noattach.pid]) 180AC_DEFINE_UNQUOTED(PID_FILE, "$PID_FILE") 181AC_MSG_RESULT($PID_FILE) 182AC_SUBST(PID_FILE) 183 184AC_MSG_CHECKING(for PAT_FILE) 185AC_ARG_WITH(pat-file, [[ --with-pat-file=FILE set the name of the pattern file 186 [PREFIX/etc/noattach.patterns]]], 187 [PAT_FILE=$withval], [PAT_FILE=$prefix/etc/noattach.patterns]) 188AC_DEFINE_UNQUOTED(PAT_FILE, "$PAT_FILE") 189AC_MSG_RESULT($PAT_FILE) 190AC_SUBST(PAT_FILE) 191 192AC_MSG_CHECKING(for SENDMAIL_INCLUDE) 193AC_ARG_WITH(sendmail-include, [[ --with-sendmail-include=DIR set the sendmail include dir 194 [/usr/local/include]]], 195 [SENDMAIL_INCLUDE=$withval], [SENDMAIL_INCLUDE=/usr/local/include]) 196AC_DEFINE_UNQUOTED(SENDMAIL_INCLUDE, "$SENDMAIL_INCLUDE") 197AC_MSG_RESULT($SENDMAIL_INCLUDE) 198AC_SUBST(SENDMAIL_INCLUDE) 199 200CPPFLAGS="$CPPFLAGS -I$SENDMAIL_INCLUDE" 201 202AC_MSG_CHECKING(for SENDMAIL_LIB) 203AC_ARG_WITH(sendmail-lib, [[ --with-sendmail-lib=DIR set the sendmail lib dir [/usr/local/lib]]], 204 [SENDMAIL_LIB=$withval], [SENDMAIL_LIB=/usr/local/lib]) 205AC_DEFINE_UNQUOTED(SENDMAIL_LIB, "$SENDMAIL_LIB") 206AC_MSG_RESULT($SENDMAIL_LIB) 207AC_SUBST(SENDMAIL_LIB) 208 209LDFLAGS="$LDFLAGS -L$SENDMAIL_LIB" 210 211 212dnl If sendmail has been compiled with LDAP support we need to link libldap and libber also 213 214AC_ARG_ENABLE(ldap,[ --enable-ldap Link with ldap library],LDAP=true) 215if test "$LDAP" = "true" 216then 217 AC_CHECK_LIB(ldap,ldap_init,result=yes,result=no,-llber) 218 if test "$result" = "yes" 219 then 220 LIBS="$LIBS -lldap -llber" 221 else 222 AC_MSG_ERROR([Unable to find libldap or libber]) 223 fi 224fi 225 226 227dnl Needed libmilter include and lib files from the sendmail include/lib dirs 228 229AC_CHECK_HEADER(mfapi.h, 230ac_have_mfapi=yes \ 231AC_DEFINE(MFAPI_H, 1, [We have mfapi.h]), 232ac_have_mfapi=no) 233if test "$ac_have_mfapi" = "no" 234then 235 AC_CHECK_HEADER(libmilter/mfapi.h, 236 ac_have_mfapi=yes, 237 AC_MSG_ERROR([Unable to find mfapi.h])) 238fi 239 240AC_CHECK_LIB(milter,smfi_main,result=yes,result=no) 241if test "$result" = "yes"; then 242 LIBS="$LIBS -lmilter" 243else 244 AC_MSG_ERROR([Unable to find libmilter]) 245fi 246 247 248dnl DEBUG stuff 249 250if test "$DMALLOC" = "true" 251then 252 AC_MSG_CHECKING([for dmalloc]) 253 ac_save_LIBS="$LIBS" 254 LIBS="$LIBS -ldmalloc" 255 AC_TRY_LINK( 256 [#include <dmalloc.h>], 257 [ (void) malloc(1); ], 258 with_dmalloc=yes,with_dmalloc=no) 259 AC_MSG_RESULT([$with_dmalloc]) 260 if test "$with_dmalloc" = "no" 261 then 262 LIBS="$ac_save_LIBS" 263 else 264 CFLAGS="$CFLAGS -DDMALLOC" 265 fi 266 267 if test "$EFENCE" = "true" 268 then 269 AC_MSG_ERROR([Unable to use both dmalloc and efence at the same time]) 270 fi 271else 272 if test "$EFENCE" = "true" 273 then 274 AC_CHECK_LIB(efence,malloc,result=yes,result=no) 275 if test "$result" = "yes" 276 then 277 LIBS="$LIBS -lefence" 278 fi 279 fi 280fi 281 282dnl Define symbols 283 284AC_DEFINE(PID_FILE, $PID_FILE, [Our pid file]) 285AC_DEFINE(PAT_FILE, $PAT_FILE, [Our pattern file]) 286AC_DEFINE(SENDMAIL_INCLUDE, $SENDMAIL_INCLUDE, [Sendmail include dir]) 287AC_DEFINE(SENDMAIL_LIB, $SENDMAIL_LIB, [Sendmail lib dir]) 288 289 290 291AC_CONFIG_FILES([Makefile]) 292AC_OUTPUT(fedora/noattach.spec) 293AC_OUTPUT(fedora/noattach.sh) 294