1# To build with SQLite3, use:
2#
3# rpmbuild --define 'with_sqlite 1' --sign -bb bogofilter.spec
4
5# To build -debuginfo RPMs on systems with RPM 4.2 or newer and recent
6# elfutils, add
7#
8# --define 'debugrpm 1'
9#
10# or place   %debugrpm 1   into your ~/.rpmmacros file.
11
12%define	Name		@PACKAGE@
13%define	Version		@VERSION@
14%define	Release		1
15
16%{?with_db42:   %define with_db42 1}
17%{!?with_db42:  %define with_db42 0}
18
19%{?with_sqlite:  %define with_sqlite 1}
20%{!?with_sqlite: %define with_sqlite 0}
21
22%if %{with_db42}
23%define DBFlag 1
24%define DBName -db42
25%endif
26
27%if %{with_sqlite}
28%define DBFlag 1
29%define DBName -sqlite3
30%endif
31
32%{!?DBFlag: %define DBFlag 0}
33%{!?bf_nameext: %define bf_nameext %{nil}}
34
35Summary:	Fast anti-spam filtering by Bayesian statistical analysis
36%if ! %{DBFlag}
37Name:		%{Name}%{bf_nameext}
38%else
39Name:		%{Name}%{DBName}%{bf_nameext}
40%endif
41Version:	%{Version}
42Release:	%{Release}
43License:	GPL
44Group:		Networking/Mail
45URL:		http://bogofilter.sourceforge.net
46Source0:	%{Name}-%{Version}.tar.xz
47
48%define _requires_exceptions perl
49
50Buildroot:	%{_tmppath}/%{Name}-%{Version}-root
51
52%description
53Bogofilter is a Bayesian spam filter.  In its normal mode of
54operation, it takes an email message or other text on standard input,
55does a statistical check against lists of "good" and "bad" words, and
56returns a status code indicating whether or not the message is spam.
57Bogofilter is designed with fast algorithms (including Berkeley DB system),
58coded directly in C, and tuned for speed, so it can be used for production
59by sites that process a lot of mail.
60
61%if %{with_sqlite}
62This version was built with SQLite3 support.
63%else
64This version was built with Berkeley DB support.
65%endif
66
67# use the debug_package macro if applicable:
68%{?debugrpm:%debug_package}
69
70%prep
71%setup -q -n %{Name}-%{Version}
72CFLAGS="$RPM_OPT_FLAGS" \
73./configure \
74  --prefix=%{_prefix} \
75  --mandir=%{_mandir} \
76  --sysconfdir=%{_sysconfdir} \
77%if %{?with_db42}
78  --with-database=db \
79%endif
80%if %{?with_sqlite}
81  --with-database=sqlite3 \
82%endif
83  --with-included-gsl
84
85%build
86make %_smp_mflags
87make %_smp_mflags DESTDIR="%{buildroot}" check
88
89%clean
90[ -n "%{buildroot}" -a "%{buildroot}" != / ] && rm -rf %{buildroot}
91
92%install
93[ -n "%{buildroot}" -a "%{buildroot}" != / ] && rm -rf %{buildroot}
94make DESTDIR=%{buildroot} install
95
96cp %{buildroot}%{_sysconfdir}/bogofilter.cf.example \
97   %{buildroot}%{_sysconfdir}/bogofilter.cf
98
99for n in xml html ; do
100  install -d .inst/$n
101  install -m644 doc/*.$n .inst/$n
102done
103
104for n in `find %{buildroot}%{_datadir}/%{name} -type d` ; do
105  chmod o-w $n
106done
107
108for d in contrib ; do
109  install -d %{buildroot}%{_datadir}/%{name}/$d
110  files=$(find "$d" -maxdepth 1 -type f -print)
111  for f in $files ; do
112    case $f in
113      *.c|*.o|*.obj|*/Makefile*) continue ;;
114      *.1)
115	cp -p $f %{buildroot}%{_mandir}/man1 ;;
116      *)
117	cp -p $f %{buildroot}%{_datadir}/%{name}/$d ;;
118    esac
119  done
120done
121
122mv bogogrep* contrib
123
124find %{buildroot}%{_datadir}/%{name} -name .dirstamp -print -delete
125
126%post
127
128%files
129%defattr(-,root,root)
130
131%doc AUTHORS COPYING INSTALL
132%doc GETTING.STARTED
133%doc NEWS README* RELEASE.NOTES TODO
134%doc doc/bogofilter-tuning.HOWTO.html
135%doc doc/bogofilter-SA-2002-01
136%doc doc/integrating*
137%doc doc/programmer
138%doc doc/README.*db
139%doc .inst/html .inst/xml
140
141%{_sysconfdir}/bogofilter.cf.example
142%config(noreplace) %{_sysconfdir}/bogofilter.cf
143
144%{_bindir}/bogofilter
145%{_bindir}/bogolexer
146%{_bindir}/bogotune
147%{_bindir}/bogoutil
148%{_bindir}/bogoupgrade
149%{_bindir}/bf_copy
150%{_bindir}/bf_compact
151%{_bindir}/bf_tar
152
153%{_mandir}/man1/bogofilter.1*
154%{_mandir}/man1/bogolexer.1*
155%{_mandir}/man1/bogotune.1*
156%{_mandir}/man1/bogoutil.1*
157%{_mandir}/man1/bogoupgrade.1*
158%{_mandir}/man1/bf_compact.1*
159%{_mandir}/man1/bf_copy.1*
160%{_mandir}/man1/bf_tar.1*
161
162%{_datadir}/%{name}/contrib/*
163
164%changelog
165