1# **********************************************************************
2# *
3# * PostGIS - Spatial Types for PostgreSQL
4# * http://postgis.net
5# *
6# * Copyright (C) 2010-2011 Sandro Santilli <strk@kbt.io>
7# * Copyright (C) 2008 Mark Cave-Ayland
8# * Copyright (C) 2005 Refractions Research Inc.
9# *
10# * This is free software; you can redistribute and/or modify it under
11# * the terms of the GNU General Public Licence. See the COPYING file.
12# *
13# **********************************************************************
14
15#
16# PostGIS PGXS build system
17#
18
19POSTGIS_PGSQL_VERSION=@POSTGIS_PGSQL_VERSION@
20
21MODULE_big=postgis_topology-@POSTGIS_MAJOR_VERSION@
22MODULEDIR=contrib/postgis-@POSTGIS_MAJOR_VERSION@.@POSTGIS_MINOR_VERSION@
23MODULEPATH=$$libdir/postgis_topology-@POSTGIS_MAJOR_VERSION@
24
25ifeq (@LIBINCLUDEMINORVERSION@,yes)
26MODULEPATH=$$libdir/postgis_topology-@POSTGIS_MAJOR_VERSION@.@POSTGIS_MINOR_VERSION@
27MODULE_big=postgis_topology-@POSTGIS_MAJOR_VERSION@.@POSTGIS_MINOR_VERSION@
28endif
29
30# Files to be copied to the contrib/ directory
31DATA_built=topology.sql topology_upgrade.sql uninstall_topology.sql
32
33# SQL preprocessor
34SQLPP = @SQLPP@
35
36# SQL objects (files requiring pre-processing)
37SQL_OBJS = \
38  topology.sql \
39  topology_upgrade.sql \
40  topology_before_upgrade.sql \
41  topology_after_upgrade.sql
42
43# Objects to build using PGXS
44
45OBJS = postgis_topology.o
46
47# Libraries to link into the module (proj, geos)
48#
49# Note: we specify liblwgeom.a directly in SHLIB_LINK rather than using
50# -L... -l options to prevent issues with some platforms trying to link
51# to an existing liblwgeom.so in the PostgreSQL $libdir supplied by an
52# older version of PostGIS, rather than with the static liblwgeom.a
53# supplied with newer versions of PostGIS
54PG_CPPFLAGS += -I../liblwgeom -I../libpgcommon @CFLAGS@ @CPPFLAGS@ @PICFLAGS@
55SHLIB_LINK_F = ../libpgcommon/libpgcommon.a ../liblwgeom/.libs/liblwgeom.a @SHLIB_LINK@
56
57# Add SFCGAL Flags if defined
58ifeq (@SFCGAL@,sfcgal)
59PG_CPPFLAGS += @SFCGAL_CPPFLAGS@
60SHLIB_LINK_F += @SFCGAL_LDFLAGS@
61endif
62
63
64# Extra files to remove during 'make clean'
65EXTRA_CLEAN=$(SQL_OBJS) topology_upgrade.sql.in
66
67# PGXS information
68PG_CONFIG := @PG_CONFIG@
69PGXS := @PGXS@
70# NO_TEMP_INSTALL is a workaround for a 9.5dev bug. See:
71# http://www.postgresql.org/message-id/CAB7nPqTsR5o3g-fBi6jbsVdhfPiLFWQ_0cGU5=94Rv_8W3qvFA@mail.gmail.com
72NO_TEMP_INSTALL=yes
73include $(PGXS)
74
75# Set PERL _after_ the include of PGXS
76PERL=@PERL@
77
78# This is to workaround a bug in PGXS 8.4 win32 link line,
79# see http://trac.osgeo.org/postgis/ticket/1158#comment:57
80SHLIB_LINK := $(SHLIB_LINK_F) $(SHLIB_LINK)
81
82$(OBJS): ../liblwgeom/.libs/liblwgeom.a ../libpgcommon/libpgcommon.a ../postgis_config.h
83
84
85# If REGRESS=1 passed as a parameter, change the default install paths
86# so that no prefix is included. This allows us to relocate to a temporary
87# directory for regression testing.
88ifeq ($(REGRESS),1)
89        bindir=/bin
90        pkglibdir=/lib
91        datadir=/share
92        datamoduledir=contrib/postgis
93endif
94
95
96
97# Generate any .sql file from .sql.in files by running them through the SQL pre-processor
98%.sql: %.sql.in
99	$(SQLPP) $< | grep -v '^#' | \
100	$(PERL) -lpe "s'MODULE_PATHNAME'\$(MODULEPATH)'g" > $@
101
102#Generate upgrade script by stripping things that can't be reinstalled
103#e.g. don't bother with tables, types, triggers, and domains
104# TODO: use postgis_proc_upgrade.pl
105topology_upgrade.sql.in:  topology.sql
106	$(PERL) -0777 -ne 's/^(CREATE|ALTER) (CAST|OPERATOR|TYPE|TABLE|SCHEMA|DOMAIN|TRIGGER).*?;//msg;print;' $< > $@
107
108topology_upgrade.sql: topology_before_upgrade.sql topology_upgrade.sql.in topology_after_upgrade.sql
109	cat $^ > $@
110
111topology.sql: \
112	sql/sqlmm.sql.in \
113	sql/populate.sql.in \
114	sql/polygonize.sql.in \
115	sql/export/gml.sql.in \
116	sql/export/TopoJSON.sql.in \
117	sql/query/getnodebypoint.sql.in \
118	sql/query/getedgebypoint.sql.in \
119	sql/query/getfacebypoint.sql.in \
120	sql/query/GetRingEdges.sql.in \
121	sql/query/GetNodeEdges.sql.in \
122	sql/query/GetFaceContainingPoint.sql.in \
123	sql/manage/TopologySummary.sql.in \
124	sql/manage/CopyTopology.sql.in \
125	sql/manage/FindLayer.sql.in \
126	sql/manage/FindTopology.sql.in \
127	sql/manage/ManageHelper.sql.in \
128	sql/manage/ValidateTopology.sql.in \
129	sql/manage/ValidateTopologyRelation.sql.in \
130	sql/topoelement/topoelement_agg.sql.in \
131	sql/topogeometry/type.sql.in \
132	sql/topogeometry/totopogeom.sql.in \
133	sql/topogeometry/cleartopogeom.sql.in \
134	sql/topogeometry/topogeom_edit.sql.in \
135	sql/topogeometry/simplify.sql.in \
136	sql/predicates.sql.in \
137	../postgis/sqldefines.h \
138	../postgis_revision.h
139
140uninstall_topology.sql: topology.sql ../utils/create_undef.pl
141	$(PERL) ../utils/create_undef.pl $< $(POSTGIS_PGSQL_VERSION) > $@
142
143check-unit:
144
145check-regress: topology.sql
146	$(MAKE) -C test $@
147
148check: check-regress
149
150distclean: clean
151	rm -f Makefile test/Makefile
152