#############################################################################
##
#W Makefile.in                                              Laurent Bartholdi
##
#Y Copyright (C) 2007-2012, Laurent Bartholdi
##
#############################################################################
##
##  This creates archives, or compiles the documentation
##
#############################################################################

.PHONY: all doc clean distribute mrproper checkblocks tarballs wwwdir

PWDU:=$(shell dirname $(PWD))
PWDUU:=$(shell dirname $(PWDU))
VERSION:=$(shell grep '^Version :=' PackageInfo.g | cut -f2 -d'"')

LOCALBIN=bin/@GAPARCH@

all: $(LOCALBIN)

distribute: wwwdir doc

$(LOCALBIN):
	mkdir -p $(LOCALBIN)

clean:
	rm -rf config.log $(LOCALBIN) `find doc -type l`

mrproper: clean
	rm Makefile

configure: cnf/Makefile.in cnf/configure.ac
	(cd cnf; aclocal -Im4; autoconf; mv -f configure ..)

doc: doc/chap0.html

doc/chap0.html: doc/fr.xml doc/frbib.xml gap/*.gd
	echo 'LoadPackage("fr"); DOC@FR();' | @GAP_EXEC@ -q -T

checkblocks:
	grep '<#GAPDoc' PackageInfo.g gap/*d | awk -F'"' '{print $$2}' | sort > @@-blocks
	grep '<#Include' doc/fr.xml | awk -F'"' '{print $$2}' | sort > @@-in
	comm -3 @@-blocks @@-in
	@rm @@-blocks @@-in

tarballs: doc
	mkdir -p zips
	tar -c -f zips/fr-$(VERSION).tar.gz -z --exclude '*~' --exclude '.[a-z]*' --exclude 'config.[ls]*' --exclude 'fr/Makefile*' --exclude autom4te.cache --exclude sandbox --exclude zips --exclude bin -C .. fr
	ln -sf fr-$(VERSION).tar.gz zips/fr.tar.gz

wwwdir: doc
	git tag -f $(VERSION)
	git push origin :refs/tags/$(VERSION)
	git push --tags
	cp PackageInfo.g doc/
	cp README doc/README.fr
	(cd doc; git add *.html manual.pdf manual.css PackageInfo.g README.fr; git commit -m 'New html files'; git push github master:gh-pages --force)
	rm doc/PackageInfo.g doc/README.fr

#E Makefile.in . . . . . . . . . . . . . . . . . . . . . . . . . . . ends here
