aboutsummaryrefslogtreecommitdiff
path: root/build.sh
blob: f1befea503c314e0fa3d053dc8f89e66145854a7 (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
#!/bin/sh

cd ${0%/*} # go to project root

FLAGS="-Wall -Wextra -g -pedantic"
SRCD="src"
BIN="bin"
FILES="files"
RUN=0

function __run__ {
    RUN=1
}

function __clean__ {
    rm -rf $BIN
    rm -rf $FILES/*.txt
    kill $( ps -q $$ -o pgid= ) # exit
}

set -xe

if ! { [[ $# -eq 0 ]]; } 2> /dev/null
then
    __$1__
fi


mkdir -p $BIN
mkdir -p $FILES

gcc -o $BIN/main      $FLAGS $SRCD/main.c
gcc -o $BIN/gen_chain $FLAGS $SRCD/gen_chain.c

if ! { [[ $RUN -eq 0 ]]; } 2> /dev/null
then
    $BIN/gen_chain
    $BIN/main
fi