#--------------------------------------------------------------------------------
#	definition du compilateur
#--------------------------------------------------------------------------------

compilo = g++

#--------------------------------------------------------------------------------
#	definition des chemins
#--------------------------------------------------------------------------------

chem_src = src/
chem_bin = bin/
chem_inc = inc/
chem_lib = lib/

#--------------------------------------------------------------------------------
#	definition des options
#--------------------------------------------------------------------------------

opt0 = -I inc/
opt1 = -O2 -Wno-deprecated
opt2 = -lm 

opt = $(opt0) $(opt1) $(opt2)

#--------------------------------------------------------------------------------
#	fichiers
#--------------------------------------------------------------------------------

fic0 = commun
fic1 = specifique

#--------------------------------------------------------------------------------
#	objet
#--------------------------------------------------------------------------------

obj0 = $(chem_bin)$(fic0).o
obj1 = $(chem_bin)$(fic1).o

obj = $(obj0) $(obj1)

#--------------------------------------------------------------------------------
#	source
#--------------------------------------------------------------------------------

src0 = $(chem_src)$(fic0).cpp
src1 = $(chem_src)$(fic1).cpp

#--------------------------------------------------------------------------------
#	inclu
#--------------------------------------------------------------------------------

inc0 = $(chem_inc)$(fic0).h
inc1 = $(chem_inc)$(fic1).h

#--------------------------------------------------------------------------------
#	compilations
#--------------------------------------------------------------------------------

#------------------
#	main
#------------------
main	:	$(chem_bin)main.o $(obj)
			$(compilo) $(chem_bin)main.o $(obj) $(opt) -o main
			
$(chem_bin)main.o	:	$(chem_src)main.cpp $(chem_inc)main.h
						$(compilo) -c $(chem_src)main.cpp $(opt) -o $(chem_bin)main.o

#------------------
#	commun
#------------------
$(obj0)	:	$(src0) $(inc0)
			$(compilo) -c $(src0) $(opt) -o $(obj0)


#------------------
#	specifique
#------------------
$(obj1)	:	$(src1) $(inc1)
			$(compilo) -c $(src1) $(opt) -o $(obj1)



#--------------------------------------------------------------------------------
#	outils
#--------------------------------------------------------------------------------
run :
		time nice -20 ./main
gaz : 
		clear
		make
		make run
		
gaz_all :

		make clean
		make gaz

clean :
		rm -f src/*~
		rm -f bin/*~
		rm -f inc/*~
		rm -f lib/*~
		rm -f bin/*.o
		rm -f lib/*.a
		rm -f *~
		rm -f main
		
docu :	
		doxygen doc/Doxyfile
		make -C doc/latex pdf
		evince doc/latex/refman.pdf &
		
clean_docu :
		rm -rf doc/html
		rm -rf doc/latex
		
clean_all :
		make clean
		make clean_docu

tar :
		rm -f prog_PC.tar
		tar cvf prog_PC.tar *
		chown phil prog_PC.tar
		chgrp phil prog_PC.tar
		
help :
		clear
		@echo "make"
		@echo "	compile uniquement les fichiers recents"
		@echo
		@echo "make run"
		@echo "	execute l'executable"
		@echo
		@echo "make gaz"
		@echo "	compile uniquement les fichiers recents et execute le programme"
		@echo
		@echo "make gaz_all"
		@echo "	compile tous les fichiers recents et execute le programme"
		@echo
		@echo "make docu"
		@echo "	creer la documentation via doxygen"
		@echo
		@echo "make clean"
		@echo "	efface les fichiers *.o *.a *~ ainsi que l'executable"
		@echo
		@echo "make clean_docu"
		@echo "	efface les repertoires doc/html et doc/latex"
		@echo
		@echo "make clean_all"
		@echo "	efface les fichiers *.o *.a *~ ainsi que l'executable"
		@echo "	efface les repertoires doc/html et doc/latex"
		@echo
		@echo "make tar"
		@echo "	creer un fichier tar du projet"
			
	
