From c511ca9f0fd787e71febc7e486584febdd36e12a Mon Sep 17 00:00:00 2001 From: Jordan Bancino Date: Tue, 30 May 2023 13:20:23 +0000 Subject: [PATCH] Add a recipe to build the examples. --- Cytoplasm/make.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Cytoplasm/make.sh b/Cytoplasm/make.sh index c3d7388..341c539 100755 --- a/Cytoplasm/make.sh +++ b/Cytoplasm/make.sh @@ -20,6 +20,7 @@ addprefix() { : "${SRC:=src}" : "${TOOLS:=tools}" +: "${EXAMPLES:=examples}" : "${BUILD:=build}" : "${OUT:=out}" : "${STUB:=RtStub}" @@ -195,6 +196,22 @@ recipe_build() { recipe_docs } +recipe_examples() { + for src in $(find "${EXAMPLES}" -name '*.c'); do + out=$(basename "$src" .c) + out="${OUT}/bin/$out" + + if [ $(mod_time "$src") -ge $(mod_time "$out") ]; then + echo "CC $(basename $out)" + mkdir -p "$(dirname $out)" + if ! $CC $CFLAGS -o "$out" "$src" "${OUT}/lib/${LIB_NAME}.o" "-L${OUT}/lib" "-l${LIB_NAME}" ${LDFLAGS}; then + exit 1 + fi + fi + done + +} + recipe_clean() { rm -r "${BUILD}" "${OUT}" }