########################################
# Trombi - Copyright 2007-2008 Louis Paternault
# 
# This file is part of Trombi.
# 
# Trombi 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 3 of the License, or
# (at your option) any later version.
# 
# Trombi 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 Trombi.  If not, see <http://www.gnu.org/licenses/>.
########################################

all: trombi
trombi: diacritiques/affichagediac.adb diacritiques/accent.adb diacritiques/html.adb *.ad[bs] */*.ad[bs]
	rm -fr trombi
	gnatmake -P trombi.gpr

diacritiques/html.adb: diacritiques/htmlDebut.adb diacritiques/htmlFin.adb diacritiques/liste.txt diacritiques/creerHtmlADB.pl
	cd diacritiques && ./creerHtmlADB.pl

diacritiques/accent.adb: diacritiques/accentDebut.adb diacritiques/accentFin.adb diacritiques/liste.txt diacritiques/creerAccentADB.pl
	cd diacritiques && ./creerAccentADB.pl

diacritiques/affichagediac.adb: diacritiques/affichagediacDebut.adb diacritiques/affichagediacFin.adb diacritiques/liste.txt diacritiques/creerAffichageDiacADB.pl
	cd diacritiques && ./creerAffichageDiacADB.pl


test: all
	@(cd tests; ./tests.sh)

clean:
	rm -f objets/*.{ali,o} \
		diacritiques/affichagediac.adb \
		diacritiques/html.adb \
		diacritiques/accent.adb

allclean: clean
	rm -f trombi

help:
	@echo "all :      compile le projet"
	@echo "test :     teste le projet sur un jeu de tests predefinis"
	@echo "clean :    efface les fichiers temporaire de compilation"
	@echo "allclean : efface les fichiers temporaire de compilation, ainsi que l'executable"
	@echo ""
	@echo "  La suite est ce qui arrive lorsqu'un geek trompe l'ennui..."
	@echo ""
	@echo "stat :     quelques statistiques inutiles..."
	@echo "temps :    en combien de temps se compile le projet ?"

# La suite du makefile, c'est juste le resultat d'un geek qui s'amuse...

stat:
	@echo "`cat *.ad[bs] */*.ad[bs] | wc -l` lignes de code, dont :"
	@echo "  `cat *.ad[bs] */*.ad[bs] | grep -v ^[[:space:]]*-- | grep -v '^[[:space:]]*$$' | wc -l` lignes de *vrai* code"
	@echo "  `cat *.ad[bs] */*.ad[bs] | grep -v ^[[:space:]]*-- | grep '^[[:space:]]*$$' | wc -l` lignes vides"
	@echo "  `cat *.ad[bs] */*.ad[bs] | grep ^[[:space:]]*-- | grep -v '^[[:space:]]*$$' | wc -l` lignes de commentaires"
	@echo "`ls -1 *.ad[bs] */*.ad[bs] | wc -l` fichiers"
	@echo "`ls -1 *.ads */*.ads | wc -l` paquetages"

temps: allclean
	@(\
		d="`date +%s`";\
		make all;\
		f="`date +%s`";\
		echo "Compilation realisee en $$(( f-d )) secondes";\
	)
