-
Notifications
You must be signed in to change notification settings - Fork 0
/
MakeFiles
39 lines (33 loc) · 1 KB
/
MakeFiles
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
32
33
34
35
36
37
38
39
#! /bin/bash
rm -f Makefile
touch Makefile
if [[ -z "$1" ]]
then
echo Executable name required.;
echo usage: makemake.sh executable_name;
else
str1=$1
shift
# if [[ -z "$@" ]]
# then
# exit
# fi
if [[ -n "$@" ]]
then
str2=$@" "
fi
#echo "2"
echo -e "$str1 : $(ls | awk ' /.cpp/ { printf $str1" " }' | sed s/cpp/o/g) \n\tg++ -ansi -Wall -g -o $str1 $str2$(ls | awk ' /.cpp/ { printf $str1" " }' | sed s/cpp/o/g) \n">> Makefile
#echo "3"
for filename in *.cpp; do
#echo "fix : bug "
headerFile=$(cat $filename | awk ' /#include "/ { printf $2" " }' | sed s/'"'//g)
Ofile=`echo $filename | cut -f1 -d'.'`
echo -e "$Ofile.o : $filename $headerFile\n\tg++ -ansi -Wall -g -c $str2$filename\n" >> Makefile
# echo -e "$Ofile.o : $filename $headerFile" >> Makefile
# echo -e "\n" >> Makefile
# echo -e "\t" >> Makefile
# echo -e "g++ -ansi -Wall -g -c $str2$filename\n" >> Makefile
done
echo -e "clean : \n\trm -f $str1 $(ls | awk ' /.cpp/ { printf $str1" " }' | sed s/cpp/o/g) " >> Makefile
fi