Programmation shell makefile
Bonjour
Je suis un débutant en programmation shell, j'aimerai créer un script permettant de générer automatiquement un fichier Makefile. Malheuresment quand je lance ce script depuis mon terminal on m'affiche quelques erreurs en tappant ./ex7.sh prog :
Citation:
./ex7.sh: line 11: fonctions.cpp: command not found
./ex7.sh: line 12: fonctions: command not found
./ex7.sh: line 11: main.cpp: command not found
./ex7.sh: line 12: main: command not found
Et voilà mon script :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| #!/bin/bash
for i in `ls *.cpp`
do
if [ "basename $i" == "main.cpp" ]; then
{
objet1= ` basename $i `
objet= ` basename $i .cpp `
}
else
{
p1= ` basename $i `
p= ` basename $i .cpp `
}
fi
done
echo $1 : $objet.o $p.o >> Makefile
echo -e "\n\t gcc $objet.o $p.o -o $1 \n" >> Makefile
echo -e " $objet.o : $objet1 $p1 \n\t" >> Makefile
echo gcc -c $objet1 -o $objet.o >> Makefile
echo -e "\n $p.o: $p1 \n\t" >> Makefile
echo gcc -c $p1 -o $p.o >> Makefile
echo -e "clean :\n rm -f *.o" >> Makefile |
Je vous remercie pour toute éventuelle aide.