From f38573f5ab9115c2b4f315cfb7cc2be14e025f54 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Thu, 12 Nov 2009 21:47:47 -0500 Subject: [PATCH] Modified the makefile to use the find_file_paths script rather than guessing at some important file locations. --- makefile | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/makefile b/makefile index 649eb59..7d765c6 100644 --- a/makefile +++ b/makefile @@ -4,12 +4,12 @@ TIGER_SRID=4269 SHAPELY_URL=http://pypi.python.org/packages/source/S/Shapely/Shapely-1.0.14.tar.gz -# Starting with PostGIS 1.4.0, these paths are calculated at install -# time using the pg_config utility. Rather than try to guess where -# PostGIS will wind up installed, we can just check the output of -# pg_config ourselves. -PG_BINDIR=`pg_config --bindir` -PG_SHAREDIR=`pg_config --sharedir` +# Dark magic. We set these makefile variables to be the result of the +# 'shell' function. The shell function, in turn, executes a Python +# script which determines the locations of these files. +SHP2PGSQL := $(shell bin/find_file_paths --root /usr --single shp2pgsql) +POSTGIS_SQL := $(shell bin/find_file_paths --root /usr lwpostgis.sql postgis.sql) +SPATIAL_REF_SYS_SQL := $(shell bin/find_file_paths --root /usr spatial_ref_sys.sql) # Necessary to run test/data without prerequisites. # @@ -58,11 +58,11 @@ db: data newdb tiger_blocks_table tiger_lines_table sf1_blocks_table # The table already exists, so we can append to it, and we don't have # to create the GiST index. for state in data/census2000/*; do \ - $(PG_BINDIR)/shp2pgsql \ + $(SHP2PGSQL) \ -a \ -s $(TIGER_SRID) \ -D \ - $$state/blocks/*.shp \ + $$state/blocks/*.shp \ tiger_blocks \ | psql -U $(DB_USER) -d $(DB_NAME); \ done; @@ -74,7 +74,7 @@ db: data newdb tiger_blocks_table tiger_lines_table sf1_blocks_table for state in data/census2000/*; do \ for shapefile in $$state/lines/*.shp; do \ echo "Importing $$shapefile."; \ - $(PG_BINDIR)/shp2pgsql \ + $(SHP2PGSQL) \ -a \ -s $(TIGER_SRID) \ $$shapefile \ @@ -112,14 +112,14 @@ newdb: createdb -U $(DB_USER) $(DB_NAME) createlang -U $(DB_USER) plpgsql $(DB_NAME) - psql -d $(DB_NAME) \ - -U $(DB_USER) \ - -f $(PG_SHAREDIR)/contrib/postgis.sql \ + psql -d $(DB_NAME) \ + -U $(DB_USER) \ + -f $(POSTGIS_SQL) \ > /dev/null - psql -d $(DB_NAME) \ - -U $(DB_USER) \ - -f $(PG_SHAREDIR)/contrib/spatial_ref_sys.sql \ + psql -d $(DB_NAME) \ + -U $(DB_USER) \ + -f $(SPATIAL_REF_SYS_SQL) \ > /dev/null @@ -135,11 +135,11 @@ sf1_blocks_table: # table already exist makes importing via shp2pgsql much easier. # Any blocks file will work as an argument. tiger_blocks_table: - $(PG_BINDIR)/shp2pgsql \ + $(SHP2PGSQL) \ -p \ -I \ -s $(TIGER_SRID) \ - data/census2000/maryland/blocks/tl_2009_24_tabblock00.shp \ + data/census2000/maryland/blocks/tl_2009_24_tabblock00.shp \ tiger_blocks \ | psql -U postgres -d $(DB_NAME) \ > /dev/null @@ -148,7 +148,7 @@ tiger_blocks_table: # Prepare the tiger_lines table, and create the GiST index on its # geometry column. Any lines shapefile will do here. tiger_lines_table: - $(PG_BINDIR)/shp2pgsql \ + $(SHP2PGSQL) \ -p \ -I \ -s $(TIGER_SRID) \ -- 2.44.2