From: Mikhail Kobuk Date: Sat, 13 Apr 2024 00:18:44 +0000 (+0300) Subject: Add build system X-Git-Url: http://arktixord.com/git/?a=commitdiff_plain;h=2df40bb5b6e480061ec66e82aeab357ad4498355;p=linux-labs.git Add build system --- 2df40bb5b6e480061ec66e82aeab357ad4498355 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..bb3ccd3 --- /dev/null +++ b/Makefile @@ -0,0 +1,32 @@ +PANDOC ?= pandoc +PD_FLAGS=--resource-path=$(CURDIR):src --template=uikit.html --toc +PD_FORMAT=-f markdown -t html +PD_STANDALONE=--standalone --embed-resources + +# SRC = $(wildcard ./lab*/*.md) +SRC = $(wildcard ./lab*) +SRC += Linux_labs_0_Introduction.md + +default: all + +all: build + +build: prerequisites + +standalone: prerequisites + ./build.sh "$(PANDOC)" "$(PD_FLAGS) $(PD_STANDALONE)" "$(PD_FORMAT)" $(SRC) + +clean: + rm -rf easy-pandoc-templates + rm -f ./*.html + +prerequisites: easy-pandoc-templates $(SRC) + +easy-pandoc-templates: + git clone https://github.com/ryangrose/easy-pandoc-templates + +sources: + @echo $(CURDIR): + @echo $(SRC) + +.PHONY: build standalone clean diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..cf09148 --- /dev/null +++ b/build.sh @@ -0,0 +1,40 @@ +#! /bin/bash + +# USE: ./build.sh [sources] + +pancompile="$1 $2 $3" +panexec="$1" +panflags="$2" +panformat="$3" +sources=${@:4} + +echo "using command <${pancompile}>" +echo "for sources: ${sources}" + +for src in ${sources}; do + if [ -d ${src} ]; then + printf "\tfound dir: ${src}\n" + + if [ "$(find ${src} -name '*.md' | wc -l)" != "1" ]; then + printf "\tToo many files in dir. Won't build. Skipping.\n" + continue + fi + + indir_src="$(find ${src} -name '*.md')" + indir_out="${indir_src##*/}" + ${panexec} ${panflags} ${indir_src} ${panformat} -o ${indir_out%.*}.html + + elif [ -f ${src} ] && [ "${src##*.}" == "md" ]; then + printf "\tfound md file: ${src}\n" + + printf "\t${panexec} ${panflags} ${src} ${panformat} -o ${src%.*}.html" + ${panexec} ${panflags} ${src} ${panformat} -o ${src%.*}.html + else + echo "unknown source" + exit 1 + fi +done + +#for lab in $(find . -maxdepth 1 -name "lab*" -type d); do +# echo "Found directory ${lab}" +#done