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