1## Process this file with automake to produce Makefile.in
2#
3# (C) 2001 - 2006, 2008, 2009, 2012 Matthias Andree
4#
5# This file is part of leafnode.
6#
7# This library is free software; you can redistribute it and/or modify
8# it under the terms of the GNU Lesser General Public License as
9# published by the Free Software Foundation; either version 2 or 2.1 of
10# the License. See the file COPYING.LGPL for details.
11#
12# This library is distributed in the hope that it will be useful, but
13# WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15# Lesser General Public License for more details.
16#
17# You should have received a copy of the GNU Lesser General Public
18# License along with this library; if not, write to the Free Software
19# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20# USA
21
22SUBDIRS=. doc_german
23AM_MAKEFLAGS='LDFLAGS=$(LDFLAGS)'
24AUTOMAKE_OPTIONS=foreign dist-bzip2 no-installinfo 1.5
25
26CC = @CC@ $(GCC_FLAGS)
27
28# additional autoconf stuff
29RPM = @RPM@
30
31BUILT_SOURCES=config.c
32
33# globals
34sbin_PROGRAMS=leafnode fetchnews texpire checkgroups applyfilter
35bin_PROGRAMS=newsq leafnode-version
36noinst_PROGRAMS=quickmkdir amiroot lsort
37# quickmkdir is no longer referenced by this Makefile,
38# as it is no longer necessary. It is kept available for compatibility,
39# so that existing scripts to wrap leafnode in a package continue to
40# work
41noinst_SCRIPTS=update.sh makesubst subst setup-daemontools.sh \
42	       leafnode.cron.daily
43
44noinst_DATA=leafnode.xinetd
45
46sysconf_DATA=config.example filters.example run.tcpserver.dist run.tcpd.dist \
47    nntp.rules.dist Makefile.dist UNINSTALL-daemontools
48mydocs=README-FQDN README-FQDN.html README-FQDN.pdf \
49       README-daemontools \
50       FAQ.html FAQ.txt FAQ.pdf
51
52man_MANS=applyfilter.8 checkgroups.8 fetchnews.8 leafnode.8\
53	newsq.1 leafnode-version.1 texpire.8
54EXTRA_DIST=leafnode.spec leafnode.spec.in $(sysconf_DATA) CREDITS \
55	ChangeLog ChangeLog.old sanitize.sed \
56	README-MAINTAINER update.sh COPYING.LGPL COPYING.GPL \
57	getline.c mkstemp.c strdup.c strlcpy.c strlcpy.h \
58	.indent.pro config.h.in cindent README-FQDN.pod \
59	$(mydocs) $(MANPAGES_IN) makesubst subst.in \
60	FAQ.xml timegm.c \
61	run.tcpserver.dist.in run.tcpd.dist.in setup-daemontools.sh.in \
62	UNINSTALL-daemontools leafnode.cron.daily.in \
63	t.pcre_extract .lclintrc KNOWNBUGS \
64	leafnode-SA-2002-01.txt \
65	leafnode-SA-2003-01.txt \
66	leafnode-SA-2004-01.txt \
67	leafnode-SA-2005-01.txt \
68	leafnode-SA-2005-02.txt \
69	t/cmp.gal1t t/cmp.gal1w \
70	t/cmp.gal2t t/cmp.gal2w \
71	t/cmp.gal3t t/cmp.gal3w \
72	t/cmp.gal4t t/cmp.gal4w \
73	t/cmp.gal5t t/cmp.gal5w \
74	t/cmp.gal6t t/cmp.gal6w \
75	ADD-ONS leafnode.xinetd.in OLDNEWS tools/newsq.pl tools/archivefaq.pl \
76	GMakefile.doc preamble.tex
77
78MAINTAINERCLEANFILES=$(mydocs)
79
80README-FQDN.html: README-FQDN.pod
81	pod2html >$@ $(top_srcdir)/README-FQDN.pod \
82	|| { rm -f $@ ; false ; }
83	rm -f *~~
84
85README-FQDN: README-FQDN.pod
86	pod2text >$@ $(top_srcdir)/README-FQDN.pod \
87	|| { rm -f $@ ; false ; }
88
89README-FQDN.tex: README-FQDN.pod preamble.tex
90	pod2latex -full -prefile $(top_srcdir)/preamble.tex $(top_srcdir)/README-FQDN.pod
91
92README-FQDN.pdf: README-FQDN.tex
93	pdflatex README-FQDN.tex && \
94	pdflatex README-FQDN.tex && \
95	makeindex README-FQDN.idx && \
96	pdflatex README-FQDN.tex || \
97	rm -f README-FQDN.pdf
98
99LDADD=@LIBOBJS@ liblnutil.a @PCRELIB@
100
101# particulars
102leafnode_SOURCES=nntpd.c nntpd_dodate.c nntpd.h leafnode.h
103
104fetchnews_SOURCES=fetchnews.c fetchnews_check_date.c fetchnews.h
105
106filterutil.o: filterutil.c $(PCREDEP)
107
108MANPAGES_IN=applyfilter.8.in checkgroups.8.in fetchnews.8.in \
109	leafnode.8.in texpire.8.in leafnode-version.1.in newsq.1.in
110applyfilter.8: $(srcdir)/applyfilter.8.in subst
111	$(SHELL) ./subst <$(srcdir)/applyfilter.8.in >$@
112checkgroups.8: $(srcdir)/checkgroups.8.in subst
113	$(SHELL) ./subst <$(srcdir)/checkgroups.8.in >$@
114fetchnews.8: $(srcdir)/fetchnews.8.in subst
115	$(SHELL) ./subst <$(srcdir)/fetchnews.8.in >$@
116leafnode.8: $(srcdir)/leafnode.8.in subst
117	$(SHELL) ./subst <$(srcdir)/leafnode.8.in >$@
118texpire.8: $(srcdir)/texpire.8.in subst
119	$(SHELL) ./subst <$(srcdir)/texpire.8.in >$@
120setup-daemontools.sh: $(srcdir)/setup-daemontools.sh.in subst
121	$(SHELL) ./subst <$(srcdir)/setup-daemontools.sh.in >$@
122leafnode-version.1: $(srcdir)/leafnode-version.1.in subst
123	$(SHELL) ./subst <$(srcdir)/leafnode-version.1.in >$@
124newsq.1: $(srcdir)/newsq.1.in subst
125	$(SHELL) ./subst <$(srcdir)/newsq.1.in >$@
126
127run.tcpserver.dist: $(srcdir)/run.tcpserver.dist.in subst
128	$(SHELL) ./subst <$(srcdir)/run.tcpserver.dist.in >$@
129run.tcpd.dist: $(srcdir)/run.tcpd.dist.in subst
130	$(SHELL) ./subst <$(srcdir)/run.tcpd.dist.in >$@
131
132leafnode.cron.daily: $(srcdir)/leafnode.cron.daily.in subst
133	$(SHELL) ./subst <$(srcdir)/leafnode.cron.daily.in >$@
134
135$(srcdir)/subst.in: $(srcdir)/makesubst $(srcdir)/configure.ac
136	$(SHELL) $(srcdir)/makesubst $(srcdir)/configure.ac >$@
137
138leafnode.xinetd: leafnode.xinetd.in Makefile
139	echo '# THIS IS A GENERATED FILE - MAINTAINER, EDIT THE .in FILE INSTEAD' >$@ \
140	&& sed -e 's}[@]sbindir@}$(sbindir)}g' \
141	       -e 's}[@]NEWS_USER@}$(NEWS_USER)}g' \
142	    <$(srcdir)/leafnode.xinetd.in >>$@ || rm -f $@
143
144.PHONY: rpm
145rpm:	leafnode.spec
146	if test @RPMSRC@ = none ; then \
147	  echo "No RPM build dir. RPM not installed?" 1>&2 ; exit 2 ; fi
148	$(MAKE) dist-bzip2
149	rm -f @RPMSRC@/SOURCES/@PACKAGE@-@VERSION@.tar.bz2
150	cp @PACKAGE@-@VERSION@.tar.bz2 @RPMSRC@/SOURCES
151	rpmbuild -ba leafnode.spec || rpm -ba leafnode.spec
152
153install-data-hook: amiroot
154	set -e ; for i in "" /leaf.node /failed.postings /interesting.groups \
155		/out.going /message.id /temp.files ; do \
156        mkdir -p $(DESTDIR)$(SPOOLDIR)$$i ; \
157	if ./amiroot ; then \
158	 chown @NEWS_USER@:@NEWS_GROUP@ $(DESTDIR)$(SPOOLDIR)/$$i ; \
159	 chmod 2775      $(DESTDIR)$(SPOOLDIR)/$$i ; fi ; \
160	done
161	d="`dirname $(DESTDIR)@LOCKFILE@`" ; mkdir -p "$${d}" && \
162	if ./amiroot ; then \
163          chown @NEWS_USER@:@NEWS_GROUP@ "$${d}" ; \
164	  chmod 2775 "$${d}" ; fi
165
166uninstall-hook:
167	rm -f $(DESTDIR)@LOCKFILE@
168	@echo
169	@echo '===================================================='
170	@echo 'If you want to delete leafnode'"'"'s news spool, type:'
171	@echo 'rm -rf "$(DESTDIR)$(SPOOLDIR)"'
172	@echo
173	@echo 'Note that this will permanently remove articles from'
174	@echo 'all newsgroups, including local and archived groups!'
175	@echo '===================================================='
176	@echo
177
178.PHONY: update
179update: lsort
180	$(SHELL) $(srcdir)/update.sh "$(SPOOLDIR)" "$(sysconfdir)" "$(LOCKFILE)" "@NEWS_USER@" "@NEWS_GROUP@"
181
182config.c: Makefile configure
183	( echo '/* DO NOT EDIT! This file is auto-generated by Makefile. */' ; \
184	  echo '/* user programs go into @bindir@ */'; \
185	  echo '/* system programs go into @sbindir@ */'; \
186	  echo '#include "leafnode.h"'; \
187	  echo 'const char *spooldir = "@SPOOLDIR@" ;' ; \
188	  echo 'const char *sysconfdir = "@sysconfdir@" ;' ; \
189	  echo 'const char *lockfile = "@LOCKFILE@" ;' ; \
190	  echo 'const char *version  = "@VERSION@" ;' ) >$@ \
191	|| rm -f $@
192
193noinst_LIBRARIES=liblnutil.a
194liblnutil_a_SOURCES=nntputil.c configutil.c xoverutil.c activutil.c \
195	activutil_resolve.c activutil.h agetcwd.c \
196	miscutil.c artutil.c filterutil.c syslog.c getaline.c \
197	critmem.c critmem.h lockfile.c validatefqdn.c mgetaline.c \
198	leafnode.h mastring.h mastring.c getline.h \
199	wildmat.c validatefqdn.h getfoldedline.c writes.c ln_log.c \
200	ln_log.h grouplist.c checkpeerlocal.c pcre_extract.c version.h \
201	masock_sa2name.c masock.h groupselect.c groupselect.h system.h \
202	mysigact.h mysigact.c log_unlink.c wantassert.h snprintf.c
203
204nodist_liblnutil_a_SOURCES=config.c
205
206# for testing
207check_PROGRAMS = test1 testgen xsnprintf checkpeerlocal validatefqdn \
208		 pcre_extract nntputil t.rfctime grouplist
209dist_check_SCRIPTS = t.validate-xml
210checkpeerlocal_SOURCES	= checkpeerlocal.c
211t_rfctime_SOURCES = t.rfctime.c
212checkpeerlocal_CFLAGS	= -DTEST -DTEST_LOCAL $(AM_CFLAGS) $(CFLAGS)
213pcre_extract_CFLAGS = -DTEST $(AM_CFLAGS) $(CFLAGS)
214nntputil_CFLAGS=-DMAIN $(AM_CFLAGS) $(CFLAGS)
215validatefqdn_CFLAGS=-DTEST  $(AM_CFLAGS) $(CFLAGS)
216grouplist_CFLAGS=-DTEST  $(AM_CFLAGS) $(CFLAGS)
217
218MYTESTS=\
219t.gal2 t.gal3 t.gal4 t.gal6
220$(MYTESTS): Makefile \
221  $(top_srcdir)/t/cmp.gal1t $(top_srcdir)/t/cmp.gal1w \
222  $(top_srcdir)/t/cmp.gal2t $(top_srcdir)/t/cmp.gal2w \
223  $(top_srcdir)/t/cmp.gal3t $(top_srcdir)/t/cmp.gal3w \
224  $(top_srcdir)/t/cmp.gal4t $(top_srcdir)/t/cmp.gal4w \
225  $(top_srcdir)/t/cmp.gal5t $(top_srcdir)/t/cmp.gal5w \
226  $(top_srcdir)/t/cmp.gal6t $(top_srcdir)/t/cmp.gal6w
227$(MYTESTS):
228	i() { ( echo '#! /bin/sh' ; \
229	echo "./test1 <\"$$1\" | cmp - \"$$2\"" ); }; i \
230		`echo $(top_srcdir)/$@ | sed 's/t\.\(.*\)/t\/cmp.\1t/'` \
231		`echo $(top_srcdir)/$@ | sed 's/t\.\(.*\)/t\/cmp.\1w/'` \
232		>$@ && chmod +x $@
233
234TESTS=$(MYTESTS) xsnprintf t.pcre_extract t.validate-xml
235TESTS_ENVIRONMENT=srcdir=$(srcdir) SHELL="$(SHELL)"
236
237CLEANFILES=$(MYTESTS) xsnprintf $(man_MANS) FAQ.aux FAQ.tex FAQ.out FAQ.log \
238	   README-FQDN.aux README-FQDN.log README-FQDN.ind README-FQDN.idx \
239	   README-FQDN.ilg \
240	   README-FQDN.toc README-FQDN.pdf README-FQDN.idxs README-FQDN.tex
241
242distclean-local:
243	rm -f README-FQDN README-FQDN.html pod2html-itemcache pod2html-dircache
244	rm -f config.c stamp-h leafnode.cron.daily leafnode.xinetd
245	rm -f setup-daemontools.sh run.tcpserver.dist run.tcpd.dist
246	rm -f FAQ.html FAQ.txt FAQ.pdf FAQ.fo
247
248# NOTE: $< does not work with BSD make
249# ####################################
250#FAQ.tex: FAQ.xml
251#	openjade -t tex -V %generate-article-toc% -V '%paper-type%=A4' -d /usr/share/sgml/docbook/dsssl-stylesheets-1.79/print/docbook.dsl -o $@ $< \
252#	|| { rm -f $@ ; false ; }
253#
254#FAQ.pdf: FAQ.tex
255#	pdfjadetex $< || { rm -f $@ ; false ; }
256#	pdfjadetex $< || { rm -f $@ ; false ; }
257#	pdfjadetex $< || { rm -f $@ ; false ; }
258
259FAQ.fo: FAQ.xml
260	xmlto fo --extensions $(srcdir)/FAQ.xml
261
262FAQ.pdf: FAQ.fo
263#	$$HOME/XEP/xep -quiet -xml FAQ.fo -pdf $@
264	fop FAQ.fo $@
265
266FAQ.html: FAQ.xml
267	xmlto html-nochunks --extensions $(srcdir)/FAQ.xml
268
269FAQ.txt: FAQ.html
270	w3m -dump FAQ.html >$@
271
272docs:
273	gmake -f $(top_srcdir)/GMakefile.doc
274	cd doc_german && $(MAKE) docs
275
276# this target expects a .rsyncs file with lines of this format:
277# host:directory/
278# it will call rsync from its source directory to the destination for
279# each of them, running them in parallel
280.PHONY: rsync rsynconly
281rsync:	distdir rsynconly
282rsynconly:	$(srcdir)/.rsyncs
283	@( cat $(srcdir)/.rsyncs | sed -e 's}^}rsync -avessh --delete $(PACKAGE)-$(VERSION)/ }; s/\($$\)/ \&/;' ; echo "wait" ) | $(SHELL) -x
284