aboutsummaryrefslogtreecommitdiff
path: root/build.sh
blob: 6c4860e2c69114c53ba1ba9913c48ddf1c9a17e3 (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
48
49
50
#!/bin/sh

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

FLAGS="-Wall -Wextra -g -pedantic"
SRCD="src"
ODIR="obj"
BIN="bin"
VALGRND=""

RUN=0

function run {
    RUN=1
}

function leak {
    VALGRND="valgrind --leak-check=full"
}

function clean {
    rm -rf $BIN
    rm -rf $ODIR
    rm -rf files
    kill $( ps -q $$ -o pgid= )
}

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

mkdir -p $ODIR
mkdir -p $BIN


gcc -c $SRCD/gen_tiles.c -o $ODIR/gen_tiles.o $FLAGS
gcc -c $SRCD/ppm.c       -o $ODIR/ppm.o       $FLAGS
gcc -c $SRCD/tiles.c     -o $ODIR/tiles.o      $FLAGS
gcc -c $SRCD/main.c      -o $ODIR/main.o       $FLAGS
gcc -o $BIN/wfc $ODIR/main.o $ODIR/ppm.o $ODIR/tiles.o $FLAGS

gcc -o $BIN/gen_tiles $ODIR/gen_tiles.o $ODIR/ppm.o $FLAGS

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