#!/bin/sh cd ${0%/*} # go to project root NAME="web-server" FLAGS="-std=c99 -Wall -Wextra -g -pedantic -D_POSIX_C_SOURCE=200112L" SRCD="src" ODIR="obj" BIN="bin" FILES="files" RUN=0 function __run__ { RUN=1 } function __leak__ { VALGRND="valgrind --leak-check=full --show-leak-kinds=all -s" RUN=1 } function __clean__ { rm -rf $BIN rm -rf $ODIR exit 0 } set -xe mkdir -p $BIN mkdir -p $ODIR mkdir -p $FILES if ! { [[ $# -eq 0 ]]; } 2> /dev/null then __$1__ fi gcc -c $SRCD/server.c -o $ODIR/server.o $FLAGS gcc -c $SRCD/main.c -o $ODIR/main.o $FLAGS -DFILES=\"$FILES\" gcc -o $BIN/$NAME $ODIR/main.o $ODIR/server.o $FLAGS if ! { [[ $RUN -eq 0 ]]; } 2> /dev/null then $VALGRND $BIN/$NAME fi