| 1 |
# |
# |
| 2 |
# Makefile for the Securing Debian HOWTO (copied from Makefile.intln) |
# 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 |
# Should work both for a manual in the Debian Documentation Project |
| 7 |
# manuals.sgml tree, and for the package build. |
# 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 |
##### CONF PART |
export PATH:=../quick-reference/bin/:${PATH} |
| 16 |
# this can and will be overriden by a higher level makefile |
|
| 17 |
PUBLISHDIR := /org/www.debian.org/www/doc/manuals |
# Woodys default LaTeX settings need more memory for en PDF |
| 18 |
|
export TEXMFCNF:=../quick-reference/texmf/: |
| 19 |
# Darn, I should have named dir and file the same way |
|
| 20 |
#MANUAL = $(notdir $(shell pwd)) |
.SUFFIXES: |
| 21 |
MANUAL = securing-debian-howto |
|
| 22 |
|
# Following default shall be edited by the coordinator for the entire |
| 23 |
LNPUBDIRMAN=$(PUBLISHDIR)/$(MANUAL)/ |
# set of languages. If a subsection owner wishes to override settings, |
| 24 |
|
# they can be overridden by running make with "make 'LANGS1=fi'" etc.. |
| 25 |
# The cannonical language, in which the original document is |
|
| 26 |
ORIG_LANG=en |
# =================================================================== # |
| 27 |
# list of langs (above the canonical one) |
# Default configuration part: Customize # |
| 28 |
# LANGS=$(shell ls $(MANUAL).*.sgml|sed 's/.*$(MANUAL)\.\([^.]*\)\.sgml/\1/') |
# =================================================================== # |
| 29 |
# |
|
| 30 |
# Since portuguese is not yet in debiandoc format we cannot publish it until it is |
# The directory in which this makefile resides must also contain a file |
| 31 |
# |
# called <directoryname>.[<language>.]sgml, which is the top-level file |
| 32 |
LANGS = es ja ru |
# for the manual in this directory. |
| 33 |
|
|
| 34 |
|
# Basename for language-dependent SGML (DDP default, generated) |
| 35 |
|
MANUAL := securing-debian-howto |
| 36 |
|
|
| 37 |
|
# Basename for language-independent SGML-template. |
| 38 |
|
MANUAL0 := $(MANUAL) |
| 39 |
|
|
| 40 |
|
# Build type: Possible values are BUILD_TYPE = web|package |
| 41 |
|
BUILD_TYPE := web |
| 42 |
|
|
| 43 |
|
# Publish directory |
| 44 |
|
# This can and will be overridden by a higher level makefile |
| 45 |
|
PUBLISHDIR := ~/public_html/manuals.html |
| 46 |
|
|
| 47 |
|
# List of languages built for "distclean" target for DDP: |
| 48 |
|
LANGSALL := en de fr es it ru ja zh-cn |
| 49 |
|
# List of languages built for "publish" target for DDP |
| 50 |
|
LANGS := en de fr es it ru ja zh-cn |
| 51 |
|
|
| 52 |
|
# Files which affect SGML generation (excluding *.sgml) |
| 53 |
|
SGMLENTS := custom.ent default.ent |
| 54 |
|
|
| 55 |
|
# All SGML source files |
| 56 |
|
SGMLSRCS := $(foreach lang, $(LANGS), $(MANUAL).$(lang).sgml) \ |
| 57 |
|
$(foreach lang, $(LANGS), $(wildcard $(lang)/*.sgml ) ) \ |
| 58 |
|
$(SGMLENTS) |
| 59 |
|
|
| 60 |
|
# =================================================================== # |
| 61 |
|
# Build target default part: Routine # |
| 62 |
|
# =================================================================== # |
| 63 |
|
# If some languages have problems building, filter-out in here. |
| 64 |
|
|
| 65 |
|
# define $(locale) for the following targets |
| 66 |
|
$(MANUAL).%.html.stamp $(MANUAL).%.txt $(MANUAL).%.ps $(MANUAL).%.pdf: \ |
| 67 |
|
locale=$(subst pt-br,pt_BR,\ |
| 68 |
|
$(subst zh-cn,zh_CN,\ |
| 69 |
|
$*)) |
| 70 |
|
|
| 71 |
|
### Full guide |
| 72 |
|
|
| 73 |
|
# List of html stamp files to be built |
| 74 |
|
HTMLS := $(foreach lang,$(LANGS),$(MANUAL).$(lang).html.stamp) |
| 75 |
|
|
| 76 |
|
# List of txt to be built |
| 77 |
|
TXTS := $(foreach lang,$(LANGS),$(MANUAL).$(lang).txt) |
| 78 |
|
|
| 79 |
|
# List of ps to be built |
| 80 |
|
PSS := $(foreach lang,$(LANGS),$(MANUAL).$(lang).ps) |
| 81 |
|
|
| 82 |
|
# List of pdf to be built |
| 83 |
|
PDFS := $(foreach lang,$(LANGS),$(MANUAL).$(lang).pdf) |
| 84 |
|
|
| 85 |
|
|
| 86 |
|
# =================================================================== # |
| 87 |
|
# Build target part: Customize # |
| 88 |
|
# =================================================================== # |
| 89 |
|
# If some languages have problems building, filter-out in here. |
| 90 |
|
|
| 91 |
|
all: html txt ps pdf |
| 92 |
|
html: $(HTMLS) |
| 93 |
|
text txt: $(TXTS) |
| 94 |
|
ps: $(PSS) |
| 95 |
|
pdf: $(PDFS) |
| 96 |
|
|
| 97 |
|
publish: publish-html publish-txt publish-ps publish-pdf |
| 98 |
|
|
| 99 |
EXTS=txt info |
# =================================================================== # |
| 100 |
##### END OF CONF PART CHANGE THE END AT YOU OWN RISK |
# Build rule part: If not package build # |
| 101 |
|
# =================================================================== # |
| 102 |
|
|
| 103 |
# what will be built |
$(MANUAL).%.ent: |
| 104 |
HTMLDIRS=$(MANUAL).html $(foreach lang,$(LANGS),$(MANUAL).$(lang).html) |
echo "<!ENTITY language \"$*\">" > $@ |
| 105 |
ALLFILES=$(foreach ext,$(EXTS),\ |
echo "<!ENTITY % lang-$* \"INCLUDE\">" >> $@ |
| 106 |
$(MANUAL).$(ORIG_LANG).$(ext)\ |
echo "<!ENTITY docdate \"`LC_ALL=C date -R`\">" >> $@ |
| 107 |
$(foreach lang,$(LANGS),$(MANUAL).$(lang).$(ext))\ |
echo "<!ENTITY docversion \"CVS\">" >> $@ |
|
) |
|
|
|
|
|
|
|
|
#====[ build rules ]=========================================================== |
|
|
# generate anything some dirs want version.ent to be builded, some not |
|
|
|
|
|
DEBIAN=$(wildcard debian) |
|
|
ifeq ($(DEBIAN),"debian") |
|
|
all: version.ent $(HTMLDIRS) $(ALLFILES) |
|
|
else |
|
|
all: $(HTMLDIRS) $(ALLFILES) |
|
|
endif |
|
|
|
|
|
version.ent: debian/changelog |
|
|
./debian/rules $@ |
|
|
|
|
|
#----[ generating HTML ]------------------------------------------------------- |
|
|
# for orig_lang |
|
|
$(MANUAL).html: $(MANUAL).sgml |
|
|
debiandoc2html -l $(ORIG_LANG) -c $< |
|
|
|
|
|
# for translated languages |
|
|
# FIXME: there is a trick because debiandoc2html does a sed 'y/.../...' |
|
|
# which should be reverted to have the content negociation working. |
|
|
# This trick is bad. debiandoc2html should be corrected. |
|
|
$(MANUAL).%.html: $(MANUAL).%.sgml |
|
|
debiandoc2html -l $* -c $< |
|
|
@echo "cleaning up file extensions";\ |
|
|
for file in `ls $(MANUAL).$*.html/*` ; do\ |
|
|
newfile=`echo $$file|\ |
|
|
sed 's/$(shell echo $*|\ |
|
|
sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ_/abcdefghijklmnopqrstuvwxyz-/'\ |
|
|
)\.html/$*\.html/'`;\ |
|
|
if [ $$file != $$newfile ] ; then\ |
|
|
mv $$file $$newfile;\ |
|
|
fi\ |
|
|
done; |
|
|
|
|
|
|
|
|
#----[ generating plain text ]------------------------------------------------- |
|
|
# for orig_lang |
|
|
$(MANUAL).$(ORIG_LANG).txt: $(MANUAL).sgml |
|
|
debiandoc2text -l $(ORIG_LANG) -c $< |
|
|
|
|
|
# for translated languages |
|
|
$(MANUAL).%.txt: $(MANUAL).%.sgml |
|
|
debiandoc2text -l $* $< |
|
|
|
|
|
#----[ generating tov ]-------------------------------------------------------- |
|
|
# for orig_lang |
|
|
$(MANUAL).$(ORIG_LANG).tov: $(MANUAL).sgml |
|
|
debiandoc2textov -l $(ORIG_LANG) -c $< |
|
|
|
|
|
# for translated languages |
|
|
$(MANUAL).%.tov: $(MANUAL).%.sgml |
|
|
debiandoc2textov -l $* $< |
|
|
|
|
|
#----[ generating info ]------------------------------------------------------- |
|
|
# for orig_lang |
|
|
$(MANUAL).$(ORIG_LANG).info: $(MANUAL).sgml |
|
|
debiandoc2info -l $(ORIG_LANG) -c $< |
|
|
|
|
|
# for translated languages |
|
|
$(MANUAL).%.info: $(MANUAL).%.sgml |
|
|
debiandoc2info -l $* $< |
|
|
|
|
|
#----[ generating PostScript ]------------------------------------------------- |
|
|
# for orig_lang |
|
|
$(MANUAL).$(ORIG_LANG).ps: $(MANUAL).sgml |
|
|
debiandoc2latexps -l $(ORIG_LANG) -c $< |
|
|
|
|
|
# for translated languages |
|
|
$(MANUAL).%.ps: $(MANUAL).%.sgml |
|
|
debiandoc2latexps -l $* $< |
|
|
|
|
|
#----[ generating PDF ]-------------------------------------------------------- |
|
|
# for orig_lang |
|
|
$(MANUAL).$(ORIG_LANG).pdf: $(MANUAL).sgml |
|
|
debiandoc2latexpdf -l $(ORIG_LANG) -c $< |
|
|
|
|
|
# for translated languages |
|
|
$(MANUAL).%.pdf: $(MANUAL).%.sgml |
|
|
debiandoc2latexpdf -l $* $< |
|
| 108 |
|
|
|
#====[ publishing to the DDP web pages ]======================================= |
|
|
publish: publish-html publish-files |
|
| 109 |
|
|
| 110 |
#----[ publish html ]---------------------------------------------------------- |
# =================================================================== # |
| 111 |
publish-html: $(HTMLDIRS) |
# Build rule part: Routine # |
| 112 |
|
# =================================================================== # |
| 113 |
|
|
| 114 |
|
# SGML |
| 115 |
|
|
| 116 |
|
# Create starting SGML for each language from the template. Actual |
| 117 |
|
# contents reside in language-segregated subdirectories. |
| 118 |
|
|
| 119 |
|
$(MANUAL).%.sgml: $(MANUAL0).sgml |
| 120 |
|
sed -e "s/@@LANGS@@/$*/g" \ |
| 121 |
|
-e "s/@@DIRS@@/$*/g" \ |
| 122 |
|
-e "s/@@NAME@@/$(MANUAL)/g" \ |
| 123 |
|
$< > $(MANUAL).$*.sgml |
| 124 |
|
|
| 125 |
|
# HTML |
| 126 |
|
$(MANUAL).%.html.stamp: $(MANUAL).%.sgml $(MANUAL).%.ent $(SGMLSRCS) |
| 127 |
|
debiandoc2html -l $(locale) -c $< |
| 128 |
|
# since $(MANUAL).%.html/index.%.html cannot be a target file |
| 129 |
|
@for file in `ls $(MANUAL).$*.html/*` ; do\ |
| 130 |
|
newfile=`echo $$file|\ |
| 131 |
|
sed 's/$(shell echo $*|\ |
| 132 |
|
sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ_/abcdefghijklmnopqrstuvwxyz-/'\ |
| 133 |
|
)\.html/$*\.html/'`;\ |
| 134 |
|
if [ $$file != $$newfile ] ; then\ |
| 135 |
|
mv $$file $$newfile;\ |
| 136 |
|
echo "Rename $$file --> $$newfile";\ |
| 137 |
|
fi\ |
| 138 |
|
done |
| 139 |
|
touch $(MANUAL).$*.html.stamp |
| 140 |
|
|
| 141 |
|
# TXT |
| 142 |
|
|
| 143 |
|
$(MANUAL).%.txt: $(MANUAL).%.sgml $(MANUAL).%.ent $(SGMLSRCS) |
| 144 |
|
debiandoc2text -l $(locale) $< |
| 145 |
|
|
| 146 |
|
|
| 147 |
|
# PS |
| 148 |
|
|
| 149 |
|
$(MANUAL).%.ps: $(MANUAL).%.sgml $(MANUAL).%.ent $(SGMLSRCS) |
| 150 |
|
debiandoc2latexps -l $(locale) $< |
| 151 |
|
|
| 152 |
|
# PDF |
| 153 |
|
|
| 154 |
|
$(MANUAL).%.pdf: $(MANUAL).%.sgml $(MANUAL).%.ent $(SGMLSRCS) |
| 155 |
|
debiandoc2latexpdf -l $(locale) $< |
| 156 |
|
|
| 157 |
|
|
| 158 |
|
# =================================================================== # |
| 159 |
|
# Build rule part: Web publish # |
| 160 |
|
# =================================================================== # |
| 161 |
|
|
| 162 |
|
publish-html: html |
| 163 |
test -d $(PUBLISHDIR)/$(MANUAL) \ |
test -d $(PUBLISHDIR)/$(MANUAL) \ |
| 164 |
|| install -d -m 755 $(PUBLISHDIR)/$(MANUAL) |
|| install -d -m 755 $(PUBLISHDIR)/$(MANUAL) |
| 165 |
rm -f $(PUBLISHDIR)/$(MANUAL)/*.html |
rm -f $(PUBLISHDIR)/$(MANUAL)/*.html |
| 166 |
# install any translated html |
# install all html |
| 167 |
$(foreach lang,$(LANGS),\ |
$(foreach lang,$(LANGS),\ |
| 168 |
install -p -m 644 $(MANUAL).$(lang).html/*.html $(PUBLISHDIR)/$(MANUAL)/;) |
install -p -m 644 $(MANUAL).$(lang).html/*.html \ |
| 169 |
# install original html |
$(PUBLISHDIR)/$(MANUAL)/ ;\ |
| 170 |
install -p -m 644 $(MANUAL).html/*.html \ |
) |
| 171 |
$(PUBLISHDIR)/$(MANUAL)/ |
publish-txt: txt |
| 172 |
# make the symlinks for html files |
test -d $(PUBLISHDIR)/$(MANUAL) \ |
| 173 |
@$(foreach file,$(wildcard $(MANUAL).html/*.html),\ |
|| install -d -m 755 $(PUBLISHDIR)/$(MANUAL) |
| 174 |
name=`echo $(file) | sed 's/$(MANUAL).html\///'`; \ |
rm -f $(PUBLISHDIR)/$(MANUAL)/*.txt |
| 175 |
link=`echo $$name|sed 's/.$(ORIG_LANG).html$$/.html/'`;\ |
# install all txt |
| 176 |
echo "$$link -> $$name";\ |
@$(foreach lang,$(LANGS),\ |
| 177 |
ln -sf $$name\ |
install -p -m 644 $(MANUAL).$(lang).txt \ |
| 178 |
$(PUBLISHDIR)/$(MANUAL)/$$link;\ |
$(PUBLISHDIR)/$(MANUAL)/ ;\ |
| 179 |
) |
) |
| 180 |
|
|
| 181 |
#----[ publish the files ]----------------------------------------------------- |
publish-ps: ps |
|
publish-files: $(ALLFILES) |
|
| 182 |
test -d $(PUBLISHDIR)/$(MANUAL) \ |
test -d $(PUBLISHDIR)/$(MANUAL) \ |
| 183 |
|| install -d -m 755 $(PUBLISHDIR)/$(MANUAL) |
|| install -d -m 755 $(PUBLISHDIR)/$(MANUAL) |
| 184 |
$(foreach ext,$(EXTS),\ |
rm -f $(PUBLISHDIR)/$(MANUAL)/*.ps |
| 185 |
rm -f $(PUBLISHDIR)/$(MANUAL)/*.$(ext);\ |
# install all ps |
| 186 |
\ |
@$(foreach lang,$(LANGS),\ |
| 187 |
$(foreach lang,$(LANGS),\ |
install -p -m 644 $(MANUAL).$(lang).ps \ |
| 188 |
install -p -m 644 $(MANUAL).$(lang).$(ext)\ |
$(PUBLISHDIR)/$(MANUAL)/ ;\ |
|
$(PUBLISHDIR)/$(MANUAL)/;)\ |
|
|
\ |
|
|
install -p -m 644 $(MANUAL).$(ORIG_LANG).$(ext)\ |
|
|
$(PUBLISHDIR)/$(MANUAL)/;\ |
|
|
\ |
|
|
ln -sf $(MANUAL).$(ORIG_LANG).$(ext)\ |
|
|
$(PUBLISHDIR)/$(MANUAL)/$(MANUAL).$(ext);\ |
|
| 189 |
) |
) |
| 190 |
|
|
| 191 |
|
|
| 192 |
#----[ publish the ps ]-------------------------------------------------------- |
publish-pdf: pdf |
|
publish-ps: ps |
|
| 193 |
test -d $(PUBLISHDIR)/$(MANUAL) \ |
test -d $(PUBLISHDIR)/$(MANUAL) \ |
| 194 |
|| install -d -m 755 $(PUBLISHDIR)/$(MANUAL) |
|| install -d -m 755 $(PUBLISHDIR)/$(MANUAL) |
| 195 |
rm -f $(PUBLISHDIR)/$(MANUAL)/*.ps |
rm -f $(PUBLISHDIR)/$(MANUAL)/*.pdf |
| 196 |
# install any translated ps |
# install all pdf1 |
| 197 |
$(foreach lang,$(LANGS),\ |
@$(foreach lang,$(LANGS),\ |
| 198 |
install -p -m 644 $(MANUAL).$(lang).ps \ |
install -p -m 644 $(MANUAL).$(lang).pdf \ |
| 199 |
$(PUBLISHDIR)/$(MANUAL)/ ;) |
$(PUBLISHDIR)/$(MANUAL)/ ;\ |
| 200 |
# install original ps |
) |
|
install -p -m 644 $(MANUAL).$(ORIG_LANG).ps\ |
|
|
$(PUBLISHDIR)/$(MANUAL)/ |
|
|
# make the symlinks for ps |
|
|
ln -sf $(MANUAL).$(ORIG_LANG).ps\ |
|
|
$(PUBLISHDIR)/$(MANUAL)/$(MANUAL).ps |
|
| 201 |
|
|
| 202 |
|
|
| 203 |
#====[ validating SGML ]======================================================= |
#====[ validating SGML ]======================================================= |
| 204 |
validate: |
validate: |
| 205 |
set -x; for i in $(wildcard *.sgml); do nsgmls -ges -wall $$i; done |
set -x; for i in $(LANGS); do $(MAKE) validate1-$$i ; done |
| 206 |
|
|
| 207 |
|
validate1-%: $(SGMLSRCS) $(MANUAL)-%.ent |
| 208 |
|
nsgmls -gues -wall $(MANUAL)-$*.sgml |
| 209 |
|
|
| 210 |
|
|
| 211 |
#====[ cleaning up ]=========================================================== |
#====[ cleaning up ]=========================================================== |
| 212 |
clean distclean: |
distclean: clean |
| 213 |
rm -f securing-debian-howto*.{txt,ps,dvi,pdf,info*,log,tex,aux,toc,sasp*} *~ |
rm -Rf $(PUBLISHDIR)/$(MANUAL) |
| 214 |
rm -rf securing-debian-howto*.html |
rm -f *.error $(MANUAL).*.sgml |
| 215 |
|
|
| 216 |
|
clean: |
| 217 |
|
rm -f $(MANUAL)*.{txt,ps,dvi,pdf,info*,log,tex,aux,toc,sasp*,out,tov} |
| 218 |
|
rm -f *~ prior.aux pprior.aux tar.gz.log |
| 219 |
|
rm -f *.error $(MANUAL).*.ent $(MANUAL).*.sgml date.ent $(MANUAL).*.tpt |
| 220 |
|
rm -rf $(MANUAL)*.html *stamp |
| 221 |
|
|
| 222 |
.PHONY: all html txt ps\ |
.PHONY: all html text txt ps pdf \ |
| 223 |
publish publish-html publish-txt publish-ps\ |
publish publish-html publish-tst publish-ps publish-pdf \ |
| 224 |
clean distclean validate |
clean distclean validate |
| 225 |
|
|