Skip to content

Fixing OSX makefile #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Mar 26, 2011
23 changes: 20 additions & 3 deletions README.osx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,29 @@ Build 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
99 changes: 45 additions & 54 deletions make.osx
Original file line number Diff line number Diff line change
@@ -1,106 +1,97 @@
# -*- makefile -*-
# build mpl into a local install dir with
# 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
# (see README.osx for more details)

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

## 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"

clean:
rm -rf zlib-${ZLIBVERSION}.tar.gz libpng-${PNGVERSION}.tar.bz2 \
rm -rf zlib-${ZLIBVERSION}.tar.gz libpng-${PNGVERSION}.tar.gz \
freetype-${FREETYPEVERSION}.tar.bz2 bdist_mpkg-${BDISTMPKGVERSION}.tar.gz \
bdist_mpkg-${BDISTMPKGVERSION} \
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://sourceforge.net/projects/libpng/files/zlib/${ZLIBVERSION}/zlib-${ZLIBVERSION}.tar.gz/download", "zlib-${ZLIBVERSION}.tar.gz")' &&\
${PYTHON} -c 'import urllib; urllib.urlretrieve("http://sourceforge.net/projects/libpng/files/libpng12/older-releases/${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")'

check-prefix:
@if [ ! -d "$(PREFIX)" ]; then echo Set PREFIX to a directory - see README.osx; exit 1; fi



zlib:
export PKG_CONFIG_PATH=${PKG_CONFIG_PATH} &&\
zlib: check-prefix
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
${MAKE} -j3 install

png: zlib
export PKG_CONFIG_PATH=${PKG_CONFIG_PATH} &&\
png: check-prefix zlib
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} &&\
./configure --disable-dependency-tracking --prefix=${PREFIX} &&\
make -j3 install&&\
cp .libs/libpng.a . &&\
unset MACOSX_DEPLOYMENT_TARGET
${MAKE} -j3 install&&\
cp .libs/libpng.a .


freetype: zlib
export PKG_CONFIG_PATH=${PKG_CONFIG_PATH} &&\
freetype: check-prefix zlib
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 &&\
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:
export PKG_CONFIG_PATH=${PKG_CONFIG_PATH} &&\
export MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET} &&\
export CFLAGS=${CFLAGS} &&\
export LDFLAGS=${LDFLAGS} &&\
mpl_install: check-prefix
${PYTHON} setup.py install --prefix=${PREFIX}

mpl_install_std: check-prefix
${PYTHON} setup.py install
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is John's code, so I would like to hear his opinion about this change.


mpl_install_egg: check-prefix
${PYTHON} setupegg.py install

mpl_install_develop: check-prefix
${PYTHON} setupegg.py develop


binaries:
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 &&\
/Library/Frameworks/Python.framework/Versions/${PYVERSION}/bin/bdist_mpkg --readme=ReadMe.txt &&\
hdiutil create -srcdir dist/matplotlib-${MPLVERSION}-py${PYVERSION}-macosx10.5.mpkg dist/matplotlib-${MPLVERSION}-py${PYVERSION}-macosx10.5.dmg &&\
Expand Down