Last active
January 2, 2016 15:09
-
-
Save thorrr/8321862 to your computer and use it in GitHub Desktop.
Makefile for building quantlib + python extensions.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.PHONY: all downloads clean clean_downloads | |
### URLS ######## | |
boost_url := 'http://downloads.sourceforge.net/project/boost/boost/1.53.0/boost_1_53_0.tar.bz2' | |
quantlib_url := 'http://sourceforge.net/projects/quantlib/files/QuantLib/1.2.1/QuantLib-1.2.1.tar.gz' | |
quantlib_swig_url := 'http://sourceforge.net/projects/quantlib/files/QuantLib/1.2/other%20languages/QuantLib-SWIG-1.2.tar.gz' | |
################# | |
#### subdirectory names ##### | |
ql_swig_install_dir := quantlib-swig-install | |
boost_dir := boost_1_53_0 | |
ql_install_dir = quantlib-install | |
artifacts_dir := artifacts | |
########################### | |
all: $(ql_swig_install_dir) $(ql_install_dir) | |
clean_downloads: | |
rm $(download_files) | |
clean: | |
rm -rf ql | |
repl: $(ql_swig_install_dir) $(ql_install_dir) | |
LD_LIBRARY_PATH=$(shell pwd)/$(ql_install_dir)/lib:$$LD_LIBRARY_PATH \ | |
PYTHONPATH=$(shell pwd)/$(ql_swig_install_dir)/lib/python2.7/site-packages:$$PYTHONPATH \ | |
python -i | |
boost_archive := $(artifacts_dir)/boost.bz2 | |
$(boost_archive): | |
wget -O $@ $(boost_url) | |
quantlib_archive := $(artifacts_dir)/quantlib.tgz | |
$(quantlib_archive): | |
wget -O $@ $(quantlib_url) | |
quantlib_swig_archive := $(artifacts_dir)/quantlib-swig.tgz | |
$(quantlib_swig_archive): | |
wget -O $@ $(quantlib_swig_url) | |
download_files := $(boost_archive) $(quantlib_archive) $(quantlib_swig_archive) | |
$(download_files): | $(artifacts_dir) #note order-only prereq here | |
$(artifacts_dir): | |
mkdir -p $@ | |
downloads: $(download_files) | |
$(boost_dir): $(boost_archive) | |
tar -xjf ./$< &&\ | |
cd ./$@ &&\ | |
./bootstrap.sh && ./b2 | |
ql: $(quantlib_archive) | |
mkdir -p /tmp/ql_tmp &&\ | |
tar -xf $< -C /tmp/ql_tmp &&\ | |
mv /tmp/ql_tmp/* ./$@ | |
$(ql_install_dir): | ql $(boost_dir) | |
cd ./ql/ &&\ | |
./configure --prefix="$(shell pwd)/$@" \ | |
-with-boost-include="$(shell pwd)/$(boost_dir)" \ | |
-with-boost-lib="$(shell pwd)/$(boost_dir)/libs" &&\ | |
$(MAKE) && $(MAKE) install | |
ql-swig: $(quantlib_swig_archive) | |
d=/tmp/ql_swig_tmp &&\ | |
mkdir -p $$d &&\ | |
tar -xf $< -C $$d &&\ | |
mv $$d/* ./$@ | |
$(ql_swig_install_dir): | ql-swig $(ql_install_dir) | |
ql_swig_install_dir_full=`pwd`/$(ql_swig_install_dir) &&\ | |
ql_install_dir_full=`pwd`/$(ql_install_dir) &&\ | |
PATH=$$ql_install_dir_full/bin:$$PATH &&\ | |
cd ./ql-swig &&\ | |
./configure --prefix="$$ql_swig_install_dir_full" &&\ | |
$(MAKE) -C Python && cd ./Python &&\ | |
LD_LIBRARY_PATH="$$ql_install_dir_full/lib:$$LD_LIBRARY_PATH" \ | |
python setup.py build test install --prefix="$$ql_swig_install_dir_full" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment