c-basic/compile-all.sh

25 lines
549 B
Bash
Raw Normal View History

2022-11-24 21:24:18 +01:00
#!/bin/bash
mkdir -p bin
returnCode=0
echo -e "compiling all files in working directory $(pwd)\n"
for file in $(/bin/ls *.c);
do
2022-11-25 00:14:31 +01:00
echo "compiling $file ..."
noext=$(echo "$file" | cut -f 1 -d '.')
gcc $file -o bin/$noext -lm
if [ "$?" -ne 0 ]
then
echo -e "\nERROR: could not compile $file !\n";
returnCode=1;
fi
done
2022-11-24 23:00:34 +01:00
echo -ne "\nfinished compiling all source files. ";
if [ "$returnCode" -eq 0 ]
then
echo -ne "No errors occured.";
else
echo -ne "Some errors occured.";
fi
echo "";
exit $returnCode