From 1717bafe07c9f51e0fae441db35b2d03d893cd3e Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Mon, 5 Apr 2010 14:33:36 -0400 Subject: [PATCH] Add a new makefile for the third-party libraries. Change the 'lib' target in the main makefile to recurse into the 'lib' directory. Add 'lp_solve' and 'lp_solve_55' directories to the library .gitignore. Update the readme with new instructions. --- lib/.gitignore | 2 ++ lib/README | 15 ++++------- lib/makefile | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++ makefile | 8 +----- 4 files changed, 76 insertions(+), 17 deletions(-) create mode 100644 lib/makefile diff --git a/lib/.gitignore b/lib/.gitignore index 7397096..a58bf88 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -1 +1,3 @@ +lp_solve +lp_solve_55 Shapely diff --git a/lib/README b/lib/README index 61bb6f0..699a26a 100644 --- a/lib/README +++ b/lib/README @@ -1,11 +1,6 @@ -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. diff --git a/lib/makefile b/lib/makefile new file mode 100644 index 0000000..4115134 --- /dev/null +++ b/lib/makefile @@ -0,0 +1,68 @@ +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; diff --git a/makefile b/makefile index 7472973..2631b6b 100644 --- a/makefile +++ b/makefile @@ -1,7 +1,6 @@ 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 @@ -27,12 +26,7 @@ test: # 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. -- 2.44.2