-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproject
executable file
·79 lines (65 loc) · 1.74 KB
/
project
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/sh
if [ -z "$1" ]
then echo '**** usage: ./project projectname'
exit
fi
# check if project has already been created
if [ -f ./files.log ]
then
echo '**** project already created'
exit
else
# Creates project
echo "**** Creating project $1..."
fi
# files.log
touch files.log
echo files.log >> ./files.log
# vars.log
touch vars.log
echo vars.log >> ./files.log
echo "PROJECTNAME=$1" >> ./vars.log
echo "STARTTIME="`date +%s` >> ./vars.log
if [ "$1" == "c" ]; then echo "LANGUANGE=C" >> ./vars.log; else echo "LANGUAGE=CPP" >> ./vars.log; fi
# Makefile
touch Makefile
echo Makefile >> ./files.log
echo "# Makefile for $2" >> ./Makefile
if [ "$1" == "c" ]
then
echo "CC=clang" >> ./Makefile
else
echo "CC=clang++" >> ./Makefile
fi
echo "FLAGS=-g -Wall -Werror" >> ./Makefile
echo "OBJ=main.o" >> ./Makefile
echo "JVC=" >> ./Makefile
echo "main.o:" >> ./Makefile
if [ "$1" == "c" ]
then
echo '\t${CC} ${FLAGS} -o main.o -c main.c' >> ./Makefile
else
echo '\t${CC} ${FLAGS} -o main.o -c main.cpp' >> ./Makefile
fi
echo 'main: ${OBJ}' >> ./Makefile
echo '\t${CC} ${FLAGS} -o main ${OBJ}' >> ./Makefile
echo 'clean:'>> ./Makefile
echo '\trm -f ${OBJ}' >> ./Makefile
echo '\trm -f ${JVC}' >> ./Makefile
echo 'remake: clean main' >> ./Makefile
echo 'archive: clean' >> ./Makefile
echo "\ttar -cvzf $1.tar.gz \`cat files.log\`" >> ./Makefile
# main file
if [ "$1" == "c" ]; then end='.c'; else end='.cpp'; fi
touch main$end
echo main$end >> ./files.log
echo "// main$end" >> ./main$end
echo "// created `date`" >> ./main$end
echo "\n" >> ./main$end
echo "int main(int argc, char *argv[])" >> ./main$end
echo "{" >> ./main$end
echo "\n" >> ./main$end
echo "\n" >> ./main$end
echo "\treturn 0;" >> ./main$end
echo "}" >> ./main$end
echo "**** ....done."