Skip to content
Browse files

Simplify make.osx, add targets. Closes pull request #30.

Slightly modified version of a71414d from the maintenance branch.
  • Loading branch information...
1 parent 112aeb5 commit 861da23e83e01c5a15f240419cee68006198bc55 @jkseppan jkseppan committed with efiring Jun 16, 2011
Showing with 97 additions and 73 deletions.
  1. +21 −4 README.osx
  2. +76 −69 make.osx
View
25 README.osx
@@ -1,13 +1,30 @@
-Build mpl on OSX has proven to be a nightmare because of all the
+Building mpl on OSX has proven to be a nightmare because of all the
different types of zlib, png and freetype that may be on your system.
The recommended and supported way to build is to use the make.osx file
in this directory. This script requires you to set a PREFIX
-environment variable where you want to the install to go. It will
-fetch the dependencies from a remove server and install them into your
+environment variable where you want the install to go. It will
+fetch the dependencies from a remote server and install them into your
PREFIX dir, and then build mpl against them. It should ignore any
lib, png or freetype on your system
Example usage::
- PREFIX=/Users/jdhunter/dev make -f make.osx fetch deps mpl_install
+ make -f make.osx PREFIX=/Users/jdhunter/dev PYVERSION=2.6 \
+ fetch deps mpl_install_std
+Variables:
+ PREFIX (required): where to install the dependencies
+ PYVERSION (optional): which python version to use
+ (default=python, e.g. PYVERSION=2.6 uses python2.6)
+
+Targets:
+
+ clean: remove compiled files
+ fetch: download dependencies
+ deps: build all dependencies (zlib, png, freetype)
+ mpl_build: compile matplotlib
+ mpl_install: install matplotlib in $PREFIX/lib/pythonX.Y/site-packages
+ mpl_install_std: install matplotlib in standard site-packages directory
+ mpl_install_egg: install matplotlib as an egg
+ mpl_install_develop: set up egg link to working directory (for developers)
+ binaries: create the dmg file for distribution
View
145 make.osx
@@ -1,109 +1,116 @@
+# -*- makefile -*-
# build mpl into a local install dir with
-# PREFIX=/Users/jdhunter/dev make -f make.osx fetch deps mpl_install
-MPLVERSION=1.0rc1
+# make -f make.osx PREFIX=/Users/jdhunter/dev PYVERSION=2.6 fetch deps mpl_install
+# (see README.osx for more details)
+
+MPLVERSION=1.1.0
PYVERSION=2.6
PYTHON=python${PYVERSION}
-ZLIBVERSION=1.2.3
-PNGVERSION=1.2.39
-FREETYPEVERSION=2.3.11
MACOSX_DEPLOYMENT_TARGET=10.6
OSX_SDK_VER=10.6
-ARCH_FLAGS="-arch i386-arch x86_64"
+ARCH_FLAGS=-arch i386 -arch x86_64
+
+# Dependency versions and URLs
+#
+# Adjusting these version numbers should be enough most of the time,
+# but the download URLs are subject to change.
+
+ZLIBVERSION=1.2.5
+PNGVERSION=1.5.1
+FREETYPEVERSION=2.4.4
+
+ZLIBFILE=zlib-${ZLIBVERSION}.tar.gz
+ZLIBDIR=$(basename $(basename ${ZLIBFILE}))
+ZLIBURL=http://sourceforge.net/projects/libpng/files/zlib/${ZLIBVERSION}/${ZLIBFILE}/download
+
+PNGFILE=libpng-${PNGVERSION}.tar.gz
+PNGDIR=$(basename $(basename ${PNGFILE}))
+PNGURL=http://sourceforge.net/projects/libpng/files/libpng15/${PNGVERSION}/${PNGFILE}/download
+
+FREETYPEFILE=freetype-${FREETYPEVERSION}.tar.bz2
+FREETYPEDIR=$(basename $(basename ${FREETYPEFILE}))
+FREETYPEURL=http://download.savannah.gnu.org/releases/freetype/${FREETYPEFILE}
## You shouldn't need to configure past this point
-#PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig"
-#CFLAGS="${ARCH_FLAGS} -I${PREFIX}/include -I${PREFIX}/include/freetype2 -isysroot /Developer/SDKs/MacOSX${OSX_SDK_VER}.sdk"
-#LDFLAGS="${ARCH_FLAGS} -L${PREFIX}/lib -syslibroot,/Developer/SDKs/MacOSX${OSX_SDK_VER}.sdk"
+export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig
+export CFLAGS=${ARCH_FLAGS} -I${PREFIX}/include -I${PREFIX}/include/freetype2 -isysroot /Developer/SDKs/MacOSX${OSX_SDK_VER}.sdk
+export LDFLAGS=${ARCH_FLAGS} -L${PREFIX}/lib -syslibroot,/Developer/SDKs/MacOSX${OSX_SDK_VER}.sdk
+export MACOSX_DEPLOYMENT_TARGET
-PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig"
-CFLAGS="-arch i386 -arch x86_64 -I${PREFIX}/include -I${PREFIX}/include/freetype2 -isysroot /Developer/SDKs/MacOSX${OSX_SDK_VER}.sdk"
-LDFLAGS="-arch i386 -arch x86_64 -L${PREFIX}/lib -syslibroot,/Developer/SDKs/MacOSX${OSX_SDK_VER}.sdk"
-FFLAGS="-arch i386 -arch x86_64"
+help:
+ @echo "Interesting targets: clean, fetch, deps, mpl_build, mpl_install_std"
+ @echo "See README.osx for details"
check-prefix:
@if [ ! -d "$(PREFIX)" ]; then echo Set PREFIX to a directory - see README.osx; exit 1; fi
clean:
- rm -rf zlib-${ZLIBVERSION}.tar.gz libpng-${PNGVERSION}.tar.bz2 \
- freetype-${FREETYPEVERSION}.tar.bz2 bdist_mpkg-${BDISTMPKGVERSION}.tar.gz \
- bdist_mpkg-${BDISTMPKGVERSION} \
+ rm -rf ${ZLIBFILE} ${PNGFILE} ${FREETYPEFILE} \
+ bdist_mpkg-${BDISTMPKGVERSION}.tar.gz \
+ bdist_mpkg-${BDISTMPKGVERSION} setupext.pyc \
+ lib/matplotlib/mpl-data/matplotlib.conf lib/matplotlib/mpl-data/matplotlibrc \
zlib-${ZLIBVERSION} libpng-${PNGVERSION} freetype-${FREETYPEVERSION} \
build
fetch:
- ${PYTHON} -c 'import urllib; urllib.urlretrieve("http://superb-sea2.dl.sourceforge.net/project/libpng/zlib/${ZLIBVERSION}/zlib-${ZLIBVERSION}.tar.gz", "zlib-${ZLIBVERSION}.tar.gz")' &&\
- ${PYTHON} -c 'import urllib; urllib.urlretrieve("http://sourceforge.net/projects/libpng/files/libpng-stable/${PNGVERSION}/libpng-${PNGVERSION}.tar.gz/download", "libpng-${PNGVERSION}.tar.gz")' &&\
- ${PYTHON} -c 'import urllib; urllib.urlretrieve("http://download.savannah.gnu.org/releases/freetype/freetype-${FREETYPEVERSION}.tar.bz2", "freetype-${FREETYPEVERSION}.tar.bz2")'
-
-
-
+ ${PYTHON} -c 'import urllib; urllib.urlretrieve("${ZLIBURL}", "${ZLIBFILE}")' &&\
+ ${PYTHON} -c 'import urllib; urllib.urlretrieve("${PNGURL}", "${PNGFILE}")' &&\
+ ${PYTHON} -c 'import urllib; urllib.urlretrieve("${FREETYPEURL}", "${FREETYPEFILE}")'
zlib: check-prefix
- export PKG_CONFIG_PATH=${PKG_CONFIG_PATH} &&\
- rm -rf zlib-${ZLIBVERSION} &&\
- tar xvfz zlib-${ZLIBVERSION}.tar.gz &&\
- cd zlib-${ZLIBVERSION} &&\
- export MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET} &&\
- export CFLAGS=${CFLAGS} &&\
- export LDFLAGS=${LDFLAGS} &&\
- ./configure --prefix=${PREFIX}&&\
- MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET} CFLAGS=${CFLAGS} LDFLAGS=${LDFLAGS} make -j3 install&& \
- unset MACOSX_DEPLOYMENT_TARGET
-
-png: zlib check-prefix
- export PKG_CONFIG_PATH=${PKG_CONFIG_PATH} &&\
- rm -rf libpng-${PNGVERSION} &&\
- tar xvfz libpng-${PNGVERSION}.tar.gz && \
- cd libpng-${PNGVERSION} &&\
- export MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET} &&\
- export CFLAGS=${CFLAGS} &&\
- export LDFLAGS=${LDFLAGS} &&\
+ rm -rf ${ZLIBDIR} &&\
+ tar xvfz ${ZLIBFILE} &&\
+ cd ${ZLIBDIR} &&\
+ ./configure --prefix=${PREFIX} &&\
+ ${MAKE} -j3 install
+
+png: check-prefix zlib
+ rm -rf ${PNGDIR} &&\
+ tar xvfz ${PNGFILE} && \
+ cd ${PNGDIR} &&\
./configure --disable-dependency-tracking --prefix=${PREFIX} &&\
- make -j3 install&&\
- cp .libs/libpng.a . &&\
- unset MACOSX_DEPLOYMENT_TARGET
-
-
-freetype: zlib check-prefix
- export PKG_CONFIG_PATH=${PKG_CONFIG_PATH} &&\
- rm -rf ${FREETYPEVERSION} &&\
- tar xvfj freetype-${FREETYPEVERSION}.tar.bz2 &&\
- cd freetype-${FREETYPEVERSION} &&\
- export MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET} &&\
- export CFLAGS=${CFLAGS} &&\
- export LDFLAGS=${LDFLAGS} &&\
- ./configure --prefix=${PREFIX} &&\
- make -j3 install &&\
- cp objs/.libs/libfreetype.a . &&\
- unset MACOSX_DEPLOYMENT_TARGET
+ ${MAKE} -j3 install
+freetype: check-prefix zlib
+ rm -rf ${FREETYPEDIR} &&\
+ tar xvfj ${FREETYPEFILE} &&\
+ cd ${FREETYPEDIR} &&\
+ ./configure --prefix=${PREFIX} &&\
+ ${MAKE} -j3 install &&\
+ cp objs/.libs/libfreetype.a .
deps: zlib png freetype
echo 'all done'
-mpl_build:
- export PKG_CONFIG_PATH=${PKG_CONFIG_PATH} &&\
- export MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET} &&\
- export CFLAGS=${CFLAGS} &&\
- export LDFLAGS=${LDFLAGS} &&\
+# Various build and install targets
+#
+# The values of PKG_CONFIG_PATH, MACOSX_DEPLOYMENT_TARGET, CFLAGS,
+# LDFLAGS affect the compilation; note that variables are
+# automatically put into the environment by make.
+
+mpl_build: check-prefix
${PYTHON} setup.py build
mpl_install: check-prefix
- export PKG_CONFIG_PATH=${PKG_CONFIG_PATH} &&\
- export MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET} &&\
- export CFLAGS=${CFLAGS} &&\
- export LDFLAGS=${LDFLAGS} &&\
${PYTHON} setup.py install --prefix=${PREFIX}
+mpl_install_std: check-prefix
+ ${PYTHON} setup.py install
+
+mpl_install_egg: check-prefix
+ ${PYTHON} setupegg.py install
+
+mpl_install_develop: check-prefix
+ ${PYTHON} setupegg.py develop
+
binaries: check-prefix
+ @if [ -z "$(PYVERSION)" ]; then echo Must set PYVERSION; exit 1; fi
unset PKG_CONFIG_PATH &&\
cp release/osx/data/setup.cfg release/osx/data/ReadMe.txt . &&\
- export CFLAGS=${CFLAGS} &&\
- export LDFLAGS=${LDFLAGS} &&\
rm -f ${PREFIX}/lib/*.dylib &&\
VERSIONER_PYTHON_PREFER_32_BIT=yes bdist_mpkg --readme=ReadMe.txt &&\
hdiutil create -srcdir dist/matplotlib-${MPLVERSION}-py${PYVERSION}-macosx${OSX_SDK_VER}.mpkg dist/matplotlib-${MPLVERSION}-py${PYVERSION}-macosx${OSX_SDK_VER}.dmg &&\

0 comments on commit 861da23

Please sign in to comment.
Something went wrong with that request. Please try again.