Blame build.sh

452870
#!/bin/bash
452870
452870
set -e
452870
20803a
20803a
TARGET="coolkbd"
e3897e
FLAGS="$(pkg-config --cflags --libs x11 xft xtst xrandr)"
cbe4b8
FLAGS="$FLAGS -Wall -lm"
20803a
MODE_FLAGS="-O3 -DNDEBUG"
40c5fe
DEF_CONFIG="config.h"
40c5fe
CONFIG="$DEF_CONFIG"
20803a
7e0df9
while [ "$#" != "0" ]; do
7e0df9
  if [ "$1" = "-release" ]; then
7e0df9
    true
7e0df9
  elif [ "$1" = "-debug" ]; then
7e0df9
    echo "debug mode"
7e0df9
    MODE_FLAGS="-g -O0"
7e0df9
  elif [ "$1" = "-direct-touch" ]; then
7e0df9
    FLAGS="$FLAGS -DDIRECT_TOUCH $(pkg-config --cflags --libs mtdev)"
40c5fe
  elif [ "$1" = "-config" ] && [ -n "$2" ]; then
40c5fe
    CONFIG="$2"
40c5fe
    echo "use config $CONFIG"
40c5fe
    shift
7e0df9
  elif [ "$1" = "-target" ] && [ -n "$2" ]; then
7e0df9
    TARGET="$2"
7e0df9
    shift
7e0df9
  else
40c5fe
    echo "usage: ./build.sh [-debug|-release] [-direct-touch] [-config CONFIG.H] [-target TARGET]"
7e0df9
    exit 1
7e0df9
  fi
20803a
  shift
7e0df9
done
20803a
20803a
40c5fe
if [ "$CONFIG" == "$DEF_CONFIG" ] && [ ! -f "$DEF_CONFIG" ]; then
40c5fe
  echo "copy $DEF_CONFIG from example"
40c5fe
  cp config.h.example $DEF_CONFIG
3c2742
fi
3c2742
3c2742
20803a
echo "build target: $TARGET"
40c5fe
echo cc main.c $MODE_FLAGS $FLAGS -include "$CONFIG" -o "$TARGET"
40c5fe
     cc main.c $MODE_FLAGS $FLAGS -include "$CONFIG" -o "$TARGET"
452870
452870
452870
echo done