2021-01-25 23:31:29 +00:00
|
|
|
|
# Generate the FreeBSD documentation
|
|
|
|
|
|
#
|
2025-01-07 16:32:54 +00:00
|
|
|
|
# Copyright (c) 2020-2025, The FreeBSD Documentation Project
|
|
|
|
|
|
# Copyright (c) 2020-2025, Sergio Carlavilla <carlavilla@FreeBSD.org>
|
2021-01-25 23:31:29 +00:00
|
|
|
|
#
|
|
|
|
|
|
# Targets intended for use on the command line
|
|
|
|
|
|
#
|
2023-09-27 17:32:55 +00:00
|
|
|
|
# all (default) - generate books and articles without generating the
|
|
|
|
|
|
# PDFs or EPUBs
|
2021-06-29 08:57:30 +00:00
|
|
|
|
# clean - removes generated files
|
2021-06-01 12:32:09 +00:00
|
|
|
|
# run - serves the built documentation site for local browsing
|
|
|
|
|
|
# pdf - build PDF versions of the articles and books.
|
2021-07-14 10:28:49 +00:00
|
|
|
|
# html - build HTML versions of the articles and books for
|
2023-09-27 17:32:55 +00:00
|
|
|
|
# offline use.
|
|
|
|
|
|
# If variable DOC_HTML_ARCHIVE is set, all documents will be
|
|
|
|
|
|
# archived/compressed, and only these files will be kept in the
|
|
|
|
|
|
# public directory.
|
2021-11-06 13:53:31 +00:00
|
|
|
|
# epub - build EPUB versions of the articles and books (Experimental).
|
2021-01-28 04:22:48 +00:00
|
|
|
|
#
|
|
|
|
|
|
# The run target uses hugo's built-in webserver to make the documentation 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-25 23:31:29 +00:00
|
|
|
|
|
|
|
|
|
|
MAINTAINER=carlavilla@FreeBSD.org
|
|
|
|
|
|
|
2021-06-16 16:42:28 +00:00
|
|
|
|
# List of languages without book translations
|
2022-03-19 10:52:29 +00:00
|
|
|
|
ARTICLEONLY_LANGS= bn-bd da id ko tr
|
2021-07-14 10:28:49 +00:00
|
|
|
|
# List of languages without article translations
|
|
|
|
|
|
BOOKONLY_LANGS= mn
|
2021-06-16 16:42:28 +00:00
|
|
|
|
|
2021-06-30 11:39:33 +00:00
|
|
|
|
# List of all languages we have content for
|
2022-03-19 10:52:29 +00: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
|
2021-06-30 11:39:33 +00:00
|
|
|
|
|
2021-05-07 14:02:37 +00:00
|
|
|
|
LOCALBASE?= /usr/local
|
2022-11-02 21:40:13 +00:00
|
|
|
|
USE_RUBYGEMS?= NO
|
|
|
|
|
|
GEM_PATH?=
|
2021-05-07 14:02:37 +00:00
|
|
|
|
|
2022-11-02 21:40:13 +00:00
|
|
|
|
.if ${USE_RUBYGEMS} == "YES"
|
|
|
|
|
|
GEMBASE?= ${GEM_PATH}
|
|
|
|
|
|
.else
|
|
|
|
|
|
GEMBASE?= ${LOCALBASE}
|
|
|
|
|
|
.endif
|
|
|
|
|
|
|
2023-07-14 14:36:01 +00:00
|
|
|
|
RUBY_CMD ?= ${LOCALBASE}/bin/ruby
|
2021-05-07 14:02:37 +00:00
|
|
|
|
HUGO_CMD = ${LOCALBASE}/bin/hugo
|
2023-01-21 00:57:44 +00:00
|
|
|
|
HUGO_ARGS?= --minify
|
2023-07-28 01:39:20 +00:00
|
|
|
|
HUGO_OFFLINE_ARGS?= --environment offline --minify
|
2022-11-02 21:40:13 +00:00
|
|
|
|
ROUGIFY_CMD= ${GEMBASE}/bin/rougify
|
|
|
|
|
|
ASCIIDOCTOR_CMD= ${GEMBASE}/bin/asciidoctor
|
|
|
|
|
|
ASCIIDOCTORPDF_CMD= ${GEMBASE}/bin/asciidoctor-pdf
|
|
|
|
|
|
ASCIIDOCTOREPUB3_CMD= ${GEMBASE}/bin/asciidoctor-epub3
|
2021-11-03 16:39:08 +00:00
|
|
|
|
|
2021-05-31 16:16:55 +00:00
|
|
|
|
.if defined(DOC_LANG) && !empty(DOC_LANG)
|
2021-06-16 16:42:28 +00:00
|
|
|
|
LANGUAGES= ${DOC_LANG:S/,/ /g}
|
2021-07-14 10:28:49 +00:00
|
|
|
|
.if ${LANGUAGES:Men} == "" && ${.TARGETS:Mpdf*} == "" && ${.TARGETS:Mhtml*} == ""
|
2021-06-30 11:39:33 +00:00
|
|
|
|
.warning "Warning: cannot skip 'en'; adding it back"
|
|
|
|
|
|
LANGUAGES+= en
|
|
|
|
|
|
.endif
|
2021-05-31 16:16:55 +00:00
|
|
|
|
.else
|
2021-06-30 11:39:33 +00:00
|
|
|
|
LANGUAGES= ${ALL_LANGUAGES}
|
2021-05-31 16:16:55 +00:00
|
|
|
|
.endif
|
|
|
|
|
|
|
2021-03-31 18:44:54 +00:00
|
|
|
|
RUBYLIB = ../shared/lib
|
|
|
|
|
|
.export RUBYLIB
|
2021-01-25 23:31:29 +00:00
|
|
|
|
|
2021-12-11 09:57:33 +00:00
|
|
|
|
RUN_DEPENDS= ${HUGO_CMD} \
|
2022-11-02 21:40:13 +00:00
|
|
|
|
${ASCIIDOCTOR_CMD} \
|
|
|
|
|
|
${ROUGIFY_CMD}
|
2021-05-07 14:02:37 +00:00
|
|
|
|
|
2021-02-14 21:39:20 +00:00
|
|
|
|
.ifndef HOSTNAME
|
2021-06-05 20:25:46 +00:00
|
|
|
|
. ifdef BIND
|
|
|
|
|
|
.HOST=$(BIND)
|
|
|
|
|
|
. else
|
|
|
|
|
|
.HOST=localhost
|
|
|
|
|
|
. endif
|
2021-02-14 21:39:20 +00:00
|
|
|
|
.else
|
2021-06-05 20:25:46 +00:00
|
|
|
|
.HOST=$(HOSTNAME)
|
2021-02-14 21:39:20 +00:00
|
|
|
|
.endif
|
|
|
|
|
|
|
2021-07-14 10:28:49 +00:00
|
|
|
|
# Strip the languages with only articles from the list of languages we
|
2021-06-16 16:42:28 +00:00
|
|
|
|
# will use to build books.
|
|
|
|
|
|
BOOK_LANGS= ${LANGUAGES}
|
|
|
|
|
|
.for a in ${ARTICLEONLY_LANGS}
|
|
|
|
|
|
BOOK_LANGS:= ${BOOK_LANGS:N${a}}
|
|
|
|
|
|
.endfor
|
|
|
|
|
|
|
2021-07-14 10:28:49 +00:00
|
|
|
|
# Strip the languages with only books from the list of languages we
|
|
|
|
|
|
# will use to build articles.
|
|
|
|
|
|
ARTICLE_LANGS= ${LANGUAGES}
|
|
|
|
|
|
.for a in ${BOOKONLY_LANGS}
|
|
|
|
|
|
ARTICLE_LANGS:= ${ARTICLE_LANGS:N${a}}
|
|
|
|
|
|
.endfor
|
2021-06-30 11:39:33 +00:00
|
|
|
|
|
|
|
|
|
|
# Take the list of all languages, and take out the ones we have been
|
|
|
|
|
|
# asked for. We'll feed this to hugo.
|
|
|
|
|
|
SKIP_LANGS=
|
|
|
|
|
|
.for a in ${ALL_LANGUAGES}
|
|
|
|
|
|
.if ${LANGUAGES:M${a}} == ""
|
|
|
|
|
|
SKIP_LANGS+= ${a}
|
|
|
|
|
|
.endif
|
|
|
|
|
|
.endfor
|
|
|
|
|
|
|
2021-01-28 04:22:48 +00:00
|
|
|
|
.ORDER: all run
|
|
|
|
|
|
|
2021-05-07 14:02:37 +00:00
|
|
|
|
.ORDER: requirements
|
2021-12-11 09:57:33 +00:00
|
|
|
|
.ORDER: starting-message
|
2021-01-27 16:05:58 +00:00
|
|
|
|
.ORDER: starting-message build
|
2021-12-11 09:57:33 +00:00
|
|
|
|
.ORDER: build
|
2021-01-27 16:05:58 +00:00
|
|
|
|
|
2021-12-11 09:57:33 +00:00
|
|
|
|
all: requirements starting-message generate-pgpkeys-txt build
|
|
|
|
|
|
run: requirements starting-message generate-pgpkeys-txt run-local
|
2021-05-07 14:02:37 +00:00
|
|
|
|
|
2021-06-29 08:57:30 +00:00
|
|
|
|
# clean does not call pdf-clean as that is a subset of hugo-clean
|
2021-12-11 09:57:33 +00:00
|
|
|
|
clean: hugo-clean pgp-clean
|
2021-06-29 08:57:30 +00:00
|
|
|
|
|
2021-05-07 14:02:37 +00:00
|
|
|
|
requirements:
|
|
|
|
|
|
.for dep in ${RUN_DEPENDS}
|
|
|
|
|
|
.if !exists(${dep})
|
2021-12-11 09:57:33 +00:00
|
|
|
|
@(echo ${dep} not found, please run 'pkg install docproj'; exit 1)
|
2021-05-07 14:02:37 +00:00
|
|
|
|
.endif
|
|
|
|
|
|
.endfor
|
2021-01-25 23:31:29 +00:00
|
|
|
|
|
2021-10-09 21:13:16 +00:00
|
|
|
|
requirements-pdf:
|
2022-11-02 21:40:13 +00:00
|
|
|
|
.if !exists(${ASCIIDOCTORPDF_CMD})
|
|
|
|
|
|
@(echo ${ASCIIDOCTOR_CMD} not found, please install rubygem-asciidoctor-pdf; exit 1)
|
2021-10-09 21:13:16 +00:00
|
|
|
|
.endif
|
|
|
|
|
|
|
2021-11-06 13:53:31 +00:00
|
|
|
|
requirements-epub:
|
2022-11-02 21:40:13 +00:00
|
|
|
|
.if !exists(${ASCIIDOCTOREPUB3_CMD})
|
|
|
|
|
|
@(echo ${ASCIIDOCTOREPUB3_CMD} not found, please install rubygem-asciidoctor-epub3; exit 1)
|
2021-11-06 13:53:31 +00:00
|
|
|
|
.endif
|
|
|
|
|
|
|
2021-01-27 16:09:02 +00:00
|
|
|
|
starting-message: .PHONY
|
2021-01-25 23:31:29 +00:00
|
|
|
|
@echo ---------------------------------------------------------------
|
|
|
|
|
|
@echo Building the documentation
|
2021-06-30 11:39:33 +00:00
|
|
|
|
@echo included languages: ${LANGUAGES}
|
|
|
|
|
|
@echo excluded languages: ${SKIP_LANGS}
|
2021-01-25 23:31:29 +00:00
|
|
|
|
@echo ---------------------------------------------------------------
|
|
|
|
|
|
|
2021-06-01 12:33:14 +00:00
|
|
|
|
generate-pgpkeys-txt: static/pgpkeys/pgpkeys.txt
|
|
|
|
|
|
|
|
|
|
|
|
static/pgpkeys/pgpkeys.txt: static/pgpkeys/*key
|
2021-05-16 20:41:00 +00:00
|
|
|
|
${RUBY_CMD} ./tools/global-pgpkeys-creator.rb
|
|
|
|
|
|
|
2021-02-13 21:40:00 +00:00
|
|
|
|
run-local: .PHONY
|
2021-06-30 11:39:33 +00:00
|
|
|
|
HUGO_DISABLELANGUAGES="${SKIP_LANGS}" ${HUGO_CMD} server \
|
|
|
|
|
|
${HUGO_ARGS} -D $(BIND:D--bind=$(BIND)) --baseURL="http://$(.HOST):1313"
|
2021-01-25 23:31:29 +00:00
|
|
|
|
|
2021-01-27 16:09:02 +00:00
|
|
|
|
build: .PHONY
|
2021-06-30 11:39:33 +00:00
|
|
|
|
HUGO_DISABLELANGUAGES="${SKIP_LANGS}" ${HUGO_CMD} ${HUGO_ARGS}
|
2021-05-31 16:16:55 +00:00
|
|
|
|
|
2021-11-03 16:39:08 +00:00
|
|
|
|
build-offline: .PHONY
|
|
|
|
|
|
HUGO_DISABLELANGUAGES="${SKIP_LANGS}" ${HUGO_CMD} ${HUGO_OFFLINE_ARGS}
|
|
|
|
|
|
|
2021-06-29 08:57:30 +00:00
|
|
|
|
pgp-clean: .PHONY
|
|
|
|
|
|
rm -f static/pgpkeys/pgpkeys.txt
|
|
|
|
|
|
|
|
|
|
|
|
hugo-clean: .PHONY
|
|
|
|
|
|
rm -rf resources public
|
|
|
|
|
|
|
2021-05-31 16:16:55 +00:00
|
|
|
|
#
|
|
|
|
|
|
# PDF targets
|
2021-06-16 16:42:28 +00:00
|
|
|
|
# Use DOC_LANG to choose the language, e.g., make DOC_LANG="en fr" pdf-books
|
2021-05-31 16:16:55 +00:00
|
|
|
|
#
|
|
|
|
|
|
pdf: pdf-articles pdf-books
|
|
|
|
|
|
|
2021-12-11 09:57:33 +00:00
|
|
|
|
pdf-books: requirements-pdf
|
2021-07-14 10:28:49 +00:00
|
|
|
|
.for _lang in ${BOOK_LANGS}
|
2021-11-03 16:39:08 +00:00
|
|
|
|
./tools/asciidoctor.sh books ${_lang} pdf
|
2021-05-31 16:16:55 +00:00
|
|
|
|
.endfor
|
|
|
|
|
|
|
2021-11-03 16:39:08 +00:00
|
|
|
|
pdf-articles: requirements-pdf
|
2021-07-14 10:28:49 +00:00
|
|
|
|
.for _lang in ${ARTICLE_LANGS}
|
2021-11-03 16:39:08 +00:00
|
|
|
|
./tools/asciidoctor.sh articles ${_lang} pdf
|
2021-05-31 16:16:55 +00:00
|
|
|
|
.endfor
|
|
|
|
|
|
|
|
|
|
|
|
pdf-clean: pdf-articles-clean pdf-books-clean
|
|
|
|
|
|
|
2021-11-03 16:39:08 +00:00
|
|
|
|
pdf-books-clean:
|
2021-07-14 10:28:49 +00:00
|
|
|
|
.for _lang in ${BOOK_LANGS}
|
2021-05-31 16:16:55 +00:00
|
|
|
|
rm -fr ${.CURDIR}/public/${_lang}/books
|
2021-07-14 10:28:49 +00:00
|
|
|
|
-rmdir ${.CURDIR}/public/${_lang}
|
|
|
|
|
|
.endfor
|
|
|
|
|
|
-rmdir ${.CURDIR}/public/
|
|
|
|
|
|
|
2021-11-03 16:39:08 +00:00
|
|
|
|
pdf-articles-clean:
|
2021-07-14 10:28:49 +00:00
|
|
|
|
.for _lang in ${ARTICLE_LANGS}
|
2021-11-03 16:39:08 +00:00
|
|
|
|
rm -fr ${.CURDIR}/public/${_lang}/articles
|
|
|
|
|
|
.if !exists(${.CURDIR}/public/${_lang}/books)
|
|
|
|
|
|
rm -fr ${.CURDIR}/public/${_lang}
|
2021-07-14 10:28:49 +00:00
|
|
|
|
.endif
|
|
|
|
|
|
.endfor
|
2021-11-03 16:39:08 +00:00
|
|
|
|
-rmdir ${.CURDIR}/public
|
2021-07-14 10:28:49 +00:00
|
|
|
|
|
2021-11-03 16:39:08 +00:00
|
|
|
|
#
|
|
|
|
|
|
# HTML targets
|
|
|
|
|
|
#
|
2021-12-11 09:57:33 +00:00
|
|
|
|
html: build-offline html-clean-global html-clean-articles html-clean-books html-archive html-archive-clean-files
|
2021-07-14 10:28:49 +00:00
|
|
|
|
|
2021-11-03 16:39:08 +00:00
|
|
|
|
html-clean: hugo-clean
|
2021-07-14 10:28:49 +00:00
|
|
|
|
|
2021-11-03 16:39:08 +00:00
|
|
|
|
html-clean-global:
|
|
|
|
|
|
rm -fr ${.CURDIR}/public/index.html
|
|
|
|
|
|
rm -rf pgpkeys js
|
2021-07-14 10:28:49 +00:00
|
|
|
|
|
2021-11-03 16:39:08 +00:00
|
|
|
|
html-clean-articles:
|
2021-07-14 10:28:49 +00:00
|
|
|
|
.for _lang in ${ARTICLE_LANGS}
|
2021-11-03 16:39:08 +00:00
|
|
|
|
rm -fr ${.CURDIR}/public/${_lang}/index.html
|
|
|
|
|
|
rm -fr ${.CURDIR}/public/${_lang}/articles/index.html
|
2021-05-31 16:16:55 +00:00
|
|
|
|
.endfor
|
|
|
|
|
|
|
2021-11-03 16:39:08 +00:00
|
|
|
|
html-clean-books:
|
|
|
|
|
|
.for _lang in ${BOOK_LANGS}
|
|
|
|
|
|
rm -fr ${.CURDIR}/public/${_lang}/books/index.html
|
2021-05-31 16:16:55 +00:00
|
|
|
|
.endfor
|
2021-11-04 23:07:26 +00:00
|
|
|
|
|
|
|
|
|
|
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
|
2021-11-06 13:53:31 +00:00
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
# EPUB targets
|
2021-11-06 14:00:05 +00:00
|
|
|
|
# Use DOC_LANG to choose the language, e.g., make DOC_LANG="en fr" epub-books
|
2021-11-06 13:53:31 +00:00
|
|
|
|
#
|
|
|
|
|
|
epub: epub-articles epub-books
|
|
|
|
|
|
|
2021-12-11 09:57:33 +00:00
|
|
|
|
epub-books: requirements-epub
|
2021-11-06 13:53:31 +00:00
|
|
|
|
@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, there’s 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, there’s 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
|
|
|
|
|
|
|