# (C) 2002 by Folke Ashberg <folke@ashberg.de>
# 
#  POP3-Virusscan-Proxy
#
# (C) 2002 by Folke Ashberg <folke@ashberg.de>
#
# $Id: Makefile,v 1.25 2002/06/12 00:03:55 folke Exp $ 
# 
# 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
#

CC=gcc
#CFLAGS=-Wall -ggdb
CFLAGS=-Wall -O2 -I$(PREFIX)/include -DPREFIX=\"${PREFIX}\"
LDFLAGS=-L. -lmime -lpcre -L$(PREFIX)/lib $(_LDFLAGS) #-static

OBJECTS=getline.o parsefile.o pop3vscan.o \
	scanner_basic.o scanner_avpd.o scanner_trophie.o
LIBS=libmime.a
PROGS=pop3vscan
DISTNAME="pop3vscan-0.4"

all: $(PROGS)

ripmime/ripmime.a:
	cd ripmime && $(MAKE) mimelib || exit 1
	
libmime.a: ripmime/ripmime.a
	ln -sf ripmime/ripmime.a libmime.a 

pop3vscan: $(OBJECTS) $(LIBS)
	$(CC) -o $@ $(OBJECTS) $(LDFLAGS)

.c.o:
	@# generic for all c .o
	$(CC) $(CFLAGS) -c $<

dep depend .dep:
	@echo "creating depencies"
	rm -f .tmp.dep 
	@find . -name "*.c" -maxdepth 1 -print0 | xargs -n 1 -0t $(CC) -M $(CFLAGS)  >>.tmp.dep
	mv .tmp.dep .dep
	    
install: pop3vscan
	ginstall -v -m 550 --strip pop3vscan $(PREFIX)/sbin/
	@if [ -f /etc/pop3vscan.conf ] ; then \
	    echo "/etc/pop3vscan.conf already exists, copying to /etc/pop3vscan.conf.sample" ; \
	    ginstall -v -m 700 pop3vscan.conf /etc/pop3vscan.conf.sample ; \
	else \
	    ginstall -v -m 700 pop3vscan.conf /etc/ ; \
	fi
	@if [ -f /etc/pop3vscan.mail ] ; then \
	    echo "/etc/pop3vscan.mail already exists, copying to /etc/pop3vscan.mail.sample" ; \
	    ginstall -v -m 744 pop3vscan.mail /etc/pop3vscan.mail.sample ; \
	else \
	    ginstall -v -m 744 pop3vscan.mail /etc/ ; \
	fi

	@if [ -f /etc/SuSE-release ] ; then \
	    echo "" ; \
	    echo "It looks like a SuSE-System" ; \
	    echo "Chdir to stuff and run pop3vscan.rc.suse-install " ; \
	    echo "to install the startup-scripts" ; \
	fi

	@if [ -f /etc/debian_version ] ; then \
	    echo "" ; \
	    echo "It looks like a Debian-System" ; \
	    echo "Chdir to stuff and run pop3vscan.rc.debian-install " ; \
	    echo "to install the startup-scripts" ; \
	fi

clean:
	cd ripmime && $(MAKE) clean
	rm -f $(PROGS) $(OBJECTS) $(LIBS) .dep core

tags:
	@#VIM Users know why! *g*
	ctags --c-types=+c+p+f+x -R .

fulltags:
	@#VIM Users know why! *g*
	find -name "*.c" -maxdepth 1 -print0 \
	| xargs -n 1 -0r $(CC) -M -H $(CFLAGS) 2>.totag >/dev/null
	find -name "*.c" -maxdepth 1 -print0 \
	| xargs -n 1 -0r echo >>.totag
	cat .totag | sed "s/^[[:space:]]*//" | grep -v "^$(CC)" | sort | uniq >.totag
	ctags --c-types=+c+p+f+x -L .totag .
	rm -f .totag

dist:
	mkdir $(DISTNAME)
	mkdir $(DISTNAME)/stuff
	$(MAKE) clean
	cp Makefile getline.{c,h} parsefile.{c,h} pop3vscan.{c,h} $(DISTNAME)
	cp scanner.h scanner_*.c $(DISTNAME)
	cp pop3vscan.conf pop3vscan.mail $(DISTNAME)
	cp README LICENCE $(DISTNAME)
	cp ripmime $(DISTNAME) -Rv
	cp stuff  $(DISTNAME)/stuff -Rv
	tar cfv $(DISTNAME).tar $(DISTNAME)/
	rm -rf $(DISTNAME)
	gzip -9f $(DISTNAME).tar

	
.PHONY: clean install all tags fulltags dist dep depend

include .dep



syntax highlighted by Code2HTML, v. 0.9.1