| 1 |
#
|
| 2 |
# Based Makefile Template from Osamu Aoki
|
| 3 |
#
|
| 4 |
# Build html(multi-page), txt, ps, pdf, and other formats.
|
| 5 |
#
|
| 6 |
# Should work both for a manual in the Debian Documentation Project
|
| 7 |
# manuals.sgml tree, and for the package build.
|
| 8 |
# ------------------------------------------------------------------- #
|
| 9 |
# WARNING #
|
| 10 |
# Use with caution, aimed at Woody system #
|
| 11 |
# "ps" and "pdf" tends to break in some ill-configured systems #
|
| 12 |
# ------------------------------------------------------------------- #
|
| 13 |
# Read local texmf.cnf file
|
| 14 |
|
| 15 |
export PATH:=../quick-reference/bin/:${PATH}
|
| 16 |
|
| 17 |
export TEXMFCNF=texmf:
|
| 18 |
|
| 19 |
# Following default shall be edited by the coordinator for the entire
|
| 20 |
# set of languages. If a subsection owner wishes to override settings,
|
| 21 |
# they can be overridden by running make with "make 'LANGS1=fi'" etc..
|
| 22 |
|
| 23 |
# =================================================================== #
|
| 24 |
# Default configuration part: Customize #
|
| 25 |
# =================================================================== #
|
| 26 |
|
| 27 |
# The directory in which this makefile resides must also contain a file
|
| 28 |
# called <directoryname>.[<language>.]sgml, which is the top-level file
|
| 29 |
# for the manual in this directory.
|
| 30 |
|
| 31 |
# Basename for language-dependent SGML (DDP default, generated)
|
| 32 |
MANUAL := securing-debian-howto
|
| 33 |
|
| 34 |
# Basename for language-independent SGML-template.
|
| 35 |
MANUAL0 := $(MANUAL)
|
| 36 |
|
| 37 |
# Build type: Possible values are BUILD_TYPE = web|package
|
| 38 |
BUILD_TYPE := web
|
| 39 |
|
| 40 |
# Publish directory
|
| 41 |
# This can and will be overridden by a higher level makefile
|
| 42 |
PUBLISHDIR := ~/public_html/manuals.html
|
| 43 |
|
| 44 |
# List of languages built for "distclean" target for DDP:
|
| 45 |
LANGSALL := en de fr es it ru ja
|
| 46 |
# List of languages built for "publish" target for DDP
|
| 47 |
LANGS := en de fr es it ru
|
| 48 |
|
| 49 |
|
| 50 |
# Files which affect SGML generation (excluding *.sgml)
|
| 51 |
SGMLENTS := custom.ent default.ent
|
| 52 |
|
| 53 |
# All SGML source files
|
| 54 |
SGMLSRCS := $(foreach lang, $(LANGS), $(MANUAL).$(lang).sgml) \
|
| 55 |
$(foreach lang, $(LANGS), $(wildcard $(lang)/*.sgml ) ) \
|
| 56 |
$(SGMLENTS)
|
| 57 |
|
| 58 |
# =================================================================== #
|
| 59 |
# Build target default part: Routine #
|
| 60 |
# =================================================================== #
|
| 61 |
# If some languages have problems building, filter-out in here.
|
| 62 |
|
| 63 |
### Full guide
|
| 64 |
|
| 65 |
# List of html stamp files to be built
|
| 66 |
HTMLS := $(foreach lang,$(LANGS),$(MANUAL).$(lang).html.stamp)
|
| 67 |
|
| 68 |
# List of txt to be built
|
| 69 |
TXTS := $(foreach lang,$(LANGS),$(MANUAL).$(lang).txt)
|
| 70 |
|
| 71 |
# List of ps to be built
|
| 72 |
PSS := $(foreach lang,$(LANGS),$(MANUAL).$(lang).ps)
|
| 73 |
|
| 74 |
# List of pdf to be built
|
| 75 |
PDFS := $(foreach lang,$(LANGS),$(MANUAL).$(lang).pdf)
|
| 76 |
|
| 77 |
|
| 78 |
# =================================================================== #
|
| 79 |
# Build target part: Customize #
|
| 80 |
# =================================================================== #
|
| 81 |
# If some languages have problems building, filter-out in here.
|
| 82 |
|
| 83 |
all: html txt ps pdf
|
| 84 |
html: $(HTMLS)
|
| 85 |
text txt: $(TXTS)
|
| 86 |
ps: $(PSS)
|
| 87 |
pdf: $(PDFS)
|
| 88 |
|
| 89 |
publish: publish-html publish-txt publish-ps publish-pdf
|
| 90 |
|
| 91 |
# =================================================================== #
|
| 92 |
# Build rule part: If not package build #
|
| 93 |
# =================================================================== #
|
| 94 |
|
| 95 |
$(MANUAL).%.ent:
|
| 96 |
echo "<!ENTITY language \"$*\">" > $@
|
| 97 |
echo "<!ENTITY % lang-$* \"INCLUDE\">" >> $@
|
| 98 |
echo "<!ENTITY docdate \"`LC_ALL=C date -R`\">" >> $@
|
| 99 |
echo "<!ENTITY docversion \"CVS\">" >> $@
|
| 100 |
|
| 101 |
|
| 102 |
# =================================================================== #
|
| 103 |
# Build rule part: Routine #
|
| 104 |
# =================================================================== #
|
| 105 |
|
| 106 |
# SGML
|
| 107 |
|
| 108 |
# Create starting SGML for each language from the template. Actual
|
| 109 |
# contents reside in language-segregated subdirectories.
|
| 110 |
|
| 111 |
$(MANUAL).%.sgml: $(MANUAL0).sgml
|
| 112 |
sed -e "s/@@LANGS@@/$*/g" \
|
| 113 |
-e "s/@@DIRS@@/$*/g" \
|
| 114 |
-e "s/@@NAME@@/$(MANUAL)/g" \
|
| 115 |
$< > $(MANUAL).$*.sgml
|
| 116 |
|
| 117 |
# HTML
|
| 118 |
|
| 119 |
$(MANUAL).%.html.stamp: $(MANUAL).%.sgml $(MANUAL).%.ent $(SGMLSRCS)
|
| 120 |
debiandoc2html -l $* -c $<
|
| 121 |
# since $(MANUAL).%.html/index.%.html cannot be a target file
|
| 122 |
@for file in `ls $(MANUAL).$*.html/*` ; do\
|
| 123 |
newfile=`echo $$file|\
|
| 124 |
sed 's/$(shell echo $*|\
|
| 125 |
sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ_/abcdefghijklmnopqrstuvwxyz-/'\
|
| 126 |
)\.html/$*\.html/'`;\
|
| 127 |
if [ $$file != $$newfile ] ; then\
|
| 128 |
mv $$file $$newfile;\
|
| 129 |
echo "Rename $$file --> $$newfile";\
|
| 130 |
fi\
|
| 131 |
done
|
| 132 |
touch $(MANUAL).$*.html.stamp
|
| 133 |
|
| 134 |
# TXT
|
| 135 |
|
| 136 |
$(MANUAL).%.txt: $(MANUAL).%.sgml $(MANUAL).%.ent $(SGMLSRCS)
|
| 137 |
debiandoc2text -l $* $<
|
| 138 |
|
| 139 |
|
| 140 |
# PS
|
| 141 |
|
| 142 |
$(MANUAL).%.ps: $(MANUAL).%.sgml $(MANUAL).%.ent $(SGMLSRCS)
|
| 143 |
debiandoc2latexps -l $(subst pt-br,pt_BR,$*) $<
|
| 144 |
|
| 145 |
# PDF
|
| 146 |
|
| 147 |
$(MANUAL).%.pdf: $(MANUAL).%.sgml $(MANUAL).%.ent $(SGMLSRCS)
|
| 148 |
debiandoc2latexpdf -l $* $<
|
| 149 |
|
| 150 |
|
| 151 |
# =================================================================== #
|
| 152 |
# Build rule part: Web publish #
|
| 153 |
# =================================================================== #
|
| 154 |
|
| 155 |
publish-html: html
|
| 156 |
test -d $(PUBLISHDIR)/$(MANUAL) \
|
| 157 |
|| install -d -m 755 $(PUBLISHDIR)/$(MANUAL)
|
| 158 |
rm -f $(PUBLISHDIR)/$(MANUAL)/*.html
|
| 159 |
# install all html
|
| 160 |
$(foreach lang,$(LANGS),\
|
| 161 |
install -p -m 644 $(MANUAL).$(lang).html/*.html \
|
| 162 |
$(PUBLISHDIR)/$(MANUAL)/ ;\
|
| 163 |
)
|
| 164 |
publish-txt: txt
|
| 165 |
test -d $(PUBLISHDIR)/$(MANUAL) \
|
| 166 |
|| install -d -m 755 $(PUBLISHDIR)/$(MANUAL)
|
| 167 |
rm -f $(PUBLISHDIR)/$(MANUAL)/*.txt
|
| 168 |
# install all txt
|
| 169 |
@$(foreach lang,$(LANGS),\
|
| 170 |
install -p -m 644 $(MANUAL).$(lang).txt \
|
| 171 |
$(PUBLISHDIR)/$(MANUAL)/ ;\
|
| 172 |
)
|
| 173 |
|
| 174 |
publish-ps: ps
|
| 175 |
test -d $(PUBLISHDIR)/$(MANUAL) \
|
| 176 |
|| install -d -m 755 $(PUBLISHDIR)/$(MANUAL)
|
| 177 |
rm -f $(PUBLISHDIR)/$(MANUAL)/*.ps
|
| 178 |
# install all ps
|
| 179 |
@$(foreach lang,$(LANGS),\
|
| 180 |
install -p -m 644 $(MANUAL).$(lang).ps \
|
| 181 |
$(PUBLISHDIR)/$(MANUAL)/ ;\
|
| 182 |
)
|
| 183 |
|
| 184 |
|
| 185 |
publish-pdf: pdf
|
| 186 |
test -d $(PUBLISHDIR)/$(MANUAL) \
|
| 187 |
|| install -d -m 755 $(PUBLISHDIR)/$(MANUAL)
|
| 188 |
rm -f $(PUBLISHDIR)/$(MANUAL)/*.pdf
|
| 189 |
# install all pdf1
|
| 190 |
@$(foreach lang,$(LANGS),\
|
| 191 |
install -p -m 644 $(MANUAL).$(lang).pdf \
|
| 192 |
$(PUBLISHDIR)/$(MANUAL)/ ;\
|
| 193 |
)
|
| 194 |
|
| 195 |
|
| 196 |
#====[ validating SGML ]=======================================================
|
| 197 |
validate:
|
| 198 |
set -x; for i in $(LANGS); do $(MAKE) validate1-$$i ; done
|
| 199 |
|
| 200 |
validate1-%: $(SGMLSRCS) $(MANUAL)-%.ent
|
| 201 |
nsgmls -gues -wall $(MANUAL)-$*.sgml
|
| 202 |
|
| 203 |
|
| 204 |
#====[ cleaning up ]===========================================================
|
| 205 |
distclean: clean
|
| 206 |
rm -Rf $(PUBLISHDIR)/$(MANUAL)
|
| 207 |
rm -f *.error $(MANUAL).*.sgml
|
| 208 |
|
| 209 |
clean:
|
| 210 |
rm -f $(MANUAL)*.{txt,ps,dvi,pdf,info*,log,tex,aux,toc,sasp*,out,tov}
|
| 211 |
rm -f *~ prior.aux pprior.aux tar.gz.log
|
| 212 |
rm -f *.error $(MANUAL).*.ent $(MANUAL).*.sgml date.ent $(MANUAL).*.tpt
|
| 213 |
rm -rf $(MANUAL)*.html *stamp
|
| 214 |
|
| 215 |
.PHONY: all html text txt ps pdf \
|
| 216 |
publish publish-html publish-tst publish-ps publish-pdf \
|
| 217 |
clean distclean validate
|
| 218 |
|