Dev:2.4/Doc/Building Blender/Mac

提供: wiki
< Dev:2.4‎ | Doc‎ | Building BlenderBuildingBlender/Macから転送)
移動先: 案内検索
Blender2.5
Instructions for building Blender2.5 should be placed here


  • Make, SCons and CMake are all command line programs, and will require you to execute the build commands from the shell /Applications/Utilities/Terminal.
  • If you want to use XCode, then you should use CMake -G Xcode
  • If you want to link against a version of Python not generally included on Mac OS X, you'll need to read this message, but the basic idea is: Install MacPython for the version(s) of Python you want to support, or use Ports or Fink to do the same and symlink those into the /Library/Frameworks folder. Then, to switch the /Library/Frameworks/Python.framework you want to use, rename /Library/Frameworks/Python.framework to something like /Library/Frameworks/Python<version>.framework. This will automagically switch the Python version, because the linker will look there first--- regardless of the build variables set by the build system.

Mac OS X Build Assumptions

  1. Due to the ABI changes in Mac OS X, and due to the fact that Intel Macs require Mac OS X 10.4 (Tiger) and up, these instructions assume that you are building on Mac OS X 10.4 or newer. Before building blender you should familiarize yourself with the impact of the ABI changes on your choices for satisfying depenencies.
  2. Use GCC 4.0.x. To check this, open /Applications/Utilities/Terminal and type gcc_select. To switch, type: gcc_select 4. This will set gcc-4.x.x as the default compiler.
  3. Shell commands assume that you are using the default shell: bash.
  4. These instructions assume that you installed Python 2.4 using the MacPython distribution, or otherwise have /Library/Frameworks/Python.framework as version 2.4 of Python.

Make

  • Read the Mac OS X Build Assumptions
  • The NaN Makefiles are custom built and well maintained. You may need to run ranlib a few times, but if you have the dependencies available, and you set them in bf-blender/blender/user-def.mk, you should have no problem building with the NaN Makefile system.
  • Object output directories for NaN Make and Mac OS X:

bf-blender/blender/obj/ 2.42a/ (release files) darwin-8.7.0-powerpc/ (libraries) darwin-8.8.0-powerpc/ (objects) darwin-8.6.2-i386/ (objects and libraries)

To make, do the following:

  1. Open /Applications/Utilities/Terminal
  2. Set the home directory for your blender source code in an environment variable, like so (assuming you're using bash): export NANBLENDERHOME=<path to bf-blender/blender>
  3. Type cd $NANBLENDERHOME
  4. Copy the appropriate snippet of bf-blender/user-def.mk below, to your own bf-blender/user-def.mk file.
  5. Type make
    Make will spit out lots of information about what it is doing.
    When something goes wrong, and you need to see exactly what make did, try:
make NAN_QUIET=0
Intel

The bf-blender/lib/darwin-8.x.i386 directory satisfies most (if not all) of the dependencies for Intel build targets. You may need to install some of the dependencies with MacPorts (formerly DarwinPorts). You may need to set the following in your bf-blender/blender/user-def.mk file:

export NAN_PYTHON_VERSION=2.5

Note that the OpenAL libraries on Intel suffer from endian issues and are not supported at this time. The NaN Makefiles have disabled OpenAL for the time being.

PowerPC

The main difficulty building on PowerPC, is that the bf-blender/lib directory structure does not self-document the ABI shifts. Knowing what binary libraries were written in C++ is not always so trivial, although nm -a | grep will help. Hopefully, this example bf-blender/user-def.mk file for Mac OS X 10.4 (Tiger) for PowerPC will help get you started:

export NAN_LIBDIR ?= $(NANBLENDERHOME)/../lib
WITH_VERSE=true
export NAN_FREETYPE=$(NAN_LIBDIR)/darwin-6.1-powerpc/freetype
export NAN_OPENAL=$(NAN_LIBDIR)/darwin-8.0.0-powerpc/openal
export NAN_OPENEXR=/usr/local
export NAN_OPENEXR_LIBS ?= \
  $(NAN_OPENEXR)/lib/libIlmImf.a \
  $(NAN_OPENEXR)/lib/libHalf.a \
  $(NAN_OPENEXR)/lib/libIex.a \
  $(NAN_OPENEXR)/lib/libIlmThread.a
export NAN_SDL=$(NAN_LIBDIR)/darwin-6.1-powerpc/sdl
export NAN_JPEG=$(NAN_LIBDIR)/darwin-6.1-powerpc/jpeg
export NAN_PNG = $(NAN_LIBDIR)/darwin-6.1-powerpc/png
export NAN_GETTEXT= $(NAN_LIBDIR)/darwin-6.1-powerpc/gettext
export NAN_FMOD = $(NAN_LIBDIR)/darwin-6.1-powerpc/fmod
export NAN_ODE = $(NAN_LIBDIR)/darwin-6.1-powerpc/ode
Making Release builds with Make

If you're building for release on Mac OS X, you will probably want to make a compressed disk image with hdiutil instead of distributing a *.tar.bz2 file. Mac OS X users expect it. Type man hdiutil for help with hdiutil. To create such a disk image:

$ make release
$ cd bf-blender/blender/obj/2.43
$ export UNAME=darwin-`uname -r`-`uname -p`
$ export BF-VERSION=2.43
$ tar zxvf blender-$BF-VERSION-$UNAME.tar.bz
$ hdiutil create -srcfolder blender-$BF-VERSION-$UNAME blender-$BF-VERSION-$UNAME.dmg \
-volname blender-$BF-VERSION-$UNAME -uid 99 -gid 99
$ hdiutil convert -format UDBZ -o blender-$BF-VERSION-$UNAME-bz2.dmg \
blender-$BF-VERSION-$UNAME.dmg (for Mac OS X 10.4+ only!)

OR

$ hdiutil convert -format UDZO -o blender-$BF-VERSION-$UNAME-bz2.dmg \
blender-$BF-VERSION-$UNAME.dmg

Verify that the dynamic links for the minty fresh blender you've just compiled will be available on other systems which lack your development environment. Look for non-system paths, such as /usr/local/, /sw/, /opt/, or others with:

$ otool -L bf-blender/blender/obj/$UNAME/bin/blender
$ otool -L bf-blender/blender/obj/$UNAME/bin/blenderplayer
$ otool -L bf-blender/blender/obj/$UNAME/bin/verse

If you find dynamically linked libraries in non-system paths, you'll need to fix the link line. This is usually not the case with NaN Make, however. With SCons and CMake, you may need to rewrite the link line to statically link against libraries (and library versions) that are unavailable on default installs of Mac OS X.

When you strip the build products, be sure to use strip -x otherwise the plugins will not link.

SCons

General observations of building with SCons include the following CRITICAL notes:

  • Read the Mac OS X Build Assumptions
  • Visit Mac-How
  • Move or remove any SDL libs you've installed in the /usr/local/ tree. SCons has default search paths (from scons-user.pdf): path = ['/usr/local/bin', '/bin', '/usr/bin'] as this includes /usr/local/bin/sdl-config, the linker -l always links against libs in /usr/local/ and will ignore the libsdl versions in the bf-blender/lib tree.
  • If you get conflicts with OpenAL, the linker is probably not seeing the bf-blender/lib for SDL, and is instead finding a different version, with a different ABI/compiler version.
  • To avoid hacking the bf-blender/blender/user-config.py very much, download, build, and install openexr (in the default location of /usr/local/) directly from openexr.org.
  • The greatest difficulties building with SCons are difficulties satisfying dependencies.
Intel

Here is an example scons command line with options set, as documented in bf-blender/doc/blender-scons.txt:

$ python scons/scons.py BF_DEBUG=0 WITH_BF_GAMEENGINE=true WITH_BF_PLAYER=true \
WITH_BF_VERSE=yes BF_QUIET=0 WITH_BF_SDL=true \
WITH_BF_OPENEXR=true BF_INSTALLDIR=$INSTALLDIR
PowerPC

Here is an example scons command line with options set, as documented in bf-blender/doc/blender-scons.txt:

$ python scons/scons.py BF_DEBUG=0 WITH_BF_GAMEENGINE=true \
WITH_BF_PLAYER=true WITH_BF_VERSE=yes BF_QUIET=0 \ 
WITH_BF_SDL=true WITH_BF_OPENEXR=true BF_INSTALLDIR=$INSTALLDIR

You may want to start with this bf-blender/blender/user-config.py snippet:

LIBSGCC4 = '#../lib/darwin-8.0.0-powerpc'
 
WITH_BF_OPENAL = 'true'
BF_OPENAL = LIBSGCC4 + '/openal'
BF_OPENAL_INC = '${BF_OPENAL}/include'
BF_OPENAL_LIB = 'openal'
BF_OPENAL_LIBPATH = '${BF_OPENAL}/lib'
 
WITH_BF_OPENEXR = 'true'
BF_OPENEXR = '/usr/local'
BF_OPENEXR_INC = '${BF_OPENEXR}/include/OpenEXR'
BF_OPENEXR_LIBPATH = "${BF_OPENEXR}/lib"
BF_OPENEXR_LIB = ' Iex Half IlmImf Imath IlmThread'
 
WITH_BF_VERSE = 'true'
BF_VERSE_INCLUDE = "#extern/verse/dist"
 
WITH_BF_GAMEENGINE='true'
WITH_BF_PLAYER='true'
 
WITH_BF_ICONV = 'true'
##BF_ICONV = LIBDIR + '/../darwin-8.8.0-powerpc/iconv'
BF_ICONV = '/usr'
BF_ICONV_INC = '${BF_ICONV}/include'
BF_ICONV_LIB = 'libiconv'
BF_ICONV_LIBPATH = '${BF_ICONV}/lib'
 
REL_CFLAGS = ['-Os','-mpowerpc-gfxopt']
REL_CCFLAGS = ['-Os','-mpowerpc-gfxopt']

Note that resultant builds using this snippet will dynamically link to non-system path libraries, most notably, OpenEXR.

CMake

  • Read the Mac OS X Build Assumptions
  • CMake is the most recent build system for blender. On Mac OS X, CMake will generate project files for XCode, KDevelop3, or "Unix Makefiles".
  • Object output directories for CMake and Mac OS X:

bf-blender/ lib/$CONFIGURATION

Intel
CMake -G "Unix Makefiles"

To build with Unix Makefiles generated by CMake:

  1. Open Terminal (Applications > Utilities > Terminal):
mkdir ~/Projects/bf-blender
  1. In bf-blender, type
ccmake -G "Unix Makefiles" ../blender
CMake -G "Xcode"
PowerPC
CMake -G "Unix Makefiles"
CMake -G "Xcode"