-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompile
executable file
·61 lines (51 loc) · 999 Bytes
/
compile
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
#!/bin/bash
valid=0
if [[ $1 == "all" ]]
then
valid=1
mkdir -p bin
mkdir -p obj
for folder in src/*
do
for FILE in $folder/*
do
file_ext=$(echo $FILE | cut -d "." -f "2")
file_root=$(echo $FILE | cut -d "." -f "1" | cut -d "/" -f "3")
if [ $file_ext = "s" ]
then
as -ggdb $FILE -o obj/$file_root.o
ld obj/$file_root.o -o bin/$file_root
fi
done
done
fi
if [[ $1 == "just" ]]
then
valid=1
mkdir -p bin
mkdir -p obj
file_ext=$(echo $2 | cut -d "." -f "2")
file_root=$(echo $2 | cut -d "." -f "1" | cut -d "/" -f "3")
if [ $file_ext = "s" ]
then
as -ggdb $2 -o obj/$file_root.o
ld obj/$file_root.o -o bin/$file_root
else
valid=0
fi
fi
if [[ $1 == clean ]]
then
valid=1
rm -r bin
rm -r obj
fi
if [[ valid -eq 0 ]]
then
echo -e "Usage:"
echo -e "\t./compile [option] [file]"
echo -e "\nOptions:"
echo -e "\tall : compile and link all source"
echo -e "\tjust [file] : compile and link single file"
echo -e "\tclean : remove binaries"
fi