]> gitweb.michael.orlitzky.com - dead/census-tools.git/commitdiff
Modified the makefile to use the find_file_paths script rather than guessing at some...
authorMichael Orlitzky <michael@orlitzky.com>
Fri, 13 Nov 2009 02:47:47 +0000 (21:47 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Fri, 13 Nov 2009 02:47:47 +0000 (21:47 -0500)
makefile

index 649eb5929a555162e43f9fa8ebb0f8965a21f45c..7d765c6cdaab32bf2a280020097a7455e5e91183 100644 (file)
--- 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
 
 
 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.
 #
 
 # 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                  \
 # 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                                  \
                        -a                                  \
                        -s $(TIGER_SRID)                    \
                        -D                                  \
-                       $$state/blocks/*.shp                 \
+                       $$state/blocks/*.shp                \
                        tiger_blocks                        \
                        | psql -U $(DB_USER) -d $(DB_NAME); \
        done;
                        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.";              \
        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                         \
                                -a                                  \
                                -s $(TIGER_SRID)                    \
                                $$shapefile                         \
@@ -112,14 +112,14 @@ newdb:
        createdb -U $(DB_USER) $(DB_NAME)
        createlang -U $(DB_USER) plpgsql $(DB_NAME)
 
        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
 
              > /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
 
 
             > /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:
 # 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)                                          \
                -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
                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:
 # 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)                                       \
                -p                                                     \
                -I                                                     \
                -s $(TIGER_SRID)                                       \