| 1 |
#
|
| 2 |
# New Makefile Template (Osamu Aoki)
|
| 3 |
#
|
| 4 |
# Build html(multi-page), txt, ps, pdf, and other formats.
|
| 5 |
#
|
| 6 |
# $(MANUAL).xx.yyy are created in w.d.o/doc/manuals/$(MANUAL)
|
| 7 |
# xx = en, fr, it, (LANGS)
|
| 8 |
# yyy = txt, pdf ... (EXTS)
|
| 9 |
#
|
| 10 |
# Should work both for a manual in the Debian Documentation Project
|
| 11 |
# manuals.sgml tree, and for the package build.
|
| 12 |
##-------------------------------------------------------------------##
|
| 13 |
## WARNING ##
|
| 14 |
## Use with caution, aimed at post-woody system ##
|
| 15 |
## "ps" and "pdf" tends to break in some ill-configured system ##
|
| 16 |
##-------------------------------------------------------------------##
|
| 17 |
|
| 18 |
# You must clean before any html build/publish
|
| 19 |
|
| 20 |
# ============================================================================
|
| 21 |
# CONF PART
|
| 22 |
|
| 23 |
# The directory in which this makefile resides must also contain a file
|
| 24 |
# called <directoryname>.sgml, which is the top-level file for the manual
|
| 25 |
# in this directory.
|
| 26 |
|
| 27 |
# Basename for sgml
|
| 28 |
MANUAL := $(notdir $(shell pwd))
|
| 29 |
|
| 30 |
# Publish directory
|
| 31 |
# This can and will be overriden by a higher level makefile
|
| 32 |
PUBLISHDIR := /org/www.debian.org/www/doc/manuals
|
| 33 |
|
| 34 |
# The cannonical language, in which the original document is
|
| 35 |
ORIG_LANG := en
|
| 36 |
|
| 37 |
# List of langs (above the canonical one)
|
| 38 |
#LANGS := en de es fr it ja pl pt_BR ru
|
| 39 |
LANGS := en
|
| 40 |
|
| 41 |
# List of output format
|
| 42 |
# Possible values are EXTS=html txt tov pdf ps info
|
| 43 |
EXTS := html txt pdf
|
| 44 |
|
| 45 |
# maximum times we're willing to run TeX to get cross-references right,
|
| 46 |
# if you subtract by 3 (taken from Adam di Carlo's boot-floppy trick)
|
| 47 |
MAX_TEX_RECURSION := 4
|
| 48 |
|
| 49 |
all: $(ALLFILES)
|
| 50 |
|
| 51 |
# List of publish target for DDP
|
| 52 |
publish: publish-html publish-files
|
| 53 |
|
| 54 |
# If sgml for original language does not use mid-extension
|
| 55 |
%.$(ORIG_LANG).sgml: %.sgml
|
| 56 |
rm -f $*.$(ORIG_LANG).sgml
|
| 57 |
ln -sf $*.sgml $*.$(ORIG_LANG).sgml
|
| 58 |
|
| 59 |
# END OF CONF PART CHANGE THE END AT YOU OWN RISK
|
| 60 |
# =============================================================================
|
| 61 |
|
| 62 |
# List of html to be built
|
| 63 |
HTMLDIRS := $(foreach lang,$(LANGS),$(MANUAL).$(lang).html)
|
| 64 |
|
| 65 |
# List of non-html EXTS
|
| 66 |
FILEEXTS := $(filter-out html,$(EXTS))
|
| 67 |
|
| 68 |
# List of non-html to be build
|
| 69 |
ALLFILES := $(foreach ext,$(FILEEXTS),\
|
| 70 |
$(foreach lang,$(LANGS),$(MANUAL).$(lang).$(ext))\
|
| 71 |
)
|
| 72 |
|
| 73 |
# List of ps to be build (compatibility)
|
| 74 |
PSFILES := $(foreach lang,$(LANGS),$(MANUAL).$(lang).ps)
|
| 75 |
|
| 76 |
# List of sgml to be build
|
| 77 |
#SGMLFILES := $(foreach lang,$(LANGS),$(MANUAL).$(lang).sgml)
|
| 78 |
SGMLFILES := $(MANUAL).sgml
|
| 79 |
|
| 80 |
#====[ build rules ]===========================================================
|
| 81 |
# generate anything some dirs want version.ent to be builded, some not
|
| 82 |
|
| 83 |
DEBIAN=$(wildcard debian)
|
| 84 |
ifeq ($(DEBIAN),"debian")
|
| 85 |
all: version.ent $(HTMLDIRS) $(ALLFILES)
|
| 86 |
else
|
| 87 |
all: $(HTMLDIRS) $(ALLFILES)
|
| 88 |
endif
|
| 89 |
|
| 90 |
version.ent: debian/changelog
|
| 91 |
./debian/rules $@
|
| 92 |
|
| 93 |
|
| 94 |
#----[ generating HTML ]-------------------------------------------------------
|
| 95 |
# FIXME: there is a trick because debiandoc2html does a sed 'y/.../...'
|
| 96 |
# which should be reverted to have the content negociation working.
|
| 97 |
# This trick is bad. debiandoc2html should be corrected.
|
| 98 |
$(MANUAL).%.html: $(MANUAL).%.sgml
|
| 99 |
debiandoc2html -l $* -c $<
|
| 100 |
# debiandoc2html -1 -l $* -c $<
|
| 101 |
@echo "cleaning up file extensions";\
|
| 102 |
for file in `ls $(MANUAL).$*.html/*` ; do\
|
| 103 |
newfile=`echo $$file|\
|
| 104 |
sed 's/$(shell echo $*|\
|
| 105 |
sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ_/abcdefghijklmnopqrstuvwxyz-/'\
|
| 106 |
)\.html/$*\.html/'`;\
|
| 107 |
if [ $$file != $$newfile ] ; then\
|
| 108 |
mv $$file $$newfile;\
|
| 109 |
fi;\
|
| 110 |
done
|
| 111 |
|
| 112 |
#----[ generating plain text ]-------------------------------------------------
|
| 113 |
$(MANUAL).%.txt: $(MANUAL).%.sgml
|
| 114 |
debiandoc2text -l $* $<
|
| 115 |
|
| 116 |
#----[ generating tov text ]---------------------------------------------------
|
| 117 |
$(MANUAL).%.tov: $(MANUAL).%.sgml
|
| 118 |
debiandoc2textov -l $* $<
|
| 119 |
|
| 120 |
#----[ generating info ]-------------------------------------------------------
|
| 121 |
#$(MANUAL).%.info: $(MANUAL).%.sgml
|
| 122 |
# debiandoc2info -l $* $<
|
| 123 |
|
| 124 |
# for now we avoid problem with above with followings
|
| 125 |
$(MANUAL).%.texinfo: $(MANUAL).%.sgml
|
| 126 |
debiandoc2texinfo -l $* $<
|
| 127 |
|
| 128 |
$(MANUAL).%.info: $(MANUAL).%.texinfo
|
| 129 |
makeinfo --force -v -o $(MANUAL).$*.info $(MANUAL).$*.texinfo
|
| 130 |
|
| 131 |
#----[ generating teTeX ]------------------------------------------------------
|
| 132 |
$(MANUAL).%.tex: $(MANUAL).%.sgml
|
| 133 |
debiandoc2latex -l $* $<
|
| 134 |
|
| 135 |
#----[ generating PostScript ]-------------------------------------------------
|
| 136 |
$(MANUAL).%.ps: $(MANUAL).%.sgml
|
| 137 |
debiandoc2latexps -l $* $<
|
| 138 |
|
| 139 |
#----[ generating PDF ]--------------------------------------------------------
|
| 140 |
$(MANUAL).%.pdf: $(MANUAL).%.sgml
|
| 141 |
debiandoc2latexpdf -l $* $<
|
| 142 |
|
| 143 |
#====[ publishing to the DDP web pages ]=======================================
|
| 144 |
#----[ publish html ]----------------------------------------------------------
|
| 145 |
publish-html: $(HTMLDIRS)
|
| 146 |
test -d $(PUBLISHDIR)/$(MANUAL) \
|
| 147 |
|| install -d -m 755 $(PUBLISHDIR)/$(MANUAL)
|
| 148 |
rm -f $(PUBLISHDIR)/$(MANUAL)/*.html
|
| 149 |
# install all html
|
| 150 |
@$(foreach lang,$(LANGS),\
|
| 151 |
install -p -m 644 $(MANUAL).$(lang).html/*.html $(PUBLISHDIR)/$(MANUAL)/;\
|
| 152 |
)
|
| 153 |
ln -sf index.$(ORIG_LANG).html\
|
| 154 |
$(PUBLISHDIR)/$(MANUAL)/index.html
|
| 155 |
|
| 156 |
#----[ publish all files except html ]-----------------------------------------
|
| 157 |
publish-files: $(ALLFILES)
|
| 158 |
test -d $(PUBLISHDIR)/$(MANUAL) \
|
| 159 |
|| install -d -m 755 $(PUBLISHDIR)/$(MANUAL)
|
| 160 |
# clear all old non-html: $(FILEEXTS)
|
| 161 |
@$(foreach ext,$(FILEEXTS),\
|
| 162 |
if [ "$(ext)" == "info" ] ; then \
|
| 163 |
rm -f $(PUBLISHDIR)/$(MANUAL)/*.info*;\
|
| 164 |
else \
|
| 165 |
rm -f $(PUBLISHDIR)/$(MANUAL)/*.$(ext);\
|
| 166 |
fi ;\
|
| 167 |
)
|
| 168 |
# install all non-html: $(FILEEXTS)
|
| 169 |
@$(foreach ext,$(FILEEXTS),\
|
| 170 |
$(foreach lang,$(LANGS),\
|
| 171 |
if [ "$(ext)" == "info" ] ; then \
|
| 172 |
install -p -m 644 $(MANUAL).$(lang).info* $(PUBLISHDIR)/$(MANUAL)/;\
|
| 173 |
else \
|
| 174 |
install -p -m 644 $(MANUAL).$(lang).$(ext) $(PUBLISHDIR)/$(MANUAL)/;\
|
| 175 |
fi ;\
|
| 176 |
)\
|
| 177 |
)
|
| 178 |
# make the symlinks for $(FILEEXTS)
|
| 179 |
@$(foreach ext,$(FILEEXTS),\
|
| 180 |
ln -sf $(MANUAL).$(ORIG_LANG).$(ext)\
|
| 181 |
$(PUBLISHDIR)/$(MANUAL)/$(MANUAL).$(ext);\
|
| 182 |
)
|
| 183 |
|
| 184 |
#----[ publish the ps ]--------------------------------------------------------
|
| 185 |
# Just in case external program uses this target (Doubtful)
|
| 186 |
publish-ps: $(PSFILES)
|
| 187 |
test -d $(PUBLISHDIR)/$(MANUAL) \
|
| 188 |
|| install -d -m 755 $(PUBLISHDIR)/$(MANUAL)
|
| 189 |
rm -f $(PUBLISHDIR)/$(MANUAL)/*.ps
|
| 190 |
# install all ps
|
| 191 |
@$(foreach lang,$(LANGS),\
|
| 192 |
install -p -m 644 $(MANUAL).$(lang).ps \
|
| 193 |
$(PUBLISHDIR)/$(MANUAL)/ ;
|
| 194 |
)
|
| 195 |
# make the symlinks for ps
|
| 196 |
ln -sf $(MANUAL).$(ORIG_LANG).ps\
|
| 197 |
$(PUBLISHDIR)/$(MANUAL)/$(MANUAL).ps
|
| 198 |
|
| 199 |
#====[ validating SGML ]=======================================================
|
| 200 |
validate: $(SGMLFILES)
|
| 201 |
set -x; for i in $(SGMLFILES); do nsgmls -gues -wall $$i; done
|
| 202 |
|
| 203 |
#====[ cleaning up ]===========================================================
|
| 204 |
distclean: clean
|
| 205 |
rm -rf $(PUBLISHDIR)/$(MANUAL)
|
| 206 |
|
| 207 |
clean:
|
| 208 |
rm -f $(MANUAL)*.{txt,ps,dvi,pdf,info*,log,tex,aux,toc,sasp*,out,tov,tpt}
|
| 209 |
rm -f *~ prior.aux pprior.aux head.tmp body.tmp $(MANUAL).en.sgml
|
| 210 |
rm -rf $(MANUAL)*.html
|
| 211 |
|
| 212 |
.PHONY: all publish\
|
| 213 |
publish-html publish-ps publish-files\
|
| 214 |
clean distclean validate
|