-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·53 lines (46 loc) · 998 Bytes
/
build.sh
File metadata and controls
executable file
·53 lines (46 loc) · 998 Bytes
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
#!/usr/bin/bash
idx=0
CNT=0
ec(){
idx=$(($idx+1))
sh -c "$*"
exitcode=$?
printf " [%*d/$CNT] $*\n" ${#CNT} $idx
if [ "$exitcode" != "0" ] && [ "$exitcode" != "" ]; then
if [ "$1" == "mkdir" ]; then
echo Mkdir failed to create directory, ignored
return
fi
echo Compilation failed at \`$*\'
exit 1
fi
unset exitcode
}
UNDEBUG_FL=-s
UNCLEAN_FL=n
for arg in $@; do
if [ "$arg" == "--debug" ]; then
UNDEBUG_FL=""
DEBUG_FL="--defsym DBG=1"
elif [ "$arg" == "--noclean" ]; then
UNCLEAN_FL=y
fi
done
ASM=${ASM:=as}
LD=${LD:=ld}
SOURCES=(`cd src/; ls *.s | sed 's/\.s//'`)
#SOURCES=${SOURCES:="main"}
#SOURCES=(${SOURCES[*]})
CNT=${#SOURCES[*]}
CNT=$(($CNT+3+$(if [ $UNCLEAN_FL == n ]; then echo 1; else echo 0; fi)))
objs=""
ec mkdir objs
for i in ${SOURCES[*]} ; do
ec $ASM $DEBUG_FL -O2 -o objs/$i.o src/$i.s
objs+="objs/$i.o "
done
ec ar scr server.a ${objs[@]}
ec $LD -O1 $UNDEBUG_FL -o server server.a
if [ $UNCLEAN_FL == n ]; then
ec rm -rf objs/ server.a
fi