# $Id: Makefile 1702 2025-06-15 14:36:01Z karl $
# This file is public domain. Originally written 2010, Karl Berry.
# Assumes GNU make.
# todo: look for xx below, among much more.
SHELL = /bin/sh
# setting PATH as it's nice to find our own (development) scripts,
# e.g., look for xmlint and vcss in ./extra-bin.
extra_bin = ./extra-bin
ht_bin = ../bin/ht/unix
PATH := $(shell echo $$PATH)
#
# per-user addition to PATH. We need to use LaTeX out of current TeX Live,
# since changes that affect tex4ht are often made. If set, include trailing :.
user_bin :=
#
export PATH := $(ht_bin):$(extra_bin):$(user_bin)$(PATH)
# do_java variable to control how tex4ht.jar is built.
# 0 = in Makefile only
# 1 = in .tex only
# 2 = no java compilation
#
# do_java=1 works only if tex4ht-dir.tex is not already built with
# the do_java=0 option.
# do_java=0 will keep java compilation in tex in addition to
# building in Makefile if tex4ht-dir.tex was already built
# with do_java=1
do_java ?= 2
java_in_make := false
java_in_tex := false
ifeq ($(do_java),0)
java_in_make := true
else ifeq ($(do_java),1)
java_in_tex := true
else ifneq ($(do_java),2)
$(error Invalid do_java, supported values are 0, 1, and 2)
endif
# The xtpipes.jar is an intermediate product that is needed only when
# java compilation is made through t4ht system call (do_java=1), not
# when the java compilation is made in Makefile (do_java=0)
ifeq ($(java_in_tex),true)
xtpipe_jar = $(wd)/bin/xtpipes.jar
else
xtpipe_jar = #
endif
tex_opts = --interaction=nonstopmode -recorder #--file-line-error
tex_1opt = "$(tex_opts)" # must be quoted, passing to shell script
dev_null = </dev/null # when we don't call tex directly.
HTTEX = ht "etex $(tex_opts)" # set tex options for plain tex
# Although many of the source files say to use xhlatex, we always use
# htlatex instead. xhlatex generates XHTML from the literate source and
# then validates each (sub)file with xmllint (as defined in tex4ht.env),
# which is hundreds of calls, none of which we care about. It's fine for
# us to just generate regular HTML, in the unlikely event of wanting to
# look at those generated files anyway.
default: all
# tex4ht.sty is read by most (all?) files, but we have to avoid
# depending on it for the file which generates it (tex4ht-sty.tex), so
# we need two different variables.
#
common_no_tex4ht_sty = tex4ht-cpright.tex common.tex common-code.tex \
ProTex.sty AlProTex.sty tex4ht-dir.tex
common = tex4ht.sty $(common_no_cond_sty)
common_info = $(common) common-info.tex
#
# mktex4ht.4ht is read by almost everything, but since it is mostly just
# the list of packages, it changes often, without any particular need to
# rebuild everything when it does. So leave it out.
# Substitute directories used, especially for Java.
tex4ht-dir.tex: tex4ht-dir.m4
m4 $(foreach def,$(dirs) java_in_tex,-D $(def)="$($(def))") $< >$@ || rm -f $@
# Start long list of generated files from the literate sources. Needs more.
derived =
# Although SearchFonts.java is created by fonts-noncjk, it's a
# development tool that we don't use and have no need for, so don't list
# it or try to compile it. (See source for a little more info.)
# $(wd)/src/SearchFonts.java
derived += $(tex4ht_fonts_opensans_derived)
tex4ht_fonts_opensans_derived = \
$(ht_fonts_devdir)/unicode/Open_Sans_Light/OpenSans-LightItalic-OT1-LF.htf
# xx and many more
# whither tmp? how change target dir? what happened to cmtex.htf? etc.
# somehow have to push this to tlcontrib; since Minion is nonfree,
# can't put it into TL. For now, avoid compiling/installing it,
# since then it shows up with all the consistency checks.
#derived += $(tex4ht_fonts_minionpro_derived)
tex4ht_fonts_minionpro_derived = \
$(ht_fonts_devdir)/unicode/Minion_Pro/MinionPro-It-lf-l1-ot1.htf
$(xtpipes_derived): xtpipes.tex $(common)
htlatex $< "xhtml,3,next" "" "" $(tex_1opt)
# Derived files are generated in . and $(wd).
# (corresponds to src/java for xtpipes.tex)
#
# Remake all *-fonts-*.tex files, i.e., update all htf. Since we list
# few dependencies for these, have to have some other way. Assume GNU make.
# Takes ~20 min and generates ~50MB of output.
update-all-fonts:
date; for f in *-fonts-*.tex; do \
printf "\n\f making $$f"; \
$(MAKE) -W $$f || exit $?; done
@echo "update-all-fonts done."
# Simple make abbrev for convenience.
upmake upm:
svn update && make
# Simple command to "install" from dev to TL.
# (Other methods are also used.)
install_data = cp -p
# svn status of installed tree.
svnstatus st:
svn status $(inst_dir_all) | sed s,$(texmf),, # reduce output
@echo $(inst_dir_all)
# Diff and install the *.unix and *.bat scripts.
# The suffix changes from .unix in development to .sh in TL,
# and many of the scripts are not installed at all;
# don't worry about that. We also won't worry about the
# Perl scripts (mk4ht) at present.
#
diff-scripts:
@echo; echo '>>> $@'
for f in *.unix; do \
inst_f=$(inst_dir_scripts)/`basename $$f .unix`.sh; \
test -r $$inst_f || continue; \
$(diff) $$inst_f $$f; done
# Diff from installed to dev, but install from dev to installed.
install-scripts:
@echo; echo '>>> $@'
for f in *.unix; do \
inst_f=$(inst_dir_scripts)/`basename $$f .unix`.sh; \
test -r $$inst_f || continue; \
echo $(install_data) $$inst_f $$f; \
$(install_data) $$f $$inst_f; done
#
# Checking and updating source files from development vs. TeX Live,
# from whence they get to CTAN.
# Diff source files from installed to dev.
diff-src:
@echo; echo '>>> $@'
for f in $(srcfiles); do $(diff) $(inst_dir_source)/$$f $$f; done
#
# Install from dev to installed.
update-src:
for f in $(srcfiles); do $(install_data) $$f $(inst_dir_source); done
svn status $(inst_dir_source)
#
# Just list the files.
list-src:
@echo $(srcfiles) | tr ' ' '\n'
#
# Checking and updating font support files.
# Where they are in the installed tree.
ht_fonts_instdir = $(inst_dir_top)/ht-fonts
# Compare only. Must run make all first.
diff-htfonts:
@echo; echo '>>> $@'
./update-htfonts diff $(ht_fonts_devdir) $(ht_fonts_instdir) | tee /tmp/htdif
# Compare and update. Must run make all first.
update-htfonts:
./update-htfonts update $(ht_fonts_devdir) $(ht_fonts_instdir) | tee /tmp/htupd
PHONY: update-htfonts
#
# Checking and updating tex4ht.env files.
# Where they are in the installed tree.
env_instdir = $(inst_dir_top)/base
#
# diff all files in the main TeX Live installation directory against
# cwd (development). the --ignore-matching-lines below only works when
# that's the only change in the hunk, so ignore them all explicitly.
# also ignore commented changes.
#
# htf files, scripts, etc. are in different places, so don't include them here,
#
# The diff-scripts output is usually empty, so we can run that;
# but diff-htfonts is too verbose to run every time.
diff-all: diff-src diff-scripts diff-htfonts diff-env
@echo; echo '>>> $@'
-for f in $(inst_dir_4ht)/*; do $(diff) $$f .; done \
| tee /tmp/u | egrep -v '^ *[-+]%|^@@ |^- *$$|-1.version' \
| egrep -v '^..ifx.infoIVht.UnDeF.*//$$' \
| egrep -v '^--- '
# For checking the derived files that are explicitly listed above
# against installed (in TL) files. This is a small subset of all the
# generated files.
diff_files = $(filter-out %.htf %.4hf tex4ht.env% %.c lm-htf.tex \
mk4ht.perl ht.unix ht.bat,\
$(derived))
diff-derived:
@echo; echo '>>> $@'
-for f in $(diff_files); do $(diff) $(inst_dir_4ht)/$$f .; done \
| tee /tmp/u | egrep -v '^ *[-+]%|^@@ |^- *$$|-1.version' \
| egrep -v '^..ifx.infoIVht.UnDeF.*//$$'
# Check that anything with a \version of this year
# also has a copyright of this year.
inst-check-copyright:
@echo; echo '>>> $@'
-cd $(inst_dir_4ht) && for f in *; do \
if grep "version.*`date +%Y`" $$f >/dev/null; then \
grep "Copyright.*`date +%Y`" $$f >/dev/null || echo $$f; fi; done
# Check that all *.4ht in dev are installed. Other file types are
# difficult, but all 4ht's should be present, except mktex4ht.4ht.
inst-check-files:
@echo; echo '>>> $@'
cd $(inst_dir_4ht) && ls -1 *.4ht >/tmp/instlist
ls -1 *.4ht | fgrep -v mktex4ht.4ht >/tmp/devlist
comm -3 /tmp/devlist /tmp/instlist
# Check for missing version identifications.
inst-check-version:
@echo; echo '>>> $@'
-cd $(inst_dir_4ht) && for f in *; do \
grep 'write-1.*version' $$f >/dev/null || echo $$f; done
#
# diff one specified file, as in "make d1 d=filename.4ht".
diff1 d1:
$(diff) $(inst_dir_4ht)/$(d) .
# the diff command used pervasively.
diff = diff -u0 --ignore-all-space --ignore-blank-lines \
--ignore-matching-lines='write-1.version\|, generated from\|Copyright'
# run weekly by karl.
croncheck: upm diff-all \
inst-check-copyright inst-check-files inst-check-version \
diff-htfonts