-Third-party libraries are stored here. Currently, Shapely is the only
-one we're using which isn't available through package managers.
+Third-party libraries are stored here. Currently, we use Shapely and
+lp_solve (along with its Python bindings). To install them, simply run
+'make' within this directory. You can also run 'make lib' in the
+top-level directory.
-Shapely should be downloaded and extracted:
-
- wget http://pypi.python.org/packages/source/S/Shapely/Shapely-1.0.14.tar.gz
- tar -xvzf Shapely-1.0.14.tar.gz
- mv Shapely-1.0.14 Shapely
- rm Shapely-1.0.14.tar.gz
-
-This will probably be handled by the makefile.
+You will need GEOS installed for Shapely to work properly.
--- /dev/null
+SHAPELY_URL=http://pypi.python.org/packages/source/S/Shapely/Shapely-1.0.14.tar.gz
+LP_SOLVE_LIB_URL=http://downloads.sourceforge.net/project/lpsolve/lpsolve/5.5.0.15/lp_solve_5.5.0.15_source.tar.gz
+LP_SOLVE_PYTHON_URL=http://downloads.sourceforge.net/project/lpsolve/lpsolve/5.5.0.15/lp_solve_5.5.0.15_Python_source.tar.gz
+
+
+all: lp_solve shapely
+
+
+clean:
+ rm -rf lp_solve
+ rm -rf lp_solve_5.5
+ rm -rf Shapely
+ rm -f *.tar.gz
+
+
+shapely: ./Shapely/setup.py
+
+# We just need to check for any Shapely file here. There
+# is nothing special about setup.py.
+./Shapely/setup.py:
+ if [ ! -d Shapely ]; then \
+ wget -O shapely.tar.gz $(SHAPELY_URL); \
+ tar -xvzf shapely.tar.gz; \
+ rm shapely.tar.gz; \
+ mv Shapely* Shapely; \
+ fi;
+
+
+lp_solve: ./lp_solve/liblpsolve55.so ./lp_solve/lpsolve55.so
+
+
+# Patch Makefile.Linux so that it doesn't pass the -l
+# flag to flex. Double dollar signs are required to get
+# a single '$' within a makefile.
+LFLAGS_PATCH = sed -i 's/^LFLAGS = -L -l$$/LFLAGS = -L/'
+./lp_solve/liblpsolve55.so:
+ make lp_solve_lib_src
+ if [ -f lp_solve_5.5/Makefile.Linux ]; then \
+ $(LFLAGS_PATCH) lp_solve_5.5/Makefile.Linux; \
+ mv lp_solve_5.5/Makefile.Linux lp_solve_5.5/Makefile; \
+ fi;
+ make -C lp_solve_5.5
+ mkdir -p lp_solve
+ mv lp_solve_5.5/lpsolve55/liblpsolve55.so ./lp_solve
+
+
+./lp_solve/lpsolve55.so:
+ make ./lp_solve/liblpsolve55.so lp_solve_python_src
+ cd lp_solve_5.5/extra/Python; \
+ sed -i 's~lpsolve55/bin/\(ux\|win\)32~../lp_solve~' setup.py; \
+ python setup.py build; \
+ mv build/lib.linux-*/* ../../../lp_solve/;
+
+
+lp_solve_lib_src:
+ if [ ! -d lp_solve_5.5 ]; then \
+ wget -O lp_solve.tar.gz $(LP_SOLVE_LIB_URL); \
+ tar -xvzf lp_solve.tar.gz; \
+ rm lp_solve.tar.gz; \
+ fi;
+
+
+lp_solve_python_src: lp_solve_lib_src
+ if [ ! -d lp_solve_5.5/extra ]; then \
+ wget -O lp_solve_python.tar.gz $(LP_SOLVE_PYTHON_URL); \
+ tar -xvzf lp_solve_python.tar.gz; \
+ rm lp_solve_python.tar.gz; \
+ fi;
DB_NAME=census
DB_USER=postgres
TIGER_SRID=4269
-SHAPELY_URL=http://pypi.python.org/packages/source/S/Shapely/Shapely-1.0.14.tar.gz
# Dark magic. We set these makefile variables to be the result of the
# Download or check out any third-party libraries.
lib:
- if [ ! -d lib/Shapely ]; then \
- wget -O shapely.tar.gz $(SHAPELY_URL); \
- tar -xvzf shapely.tar.gz -C lib/ ; \
- rm shapely.tar.gz; \
- mv lib/Shapely* lib/Shapely; \
- fi;
+ make -C lib/
# Remove byte-compiled python code.