# Development tree name for this version
PRODUCT = annoyance-filter
VERSION = 1.0d
TREE = $(PRODUCT)-$(VERSION)
# Build environment
OSNAME = Darwin
# Libraries
INCLUDE_LIBS = -IDCDFlib/doc
# Utilities used in building the program
SHELL = /bin/sh
CC = cc
CXX = c++
CTANGLE = cweb/ctangle
CWEAVE = cweb/cweave
DVIPS = dvips
INSTALL = /usr/bin/install -c -o root -g wheel
INSTALL_PROGRAM = install -s -o root -g wheel -m 555
INSTALL_DATA = install -o root -g wheel -m 444
PAGER = less
PDFTEX = pdftex
TEX = tex
XDVI = xdvi
COMPRESSOR = gzip
PERL = perl
MAN2HTML = man2html
MAN2HTMLHOST = www.fourmilab.ch
# Utility options
CFLAGS = -fno-common
LDFLAGS = -lm
# Targets
TOOLS = cweb/ctangle cweb/cweave
PROGS = $(TOOLS) $(PRODUCT) statlib_test
DATA =
DOCUMENTS = $(PRODUCT).tex $(PRODUCT).pdf statlib.pdf $(PRODUCT)_man.html
# Installation destinations
## The 'DESTDIR' variable allows you to install the program into a different
## location, e.g., for packaging, without affecting the compiled-in pathnames.
DESTDIR =
# Publication destinations
## PUBDEST specifies the location into which the "publish"
## target should copy the components downloadable from the
## Web page. This is set for the www.fourmilab.ch site
## architecture, and may be modified for mirror sites or
## to publish experimental versions in other locations.
WEBDIR = /ftp
PUBDEST = $(WEBDIR)/$(PRODUCT)
prefix =
exec_prefix = ${prefix}
bindir = ${exec_prefix}/bin
mandir = ${prefix}/man
man1dir = $(mandir)/man1
man1ext = .1
BINDIR = $(DESTDIR)$(bindir)
MAN1DIR = $(DESTDIR)$(man1dir)
prog: $(PROGS) $(DATA)
data: $(DATA)
doc: $(DOCUMENTS)
all: $(PROGS) $(DATA) $(DOCUMENTS)
# DCDFlib objects
DCDFLIB_OBJS = dcdflib.o ipmpar.o
dcdflib.o: DCDFlib/src/dcdflib.c
$(CXX) $(CFLAGS) -IDCDFlib/src -c DCDFlib/src/dcdflib.c
ipmpar.o: DCDFlib/src/ipmpar.c
$(CXX) $(CFLAGS) -IDCDFlib/src -c DCDFlib/src/ipmpar.c
# Annoyance filter program
$(PRODUCT): $(PRODUCT).o statlib.o $(DCDFLIB_OBJS)
$(CXX) $(PRODUCT).o statlib.o $(DCDFLIB_OBJS) -o $(PRODUCT) $(CFLAGS) $(LDFLAGS)
@rm -f core core.*
$(PRODUCT).o: $(PRODUCT).cc config.h
$(PRODUCT).cc: $(PRODUCT).w
$(PRODUCT).tex: $(PRODUCT).w log.w $(TOOLS)
$(PRODUCT).view: $(PRODUCT).dvi
getopt.o: getopt.c getopt.h
getopt1.o: getopt1.c getopt.h
# Statistical library
statlib_test: statlib_test.o statlib.o $(DCDFLIB_OBJS)
$(CXX) statlib_test.o statlib.o -o statlib_test $(DCDFLIB_OBJS) $(CFLAGS) $(LDFLAGS)
statlib.o: statlib.cc config.h getopt.h
statlib.cc: statlib.w
statlib_test.o: statlib_test.cc
statlib_test.cc: statlib.w
statlib.h: statlib.w
statlib.tex: statlib.w $(TOOLS)
statlib.view: statlib.dvi
# CTANGLE and CWEAVE utilities
cweb/ctangle: cweb/ctangle.c cweb/common.c cweb/common.h
$(CC) -o cweb/ctangle cweb/common.c cweb/ctangle.c -Icweb
cweb/cweave: cweb/cweave.c cweb/common.c cweb/common.h
$(CC) -o cweb/cweave cweb/common.c cweb/cweave.c -Icweb
# Build auto-configuration scripts
configurator:
rm -f config.cache
autoconf
# Installation
install: $(PRODUCT) $(PRODUCT)-run
@if [ ! -d $(HOME)/.$(PRODUCT) ] ;\
then echo 'Creating directory $(HOME)/.$(PRODUCT)' ;\
mkdir $(HOME)/.$(PRODUCT) ;\
fi
$(INSTALL_PROGRAM) $(PRODUCT) $(HOME)/.$(PRODUCT)/$(PRODUCT)
$(INSTALL_PROGRAM) $(PRODUCT)-run $(HOME)/.$(PRODUCT)/$(PRODUCT)-run
@if [ -f dict.bin ] ;\
then if [ dict.bin -nt $(HOME)/.$(PRODUCT)/dict.bin ] ;\
then $(INSTALL_DATA) dict.bin $(HOME)/.$(PRODUCT)/dict.bin ;\
echo "Installed dict.bin in $(HOME)/.$(PRODUCT)/dict.bin" ;\
else echo "dict.bin not updated--not later than $(HOME)/.$(PRODUCT)/dict.bin" ;\
fi ;\
else if [ ! -f $(HOME)/.$(PRODUCT)/dict.bin ] ;\
then echo "You now need to build the dict.bin database and" ;\
echo "install it in $(HOME)/.$(PRODUCT)/dict.bin" ;\
else echo "Using existing dictionary $(HOME)/.$(PRODUCT)/dict.bin" ;\
fi ;\
fi
# Uninstallation
uninstall:
echo rm -rf $(HOME)/.$(PRODUCT)
# Update dependencies among source files
depend:
makedepend *.cc *.c
# There are a variety of levels of cleanliness
#
# clean: Remove object code, but leave C and TeX extracts from web
# and generated documentation. The current build configuration
# is preserved.
clean:
rm -f $(PROGS) *.o *.bak *.shar *.zip *.tar.gz *.tar.Z *.sig \
*.dvi core core.* *.out *.log *.aux *.toc *.idx \
*.scn *.gif *.pdb winarch.zip \
annoyance-filter_man_raw.html
rm -rf ii_files
( cd cweb ; make clean )
#
# distclean: Remove everything not present in the distribution.
# This wipes out the build configuration; you must
# re-run ./configure before rebuilding.
distclean: clean
rm -f config.cache config.h Makefile config.log config.status
rm -f $(PRODUCT).tex $(PRODUCT).idx \
$(PRODUCT).scn $(PRODUCT).toc \
statlib.tex statlib.idx statlib.scn statlib.toc
#
# maintainer-clean: Remove everything derivative from the
# master web. We don't delete $(PRODUCT).cc
# because that causes configure to fail.
maintainer-clean: distclean
@echo 'This command is intended for maintainers to use; it'
@echo 'deletes files that may need special tools to rebuild.'
rm -f *.ps *.pdf $(PRODUCT)_man.html $(PRODUCT).1
# reconfigure: This is a geeky target for those who
# wish to test on multiple platforms.
# Assuming you've already configured and
# have a more or less valid Makefile, it
# uses it to reconfigure for a different
# platform.
reconfigure:
rm -f config.cache
./configure
make clean
# Create distribution archives
ARCH_SOURCE = Makefile.in $(PRODUCT).cc $(PRODUCT).w config.h.in \
$(PRODUCT)-run \
getopt.c getopt1.c getopt.h \
mystrstream.h mystrstream_new.h fdstream.hpp \
statlib.cc statlib_test.cc statlib.h statlib.w \
cweb DCDFlib makew32.sh makew32.bat testw32.bat
ARCH_DOC = $(PRODUCT).1 $(PRODUCT).pdf $(PRODUCT)_man.html \
$(PRODUCT).manm \
statlib.pdf log.w \
COPYING COPYING.GNU INSTALL README README.WIN
ARCH_BIN = $(PRODUCT).exe ../cygwin/cygwin1.dll pop3proxy.pif
ARCH_BIN_DOC = COPYING.GNU README.WIN
ARCH_UTIL = docutil utilities
ARCH_DICT_TXT =
ARCH_CONF = configure configure.in install-sh
ARCH_FILES = $(ARCH_SOURCE) $(ARCH_DOC) $(ARCH_BIN) $(ARCH_CONF) \
$(ARCH_UTIL) $(ARCH_DICT_TXT)
ARCH_EXCLUDE = --exclude CVS
dist: all
# Make zipped archive of Win32 executable
rm -f $(PRODUCT).zip
zip -j $(PRODUCT).zip $(ARCH_BIN) $(ARCH_BIN_DOC)
# Make gzipped tar archive of complete distribution
( cd cweb ; make clean )
rm -f $(TREE).tar.gz
rm -rf $(TREE)
mkdir $(TREE)
chmod 777 $(TREE)
@echo "Copying distribution files"
@for file in $(ARCH_FILES); do \
cp -pr $$file $(TREE); \
done
tar cfv $(TREE).tar $(ARCH_EXCLUDE) $(TREE)
$(COMPRESSOR) $(TREE).tar
rm -rf $(TREE)
# Sign distribution files with GPG (www.fourmilab.ch specific)
signatures: dist
rm -f *.sig
gpg -u 'www.fourmilab.ch Distribution Signing Key' -sb $(TREE).tar.gz
gpg -u 'www.fourmilab.ch Distribution Signing Key' -sb $(PRODUCT).zip
# Publish distribution on Web page (www.fourmilab.ch specific)
publish: signatures dist
cp -pf $(PRODUCT).pdf statlib.pdf $(TREE).tar.gz $(PRODUCT)_man.html $(PUBDEST)
cp -pf $(PRODUCT).zip $(PUBDEST)
cp -pf *.sig $(PUBDEST)
-mkdir $(WEBDIR)/$(PRODUCT)/prior-releases/$(TREE)
cp -pf $(PRODUCT).pdf statlib.pdf $(TREE).tar.gz $(PRODUCT)_man.html $(WEBDIR)/$(PRODUCT)/prior-releases/$(TREE)
cp -pf $(PRODUCT).zip $(WEBDIR)/$(PRODUCT)/prior-releases/$(TREE)
cp -pf *.sig $(WEBDIR)/$(PRODUCT)/prior-releases/$(TREE)
# Manual page
$(PRODUCT).1: $(PRODUCT).manm $(PRODUCT).w
$(PERL) docutil/manm_expand.pl $(PRODUCT).manm $(PRODUCT).1
# View manual page
manpage: $(PRODUCT).1
nroff -man $(PRODUCT).1 | $(PAGER)
# View manual page in TROFF format (assumes groff -X works)
mantroff: $(PRODUCT).1
groff -man -X $(PRODUCT).1
# Print manual page
printman: $(PRODUCT).1
groff -man $(PRODUCT).1 | lp
# HTML edition of manual page
manhtml: $(PRODUCT)_man.html
# Test it
# Uncomment (and edit as you wish) the following line to test recognition of phrases
#PHRASE = --verb --phrasemin 1 --phrasemax 4
check: $(PRODUCT)
@( \
pass=0 ;\
fail=0 ;\
./$(PRODUCT) $(PHRASE) --mail $(PRODUCT).w --junk statlib.w --prune \
--fwrite dictf.tmp --write dict.tmp --csvw dictc.tmp ; \
a=`./$(PRODUCT) $(PHRASE) --read dict.tmp --trans - -t $(PRODUCT).w | \
head -50 | grep 'X-Annoyance-Filter-Classification: Mail'` ;\
if [ "$$a" = 'X-Annoyance-Filter-Classification: Mail' ] ;\
then echo 'Mail detection test passed.' ;\
pass=`expr $$pass + 1` ;\
else echo '*** Mail detection test failed! ***' ;\
fail=`expr $$fail + 1` ;\
fi ; \
a=`./$(PRODUCT) $(PHRASE) --fread dictf.tmp --trans - --test statlib.w | \
head -50 | grep 'X-Annoyance-Filter-Classification: Junk'` ;\
if [ "$$a" = 'X-Annoyance-Filter-Classification: Junk' ] ;\
then echo 'Junk detection test passed.' ;\
pass=`expr $$pass + 1` ;\
else echo '*** Junk detection test failed! ***' ;\
fail=`expr $$fail + 1` ;\
fi ;\
if [ $$fail -eq 0 ] ;\
then echo 'All tests passed.' ;\
else if [ $$pass -eq 0 ] ;\
then echo '*** All tests failed. ***' ;\
else echo "*** $$fail tests failed; $$pass passed. ***" ;\
fi ;\
fi ;\
)
@rm -f dict*.tmp
# Make Zipped source to build Windows executable
# The .w files are not actually required to build on
# Windows, but are extremely handy to have if you
# should encounter compile errors, as they are reported
# with line numbers from the .w files.
winarch: $(PRODUCT).cc
rm -f winarch.zip
zip -pr winarch.zip $(PRODUCT).cc \
statlib.h statlib.cc \
getopt1.c getopt.c \
DCDFlib \
config.h getopt.h \
mystrstream.h mystrstream_new.h \
fdstream.hpp \
makew32.sh makew32.bat testw32.bat \
$(PRODUCT).w statlib.w -x \*CVS\*
# Compile a program
.c.o:
$(CC) $(CFLAGS) $(INCLUDE_LIBS) -c $<
.c:
$(CC) $(CFLAGS) $(INCLUDE_LIBS) $(LDFLAGS) -o $@ $<
.cc.o:
$(CXX) $(CFLAGS) $(INCLUDE_LIBS) -c $<
.cc:
$(CXX) $(CFLAGS) $(INCLUDE_LIBS) $(LDFLAGS) -o $@ $<
.w.c:
$(CTANGLE) $<
.c.cc:
mv $*.c $*.cc
.w.tex: $(TOOLS)
$(CWEAVE) $<
.tex.dvi:
TEXINPUTS=.:./cweb:$(TEXINPUTS) $(TEX) $<
.tex.pdf:
TEXINPUTS=.:./cweb:$(TEXINPUTS) $(PDFTEX) $<
.dvi.view:
$(XDVI) -s 0 $<
.SUFFIXES:
.SUFFIXES: .bin .c .cc .o .ch .dvi .pdf .tex .view .w .1 .html .manm
syntax highlighted by Code2HTML, v. 0.9.1