1#
2# PostGIS - Spatial Types for PostgreSQL
3# http://www.postgis.net
4#
5# This is free software; you can redistribute and/or modify it under
6# the terms of the GNU General Public Licence. See the COPYING file.
7#
8# PostGIS documentation build Makefile
9#
10# Copyright 2003-2012 Sandro Santilli <strk@kbt.io>
11# Copyright 2004-2012 Paul Ramsey <pramsey@cleverelephant.ca>
12# Copyright 2009-2011 Regina Obe <lr@pcorp.us>
13# Copyright 2008-2010 Mark Cave-Ayland
14# Copyright 2008-2010 Kevin Neufeld <kneufeld.ca@gmail.com>
15# Copyright 2009-2010 Olivier Courtin <olivier.courtin@camptocamp.com>
16# Copyright 2005-2006 Markus Schaber <markus@schabi.de>
17#
18# NOTE: We don't use a standard PGXS Makefile here since the DOCS target
19# only allows files to be stored within contrib/ and we currently
20# store documentation under contrib/postgis due to the possibility
21# that we could produce a large number of files (think chunked HTML)
22#
23
24translations = it_IT pt_BR fr es pl ko_KR de ja
25
26POSTGIS_MAJOR_VERSION=@POSTGIS_MAJOR_VERSION@
27POSTGIS_MINOR_VERSION=@POSTGIS_MINOR_VERSION@
28POSTGIS_MICRO_VERSION=@POSTGIS_MICRO_VERSION@
29
30ifneq (,$(findstring dev,$(POSTGIS_MICRO_VERSION)))
31  POSTGIS_DOWNLOAD_URL=http://postgis.net/stuff
32else
33  POSTGIS_DOWNLOAD_URL=http://download.osgeo.org/postgis/source
34endif
35
36INSTALL=@INSTALL@
37INSTALL_DATA=@INSTALL_DATA@
38
39XSLTPROC=@XSLTPROC@
40XSLBASE=@XSLBASE@
41XMLLINT=@XMLLINT@
42CAN_BUILD_COMMENTS=@CAN_BUILD_COMMENTS@
43PERL=@PERL@
44
45# To allow network access use:
46#
47# $(MAKE) html XSLTPROCFLAGS=
48#
49ifeq ($(XSLTPROCFLAGS),)
50	XSLTPROCFLAGS=--nonet
51endif
52
53XSLTPROC_COMMONOPTS= \
54	--param section.autolabel 1 \
55	--param section.label.includes.component.label 1 \
56	--param chunk.section.depth 0 \
57	--param generate.section.toc.level 2 \
58	--param funcsynopsis.style kr \
59	--param admon.graphics 1 \
60	--param admon.textlabel 0 \
61	--param make.clean.html 1 \
62	--param simplesect.in.toc 0 \
63	--param use.id.as.filename 1 \
64	--param chunk.quietly 1 \
65	--param header.rule 0 \
66	--param footer.rule 0 \
67	--param table.borders.with.css 1 \
68	--stringparam chunker.output.encoding UTF-8 \
69	--stringparam chunker.output.indent no \
70	--stringparam saxon.character.representation decimal \
71	--stringparam html.stylesheet style.css \
72	$(XSLTPROCFLAGS)
73
74
75HTML_DOCBOOK_XSL=$(XSLBASE)/html/docbook.xsl
76CHUNK_HTML_DOCBOOK_XSL=$(XSLBASE)/html/chunk.xsl
77
78# DBLatex's dblatex script for PDF generation from DocBook
79DBLATEX=@DBLATEX@
80
81# Imagemagick's convert utility program for generated images used in the documentation
82IMAGEMAGICK=@IMAGEMAGICK@
83
84# Gettext for translated documentation
85MSGMERGE=msgmerge
86
87# XML gettext tools
88XML2POT=xml2pot
89
90# DOCBOOK to EPUB
91DBTOEPUB=dbtoepub
92
93# Directories for postgresql subdirectories
94PGSQL_DOCDIR=@PGSQL_DOCDIR@
95PGSQL_MANDIR=@PGSQL_MANDIR@
96PGSQL_SHAREDIR=@PGSQL_SHAREDIR@
97
98BUILD_TARGET =
99
100ifeq ($(CAN_BUILD_COMMENTS),yes)
101BUILD_TARGET += comments
102endif
103
104ifeq ($(CAN_BUILD_PDF),yes)
105BUILD_TARGET += pdf
106endif
107
108# TODO: add "html" to the BUILD_TARGET if it can be built
109
110all: $(BUILD_TARGET)
111
112XML_SOURCES = \
113    extras_address_standardizer.xml \
114	extras_historytable.xml \
115	extras_tigergeocoder.xml \
116	extras_topology.xml \
117	extras.xml \
118	faq_raster.xml \
119	faq.xml \
120	installation.xml \
121	administration.xml \
122	database_tuning.xml \
123	introduction.xml \
124	performance_tips.xml \
125	postgis.xml \
126	reference_accessor.xml \
127	reference_bbox.xml \
128	reference_cluster.xml \
129	reference_constructor.xml \
130	reference_editor.xml \
131	reference_exception.xml \
132	reference_guc.xml \
133	reference_input.xml \
134	reference_lrs.xml \
135	reference_management.xml \
136	reference_measure.xml \
137	reference_sfcgal.xml \
138	reference_operator.xml \
139	reference_output.xml \
140	reference_overlay.xml \
141	reference_processing.xml \
142	reference_raster.xml \
143	reference_relationship.xml \
144	reference_srs.xml \
145	reference_trajectory.xml \
146	reference_transaction.xml \
147	reference_transformation.xml \
148	reference_troubleshooting.xml \
149	reference_type.xml \
150	reference_validation.xml \
151	reference_version.xml \
152	reference.xml \
153	release_notes.xml \
154	reporting.xml \
155	using_postgis_app.xml \
156	using_postgis_dataman.xml \
157	using_postgis_query.xml \
158	using_raster_dataman.xml
159
160XML_GENERATED_SOURCES = \
161	postgis_aggs_mm.xml \
162	postgis-out.xml \
163
164XML_INPUTS = $(XML_SOURCES) $(XML_GENERATED_SOURCES)
165
166XML_INPUTS_POT = $(XML_SOURCES:%.xml=po/templates/%.xml.pot)
167
168.PHONY: $(XML_INPUTS_POT)
169$(XML_INPUTS_POT): po/templates/%.xml.pot: %.xml
170	@if test -f $@; then \
171	  $(XML2POT) $< > $@.tmp; \
172    changed=`diff $@.tmp $@ | grep -v '^[<>] "POT-Creation-Date:' | wc -l`; \
173    if expr $${changed} \> 3 >/dev/null; then \
174      echo "$@ updated"; \
175      mv $@.tmp $@; \
176    else \
177      echo "$@ unchanged"; \
178      rm $@.tmp; \
179    fi; \
180  else \
181	  $(XML2POT) $< > $@; \
182  fi;
183
184# Update translation templates
185update-pot: $(XML_INPUTS_POT)
186
187# Creates or updates translation files
188update-po: $(XML_INPUTS_POT)
189	@for lang in $(translations); do \
190    echo "Creating po files for language $$lang..." ; \
191    for pot in $(XML_INPUTS_POT); do \
192      mkdir -p po/$$lang; \
193      po=po/$$lang/`basename $$pot .pot`.po; \
194      if test -f $$po; then \
195        $(MSGMERGE) --update $$po $$pot; \
196      else \
197        cp $$pot $$po; \
198      fi; \
199    done; \
200  done
201
202pull-tx:
203	tx pull --all
204	$(MAKE) update-po
205
206push-tx:
207	tx push -s -t --skip
208
209# Register transifex resources, run when adding a new .xml file
210update-tx:
211	for f in $(XML_INPUTS_POT); do \
212    f=`basename $${f} .pot`; \
213    res=`echo "$${f}" | sed 's/\.//g'`pot; \
214    tx set --auto-local -r postgis.$${res} "po/<lang>/$${f}.po" \
215           --source-lang en --source-file "po/templates/$${f}.pot" \
216           --execute; \
217  done
218
219
220ifeq ($(XSLTPROC),)
221postgis_aggs_mm.xml: requirements_not_met_xsltproc
222else
223postgis_aggs_mm.xml: ./xsl/postgis_aggs_mm.xml.xsl Makefile postgis-out.xml $(XML_SOURCES)
224	$(XSLTPROC) --novalid ./xsl/postgis_aggs_mm.xml.xsl postgis-out.xml > $@
225endif
226
227postgis_comments.sql: ./xsl/postgis_comments.sql.xsl $(XML_INPUTS)
228	$(XSLTPROC) --novalid ./xsl/postgis_comments.sql.xsl postgis-out.xml > $@
229
230postgis_cheatsheet.html: ./xsl/postgis_cheatsheet.html.xsl $(XML_INPUTS)
231	$(XSLTPROC) --novalid ./xsl/postgis_cheatsheet.html.xsl postgis-out.xml > $@
232
233raster_comments.sql: ./xsl/raster_comments.sql.xsl $(XML_INPUTS)
234	$(XSLTPROC) --novalid ./xsl/raster_comments.sql.xsl postgis-out.xml > $@
235
236raster_cheatsheet.html: ./xsl/raster_cheatsheet.html.xsl $(XML_INPUTS)
237	$(XSLTPROC) --novalid ./xsl/raster_cheatsheet.html.xsl postgis-out.xml > $@
238
239topology_comments.sql: ./xsl/topology_comments.sql.xsl $(XML_INPUTS)
240	$(XSLTPROC) --novalid ./xsl/topology_comments.sql.xsl postgis-out.xml > $@
241
242topology_cheatsheet.html: ./xsl/topology_cheatsheet.html.xsl $(XML_INPUTS)
243	$(XSLTPROC) --novalid ./xsl/topology_cheatsheet.html.xsl postgis-out.xml > $@
244
245sfcgal_comments.sql: ./xsl/sfcgal_comments.sql.xsl $(XML_INPUTS)
246	$(XSLTPROC) --novalid ./xsl/sfcgal_comments.sql.xsl postgis-out.xml > $@
247
248sfcgal_cheatsheet.html: ./xsl/sfcgal_cheatsheet.html.xsl $(XML_INPUTS)
249	$(XSLTPROC) --novalid ./xsl/sfcgal_cheatsheet.html.xsl postgis-out.xml > $@
250
251tiger_geocoder_comments.sql: ./xsl/tiger_geocoder_comments.sql.xsl $(XML_INPUTS)
252	$(XSLTPROC) --novalid ./xsl/tiger_geocoder_comments.sql.xsl postgis-out.xml > $@
253
254tiger_geocoder_cheatsheet.html: ./xsl/tiger_geocoder_cheatsheet.html.xsl $(XML_INPUTS)
255	$(XSLTPROC) --novalid ./xsl/tiger_geocoder_cheatsheet.html.xsl postgis-out.xml > $@
256
257postgis-out.xml: postgis.xml Makefile
258	$(PERL) -lpe "s'@@LAST_RELEASE_VERSION@@'${POSTGIS_MAJOR_VERSION}.${POSTGIS_MINOR_VERSION}.${POSTGIS_MICRO_VERSION}'g;s'@@POSTGIS_DOWNLOAD_URL@@'${POSTGIS_DOWNLOAD_URL}'g;" $< > $@
259
260chunked-html: postgis-out.xml Makefile images $(XML_INPUTS)
261	$(XSLTPROC) $(XSLTPROC_COMMONOPTS) \
262		--output html/ \
263		$(CHUNK_HTML_DOCBOOK_XSL) \
264		$<
265
266chunked-html-web: postgis-out.xml Makefile images $(XML_INPUTS)
267	$(XSLTPROC) $(XSLTPROC_COMMONOPTS) \
268		--output html/ \
269		--stringparam html.script ga.js \
270		$(CHUNK_HTML_DOCBOOK_XSL) \
271		$<
272
273HTML_BITS = $(wildcard html/*.html)
274
275chunked-html-web-mobile: postgis-out.xml Makefile images $(XML_INPUTS)
276	$(XSLTPROC) $(XSLTPROC_COMMONOPTS) \
277		--output html/ \
278		--stringparam html.script ga.js \
279		$(CHUNK_HTML_DOCBOOK_XSL) \
280		$<
281	$(PERL) -pi -e 's/<head>/<head><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">/g' $(HTML_BITS)
282
283
284html: html/postgis$(DOCSUFFIX).html
285
286html-localized:
287	@for lang in $(translations); do \
288    echo "Creating html for language $$lang..."; \
289    $(MAKE) -C po/$$lang local-html; \
290  done
291
292html/postgis$(DOCSUFFIX).html: postgis-out.xml Makefile images $(XML_INPUTS)
293	$(XSLTPROC) $(XSLTPROC_COMMONOPTS) \
294		--output html/postgis$(DOCSUFFIX).html \
295		$(HTML_DOCBOOK_XSL) \
296		$<
297
298
299postgis-${POSTGIS_MAJOR_VERSION}.${POSTGIS_MINOR_VERSION}.${POSTGIS_MICRO_VERSION}$(DOCSUFFIX).pdf: postgis-out.xml images $(XML_INPUTS)
300	if test x"$(DBLATEX)" = x; then \
301	   echo "Error: dblatex not found, can't build pdf"; \
302	   echo "       try installing dblatex and then re-run configure"; \
303	   false; \
304	else \
305		$(DBLATEX) -T native -t pdf \
306		   -I "${PWD}/html" \
307		   -P doc.collab.show=0 \
308		   -P figure.note="${PWD}/html/images/note" \
309		   -P figure.tip="${PWD}/html/images/tip" \
310		   -P figure.important="${PWD}/html/images/important" \
311		   -P figure.warning="${PWD}/html/images/warning" \
312		   -P figure.caution="${PWD}/html/images/caution" \
313		   -P latex.output.revhistory=0 \
314		   -s "${PWD}/texstyle.sty" \
315		   -o postgis-${POSTGIS_MAJOR_VERSION}.${POSTGIS_MINOR_VERSION}.${POSTGIS_MICRO_VERSION}$(DOCSUFFIX).pdf $<; \
316	fi
317
318postgis-${POSTGIS_MAJOR_VERSION}.${POSTGIS_MINOR_VERSION}.${POSTGIS_MICRO_VERSION}$(DOCSUFFIX).epub: postgis-out.xml images $(XML_INPUTS)
319	if test x"$(DBTOEPUB)" = x; then \
320	   echo "Error: dbtoepub not found, can't build epub"; \
321	   echo "       try installing dbtoepub"; \
322	   false; \
323	else \
324		$(DBTOEPUB) -c "${PWD}/html/style.css" \
325		 -o postgis-${POSTGIS_MAJOR_VERSION}.${POSTGIS_MINOR_VERSION}.${POSTGIS_MICRO_VERSION}$(DOCSUFFIX).epub \
326		  $<; \
327	fi
328
329epub: postgis-${POSTGIS_MAJOR_VERSION}.${POSTGIS_MINOR_VERSION}.${POSTGIS_MICRO_VERSION}$(DOCSUFFIX).epub
330
331pdf: postgis-${POSTGIS_MAJOR_VERSION}.${POSTGIS_MINOR_VERSION}.${POSTGIS_MICRO_VERSION}$(DOCSUFFIX).pdf
332
333pdf-localized:
334	@for lang in $(translations); do \
335    echo "Creating pdf for language $$lang..."; \
336    $(MAKE) -C po/$$lang local-pdf; \
337  done
338
339doxygen.cfg: doxygen.cfg.in
340	$(PERL) -lpe "s'@@LAST_RELEASE_VERSION@@'${POSTGIS_MAJOR_VERSION}.${POSTGIS_MINOR_VERSION}.${POSTGIS_MICRO_VERSION}'g" $< > $@
341
342doxygen: doxygen.cfg
343	doxygen $<
344
345images:
346	$(MAKE) -C html/image_src images
347
348images-clean:
349	$(MAKE) -C html/image_src images-clean
350
351clean:
352	rm -f html/*.html
353	rm -f postgis-${POSTGIS_MAJOR_VERSION}.${POSTGIS_MINOR_VERSION}.${POSTGIS_MICRO_VERSION}.pdf
354	rm -f *.epub
355	$(MAKE) -C html/image_src clean
356	rm -f $(XML_GENERATED_SOURCES)
357	rm -f postgis_gardentest_${POSTGIS_MAJOR_VERSION}${POSTGIS_MINOR_VERSION}.sql
358	rm -f raster_gardentest_${POSTGIS_MAJOR_VERSION}${POSTGIS_MINOR_VERSION}.sql
359
360distclean: clean
361	$(MAKE) -C html/image_src distclean
362	rm -f Makefile Makefile.comments html/image_src/Makefile
363
364maintainer-clean: clean images-clean
365	rm -f postgis_comments.sql raster_comments.sql topology_comments.sql tiger_geocoder_comments.sql sfcgal_comments.sql
366
367ifneq ($(CAN_BUILD_COMMENTS),yes)
368comments:
369else
370comments: postgis_comments.sql raster_comments.sql topology_comments.sql sfcgal_comments.sql tiger_geocoder_comments.sql
371endif
372
373cheatsheets: postgis_cheatsheet.html raster_cheatsheet.html topology_cheatsheet.html sfcgal_cheatsheet.html tiger_geocoder_cheatsheet.html
374
375ifneq ($(CAN_BUILD_COMMENTS),yes)
376comments-install:
377	if test -e postgis_comments.sql  -a \
378	        -e raster_comments.sql   -a \
379	        -e topology_comments.sql -a \
380	        -e sfcgal_comments.sql -a \
381	        -e tiger_geocoder_comments.sql; then \
382	  $(MAKE) -f Makefile.comments install; \
383	fi
384else
385comments-install: comments
386	$(MAKE) -f Makefile.comments install
387endif
388
389comments-uninstall:
390	$(MAKE) -f Makefile.comments uninstall
391
392man-install: man/shp2pgsql.1 man/pgsql2shp.1
393	mkdir -p $(DESTDIR)$(PGSQL_MANDIR)/man1
394	$(INSTALL_DATA) man/pgsql2shp.1 $(DESTDIR)$(PGSQL_MANDIR)/man1/pgsql2shp.1
395	$(INSTALL_DATA) man/shp2pgsql.1 $(DESTDIR)$(PGSQL_MANDIR)/man1/shp2pgsql.1
396
397man-uninstall:
398	rm -f $(DESTDIR)$(PGSQL_MANDIR)/man1/shp2pgsql.1
399	rm -f $(DESTDIR)$(PGSQL_MANDIR)/man1/pgsql2shp.1
400
401docs-install: html/postgis.html html/style.css
402	mkdir -p $(DESTDIR)$(PGSQL_DOCDIR)/postgis/images
403	$(INSTALL_DATA) html/postgis.html $(DESTDIR)$(PGSQL_DOCDIR)/postgis/
404	$(INSTALL_DATA) html/style.css $(DESTDIR)$(PGSQL_DOCDIR)/postgis/
405	$(INSTALL_DATA) html/images/* $(DESTDIR)$(PGSQL_DOCDIR)/postgis/images/
406	$(INSTALL_DATA) ../README.postgis $(DESTDIR)$(PGSQL_DOCDIR)/postgis/README.postgis
407
408docs-uninstall:
409	rm -f $(DESTDIR)$(PGSQL_DOCDIR)/postgis/postgis.html
410	rm -f $(DESTDIR)$(PGSQL_DOCDIR)/postgis/style.css
411	rm -rf $(DESTDIR)$(PGSQL_DOCDIR)/postgis/images
412	rm -f $(DESTDIR)$(PGSQL_DOCDIR)/postgis/README.postgis
413
414install: comments-install
415
416uninstall: comments-uninstall
417
418ifeq ($(XSLTPROC),)
419garden: requirements_not_met_xsltproc
420else
421garden:	xsl/postgis_gardentest.sql.xsl $(XML_INPUTS)
422	$(XSLTPROC) -o postgis_gardentest_${POSTGIS_MAJOR_VERSION}${POSTGIS_MINOR_VERSION}.sql xsl/postgis_gardentest.sql.xsl postgis-out.xml
423	$(XSLTPROC) -o raster_gardentest_${POSTGIS_MAJOR_VERSION}${POSTGIS_MINOR_VERSION}.sql xsl/raster_gardentest.sql.xsl postgis-out.xml
424endif
425
426
427
428check: check-unit
429check-regress:
430
431ifeq ($(XMLLINT),)
432check-unit: requirements_not_met_xmllint
433else
434check-unit: $(XML_INPUTS)
435	$(XMLLINT) --loaddtd --xinclude --valid postgis-out.xml > /dev/null
436endif
437
438check-localized:
439	@for lang in $(translations); do \
440    echo "Creating html for language $$lang..."; \
441    $(MAKE) -C po/$$lang local-check; \
442  done
443
444
445requirements_not_met_xsltproc:
446	@echo
447	@echo "configure was unable to find 'xsltproc' which is required"
448	@echo "to build the documentation."
449	@echo "Install xsltproc and then re-run configure. Alternatively "
450	@echo "refer to online manual:"
451	@echo
452	@echo "  http://postgis.net/documentation"
453	@echo
454
455requirements_not_met_xmllint:
456	@echo
457	@echo "configure was unable to find 'xmllint' which is required"
458	@echo "to test the documentation."
459	@echo "Install xmllint and then re-run configure. Alternatively "
460	@echo "refer to online manual:"
461	@echo
462	@echo "  http://postgis.net/documentation"
463	@echo
464
465requirements_not_met_xslbase:
466	@echo
467	@echo "configure was unable to find the Docbook XSL stylesheet directory"
468	@echo "which is required to build the documentation."
469	@echo "Install the Docbook XSL stylesheets and/or re-run configure "
470	@echo "with the --with-xsldir option."
471	@echo "Alternatively refer to online manual:"
472	@echo
473	@echo "  http://postgis.net/documentation"
474	@echo
475
476requirements_not_met_imagemagick:
477	@echo
478	@echo "configure was unable to find the ImageMagick's 'convert' utility program."
479	@echo "To build the documentation, install ImageMagick and then re-run configure. Alternatively "
480	@echo "refer to online manual:"
481	@echo
482	@echo "  http://postgis.net/documentation"
483	@echo
484