2009-10-15 08:07:12 +00:00
|
|
|
require 'formula'
|
2009-10-02 18:02:51 +00:00
|
|
|
|
2012-02-17 07:43:48 +00:00
|
|
|
def build_gui?
|
|
|
|
ARGV.include? '--with-gui'
|
|
|
|
end
|
|
|
|
|
2011-03-10 05:11:03 +00:00
|
|
|
class Postgis < Formula
|
2011-06-26 19:34:55 +00:00
|
|
|
url 'http://postgis.refractions.net/download/postgis-1.5.3.tar.gz'
|
2009-10-02 18:02:51 +00:00
|
|
|
homepage 'http://postgis.refractions.net/'
|
2011-06-26 19:34:55 +00:00
|
|
|
md5 '05a61df5e1b78bf51c9ce98bea5526fc'
|
2009-10-02 18:02:51 +00:00
|
|
|
|
2010-09-21 19:35:53 +00:00
|
|
|
head 'http://svn.osgeo.org/postgis/trunk/', :using => :svn
|
|
|
|
|
2012-02-17 06:41:37 +00:00
|
|
|
devel do
|
2012-04-03 20:17:35 +00:00
|
|
|
url 'http://postgis.org/download/postgis-2.0.0rc2.tar.gz'
|
|
|
|
md5 '2337db7420746aeaeb631c950bbaeb82'
|
|
|
|
version '2.0.0rc2'
|
2012-02-17 06:41:37 +00:00
|
|
|
end
|
|
|
|
|
2009-10-02 18:02:51 +00:00
|
|
|
depends_on 'postgresql'
|
|
|
|
depends_on 'proj'
|
|
|
|
depends_on 'geos'
|
|
|
|
|
2012-02-17 07:43:48 +00:00
|
|
|
depends_on 'gtk+' if build_gui?
|
|
|
|
|
2012-02-17 07:55:56 +00:00
|
|
|
# For GeoJSON and raster handling
|
2012-02-17 06:41:37 +00:00
|
|
|
if ARGV.build_head? or ARGV.build_devel?
|
2012-02-17 07:55:56 +00:00
|
|
|
depends_on 'gdal'
|
|
|
|
depends_on 'json-c'
|
2011-01-01 23:33:44 +00:00
|
|
|
end
|
|
|
|
|
2012-02-28 15:39:22 +00:00
|
|
|
if ARGV.build_head? and MacOS.xcode_version >= "4.3"
|
|
|
|
depends_on "automake" => :build
|
|
|
|
depends_on "libtool" => :build
|
|
|
|
end
|
|
|
|
|
2012-02-17 07:43:48 +00:00
|
|
|
def options
|
|
|
|
[
|
2012-02-25 17:38:41 +00:00
|
|
|
['--devel', 'Build unstable snapshots of PostGIS 2.0'],
|
2012-02-17 07:43:48 +00:00
|
|
|
['--with-gui', 'Build shp2pgsql-gui in addition to command line tools']
|
|
|
|
]
|
|
|
|
end
|
|
|
|
|
2012-02-17 07:55:56 +00:00
|
|
|
# PostGIS command line tools intentionally have unused symbols in
|
|
|
|
# them---these are callbacks for liblwgeom.
|
|
|
|
skip_clean :all
|
|
|
|
|
2009-10-02 18:02:51 +00:00
|
|
|
def install
|
2010-03-22 22:43:58 +00:00
|
|
|
ENV.deparallelize
|
2012-02-17 07:55:56 +00:00
|
|
|
postgresql = Formula.factory 'postgresql'
|
2011-01-01 23:33:44 +00:00
|
|
|
|
|
|
|
args = [
|
|
|
|
"--disable-dependency-tracking",
|
2012-02-29 21:59:01 +00:00
|
|
|
# Can't use --prefix, PostGIS disrespects it and flat-out refuses to
|
|
|
|
# accept it with the 2.0 beta.
|
2012-02-17 07:55:56 +00:00
|
|
|
"--with-projdir=#{HOMEBREW_PREFIX}",
|
|
|
|
# This is against Homebrew guidelines, but we have to do it as the
|
|
|
|
# PostGIS plugin libraries can only be properly inserted into Homebrew's
|
|
|
|
# Postgresql keg.
|
|
|
|
"--with-pgconfig=#{postgresql.bin}/pg_config"
|
2011-01-01 23:33:44 +00:00
|
|
|
]
|
2012-02-17 07:43:48 +00:00
|
|
|
args << '--with-gui' if build_gui?
|
2011-01-01 23:33:44 +00:00
|
|
|
|
2012-02-17 06:41:37 +00:00
|
|
|
if ARGV.build_head? or ARGV.build_devel?
|
2012-02-17 07:55:56 +00:00
|
|
|
jsonc = Formula.factory 'json-c'
|
|
|
|
args << "--with-jsondir=#{jsonc.prefix}"
|
|
|
|
# Unfortunately, NLS support causes all kinds of headaches because
|
|
|
|
# PostGIS gets all of it's compiler flags from the PGXS makefiles. This
|
|
|
|
# makes it nigh impossible to tell the buildsystem where our keg-only
|
|
|
|
# gettext installations are.
|
|
|
|
args << '--disable-nls'
|
2011-01-01 23:33:44 +00:00
|
|
|
end
|
|
|
|
|
2012-02-17 06:41:37 +00:00
|
|
|
system './autogen.sh' if ARGV.build_head?
|
2012-02-17 07:55:56 +00:00
|
|
|
system './configure', *args
|
|
|
|
system 'make'
|
|
|
|
|
|
|
|
# __DON'T RUN MAKE INSTALL!__
|
|
|
|
#
|
|
|
|
# PostGIS includes the PGXS makefiles and so will install __everything__
|
|
|
|
# into the Postgres keg instead of the PostGIS keg. Unfortunately, some
|
|
|
|
# things have to be inside the Postgres keg in order to be function. So, we
|
|
|
|
# install the bare minimum of stuff and then manually move everything else
|
|
|
|
# to the prefix.
|
2009-10-02 22:22:45 +00:00
|
|
|
|
2012-02-17 07:55:56 +00:00
|
|
|
# Install PostGIS plugin libraries into the Postgres keg so that they can
|
|
|
|
# be loaded and so PostGIS databases will continue to function even if
|
|
|
|
# PostGIS is removed.
|
|
|
|
postgresql.lib.install Dir['postgis/postgis*.so']
|
|
|
|
|
|
|
|
# Stand-alone SQL files will be installed the share folder
|
2011-09-11 13:28:53 +00:00
|
|
|
postgis_sql = share + 'postgis'
|
2011-02-11 13:39:35 +00:00
|
|
|
|
2012-02-17 07:55:56 +00:00
|
|
|
# Install version-specific SQL scripts and tools first. Some of the
|
|
|
|
# installation routines require command line tools to still be present
|
|
|
|
# inside the build prefix.
|
2012-02-17 06:41:37 +00:00
|
|
|
if ARGV.build_head? or ARGV.build_devel?
|
2012-02-17 07:55:56 +00:00
|
|
|
# Install the liblwgeom library
|
2012-02-29 21:59:01 +00:00
|
|
|
lib.install Dir['liblwgeom/.libs/*.dylib', 'liblwgeom/.libs/*.a']
|
|
|
|
include.install 'liblwgeom/liblwgeom.h'
|
2012-02-17 07:55:56 +00:00
|
|
|
|
|
|
|
# Install raster plugin to Postgres keg
|
|
|
|
postgresql.lib.install Dir['raster/rt_pg/rtpostgis*.so']
|
|
|
|
|
|
|
|
# Install extension scripts to the Postgres keg.
|
|
|
|
# `CREATE EXTENSION postgis;` won't work if these are located elsewhere.
|
|
|
|
system 'make install -C extensions'
|
|
|
|
|
|
|
|
bin.install %w[
|
|
|
|
loader/.libs/pgsql2shp
|
|
|
|
loader/.libs/shp2pgsql
|
|
|
|
raster/loader/.libs/raster2pgsql
|
|
|
|
]
|
2012-02-17 07:43:48 +00:00
|
|
|
bin.install 'loader/.libs/shp2pgsql-gui' if build_gui?
|
2012-02-17 07:55:56 +00:00
|
|
|
|
2011-09-11 13:28:53 +00:00
|
|
|
# Install PostGIS 2.0 SQL scripts
|
|
|
|
postgis_sql.install %w[
|
2012-02-17 07:55:56 +00:00
|
|
|
postgis/legacy.sql
|
2012-03-26 20:05:15 +00:00
|
|
|
postgis/legacy_minimal.sql
|
2012-02-17 07:55:56 +00:00
|
|
|
postgis/uninstall_legacy.sql
|
2011-09-11 13:28:53 +00:00
|
|
|
postgis/postgis_upgrade_20_minor.sql
|
|
|
|
]
|
2012-02-17 07:55:56 +00:00
|
|
|
|
|
|
|
postgis_sql.install %w[
|
|
|
|
raster/rt_pg/rtpostgis.sql
|
|
|
|
raster/rt_pg/rtpostgis_drop.sql
|
|
|
|
raster/rt_pg/rtpostgis_upgrade_20_minor.sql
|
|
|
|
raster/rt_pg/rtpostgis_upgrade.sql
|
|
|
|
raster/rt_pg/rtpostgis_upgrade_cleanup.sql
|
|
|
|
raster/rt_pg/uninstall_rtpostgis.sql
|
|
|
|
]
|
|
|
|
|
|
|
|
postgis_sql.install %w[
|
|
|
|
topology/topology.sql
|
|
|
|
topology/topology_upgrade_20_minor.sql
|
|
|
|
topology/uninstall_topology.sql
|
|
|
|
]
|
2011-09-11 13:28:53 +00:00
|
|
|
else
|
2012-02-17 07:55:56 +00:00
|
|
|
bin.install %w[
|
|
|
|
loader/pgsql2shp
|
|
|
|
loader/shp2pgsql
|
|
|
|
utils/new_postgis_restore.pl
|
|
|
|
]
|
2012-02-17 07:43:48 +00:00
|
|
|
bin.install 'loader/shp2pgsql-gui' if build_gui?
|
2012-02-17 07:55:56 +00:00
|
|
|
|
2011-09-11 13:28:53 +00:00
|
|
|
# Install PostGIS 1.x upgrade scripts
|
|
|
|
postgis_sql.install %w[
|
|
|
|
postgis/postgis_upgrade_13_to_15.sql
|
|
|
|
postgis/postgis_upgrade_14_to_15.sql
|
|
|
|
postgis/postgis_upgrade_15_minor.sql
|
|
|
|
]
|
2011-02-11 13:39:35 +00:00
|
|
|
end
|
|
|
|
|
2012-02-17 07:55:56 +00:00
|
|
|
# Common tools
|
2011-09-11 13:28:53 +00:00
|
|
|
bin.install %w[
|
2012-02-17 07:55:56 +00:00
|
|
|
utils/create_undef.pl
|
|
|
|
utils/postgis_proc_upgrade.pl
|
|
|
|
utils/postgis_restore.pl
|
|
|
|
utils/profile_intersects.pl
|
|
|
|
utils/test_estimation.pl
|
|
|
|
utils/test_geography_estimation.pl
|
|
|
|
utils/test_geography_joinestimation.pl
|
|
|
|
utils/test_joinestimation.pl
|
|
|
|
]
|
|
|
|
|
|
|
|
# Common SQL scripts
|
|
|
|
postgis_sql.install %w[
|
|
|
|
spatial_ref_sys.sql
|
|
|
|
postgis/postgis.sql
|
|
|
|
postgis/uninstall_postgis.sql
|
2011-09-11 13:28:53 +00:00
|
|
|
]
|
2010-05-07 16:31:01 +00:00
|
|
|
end
|
2009-10-02 22:22:45 +00:00
|
|
|
|
2012-02-17 07:55:56 +00:00
|
|
|
def caveats;
|
|
|
|
postgresql = Formula.factory 'postgresql'
|
|
|
|
|
|
|
|
s = <<-EOS.undent
|
|
|
|
To create a spatially-enabled database, see the documentation:
|
|
|
|
http://postgis.refractions.net/documentation/manual-1.5/ch02.html#id2630392
|
|
|
|
and to upgrade your existing spatial databases, see here:
|
|
|
|
http://postgis.refractions.net/documentation/manual-1.5/ch02.html#upgrading
|
|
|
|
|
|
|
|
PostGIS SQL scripts installed to:
|
|
|
|
#{HOMEBREW_PREFIX}/share/postgis
|
|
|
|
PostGIS plugin libraries installed to:
|
|
|
|
#{postgresql.lib}
|
2010-05-07 16:31:01 +00:00
|
|
|
EOS
|
2012-02-17 07:55:56 +00:00
|
|
|
|
2012-02-17 06:41:37 +00:00
|
|
|
if ARGV.build_head? or ARGV.build_devel?
|
2012-02-17 07:55:56 +00:00
|
|
|
s += <<-EOS.undent
|
|
|
|
PostGIS extension modules installed to:
|
|
|
|
#{postgresql.share}/postgres/extension
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
2012-02-29 21:59:01 +00:00
|
|
|
return s
|
2009-10-02 18:02:51 +00:00
|
|
|
end
|
|
|
|
end
|