diff options
author | kartofen <mladenovnasko0@gmail.com> | 2023-01-26 14:58:09 +0200 |
---|---|---|
committer | kartofen <mladenovnasko0@gmail.com> | 2023-01-26 14:58:09 +0200 |
commit | 5e1ae8b33873661b669eda509fcd000f8a964126 (patch) | |
tree | 6099bee318d9f0033949d23a3eeded6974d34b35 /build.sh |
very simple work withs html based on file path
Diffstat (limited to 'build.sh')
-rwxr-xr-x | build.sh | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..370c378 --- /dev/null +++ b/build.sh @@ -0,0 +1,47 @@ +#!/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 |