Move to recipe-based make script, to allow for tests, releases, etc.

This commit is contained in:
Jordan Bancino 2022-07-23 01:05:55 -04:00
parent 768430f614
commit 13a1fdecf9

35
make.sh
View file

@ -1,6 +1,7 @@
#!/usr/bin/env sh #!/usr/bin/env sh
TELODENDRIA_VERSION="0.0.1" TELODENDRIA_VERSION="0.0.1"
CVS_TAG="Telodendria-$(echo $TELODENDRIA_VERSION | sed 's/\./_/g')"
HEADERS="-D_POSIX_C_SOURCE=199506L -DTELODENDRIA_VERSION=\"$TELODENDRIA_VERSION\"" HEADERS="-D_POSIX_C_SOURCE=199506L -DTELODENDRIA_VERSION=\"$TELODENDRIA_VERSION\""
INCLUDES="-Isrc/include" INCLUDES="-Isrc/include"
@ -28,11 +29,12 @@ mod_time() {
fi fi
} }
mkdir -p build recipe_build() {
mkdir -p build
do_rebuild=0 do_rebuild=0
objs="" objs=""
for src in $(find src -name '*.c'); do for src in $(find src -name '*.c'); do
obj=$(echo "$src" | sed -e 's/^src/build/' -e 's/\.c$/\.o/') obj=$(echo "$src" | sed -e 's/^src/build/' -e 's/\.c$/\.o/')
objs="$objs $obj" objs="$objs $obj"
@ -45,13 +47,28 @@ for src in $(find src -name '*.c'); do
fi fi
do_rebuild=1 do_rebuild=1
fi fi
done done
if [ $do_rebuild -eq 1 ] || [ ! -f "build/$PROG" ]; then if [ $do_rebuild -eq 1 ] || [ ! -f "build/$PROG" ]; then
echo "LD build/$PROG" echo "LD build/$PROG"
$CC $LDFLAGS -o "build/$PROG" $objs $CC $LDFLAGS -o "build/$PROG" $objs
else else
echo "Up to date." echo "Up to date."
fi fi
}
ls -lh "build/$PROG" recipe_clean() {
rm -rv build
}
recipe_test() {
echo "Unit tests are not implemented yet."
}
for recipe in $@; do
recipe_$recipe
done
if [ -z "$1" ]; then
recipe_build
fi