blob: 370c378f97c842ebf1b1ba28c829467d22312ed3 (
plain)
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
|
#!/bin/sh
cd ${0%/*} # go to project root
NAME="web-server"
FLAGS="-std=c99 -Wall -Wextra -g -pedantic -D_POSIX_C_SOURCE=200112L"
SRCD="src"
ODIR="obj"
BIN="bin"
FILES="files"
RUN=0
function __run__ {
RUN=1
}
function __leak__ {
VALGRND="valgrind --leak-check=full --show-leak-kinds=all -s"
RUN=1
}
function __clean__ {
rm -rf $BIN
rm -rf $ODIR
exit 0
}
set -xe
mkdir -p $BIN
mkdir -p $ODIR
mkdir -p $FILES
if ! { [[ $# -eq 0 ]]; } 2> /dev/null
then
__$1__
fi
gcc -c $SRCD/server.c -o $ODIR/server.o $FLAGS
gcc -c $SRCD/main.c -o $ODIR/main.o $FLAGS -DFILES=\"$FILES\"
gcc -o $BIN/$NAME $ODIR/main.o $ODIR/server.o $FLAGS
if ! { [[ $RUN -eq 0 ]]; } 2> /dev/null
then
$VALGRND $BIN/$NAME
fi
|