Fix the generation of nix3 manpages

- Separate the generation of the manpages from their installation
- Make sure that `make` generates the manpages
- Make sure that `make install` installs them

Fix #5051
This commit is contained in:
regnat 2021-07-27 13:46:07 +02:00
parent f52fa47e16
commit cd6e9eb024

View file

@ -77,21 +77,29 @@ $(d)/builtins.json: $(bindir)/nix
install: $(docdir)/manual/index.html install: $(docdir)/manual/index.html
# Generate 'nix' manpages. # Generate 'nix' manpages.
install: $(mandir)/man1/nix3-build.1 install: $(mandir)/man1/nix3-manpages
man: doc/manual/generated/man1/nix3-manpages
all: doc/manual/generated/man1/nix3-manpages
$(mandir)/man1/nix3-manpages: doc/manual/generated/man1/nix3-build.1
@mkdir -p $$(dirname $@)
$(trace-install) install -m 0644 $$(dirname $<)/* $$(dirname $@)
# Technically this rule generates all the `nix3-*` manpages, but since we dont # Technically this rule generates all the `nix3-*` manpages, but since we dont
# know their list statically and they are all generated at once anyways, we can # know their list statically and they are all generated at once anyways, we can
# just be dirty and only track one # just be dirty and only track one
$(mandir)/man1/nix3-build.1: $(d)/src/command-ref/new-cli doc/manual/generated/man1/nix3-manpages: $(d)/src/command-ref/new-cli
@mkdir -p $$(dirname $@)
$(trace-gen) for i in doc/manual/src/command-ref/new-cli/*.md; do \ $(trace-gen) for i in doc/manual/src/command-ref/new-cli/*.md; do \
name=$$(basename $$i .md); \ name=$$(basename $$i .md); \
tmpFile=$$(mktemp); \ tmpFile=$$(mktemp); \
if [[ $$name = SUMMARY ]]; then continue; fi; \ if [[ $$name = SUMMARY ]]; then continue; fi; \
printf "Title: %s\n\n" "$$name" > $$tmpFile; \ printf "Title: %s\n\n" "$$name" > $$tmpFile; \
cat $$i >> $$tmpFile; \ cat $$i >> $$tmpFile; \
lowdown -sT man -M section=1 $$tmpFile -o $(mandir)/man1/$$name.1; \ lowdown -sT man -M section=1 $$tmpFile -o $$(dirname $@)/$$name.1; \
rm $$tmpFile; \ rm $$tmpFile; \
done done
touch $@
$(docdir)/manual/index.html: $(MANUAL_SRCS) $(d)/book.toml $(d)/custom.css $(d)/src/SUMMARY.md $(d)/src/command-ref/new-cli $(d)/src/command-ref/conf-file.md $(d)/src/expressions/builtins.md $(docdir)/manual/index.html: $(MANUAL_SRCS) $(d)/book.toml $(d)/custom.css $(d)/src/SUMMARY.md $(d)/src/command-ref/new-cli $(d)/src/command-ref/conf-file.md $(d)/src/expressions/builtins.md
$(trace-gen) RUST_LOG=warn mdbook build doc/manual -d $(docdir)/manual $(trace-gen) RUST_LOG=warn mdbook build doc/manual -d $(docdir)/manual