1
0
mirror of https://git.FreeBSD.org/doc.git synced 2026-06-02 19:35:07 +00:00
Files
doc/documentation/Makefile
T

288 lines
7.8 KiB
Makefile
Raw Normal View History

2021-01-26 00:31:29 +01:00
# Generate the FreeBSD documentation
#
2026-02-19 11:28:04 +01:00
# Copyright (c) 2020-2026, The FreeBSD Documentation Project
# Copyright (c) 2020-2026, Sergio Carlavilla <carlavilla@FreeBSD.org>
2021-01-26 00:31:29 +01:00
#
2026-05-21 10:58:05 -04:00
# Targets intended for use on the command line:
2021-01-26 00:31:29 +01:00
#
2026-05-21 10:58:05 -04:00
# all (default) - Generate books and articles without generating
# PDFs or EPUBs.
# clean - Remove generated files.
# run - Serve the built documentation site locally.
# pdf - Build PDF versions of the articles and books.
# html - Build HTML versions of the articles and books.
# If the DOC_HTML_ARCHIVE variable is set, all
# documents will be archived/compressed, and only
# these files will be kept in public/.
# epub - Build EPUB versions of the articles and books
# (Experimental).
#
2026-05-21 10:58:05 -04:00
# The run target uses hugo's built-in webserver to make the doc site
# available for local browsing. The documentation should have been
# built prior to attempting to use the `run` target. By default, hugo
# will start its webserver on port 1313.
2021-01-26 00:31:29 +01:00
MAINTAINER=carlavilla@FreeBSD.org
# List of languages without book translations
ARTICLEONLY_LANGS= bn-bd da id ko tr
# List of languages without article translations
BOOKONLY_LANGS= mn
# List of all languages we have content for
2026-05-21 10:58:05 -04:00
ALL_LANGUAGES= bn-bd da de el en es fr hu id it ja ko mn nl \
pl pt-br ru tr zh-cn zh-tw
2026-05-21 10:58:05 -04:00
LOCALBASE?= /usr/local
USE_RUBYGEMS?= NO
2022-11-02 22:40:13 +01:00
GEM_PATH?=
2022-11-02 22:40:13 +01:00
.if ${USE_RUBYGEMS} == "YES"
2026-05-21 10:58:05 -04:00
GEMBASE?= ${GEM_PATH}
2022-11-02 22:40:13 +01:00
.else
2026-05-21 10:58:05 -04:00
GEMBASE?= ${LOCALBASE}
2022-11-02 22:40:13 +01:00
.endif
2026-05-21 10:58:05 -04:00
RUBY_CMD ?= ${LOCALBASE}/bin/ruby
HUGO_CMD = ${LOCALBASE}/bin/hugo
HUGO_ARGS?= --minify
HUGO_OFFLINE_ARGS?= --environment offline --minify
2026-05-21 10:58:05 -04:00
ROUGIFY_CMD= ${GEMBASE}/bin/rougify
2022-11-02 22:40:13 +01:00
ASCIIDOCTOR_CMD= ${GEMBASE}/bin/asciidoctor
ASCIIDOCTORPDF_CMD= ${GEMBASE}/bin/asciidoctor-pdf
2026-05-21 10:58:05 -04:00
ASCIIDOCTOREPUB3_CMD= ${GEMBASE}/bin/asciidoctor-epub3
2021-05-31 18:16:55 +02:00
.if defined(DOC_LANG) && !empty(DOC_LANG)
LANGUAGES= ${DOC_LANG:S/,/ /g}
.if ${LANGUAGES:Men} == "" && ${.TARGETS:Mpdf*} == "" && ${.TARGETS:Mhtml*} == ""
.warning "Warning: cannot skip 'en'; adding it back"
2026-05-21 10:58:05 -04:00
LANGUAGES+= en
.endif
2021-05-31 18:16:55 +02:00
.else
2026-05-21 10:58:05 -04:00
LANGUAGES= ${ALL_LANGUAGES}
2021-05-31 18:16:55 +02:00
.endif
2026-05-21 10:58:05 -04:00
RUBYLIB = ../shared/lib
.export RUBYLIB
2021-01-26 00:31:29 +01:00
2026-05-21 10:58:05 -04:00
RUN_DEPENDS= ${HUGO_CMD} \
2022-11-02 22:40:13 +01:00
${ASCIIDOCTOR_CMD} \
${ROUGIFY_CMD}
.ifndef HOSTNAME
. ifdef BIND
.HOST=$(BIND)
. else
.HOST=localhost
. endif
.else
.HOST=$(HOSTNAME)
.endif
# Strip the languages with only articles from the list of languages we
2026-05-21 10:58:05 -04:00
# will use to build books
BOOK_LANGS= ${LANGUAGES}
.for a in ${ARTICLEONLY_LANGS}
2026-05-21 10:58:05 -04:00
BOOK_LANGS:= ${BOOK_LANGS:N${a}}
.endfor
# Strip the languages with only books from the list of languages we
2026-05-21 10:58:05 -04:00
# will use to build articles
ARTICLE_LANGS= ${LANGUAGES}
.for a in ${BOOKONLY_LANGS}
2026-05-21 10:58:05 -04:00
ARTICLE_LANGS:= ${ARTICLE_LANGS:N${a}}
.endfor
# Take the list of all languages, and take out the ones we have been
2026-05-21 10:58:05 -04:00
# asked for. We'll feed this to hugo.
SKIP_LANGS=
.for a in ${ALL_LANGUAGES}
.if ${LANGUAGES:M${a}} == ""
2026-05-21 10:58:05 -04:00
SKIP_LANGS+= ${a}
.endif
.endfor
.ORDER: all run
.ORDER: requirements
2021-12-11 10:57:33 +01:00
.ORDER: starting-message
2021-01-27 10:05:58 -06:00
.ORDER: starting-message build
2021-12-11 10:57:33 +01:00
.ORDER: build
2021-01-27 10:05:58 -06:00
2021-12-11 10:57:33 +01:00
all: requirements starting-message generate-pgpkeys-txt build
run: requirements starting-message generate-pgpkeys-txt run-local
2021-06-29 09:57:30 +01:00
# clean does not call pdf-clean as that is a subset of hugo-clean
2021-12-11 10:57:33 +01:00
clean: hugo-clean pgp-clean
2021-06-29 09:57:30 +01:00
requirements:
.for dep in ${RUN_DEPENDS}
.if !exists(${dep})
2021-12-11 10:57:33 +01:00
@(echo ${dep} not found, please run 'pkg install docproj'; exit 1)
.endif
.endfor
2021-01-26 00:31:29 +01:00
requirements-pdf:
2022-11-02 22:40:13 +01:00
.if !exists(${ASCIIDOCTORPDF_CMD})
@(echo ${ASCIIDOCTOR_CMD} not found, please install rubygem-asciidoctor-pdf; exit 1)
.endif
requirements-epub:
2022-11-02 22:40:13 +01:00
.if !exists(${ASCIIDOCTOREPUB3_CMD})
@(echo ${ASCIIDOCTOREPUB3_CMD} not found, please install rubygem-asciidoctor-epub3; exit 1)
.endif
2021-01-27 10:09:02 -06:00
starting-message: .PHONY
2021-01-26 00:31:29 +01:00
@echo ---------------------------------------------------------------
@echo Building the documentation
@echo included languages: ${LANGUAGES}
@echo excluded languages: ${SKIP_LANGS}
2021-01-26 00:31:29 +01:00
@echo ---------------------------------------------------------------
generate-pgpkeys-txt: static/pgpkeys/pgpkeys.txt
static/pgpkeys/pgpkeys.txt: static/pgpkeys/*key
${RUBY_CMD} ./tools/global-pgpkeys-creator.rb
run-local: .PHONY
HUGO_DISABLELANGUAGES="${SKIP_LANGS}" ${HUGO_CMD} server \
${HUGO_ARGS} -D $(BIND:D--bind=$(BIND)) --baseURL="http://$(.HOST):1313"
2021-01-26 00:31:29 +01:00
2021-01-27 10:09:02 -06:00
build: .PHONY
HUGO_DISABLELANGUAGES="${SKIP_LANGS}" ${HUGO_CMD} ${HUGO_ARGS}
2021-05-31 18:16:55 +02:00
build-offline: .PHONY
HUGO_DISABLELANGUAGES="${SKIP_LANGS}" ${HUGO_CMD} ${HUGO_OFFLINE_ARGS}
2021-06-29 09:57:30 +01:00
pgp-clean: .PHONY
rm -f static/pgpkeys/pgpkeys.txt
hugo-clean: .PHONY
rm -rf resources public
2021-05-31 18:16:55 +02:00
#
# PDF targets
2026-05-21 10:58:05 -04:00
# Use DOC_LANG to choose the language,
# e.g., make DOC_LANG="en fr" pdf-books
2021-05-31 18:16:55 +02:00
#
pdf: pdf-articles pdf-books
2021-12-11 10:57:33 +01:00
pdf-books: requirements-pdf
.for _lang in ${BOOK_LANGS}
./tools/asciidoctor.sh books ${_lang} pdf
2021-05-31 18:16:55 +02:00
.endfor
pdf-articles: requirements-pdf
.for _lang in ${ARTICLE_LANGS}
./tools/asciidoctor.sh articles ${_lang} pdf
2021-05-31 18:16:55 +02:00
.endfor
pdf-clean: pdf-articles-clean pdf-books-clean
pdf-books-clean:
.for _lang in ${BOOK_LANGS}
2021-05-31 18:16:55 +02:00
rm -fr ${.CURDIR}/public/${_lang}/books
-rmdir ${.CURDIR}/public/${_lang}
.endfor
-rmdir ${.CURDIR}/public/
pdf-articles-clean:
.for _lang in ${ARTICLE_LANGS}
2021-05-31 18:16:55 +02:00
rm -fr ${.CURDIR}/public/${_lang}/articles
.if !exists(${.CURDIR}/public/${_lang}/books)
rm -fr ${.CURDIR}/public/${_lang}
.endif
.endfor
-rmdir ${.CURDIR}/public
2021-06-29 09:57:30 +01:00
#
# HTML targets
#
2026-05-21 10:58:05 -04:00
html: build-offline html-clean-global html-clean-articles \
html-clean-books html-archive html-archive-clean-files
html-clean: hugo-clean
html-clean-global:
rm -fr ${.CURDIR}/public/index.html
rm -rf pgpkeys js
html-clean-articles:
.for _lang in ${ARTICLE_LANGS}
rm -fr ${.CURDIR}/public/${_lang}/index.html
rm -fr ${.CURDIR}/public/${_lang}/articles/index.html
.endfor
html-clean-books:
.for _lang in ${BOOK_LANGS}
rm -fr ${.CURDIR}/public/${_lang}/books/index.html
.endfor
html-archive:
.if defined(DOC_HTML_ARCHIVE)
.for _lang in ${ARTICLE_LANGS}
./tools/asciidoctor.sh articles ${_lang} archive
.endfor
.for _lang in ${BOOK_LANGS}
./tools/asciidoctor.sh books ${_lang} archive
.endfor
.endif
html-archive-clean-files:
.if defined(DOC_HTML_ARCHIVE)
find ${.CURDIR}/public/ ! -name '*.pdf' ! -name '*.tar.gz' -type f -delete
find ${.CURDIR}/public/ -type d -empty -delete
.endif
#
# EPUB targets
2026-05-21 10:58:05 -04:00
# Use DOC_LANG to choose the language,
# e.g., make DOC_LANG="en fr" epub-books
#
epub: epub-articles epub-books
2021-12-11 10:57:33 +01:00
epub-books: requirements-epub
@echo ---------------------------------------------------------------
@echo !!! EPUB output is experimental !!!
@echo
@echo Asciidoctor EPUB3 is currently alpha software. Use accordingly. Although the
@echo bulk of AsciiDoc content is converted, theres still work needed to fill in
@echo gaps where conversion is incomplete or unstyled.
@echo https://docs.asciidoctor.org/epub3-converter/latest/#project-status
@echo ---------------------------------------------------------------
.for _lang in ${BOOK_LANGS}
./tools/asciidoctor.sh books ${_lang} epub
.endfor
epub-articles: requirements-epub
@echo ---------------------------------------------------------------
@echo !!! EPUB output is experimental !!!
@echo
@echo Asciidoctor EPUB3 is currently alpha software. Use accordingly. Although the
@echo bulk of AsciiDoc content is converted, theres still work needed to fill in
@echo gaps where conversion is incomplete or unstyled.
@echo https://docs.asciidoctor.org/epub3-converter/latest/#project-status
@echo ---------------------------------------------------------------
.for _lang in ${ARTICLE_LANGS}
./tools/asciidoctor.sh articles ${_lang} epub
.endfor
epub-clean: epub-articles-clean epub-books-clean
epub-books-clean:
.for _lang in ${BOOK_LANGS}
rm -fr ${.CURDIR}/public/${_lang}/books
-rmdir ${.CURDIR}/public/${_lang}
.endfor
-rmdir ${.CURDIR}/public/
epub-articles-clean:
.for _lang in ${ARTICLE_LANGS}
rm -fr ${.CURDIR}/public/${_lang}/articles
.if !exists(${.CURDIR}/public/${_lang}/books)
rm -fr ${.CURDIR}/public/${_lang}
.endif
.endfor
-rmdir ${.CURDIR}/public