summaryrefslogtreecommitdiff
path: root/build.sh
blob: 88b193b380ac4ec94424f68d30a72d81f8c2b717 (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
#!/bin/sh -e

CC=${CC:-gcc}
STATIC=${STATIC:-}
DEBUGFLAGS=${OPTFLAGS:-"-Og -g"}
FASTFLAGS=${OPTFLAGS:-"-O3 -flto -fwhole-program -ffunction-sections -fdata-sections -Wl,--gc-sections"}

CFLAGS=" \
    -Wall -Wextra -Wpedantic -Wshadow \
    -Wno-long-long \
    -std=c89 \
    $STATIC \
    -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L \
"

case "$1" in
    "help")
        >&2 echo "Usage: $0 [help|fast|debug]"
        >&2 echo "          fast/debug - add optimization or debug flags"
        exit 1
        ;;
    "fast")    CFLAGS="$CFLAGS $FASTFLAGS"  ;;
    "debug"|*) CFLAGS="$CFLAGS $DEBUGFLAGS" ;;
esac

$CC $CFLAGS urltool.c -o urltool
ln -rsf urltool urldec
ln -rsf urltool urlenc