File: Makefile

package info (click to toggle)
p3scan 2:2.1-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,568 kB
  • ctags: 2,371
  • sloc: ansic: 12,072; makefile: 253; sh: 234
file content (175 lines) | stat: -rw-r--r-- 6,839 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# P3Scan 2.1
#
# (C) 2003/2004 by Jack S. Lai <laitcg@cox.net>
#
# It's intent is to provide a follow on program to POP3-Virusscan-Proxy 0.4
# by Folke Ashberg <folke@ashberg.de>.
#
# It is based upon his program but provides numerous changes to include
# scanning pop3 mail for spam, hardening the program, addaption to todays
# email environment, and many other changes.
#
# The initial release of p3scan includes patches made and submitted to the
# original project but were never incorporated.
#
# 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

PROGS=p3scan
DISTNAME="p3scan-2.1"

# User options
LOGOPT="LOG_PID|LOG_CONS"
LOGFAC="LOG_DAEMON"
LOGSET=-DLOGOPT=${LOGOPT} -DLOGFAC=${LOGFAC}
LANG=en
CC=gcc
SYSINS=install
CFLAGS=-Wall -O2 ${LOGSET}
LDFLAGS=-L. -lripmime -lpcre #-static

PREFIX=/usr
#MANDIR=$(PREFIX)/share/man/man8
MANDIR=$(PREFIX)/man/man8
piddir=/var/run/$(PROGS)
datadir=/var/spool/$(PROGS)
notify=/var/spool/$(PROGS)/notify
user=mail.mail
userdir=/etc/$(PROGS)
docdir=/usr/doc/$(DISTNAME)
# End user options

OBJECTS=getline.o parsefile.o p3scan.o \
	scanner_basic.o scanner_avpd.o scanner_trophie.o
LIBS=libripmime.a

all: $(PROGS)

ripmime/libripmime.a:
	cd ripmime && $(MAKE) libripmime || exit 1

libripmime.a: ripmime/libripmime.a
	ln -sf ripmime/libripmime.a libripmime.a

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

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

dep depend .dep:
	@echo "creating depencies"
	rm .tmp.dep -f
	@find -name "*.c"   -maxdepth 1 -print0 | xargs -n 1 -0rt $(CC) -M $(CFLAGS)  >>.tmp.dep
	mv .tmp.dep .dep

install: p3scan
	$(SYSINS) -v -m 550 --strip p3scan $(PREFIX)/sbin/
	@if [ -f /etc/sysconfig/init ] ; then $(SYSINS) -v -m 755 p3scan-init.d /etc/init.d/p3scan; fi
	@if test -d $(piddir); then echo "$(piddir) exists, not creating."; else mkdir -p $(piddir); fi
	@if test -d $(userdir); then echo "$(userdir) exits, not creating."; \
	else mkdir -p $(userdir); chown $(user) $(userdir); fi
	@if [ -f $(userdir)/p3scan.conf ] ; then \
	    echo "$(userdir)/p3scan.conf already exists, copying to $(userdir)/p3scan.conf.sample" ; \
	    $(SYSINS) -v -m 600 p3scan.conf $(userdir)/p3scan.conf.sample ; \
	else \
	    $(SYSINS) -v -m 600 p3scan.conf $(userdir)/ ; \
	fi
	@if [ -f $(userdir)/p3scan.mail ] ; then \
	    echo "$(userdir)/p3scan.mail already exists, renaming to $(userdir)/p3scan.mail.old" ; \
	    mv $(userdir)/p3scan.mail $(userdir)/p3scan.mail.old ; \
	fi
	@if test -d $(datadir)/children; then echo "$(datadir)/children exists, not creating."; else mkdir -p $(datadir)/children; fi
	@if test -d $(datadir)/notify; then echo "$(datadir)/notify exists, not creating."; else mkdir $(datadir)/notify; fi
	@chown $(user) $(piddir)
	@chown -R $(user) $(datadir)
	@chmod -R 700 $(datadir)
	$(SYSINS) -v -m 644 p3scan.8.gz $(MANDIR)
	$(SYSINS) -v -m 644 p3scan_readme.8.gz $(MANDIR)
	@if test -d $(docdir); then echo "$(docdir) exists, not creating."; else mkdir -p $(docdir); fi
	$(SYSINS) -v -m 644 AUTHORS $(docdir)
	$(SYSINS) -v -m 644 CHANGELOG $(docdir)
	$(SYSINS) -v -m 644 CONTRIBUTERS $(docdir)
	$(SYSINS) -v -m 644 LICENSE $(docdir)
	$(SYSINS) -v -m 644 NEWS $(docdir)
	$(SYSINS) -v -m 644 README $(docdir)
	$(SYSINS) -v -m 644 README-rpm $(docdir)
	$(SYSINS) -v -m 644 spamfaq.* $(docdir)
	$(SYSINS) -v -m 644 TODO.list $(docdir)
# Add translated mail files here:
	$(SYSINS) -v -m 644 p3scan-??-??.mail $(userdir)
	$(SYSINS) -v -m 644 p3scan-??.mail $(userdir)
	cp $(userdir)/p3scan-$(LANG).mail $(userdir)/p3scan.mail

clean:
	cd ripmime && $(MAKE) clean
	rm -f ripmime/libripmime.a
	rm -f ripmime/ripOLE/ripole
	rm -f $(DISTNAME).tar.* $(PROGS) $(OBJECTS) $(LIBS) .dep core

uninstall:
	@if [ -f $(PREFIX)/sbin/$(PROGS) ] ; then rm -f $(PREFIX)/sbin/$(PROGS) ; fi
	@if [ -f /etc/init.d/p3scan ] ; then rm -f /etc/init.d/p3scan ; fi
	@if [ -f /etc/rc.d/rc.p3scan ] ; then rm -f /etc/rc.d/rc.p3scan ; fi
	@if [ -f $(MANDIR)/p3scan.8.gz ] ; then rm -r $(MANDIR)/p3scan.8.gz ; fi
	@if [ -f $(MANDIR)/p3scan_readme.8.gz ] ; then rm -r $(MANDIR)/p3scan_readme.8.gz ; fi
	@if [ -f $(userdir)/p3scan.conf.sample ] ; then rm -f $(userdir)/p3scan.conf.sample ; fi
	@if [ -f $(userdir)/p3scan.mail.sample ] ; then rm -f $(userdir)/p3scan.mail.sample ; fi
	@if [ -d $(docdir) ] ; then rm -rf $(docdir) ; fi
	@if [ -f $(MANDIR)/p3scan.8.gz ] ; then rm -f $(MANDIR)/p3scan.8.gz ; fi
	@if [ -f $(MANDIR)/p3scan_readme.8.gz ] ; then rm -f $(MANDIR)/p3scan_readme.8.gz ; fi
	@{ test ! -d $(datadir) || { find $(datadir) -type d ! -perm -700 -exec chmod u+w {} ';' && rm -fr $(datadir); }; }
	@{ test ! -d $(piddir) || { find $(piddir) -type d ! -perm -700 -exec chmod u+w {} ';' && rm -fr $(piddir); }; }
	@echo "$(PROGS), $(datadir), and samples removed."
	@if [ -f $(userdir)/p3scan.conf ] ; then echo "$(userdir)/p3scan.conf remains." ; fi
	@if [ -f $(userdir)/p3scan.mail ] ; then echo "$(userdir)/p3scan.mail and p3scan-??.mail remains." ; fi

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:
	rm -rf $(DISTNAME)
	mkdir $(DISTNAME)
	$(MAKE) clean
	cp Makefile getline.{c,h} parsefile.{c,h} p3scan.{c,h} $(DISTNAME)
	cp scanner.h scanner_*.c $(DISTNAME)
	cp p3scan.conf p3scan-??.mail p3scan-??-??.mail rc.p3scan $(DISTNAME)
	cp p3scan.8.gz p3scan_readme.8.gz $(DISTNAME)
	cp rc.p3scan p3scan-init.d $(DISTNAME)
	cp AUTHORS CHANGELOG CONTRIBUTERS LICENSE NEWS README README-rpm spamfaq.* TODO.list $(DISTNAME)
	cp ripmime* $(DISTNAME) -Rv
	rm -f $(DISTNAME).tar.gz*
	tar cfv $(DISTNAME).tar $(DISTNAME)/
	rm -rf $(DISTNAME)
	gzip -9f $(DISTNAME).tar
	md5sum $(DISTNAME).tar.gz > $(DISTNAME).tar.gz.md5
	@echo "Now create signature with:"
	@echo "gpg -a -o $(DISTNAME).tar.gz.asc -b $(DISTNAME).tar.gz"
#	gpg -a -o $(DISTNAME).tar.gz.asc -b $(DISTNAME).tar.gz

.PHONY: clean install all tags fulltags dist dep depend

include .dep