#!/bin/sh cd ${0%/*} # go to project root FLAGS="-Wall -Wextra -g -pedantic" FLAGS_DISPLAY="-lraylib -lm -lpthread -lGL -ldl -lrt -lX11" SRC="src" BIN="bin" OBJ="obj" RUN=0 VALGRIND="" WEB=0 RAYLIB_SRC="/usr/local/src/raylib/src" #for web only function __run__ { RUN=1 } function __valgrind__ { VALGRIND=valgrind RUN=1 } function __clean__ { rm -rf $BIN rm -rf $OBJ kill $( ps -q $$ -o pgid= ) # exit } function __web__ { WEB=1 } set -xe if ! { [[ $# -eq 0 ]]; } 2> /dev/null then __$1__ fi mkdir -p $BIN mkdir -p $OBJ if { [[ $WEB -eq 0 ]]; } 2> /dev/null then gcc -c -o $OBJ/main.o $SRC/main.c gcc -c -o $OBJ/display.o $SRC/display.c gcc -o $BIN/main $OBJ/main.o $OBJ/display.o $FLAGS $FLAGS_DISPLAY if ! { [[ $RUN -eq 0 ]]; } 2> /dev/null then $BIN/main fi else source emsdk_env.sh emcc -o $BIN/pendulum.html $SRC/main.c $SRC/display.c \ $FLAGS -DPLATFORM_WEB -DRAYLIB_SRC="\"$RAYLIB_SRC/raylib.h\"" \ $RAYLIB_SRC/libraylib.a \ -I$RAYLIB_SRC/raylib.h \ -s USE_GLFW=3 -s ASYNCIFY \ --shell-file $SRC/shell.html # delete e line that blocks backspace and tab sed -i $(($(grep "keyCode === 8" $BIN/pendulum.js -n | cut -d : -f 1)+1))d $BIN/pendulum.js > /dev/null fi