1#
2#-------------------------------------------------------------------------
3SHELL = /bin/sh
4
5AT=@
6
7#
8# bacula.env file is a local file to define specific values if any
9# bacula.env.dist is a template for it.
10BACULAENVFILE=bacula.env
11ENVFILE=$(shell [ -e ./$(BACULAENVFILE) ] && echo "OK")
12ifeq ($(ENVFILE),OK)
13  include $(BACULAENVFILE)
14  $(info Found env file $(BACULAENVFILE).)
15else
16  $(error No environment file "$(BACULAENVFILE)" found. You can copy "$(BACULAENVFILE).dist" to "$(BACULAENVFILE)" and adjust some definitions.)
17endif
18#
19# Where is latex2html tool
20BLATEX2HTMLDIR=$(CURDIR)/latex2html-2016
21#
22# LaTeX directory to build bacula documentation (classes and layout)
23LATEX_DIR=$(CURDIR)/latex
24#
25# latex2html requirements:
26## - The latex2html Makefile is required to build latex2html accordingly to our needs
27LATEX2HTMLMAKEFILE=$(BLATEX2HTMLDIR)/Makefile
28## Destination of the build of latex2html (make install)
29BBINDIR=$(CURDIR)/latex2html
30## tex files location for latex2html
31BTEXDIR=$(LATEX_DIR)/latex2html
32## Perl5 libraries to build
33PERL5LIB=$(BLATEX2HTMLDIR)
34## Files required for latex2html process when compiling tex files.
35TRANSLATEIMGS=$(CURDIR)/manuals/translate_images.pl
36LATEX2HTMLINIT=$(CURDIR)/manuals/latex2html-init.pl
37## latex2html binary
38LATEX2HTML=$(BBINDIR)/bin/latex2html
39## Tool directory for the post-process
40TOOLS_DIR=$(CURDIR)/tools
41#
42# PDF to latex compiler
43ifneq ($(TEX_TO_PDF),)
44  $(info Using $(TEX_TO_PDF) compiler.)
45else
46  $(info PDF compiler $(TEX_TO_PDF) undefined.)
47  TEX_TO_PDF=pdflatex
48endif
49COMPILER=$(shell which $(TEX_TO_PDF))
50ifneq ($(COMPILER),)
51  $(info Compiler $(COMPILER) found.)
52else
53# This will *stop* the Makefile
54  $(error Unable to find $(TEX_TO_PDF))
55endif
56#
57# For version.tex building process
58## bacula source directory
59ifeq ($(BACULASRC),)
60  BACULASRC=$(HOME)
61endif
62# Location of the version.h file
63VERSION_H=$(shell find $(BACULASRC) -name "version.h" -print)
64ifeq ($(VERSION_H),)
65  $(error Unable to find version.h in Bacula source tree $(BACULASRC).)
66else
67  $(info $(VERSION_H) file found into $(dir $(VERSION_H)))
68endif
69## Bacula source directory (in the version.h point of view)
70SOURCES_DIR=$(dir $(VERSION_H))
71## Location and name for the version.tex file
72VERSION_TEX=$(LATEX_DIR)/version.tex
73#
74# Directories required
75## images
76IMAGES_DIR=$(CURDIR)/images
77PNGIMAGES_DIR=$(IMAGES_DIR)/png
78JPGIMAGES_DIR=$(IMAGES_DIR)/jpg
79SVGIMAGES_DIR=$(IMAGES_DIR)/svg
80## covers for manuals
81COVERS_DIR=$(CURDIR)/covers
82## PDF covers
83PDFCOVERS_DIR=$(COVERS_DIR)/pdf
84## SVG covers
85SVGCOVERS_DIR=$(COVERS_DIR)/svg
86## Licence files
87LICENCE_DIR=$(MANUALS_DIR)/licences
88## Coverpage name. There is only one coverpage used by the .cls LaTeX class file.
89BMANUAL_NAME=bcoverpage
90#
91# Makefiles
92## The following Makefile is unique for PDF building and is used whatever the manual is.
93GENERAL_MAKEFILE=$(CURDIR)/manuals/Makefile
94## The following Makefile is unique for HTML building and is used whatever the manual is.
95WEB_MAKEFILE=$(CURDIR)/manuals/web.makefile
96
97export BACULAVERSION
98export PERL5LIB
99export LATEX_DIR
100export IMAGES_DIR
101export COVERS_DIR
102export PDFCOVERS_DIR
103export SVGCOVERS_DIR
104export LICENCE_DIR
105export BMANUAL_NAME
106export COMPILER
107export COVERPAGE_NAME
108export GENERAL_MAKEFILE
109export WEB_MAKEFILE
110export LATEX2HTMLINIT
111export TRANSLATEIMGS
112export LATEX2HTML
113export TOOLSDIR
114export VERSION_TEX
115export TOOLS_DIR
116export PNGIMAGES_DIR
117export JPGIMAGES_DIR
118export SVGIMAGES_DIR
119export SVGCOVERS_DIR
120
121externalreferencesfile=$(LATEX_DIR)/external-references.tex
122
123# Installation target directories & other installation stuff
124prefix = /usr/local
125exec_prefix = ${prefix}
126binprefix =
127manprefix =
128sbindir = ${exec_prefix}/sbin
129sysconfdir = ${prefix}/etc
130scriptdir = @scriptdir@
131mandir = ${datarootdir}/man/man1
132manext = 1
133datarootdir=${prefix}/share
134
135
136# Tools & program stuff
137MV = /bin/mv
138RM = /bin/rm
139RMF = /bin/rm -f
140CP = /bin/cp
141SED = @SED@
142AWK = /usr/bin/gawk
143ECHO = /bin/echo
144CMP = @CMP@
145INSTALL = /usr/bin/install -c
146# add the -s to the following in PRODUCTION mode
147INSTALL_PROGRAM = /usr/bin/install -c -m @SBINPERM@
148INSTALL_DATA = /usr/bin/install -c -m 644
149INSTALL_SCRIPT = /usr/bin/install -c -m @SBINPERM@
150INSTALL_CONFIG = /usr/bin/install -c -m 640
151
152
153# End of common section of the Makefile
154#-------------------------------------------------------------------------
155
156srcdir =	.
157.PHONY: latex2html
158.PATH:		.
159
160basedir = ..
161topdir = ..
162thisdir = docs
163TRANSLATE=./htmls.sh
164
165#
166# Distribution variables
167#
168
169de_dirs = manuals/de/console manuals/de/developers manuals/de/main \
170  manuals/de/misc manuals/de/problems manuals/de/utility
171
172
173en_dirs = manuals/en/concept manuals/en/console manuals/en/developers manuals/en/main \
174  manuals/en/misc manuals/en/problems manuals/en/utility
175
176es_dirs = manuals/es/console manuals/es/developers manuals/es/main \
177  manuals/es/misc manuals/es/problems manuals/es/utility
178
179fr_dirs = manuals/fr/console manuals/fr/developers manuals/fr/main \
180  manuals/fr/misc manuals/fr/problems manuals/fr/utility
181
182image_dirs = images/svg
183all_dirs = ${de_dirs} ${en_dirs} ${es_dirs} ${fr_dirs} ${image_dirs}
184
185#-------------------------------------------------------------------------
186
187en: all
188
189all:	$(VERSION_TEX) latex2html pdf-manuals html-manuals
190	$(AT)echo ""
191	$(AT)echo "All manuals built ..."
192	$(AT)echo ""
193	$(AT)echo ""
194	$(AT)echo ""
195
196latex2html: $(BBINDIR)
197
198$(BBINDIR): $(LATEX2HTMLMAKEFILE)
199	$(AT)$(MAKE) -C $(BLATEX2HTMLDIR) && $(MAKE) -C $(BLATEX2HTMLDIR) install
200
201$(LATEX2HTMLMAKEFILE):
202	$(AT)echo "Building latex2html Makefile"
203	$(AT)(cd ${BLATEX2HTMLDIR} ; ./configure --prefix=${BBINDIR} --with-texpath=${BTEXDIR})
204	$(AT)echo "Makefile installed."
205
206pdf-manuals: external-references
207	$(AT)echo " "
208	$(AT)echo "Generating PDF manuals..."
209	$(AT)for I in ${en_dirs}; \
210	  do $(MAKE) -C $$I pdflatex || (echo ""; echo ""; echo "  ====== Error in `pwd` ======"; echo ""; echo ""; exit 1;); done
211
212#(cd $$I; echo "==>Entering directory `pwd`"; \
213	      	done
214	$(AT)echo ""
215	$(AT)echo "All PDF manuals built ..."
216	$(AT)echo ""
217	$(AT)echo ""
218	$(AT)echo ""
219
220html-manuals:
221	$(AT)echo " "
222	$(AT)echo "Creating Web documentation..."
223	$(AT)for I in ${en_dirs}; \
224	  do (cd $$I; echo "==>Entering directory `pwd`"; \
225	      $(MAKE) web || (echo ""; echo ""; echo "	====== Error in `pwd` ======"; \
226			    echo ""; echo ""; exit 1;)); \
227	done
228	$(AT)echo "Handling external references"
229	$(AT)for I in ${en_dirs} ;\
230	  do (cd $$I ; $(MAKE) references ||  (echo ""; echo ""; echo "	====== Error in `pwd` ======"; \
231			    echo ""; echo ""; exit 1;)); \
232	done
233	$(AT)echo "Remove links ..."
234	$(AT)find . -type l -exec rm {} \;
235	$(AT)echo ""
236	$(AT)echo "All HTML manuals built ..."
237	$(AT)echo ""
238	$(AT)echo ""
239	$(AT)echo ""
240
241
242templates:
243	$(AT)echo " "
244	$(AT)echo -n "Linking templates.."
245	$(AT)mkdir -p ~/texmf/tex/latex/bsys/
246	$(AT)if [ ! -e  ~/texmf/tex/latex/bsys/bsysmanual ] || [ -h ~/texmf/tex/latex/bsys/bsysmanual ]; \
247	   then\
248		ln -sf `pwd`/bsysmanual ~/texmf/tex/latex/bsys/;\
249	fi
250	mktexlsr ~/texmf
251	$(AT)echo "Done"
252
253external-references:
254	$(AT)echo " "
255	$(AT)echo -n "Building external references file"
256	$(AT)find ${en_dirs} -mindepth 0 -maxdepth 1 -name "*tex" -exec grep -q '\label' {} \; -print| awk -F/ '{ print "\\externaldocument[" $$3 "-]{../"$$3"/"$$4"}"}'|sed -e 's/.tex//g' > ${externalreferencesfile}
257	$(AT)for I in ${en_dirs}; \
258	  do $(MAKE) -C $$I $@ || (echo ""; echo ""; echo "  ====== Error in `pwd` ======"; echo ""; echo ""; exit 1;); done
259	$(AT)echo "All $@ built ..."
260	$(AT)echo "External references for all manuals built."
261
262bacula-web:
263	$(AT)(if [ -x bacula-web ]; then cd bacula-web; make; fi)
264
265fr:	french
266
267french:
268#	$(AT)for I in ${fr_dirs}; do (if [ -x $$I ]; then cd $$I; cp -f ../../version.tex .; fi); done
269	$(AT)for I in ${fr_dirs}; \
270	  do (cd $$I; echo "==>Entering directory `pwd`"; \
271	      $(MAKE) all || (echo ""; echo ""; echo "	====== Error in `pwd` ======"; \
272			    echo ""; echo ""; exit 1;)); \
273	done
274
275de:	german
276
277german:
278#	$(AT)for I in ${de_dirs}; do (if [ -x $$I ]; then cd $$I; cp -f ../../version.tex .; fi); done
279	$(AT)for I in ${de_dirs}; \
280	  do (cd $$I; echo "==>Entering directory `pwd`"; \
281	      $(MAKE) all || (echo ""; echo ""; echo "	====== Error in `pwd` ======"; \
282			    echo ""; echo ""; exit 1;)); \
283	done
284
285es:	spanish
286
287spanish:
288#	$(AT)for I in ${es_dirs}; do (if [ -x $$I ]; then cd $$I; cp -f ../../version.tex .; fi); done
289	$(AT)for I in ${es_dirs}; \
290	  do (cd $$I; echo "==>Entering directory `pwd`"; \
291	      $(MAKE) all || (echo ""; echo ""; echo "	====== Error in `pwd` ======"; \
292			    echo ""; echo ""; exit 1;)); \
293	done
294
295
296$(basedir)/$(VERNAME).lsm: LSM.in $(srcdir)/../autoconf/Make.common.in $(srcdir)/../src/version.h
297	$(SED) $(SEDREPLACE) < $(srcdir)/LSM.in > $@
298
299clean:
300	$(AT)$(RMF) *~ 1 2 3 bacula-doc*.tar.gz
301	$(AT)(if [ -x bacula-web ] ; then cd bacula-web; make clean; fi)
302	$(AT)for I in ${all_dirs}; \
303	  do (if [ -x $$I ]; then cd $$I; echo "==>Entering directory `pwd`"; ${MAKE} $@ || exit 1; fi); done
304
305
306realclean: clean
307
308distclean: $(LATEX2HTMLMAKEFILE) clean
309	$(AT)(cd $(BLATEX2HTMLDIR) ; make $@)
310	$(AT)rm -rf $(BBINDIR)
311	$(AT)rm -rf $(BTEXDIR)
312	$(AT)$(RMF) -r CVS html-manual/CVS home-page/CVS techlogs/CVS
313	$(AT)$(RMF) -rf autom4te.cache bacula-doc-* config.log config.out
314	$(AT)$(RMF) -f config.status kernsconfig
315	$(AT)(if [ -x bacula-web ] ; then cd bacula-web; make clean; fi)
316	$(AT)for I in ${all_dirs}; \
317	  do (if [ -x $$I ]; then ${MAKE} -C $$I $@ || exit 1; fi); done
318	$(AT)rm -f ${VERSION_TEX}
319	$(AT)rm -f ${externalreferencesfile}
320
321
322
323devclean:
324
325depend:
326
327install:
328#	$(INSTALL_DATA) bacula.1 $(DESTDIR)$(mandir)/$(manprefix)bacula.$(manext)
329
330uninstall:
331#	-cd $(mandir); $(RMF) $(manprefix)bacula.$(manext)
332
333
334version: $(VERSION_TEX)
335
336$(VERSION_TEX): $(VERSION_H)
337	$(info Building version.tex)
338	$(AT)bacula=$(abspath $(SOURCES_DIR)../..) versionh=$(VERSION_H) versiontex=$(VERSION_TEX) ./update_version
339
340
341verbose:
342	$(AT)echo "version.h file: $(VERSION_H)\n"
343	$(AT)echo "version.h directory: $(SOURCES_DIR)\n"
344	$(AT)echo "version.tex file: $(VERSION_TEX)"
345	$(AT)echo "LATEX2HTML_OK: $(LATEX2HTML_OK)"
346	$(AT)echo "TEX_TO_PDF: >$(TEX_TO_PDF)<"
347	$(AT)echo "TEX_TO_PDF_OK: $(TEX_TO_PDF_OK)"
348