2 # Comm : Generateur de Makefile
7 # =============================================== al_aide
10 proc=`basename $commande`
13 $ $proc [ options ] <fichiers_source>
15 Genere un Makefile tenant compte des fichiers sources passes en argument
16 et des includes appeles par ces fichiers.
18 <fichiers_sources> liste des fichiers *.c *.cc *.cpp *.cxx et *.C
19 pris en compte pour constituer le Makefile.
20 Si des fichiers *.h sont presents, c'est pour generer des
21 fichiers qt (utilitaire moc)
23 Make=<fic> : Nom du makefile a generer
24 opt=val : Option passee
25 <autres> : options de compilation
26 (par exemple le repertoire des includes)
30 # =============================================== ana_arguments
38 for arg in $liste_args
48 make_file=`echo $arg | cut -f2 -d=`
51 arg_gcc="$arg_gcc $arg"
63 *.cpp | *.cc | *.cxx | *.C | *.c )
64 rad=`echo $arg | cut -f1 -d.`
65 liste_src="$liste_src $arg"
66 liste_rad="$liste_rad $rad"
73 # =============================================== put_includes
76 if ( [ -z "$3" ] ) then
96 # =============================================== init_par_defaut
100 if ( [ $os = Linux ] ) then
104 hdebut=`date '+%Hh %Mmn %Ss'`
106 make_file=makefile.ozz
124 cmd_cpil="g++ -c -g $opt_pic -Wall -DNO_CASCADE -Inokas --pedantic"
125 cmd_arch='ar rcvu $(BIBLI) *.o'
133 comm=`basename $commande`
134 reptools=`dirname $commande`
135 ### Definition des includes par $ozz_opt_cpp
137 if ( [ -n "$OZZ_FLAGS" -a -f "$OZZ_FLAGS" ] ) then
141 # =============================================== add_entete
144 today=`date "+%d/%m/%y a %Hh%M"`
146 echo "# Makefile OZZ genere le $today"
147 echo "# Par la commande : $comm "
148 echo "# Role de ce makefile : "
149 echo "# - Compiler les fichiers-source defraichis avec la commande \$CPIL"
150 echo "# - Les archiver sur le fichier archive \$REPLIB/\$BIBLI"
151 echo "# - Linker le programme principal (test unitaire) passe en argument"
153 echo ".SUFFIXES:" ## Pour ne pas etre emm....
154 echo "OPT = " ## Options de compilation de l'appelant
157 echo "REPEXE = ./work"
158 echo "BIBLI = $namof_lib"
159 echo "ARCH = $cmd_arch"
160 echo "CPIL = $cmd_cpil"
161 echo "LINK = $cmd_link"
162 echo "main = test_hexa"
165 precedente="OBJECTS ="
167 for module in $liste_rad
169 echo "$precedente \\"
170 precedente=" $repobj/$module.o"
179 @ echo ; echo ; echo ; echo ; echo ; echo ; echo ; echo ; echo ; echo
181 link : $repexe/\$(main).exe
183 $repexe/\$(main).cpp :
186 $repexe/\$(main).exe : $repexe/\$(main).cpp \$(REPLIB)/\$(BIBLI)
187 \$(LINK) $repexe/\$(main).cpp \$(REPLIB)/\$(BIBLI) -o $repexe/\$(main).exe
189 \$(REPLIB)/\$(BIBLI) : \$(OBJECTS)
193 rm -rf *.exe \$(REPLIB)/\$(BIBLI) \$(REPOBJ)/*.o *.bak *~
196 rm -rf \$(REPLIB)/\$(BIBLI) \$(REPOBJ)/*.o *.bak *~
200 # =============================================== add_sources
204 echo " ### Compilations"
206 for arg in $liste_src
208 radical=`echo $arg | cut -f1 -d.`
209 echo "$repobj/$radical.o : $arg"
210 echo " $compile $opt_user $arg"
213 # =============================================== Begin
216 echo " ... Generation de $make_file qui met a jour $namof_lib ..."
222 add_entete >> $make_file
223 add_sources >> $make_file
225 makedepend -f $make_file -Y -I. $liste_src 2> /dev/null
227 hfin=`date '+%Hh %Mmn %Ss'`
228 echo " ... Fin de la generation : $hfin"
229 echo " ... Elle avait debute a : $hdebut"