Skip to content

Commit 293e3c9

Browse files
committed
Makefile for php-src docs build
In 19d2b84 ("Create book for docs", 2024-01-30) the php-src documentation (php-src docs) build has been introduced, yet the build instructions, namely `make html`, did not yield the expected results within the parenting setup of the php-src project on *nix systems. The reason is that the `make html` build instruction does not execute the make.bat file which contains the recipe to build the static HTML pages. This is because — different to Windows systems — *nix systems do not have the concept of [COMSPEC] etc. for executables, and therefore we cannot expect for build scripts an interpreter for the batch file. Adding a Makefile suffices to recover the build of php-src ./docs on a *nix system. NOTE: The "help" target has been intentionally left out as this Sphinx builder [1] (with the same name) is not available in the configuration, also in CI (.github/workflows/docs.yml). It is a template file from sphinx-quickstart. Consequentially, the makefile goal does not include it, as well as a target for any other unspecified builder. [COMSPEC]: https://en.wikipedia.org/wiki/COMSPEC "COMSPEC or ComSpec is one of the environment variables used in DOS, OS/2 and Windows, which normally points to the command line interpreter, which is by default COMMAND.COM in DOS,[1] Windows 95, 98, and ME or CMD.EXE in OS/2 and Windows NT. — Uncyclopedia" [1]: https://www.sphinx-doc.org/en/master/usage/builders/index.html "Built-in Sphinx builders"
1 parent 863ddc8 commit 293e3c9

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

docs/Makefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Makefile for php-src/docs
2+
# Copyright (c) The PHP Group
3+
4+
# If people set these on the make command line, use 'em
5+
6+
SPHINXBUILD ?= sphinx-build
7+
8+
SOURCEDIR = source
9+
BUILDDIR = build
10+
11+
rwildcard = $(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d))
12+
FILES = $(call rwildcard,$(SOURCEDIR),*.rst)
13+
14+
all : html
15+
16+
.PHONY : clean html preflight
17+
18+
clean :
19+
rm -rf -- $(wildcard $(SOURCEDIR)/.~ $(BUILDDIR))
20+
21+
html : preflight
22+
$(SPHINXBUILD) -M $@ $(SOURCEDIR) $(BUILDDIR)
23+
@printf 'Browse the php-src docs \e]8;;%s\e\\%s\e]8;;\e\\.\n' \
24+
"file://$(abspath $(BUILDDIR))/$@/index.$@" "local"
25+
26+
preflight : $(SOURCEDIR)/.~
27+
28+
$(SOURCEDIR)/.~ : $(FILES)
29+
rstfmt -w 100 $?
30+
touch $@

0 commit comments

Comments
 (0)