| 1 | ############################################################################# |
|---|
| 2 | # $Id$ |
|---|
| 3 | # |
|---|
| 4 | # Copyright (c) 2009-2011 Sandro Santilli <strk@keybit.net> |
|---|
| 5 | # |
|---|
| 6 | # This is free software; you can redistribute and/or modify it under |
|---|
| 7 | # the terms of the GNU General Public Licence. See the COPYING file. |
|---|
| 8 | # |
|---|
| 9 | ############################################################################# |
|---|
| 10 | |
|---|
| 11 | POSTGIS_PGSQL_VERSION=@POSTGIS_PGSQL_VERSION@ |
|---|
| 12 | |
|---|
| 13 | MODULE_big=rtpostgis-@POSTGIS_MAJOR_VERSION@.@POSTGIS_MINOR_VERSION@ |
|---|
| 14 | MODULEDIR=contrib/postgis-@POSTGIS_MAJOR_VERSION@.@POSTGIS_MINOR_VERSION@ |
|---|
| 15 | |
|---|
| 16 | # Files to be copied to the contrib/ directory |
|---|
| 17 | DATA_built=rtpostgis.sql rtpostgis_upgrade_20_minor.sql uninstall_rtpostgis.sql rtpostgis_legacy.sql |
|---|
| 18 | DATA= |
|---|
| 19 | |
|---|
| 20 | # SQL preprocessor |
|---|
| 21 | SQLPP = @SQLPP@ |
|---|
| 22 | |
|---|
| 23 | # SQL objects (files requiring pre-processing) |
|---|
| 24 | SQL_OBJS=rtpostgis.sql.in rtpostgis_drop.sql.in rtpostgis_upgrade_cleanup.sql.in rtpostgis_legacy.sql.in |
|---|
| 25 | |
|---|
| 26 | # Objects to build using PGXS |
|---|
| 27 | OBJS=rt_pg.o |
|---|
| 28 | |
|---|
| 29 | # Libraries to link into the module (proj, geos) |
|---|
| 30 | # |
|---|
| 31 | # Note: we specify liblwgeom.a directly in SHLIB_LINK rather than using |
|---|
| 32 | # -L... -l options to prevent issues with some platforms trying to link |
|---|
| 33 | # to an existing liblwgeom.so in the PostgreSQL $libdir supplied by an |
|---|
| 34 | # older version of PostGIS, rather than with the static liblwgeom.a |
|---|
| 35 | # supplied with newer versions of PostGIS |
|---|
| 36 | # |
|---|
| 37 | LIBLWGEOM_LDFLAGS=../../liblwgeom/.libs/liblwgeom.a |
|---|
| 38 | LIBLWGEOM_CFLAGS="-I../../liblwgeom" |
|---|
| 39 | LIBPGCOMMON_CFLAGS="-I../../libpgcommon" |
|---|
| 40 | LIBPGCOMMON_LDFLAGS=../../libpgcommon/libpgcommon.a |
|---|
| 41 | LIBGDAL_CFLAGS=@LIBGDAL_CFLAGS@ |
|---|
| 42 | LIBGDAL_LDFLAGS=@LIBGDAL_LDFLAGS@ |
|---|
| 43 | LIBPROJ_CFLAGS=@PROJ_CPPFLAGS@ |
|---|
| 44 | |
|---|
| 45 | PG_CPPFLAGS+=@CPPFLAGS@ $(LIBLWGEOM_CFLAGS) $(LIBGDAL_CFLAGS) $(LIBPGCOMMON_CFLAGS) $(LIBPROJ_CFLAGS) -I../rt_core |
|---|
| 46 | SHLIB_LINK_F = ../rt_core/librtcore.a $(LIBLWGEOM_LDFLAGS) $(LIBPGCOMMON_LDFLAGS) $(LIBGDAL_LDFLAGS) @SHLIB_LINK@ |
|---|
| 47 | |
|---|
| 48 | # Extra files to remove during 'make clean' |
|---|
| 49 | EXTRA_CLEAN=$(SQL_OBJS) $(DATA_built) rtpostgis_upgrade.sql |
|---|
| 50 | |
|---|
| 51 | # PGXS information |
|---|
| 52 | PG_CONFIG = @PGCONFIG@ |
|---|
| 53 | PGXS := @PGXS@ |
|---|
| 54 | include $(PGXS) |
|---|
| 55 | |
|---|
| 56 | # Set PERL _after_ the include of PGXS |
|---|
| 57 | PERL=@PERL@ |
|---|
| 58 | |
|---|
| 59 | # This is to workaround a bug in PGXS 8.4 win32 link line, |
|---|
| 60 | # see http://trac.osgeo.org/postgis/ticket/1158#comment:57 |
|---|
| 61 | SHLIB_LINK := $(SHLIB_LINK_F) $(SHLIB_LINK) |
|---|
| 62 | |
|---|
| 63 | # PGXS override feature. The ability to allow PostGIS to install itself |
|---|
| 64 | # in a versioned directory is only available in PostgreSQL >= 8.5. To |
|---|
| 65 | # do this by default on older PostgreSQL versions, we need to override |
|---|
| 66 | # the existing PGXS targets. |
|---|
| 67 | # |
|---|
| 68 | # Once PostgreSQL 8.5 becomes the minimum supported version, this entire |
|---|
| 69 | # section and its associated Makefile.pgxs should be removed. |
|---|
| 70 | PGXSOVERRIDE = @PGXSOVERRIDE@ |
|---|
| 71 | ifeq ($(PGXSOVERRIDE),1) |
|---|
| 72 | include Makefile.pgxs |
|---|
| 73 | endif |
|---|
| 74 | |
|---|
| 75 | # If REGRESS=1 passed as a parameter, change the default install paths |
|---|
| 76 | # so that no prefix is included. This allows us to relocate to a temporary |
|---|
| 77 | # directory for regression testing. |
|---|
| 78 | ifeq ($(REGRESS),1) |
|---|
| 79 | bindir=/bin |
|---|
| 80 | pkglibdir=/lib |
|---|
| 81 | datadir=/share |
|---|
| 82 | datamoduledir=contrib/postgis |
|---|
| 83 | endif |
|---|
| 84 | |
|---|
| 85 | # Borrow the $libdir substitution from PGXS but customise by adding the version number |
|---|
| 86 | %.sql: %.sql.in |
|---|
| 87 | sed 's,MODULE_PATHNAME,$$libdir/rtpostgis-@POSTGIS_MAJOR_VERSION@.@POSTGIS_MINOR_VERSION@,g' $< >$@ |
|---|
| 88 | |
|---|
| 89 | |
|---|
| 90 | # Objects dependencies |
|---|
| 91 | $(OBJS): ../../liblwgeom/.libs/liblwgeom.a ../../libpgcommon/libpgcommon.a ../../postgis_config.h ../../postgis_svn_revision.h |
|---|
| 92 | |
|---|
| 93 | # Generate any .sql.in files from .sql.in.c files by running them through the SQL pre-processor |
|---|
| 94 | $(SQL_OBJS): %.in: %.in.c |
|---|
| 95 | $(SQLPP) -I../../postgis/ -I../../ $< | grep -v '^#' > $@ |
|---|
| 96 | |
|---|
| 97 | # SQL objects deps here |
|---|
| 98 | $(SQL_OBJS): ../../postgis/sqldefines.h ../../postgis_svn_revision.h |
|---|
| 99 | |
|---|
| 100 | #remove all create object types since these can't be done cleanly in an upgrade |
|---|
| 101 | rtpostgis_upgrade.sql: rtpostgis.sql |
|---|
| 102 | $(PERL) -0777 -ne 's/^(CREATE|ALTER) (CAST|OPERATOR|TYPE|TABLE|SCHEMA|DOMAIN|TRIGGER).*?;//msg;print;' $< > $@ |
|---|
| 103 | |
|---|
| 104 | rtpostgis_upgrade_20_minor.sql: rtpostgis_drop.sql rtpostgis_upgrade_cleanup.sql rtpostgis_upgrade.sql |
|---|
| 105 | cat $^ > $@ |
|---|
| 106 | |
|---|
| 107 | uninstall_rtpostgis.sql: rtpostgis.sql ../../utils/create_undef.pl |
|---|
| 108 | $(PERL) ../../utils/create_undef.pl $< $(POSTGIS_PGSQL_VERSION) > $@ |
|---|
| 109 | |
|---|
| 110 | distclean: clean |
|---|
| 111 | rm -f Makefile |
|---|