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

DEBUG=""
LIB="-Ilib/ -lSDL2_gfx"

while getopts "d" opt; do
    case "$opt" in
        d) DEBUG="-Wall -fsanitize=address -g"
            ;;
    esac
done

shift $((OPTIND-1))
[ "${1:-}" = "--" ] && shift

if [ "$1" ]; then
    echo "making src/$1"
    file="src/$1"
    clang -o bin/$(basename $file | sed 's/.c$//') $file $LIB `sdl2-config --cflags --libs` -lm $DEBUG
else
    for file in src/*; do 
        if [ -f "$file" ]; then 
            if [ "$file" != ".clangd" ]; then
                echo "making $file"
                clang -o bin/$(basename $file | sed 's/.c$//') $file $LIB `sdl2-config --cflags --libs` -lm $DEBUG
            fi
        fi 
    done
fi