author | Olivier Brunel
<jjk@jjacky.com> 2023-04-25 21:21:00 UTC |
committer | Olivier Brunel
<jjk@jjacky.com> 2023-06-20 07:07:15 UTC |
parent | 60dba754823acbe82ea8e9f0c94bfa14ec01e873 |
common.mk | +14 | -4 |
configure | +34 | -26 |
mkdoc | +2 | -2 |
diff --git a/common.mk b/common.mk index 573683c..7a15f5a 100644 --- a/common.mk +++ b/common.mk @@ -33,7 +33,7 @@ PRIV_LIBS = PRIV_STATIC_LIBS = $(PRIV_LIBS:%=lib%.a) PRIV_SHARED_LIBS = $(PRIV_LIBS:%=lib%.so) PRIV_BINS = -DOCS = README COPYING $(BLD_DOCS:build/doc/%=md/%) +DOCS = README COPYING $(BLD_DOCS) DATA = # to be removed upon `make clean` @@ -75,6 +75,9 @@ lib%.so: # dependencies to try and make automatically BUILD_DEPS = +DESTDOC = $(DESTDIR)$(SHAREDIR)/doc/$(PROJECT_NAME) +INSTDOC = $(_INST) install -D -m 644 $< $@ + # to be generated by ./configure include config.mk @@ -108,8 +111,14 @@ $(DESTDIR)$(SHAREDIR)/doc/$(PROJECT_NAME)/README: $(_INST) install -D -m 644 /dev/null $@ ; comain/mkreadme > $@ # install documentation -$(DESTDIR)$(SHAREDIR)/doc/$(PROJECT_NAME)/%: % - $(_INST) install -D -m 644 $< $@ +$(DESTDOC)/%: % | dummy% + $(INSTDOC) + +#$(DESTDOC)/0/%: build/doc/% +# $(INSTDOC) + +#$(DESTDOC)/3/escall_fmt.3.md: build/doc/esc.h/escall_fmt.3.md +# $(INSTDOC) # install *.md documentation $(DESTDIR)$(SHAREDIR)/doc/$(PROJECT_NAME)/md/%.md: build/doc/%.md | dummy% @@ -180,7 +189,8 @@ all: doc $(BLD_STATIC_LIBS) $(BLD_SHARED_LIBS) $(BLD_BINS) deps: $(BUILD_DEPS) -doc: $(BLD_DOCS) +doc: $(BLD_MD0) $(BLD_MD1) $(BLD_MD2) $(BLD_MD3) $(BLD_MD4) $(BLD_MD5) \ + $(BLD_MD6) $(BLD_MD7) $(BLD_MD8) $(BLD_MD9) $(BLD_BINS): $(_CC) -o $@ $(COMMON_CFLAGS) $(CFLAGS) $(COMMON_LDFLAGS) $(LDFLAGS) $^ diff --git a/configure b/configure index 44f070d..3350008 100755 --- a/configure +++ b/configure @@ -566,20 +566,32 @@ echo " => Generating files..." echo " -> Generating config.mk..." exec 5>&1 1>config.mk.tmp -echo "# This file was generated by:" -echo "# $0 $@" -echo "# Any changes you make in here will be lost on the next ./configure" -echo "" +cat <<EOF +# This file was generated by: +# $0 $@ +# Any changes you make in here will be lost on the next ./configure + +# paths +BINDIR = $bindir +LIBDIR = $libdir +INCDIR = $incdir +SHAREDIR = $sharedir + +# general variables +PROJECT_NAME = $name +PROJECT_VERSION = $version + +CC = $CC +AR = $AR +RANLIB = $RANLIB + +EOF if test -n "$BITS"; then echo "BITS := $BITS" echo "" fi -echo "CC = $CC" -echo "AR = $AR" -echo "RANLIB = $RANLIB" - # not sure this really matters, so long as both are mentioned it will be the # order of our vpath that will matter really - still, let's keep it that way if test "$prefer" = "static"; then @@ -608,13 +620,19 @@ setupobjs() local objs if test "$name" = "doc"; then objs="$(find "$d" -type f -name '*.md')" - docs_objs="$(echo "$objs" \ - | sed -e 's/^src\/doc\(.*\/\)\(.\+\.md\)$/build\/doc\/\2: src\/doc\1\2/g')" - - objs="$(echo "$objs" \ - | sed -e 's/^.\+\(\/.\+\.md\)$/build\/doc\1/g' \ - | tr '\n' ' ')" - BLD_DOCS="$objs $BLD_DOCS" + for i in {9..0}; do + local s="$(echo "$objs" \ + | sed -e 's/^src\/doc\/\(.\+\).'$i'.md$/build\/doc\/\1.'$i'.md/g' \ + -e 's/src\/.\+$//g' \ + | tr '\n' ' ' | sed -e 's/ \+/ /g')" + BLD_DOCS="BLD_MD$i=$s"$'\n'"$BLD_DOCS" + done + BLD_DOCS="BLD_DOCS=$(echo "$objs" \ + | sed -e 's/^src\/doc.*\/\(.\+\.\(.\)\.md\)$/\2\/\1/g' \ + | tr '\n' ' ' | sed -e 's/ \+/ /g')"$'\n'"$BLD_DOCS" + BLD_DOCS="$(echo "$objs" \ + | sed -e 's/^src\/doc\(.*\)\/\(.\+\.\(.\)\.md\)$/\$(DESTDOC)\/\3\/\2: build\/doc\1\/\2\n $(INSTDOC)/g' \ + )"$'\n'"$BLD_DOCS" continue fi objs="$(find "$d" -type f -name '*.[cS]' | sed -e s/^src/build/g \ @@ -680,7 +698,7 @@ setupobjs cat <<EOF # build targets -BLD_DOCS = $BLD_DOCS +$BLD_DOCS BLD_STATIC_LIBS = $BLD_STATIC_LIBS BLD_SHARED_LIBS = $BLD_SHARED_LIBS BLD_BINS = $BLD_BINS @@ -698,16 +716,6 @@ LDFLAGS += $LDFLAGS # special dependencies we try to make automatically BUILD_DEPS = $BUILD_DEPS - -# paths -BINDIR = $bindir -LIBDIR = $libdir -INCDIR = $incdir -SHAREDIR = $sharedir - -# general variables -PROJECT_NAME = $name -PROJECT_VERSION = $version EOF exec 1>&5 5>&- diff --git a/mkdoc b/mkdoc index 1b23a8c..21f11aa 100755 --- a/mkdoc +++ b/mkdoc @@ -1,7 +1,7 @@ #!/bin/sh -src="$1" -dst="$2" +dst="$1" +src="src/$(expr substr "$dst" 7 ${#dst})" awk 'BEGIN { FS="[ >]" } { if ($0 ~ /^<inc (.+)>$/) { system("test -e src/doc/include/"$2" \