aboutsummaryrefslogtreecommitdiff
path: root/build.sh
diff options
context:
space:
mode:
Diffstat (limited to 'build.sh')
-rwxr-xr-xbuild.sh25
1 files changed, 21 insertions, 4 deletions
diff --git a/build.sh b/build.sh
index 4cf5e42..7984d22 100755
--- a/build.sh
+++ b/build.sh
@@ -2,23 +2,33 @@
cc="gcc"
ld="gcc"
+ar="ar"
+
+proc=$(nproc)
rm -rf ./lib/
rm -rf ./bin/
+rm -rf ./obj/
mkdir ./lib/
mkdir ./bin/
+mkdir ./obj/
+
+echo "[BUILD] ungrateful.c"
-echo "[BUILD] entry.c"
+cflags="-std=c99 -fPIC -Wall -Wextra -g -Wno-error -pedantic"
-cflags="-std=c99 -Wall -Wextra -g -Wno-error -pedantic"
$cc $cflags \
- -c -o lib/ungrateful.o \
+ -c -o obj/ungrateful.o \
-g src/ungrateful.c
if [[ $? -ne 0 ]]; then
exit
fi
+$ar rcs lib/libungrateful.a obj/ungrateful.o
+
+# ------------ Tests from here
+#
if [[ $1 == "no_tests" ]]; then
exit
fi
@@ -31,9 +41,16 @@ for test in tests/*.c; do
echo "[BUILD] $test"
- $cc $cflags -o bin/$fname $test lib/ungrateful.o -Isrc/
+ $cc $cflags -o bin/$fname $test -Llib/ -Isrc/ -lungrateful &
+
+ if [[ $(jobs -r -p | wc -l) -ge $proc ]]; then
+ wait
+ fi
done
+wait
+echo
+
for case in bin/*; do
if [[ $1 == "quiet" ]]; then
$case > /dev/null 2>&1