# To be used only with GNU Make OSTYPE := $(shell uname -s) ifeq ($(OSTYPE), FreeBSD) CFLAGS+=-Wall ${PTHREAD_CFLAGS} -DPREFIX='"${PREFIX}"' -DRUNDIR='"${RUNDIR}"' CFLAGS+=-DSYNONYM_USER='"${SYNONYM_USER}"' -DSYNONYM_GROUP='"${SYNONYM_GROUP}"' SYNONYM_USER=${SYNONYMOWN} SYNONYM_GROUP=${SYNONYMGRP} INCLUDEPATH=-I${LOCALBASE}/include/libxml2 -I${LOCALBASE}/include LIBXML=-lxml2 ${PTHREAD_LIBS} SYNONYM_BINDIR=$(SYNONYM_BASEDIR)${PREFIX}/sbin SYNONYM_RUNDIR=$(SYNONYM_BASEDIR)${RUNDIR} SYNONYM_SCRIPTDIR=$(SYNONYM_BASEDIR)${PREFIX}/etc/rc.d SYNONYM_SCRIPT_NAME=synonym.sh SYNONYM_CONFIGDIR=$(SYNONYM_BASEDIR)/${PREFIX}/etc SYNONYM_DOCDIR=$(SYNONYM_BASEDIR)${DOCSDIR} endif ifeq ($(OSTYPE), Linux) CC=gcc -Wall SYNONYM_USER=mail SYNONYM_GROUP=mail PTHREAD=-lpthread INCLUDEPATH=-I/usr/include/libxml2 LIBXML=-lxml2 EXTRA_LIBS=-lcrypt SYNONYM_BINDIR=$(SYNONYM_BASEDIR)/usr/local/sbin SYNONYM_RUNDIR=$(SYNONYM_BASEDIR)/var/run/synonym SYNONYM_SCRIPTDIR=$(SYNONYM_BASEDIR)/etc/rc.d/init.d SYNONYM_SCRIPT_NAME=synonym SYNONYM_CONFIGDIR=$(SYNONYM_BASEDIR)/etc SYNONYM_DOCDIR=$(SYNONYM_BASEDIR)/usr/share/doc/synonym endif ifeq ($(OSTYPE), SunOS) CC=gcc -Wall SYNONYM_USER=daemon SYNONYM_GROUP=daemon PTHREAD=-lpthread INCLUDEPATH=-I/usr/local/include -I/usr/local/include/libxml2 -I/usr/local/include LIBXML=-lxml2 EXTRA_LIBS=-lresolv -lsocket -lnsl SYNONYM_BINDIR=$(SYNONYM_BASEDIR)/usr/local/sbin SYNONYM_RUNDIR=$(SYNONYM_BASEDIR)/var/run/synonym SYNONYM_SCRIPTDIR=$(SYNONYM_BASEDIR)/etc/init.d SYNONYM_SCRIPT_NAME=synonym.sh SYNONYM_CONFIGDIR=$(SYNONYM_BASEDIR)/etc SYNONYM_DOCDIR=$(SYNONYM_BASEDIR)/usr/share/doc/synonym endif # This will be set to "$location/c-client.a -lpam" if we find a location with the c-client libraries CCLIENTLIB := $(shell (echo "/lib" && echo "/usr/lib" && echo "/usr/local/lib" && if test -f /etc/ld.so.conf ; then cat /etc/ld.so.conf ; fi) | while read libpath && [ \( "$$FOUND" != "1" \) ]; do if [ -f $$libpath/c-client.a ] ; then echo "$$libpath/c-client.a -lpam";FOUND=1 ; fi; done) ifneq ($(strip $(CCLIENTLIB)),) CCLIENTINCLUDE := $(shell (echo "/usr/include" && echo "/usr/include/c-client" && echo "/usr/local/include" && echo "/usr/local/include/c-client/") | while read incpath && [ \( "$$FOUND" != "1" \) ]; do if [ -f $$incpath/flstring.h ] ; then echo "-L$$incpath/";FOUND=1 ; fi; done) ifeq ($(strip $(CCLIENTINCLUDE)),) CCLIENTLIB= endif endif # If desired, please uncomment the following two lines, indicating the location of the c-client lib and headers, if other than the system default # Also, please remember to have -lpam in the CCLIENTLIB variable - PAM is only used by c-client for now # CCLIENTLIB= /usr/lib/my-cclient/c-client.a -pam # CCLIENTINCLUDE= -L/usr/include/my-cclient/ # Define the target, if the includes are present ifneq ($(strip $(CCLIENTLIB)),) ifneq ($(strip $(CCLIENTINCLUDE)),) DISCLAIMER=disclaimer.o html_parser.o body_parser.o scan.o DISCLAIMER_DEFINE = -DDISCLAIMER_SUPPORT endif endif # This variable will be void if libsmutil.a does not exist (and hence is not needed) on the system LIBSMUTIL := $(shell (echo "/lib" && echo "/usr/lib" && echo "/usr/local/lib" && if test -f /etc/ld.so.conf ; then cat /etc/ld.so.conf ; fi) | while read libpath && [ \( "$$FOUND" != "1" \) ]; do if [ -f $$libpath/libsmutil.a ] ; then echo "-lsmutil";FOUND=1 ; fi; done) LIBPATH=-L${LOCALBASE}/lib all: synonym synonym: synonym.o config.o filtering.o $(DISCLAIMER) $(CC) ${CFLAGS} ${LDFLAGS} synonym.o $(DISCLAIMER) -lmilter config.o filtering.o $(PTHREAD) -o synonym $(LIBSMUTIL) $(LIBPATH) $(LIBXML) $(CCLIENTLIB) $(EXTRA_LIBS) synonym.o: synonym.c synonym.h config.h filtering.h $(CC) $(CFLAGS) -c synonym.c $(DISCLAIMER_DEFINE) -o synonym.o $(INCLUDEPATH) config.o: config.c config.h synonym.h $(CC) $(CFLAGS) -c config.c $(DISCLAIMER_DEFINE) -o config.o $(INCLUDEPATH) filtering.o: filtering.c filtering.h synonym.h $(CC) $(CFLAGS) -c filtering.c $(DISCLAIMER_DEFINE) -o filtering.o $(INCLUDEPATH) html_parser.o: html_parser.c html_parser.h $(CC) $(CFLAGS) -c html_parser.c -o html_parser.o $(INCLUDEPATH) disclaimer.o: disclaimer.c disclaimer.h html_parser.o scan.o $(CC) $(CFLAGS) -c disclaimer.c -o disclaimer.o $(INCLUDEPATH) $(CCLIENTINCLUDE) scan.o: scan.c $(CC) $(CFLAGS) -c scan.c -o scan.o $(INCLUDEPATH) body_parser.o: body_parser.c body_parser.h $(CC) $(CFLAGS) -c body_parser.c -o body_parser.o $(INCLUDEPATH) $(CCLIENTINCLUDE) filtering.h: milter_data.h @touch filtering.h clean: @rm -f synonym synonym.o config.o filtering.o disclaimer.o html_parser.o scan.o install_rpm: synonym @install -d $(SYNONYM_BINDIR) @cp -f synonym $(SYNONYM_BINDIR) @install -d $(SYNONYM_SCRIPTDIR) @cp -f scripts/$(SYNONYM_SCRIPT_NAME) $(SYNONYM_SCRIPTDIR) @install -d $(SYNONYM_CONFIGDIR) # Only install the config file if it does not already exist. @if [ -f $(SYNONYM_CONFIGDIR)/synonym.conf ] ; then echo "Configuration file already exists. Installing as synonym.conf.new" ; cp synonym.conf $(SYNONYM_CONFIGDIR)/synonym.conf.new ; else cp -f synonym.conf $(SYNONYM_CONFIGDIR) ; fi @install -d $(SYNONYM_DOCDIR) @cp -f README license.txt $(SYNONYM_DOCDIR) @install -d $(SYNONYM_RUNDIR) install: install_rpm @chown $(SYNONYM_USER):$(SYNONYM_GROUP) $(SYNONYM_RUNDIR)