# news system build.
# (C) Tapsell-Ferrier Limited 2004

# 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, 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; see the file COPYING.  If not, write to the
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301, USA.



# README 
# When you run this you should first "cvs update" the root,
# server and rss directorys.


# DEPENDANCIES
# This Makefile requires libxml2 and libxslt tools.
# It also requires at least cvs version 12.9.



# Do all the news updates.
all: quagga.rss gnunews

# Do the main GNU stuff.
gnunews: gnunews.en gnunews.i18n

gnunews.en: ../server ../server/whatsnew.html ../gnusflashes.include whatsnew.rss 

# Translations of news items.
# Add your translation here if you want it to be automatically built
# by the fencepost batch job.
gnunews.i18n: \
	../server/whatsnew.it.html \
	../gnusflashes.it.include  \
	whatsnew.it.rss            \
	../server/whatsnew.pl.html \
	../gnusflashes.polish.include  \
	whatsnew.pl.rss            \
	../server/whatsnew.pt.html \
	../gnusflashes.pt.include  \
	whatsnew.pt.rss		   \
	../server/whatsnew.ca.html \
	../gnusflashes.ca.include  \
	whatsnew.ca.rss		   \
	../server/whatsnew.sr.html \
	../gnusflashes.sr.include  \
	whatsnew.sr.rss


# Options for CVS commands. Set to:
#  -n
# if you DO NOT want commits to be performed.
CVSOPTS=


# Update the whole directory, not just the Makefile
Makefile:
	cvs -q update Makefile

# We could make this depend on an HTTP data check
.PHONY: quagga.rss
quagga.rss: 
	./make-rss.sh > quagga.rss
	cvs $(CVSOPTS) ci -m "automatic update of the free software directory RSS" quagga.rss



# Whatsnew update.
whatsnew.rss: ../server/whatsnew.txt
	gawk -f ../server/news-to-xml.awk $< | xsltproc whatsnew.xslt - > $@
	cvs $(CVSOPTS) ci -m "automatic update of the whatsnew RSS" $@

# This is the target that sends the email to the translators list
../server/whatsnew.html: ../server/whatsnew.txt
	cat $< | mail -s "GNU news update" trans-coord-news@gnu.org
	gawk -f ../server/news-to-xml.awk $< | xsltproc ../server/whatsnew.xslt - > $@
	cvs $(CVSOPTS) ci -m "automatic update of the whatsnew.html" $@

../gnusflashes.include: ../server/whatsnew.txt
	gawk -f ../server/news-to-xml.awk $< | xsltproc ../gnusflashes.xslt - > $@
	cvs $(CVSOPTS) ci -m "automatic update of the GNUs flashes" $@



# The command sequence we use to add non-existant files to CVS
define addfile
[ -f $@ ] || ( touch $@ ; cvs $(CVSOPTS) add $@ )
endef

# New language specific targets.
whatsnew.%.rss: ../server/whatsnew.%.txt
	$(addfile)
	gawk -f ../server/news-to-xml.awk $< | xsltproc whatsnew.xslt - > $@
	cvs $(CVSOPTS) ci -m "automatic update of the whatsnew RSS" $@

../server/whatsnew.%.html: ../server/whatsnew.%.txt 
	$(addfile)
	ENCODING=utf-8 gawk -f ../server/news-to-xml.awk $< | xsltproc ../server/whatsnew.$*.xslt - > $@
	cvs $(CVSOPTS) ci -m "automatic update whatsnew.html" $@

../gnusflashes.%.include: ../server/whatsnew.%.txt
	$(addfile)
	ENCODING=utf-8 gawk -f ../server/news-to-xml.awk $< | xsltproc ../gnusflashes.xslt - > $@
	cvs $(CVSOPTS) ci -m "automatic update" $@

# This is temporary. We need it because Apache thinks gnusflashes.pl.include is a Perl file.
../gnusflashes.polish.include: ../server/whatsnew.pl.txt
	$(addfile)
	ENCODING=utf-8 gawk -f ../server/news-to-xml.awk $< | xsltproc ../gnusflashes.xslt - > $@
	cvs $(CVSOPTS) ci -m "automatic update" $@

# End.
