Compiling on MacOSX: Difference between revisions

From GRASS-Wiki
Jump to navigation Jump to search
m (Or this other way moved to Compiling on MacOSX: Use reasonable titles please)
(this page is rather outdated)
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
== GRASS GIS 7 ==
* [[Compiling on MacOSX using homebrew]]
* ...
== GRASS GIS 6 ==
Up-to-date compilation instructions are maintained in the source <tt>[http://trac.osgeo.org/grass/browser/grass/branches/develbranch_6/macosx/ReadMe.rtf?format=raw macosx/ReadMe.rtf]</tt>.
This builds a double-clickable application with "aqua" options where possible (Tcl/Tk, Python, OpenGL,...)
and leaves out obscure X11-only-based features that have newer system-agnostic options (like motif/xganim),
though these newer features may not be quite as fully-featured, yet.
The X11 display system ''is'' included, since it is simple to include and is still quite useful.
The method below is for the older X11-based compilation, and includes the X11 motif-based xganim.
To build Grass from source you can use the frameworks that are on :  
To build Grass from source you can use the frameworks that are on :  
http://www.kyngchaos.com/software/unixport/frameworks
http://www.kyngchaos.com/software:frameworks
great thanks to W.Kyngesbury
great thanks to W.Kyngesburye.


after install the "all frameworks" you can add some library such "motif" needed by Xganim, using fink or build the source code
After installing all the frameworks you can add some library such "motif" needed by Xganim, using fink or build the source code


install from source the tcl-tk library : http://www.tcl.tk/software/tcltk/downloadnow84.tml  in /usr/local
Install from source the tcl-tk library : http://www.tcl.tk/software/tcltk/downloadnow84.tml  in /usr/local


download a cvs version http://grass.itc.it/download/index.php
Postgres can be easily compiled from source.


then configure and make grass cvs :
Download a SVN version http://grass.osgeo.org/download/index.php


Then configure and make GRASS from SVN/source code snapshot :
<pre>
cd /path_to_grass_source
cd /path_to_grass_source


./configure --prefix=/usr/local --enable-sysv --with-x --with-opengl=x11 --without-odbc --with-cxx --with-freetype  
./configure --enable-sysv --with-x --with-opengl=x11 --without-odbc --with-cxx --with-freetype \
--with-freetype-includes=/Library/Frameworks/FreeType.framework/unix/include \
--with-freetype-libs=/Library/Frameworks/FreeType.framework/unix/lib \
--with-gdal=/Library/Frameworks/GDAL.framework/Versions/1.5/Programs/gdal-config \
--with-proj-includes=/Library/Frameworks/PROJ.framework/unix/include \
--with-proj-libs=/Library/Frameworks/PROJ.framework/unix/lib \
--with-proj-share=/Library/Frameworks/PROJ.framework/Versions/4.5/unix/share/ \
--with-tiff --with-tiff-includes=/Library/Frameworks/UnixImageIO.framework/unix/include \
--with-tiff-libs=/Library/Frameworks/UnixImageIO.framework/unix/lib \
--with-png-includes=/Library/Frameworks/UnixImageIO.framework/unix/include \
--with-png-libs=/Library/Frameworks/UnixImageIO.framework/unix/lib \
--with-sqlite --with-sqlite-libs=/Library/Frameworks/SQLite3.framework/unix/lib \
--with-sqlite-includes=/Library/Frameworks/SQLite3.framework/unix/include \
--with-fftw --with-fftw-includes=/Library/Frameworks/FFTW3.framework/unix/include \
--with-fftw-libs=/Library/Frameworks/FFTW3.framework/unix/lib \
--with-postgres-includes=/usr/local/pgsql/include --with-postgres-libs=/usr/local/pgsql/lib \
--with-freetype --with-freetype-includes=/Library/Frameworks/FreeType.framework/unix/include \
--with-freetype-libs=/Library/Frameworks/FreeType.framework/unix/lib --with-python --with-readline \
--with-readline-includes=/sw/include/readline --with-readline-libs=/sw/lib --with-tcltk-includes=/usr/local/include \
--with-tcltk-libs=/usr/local/lib --with-blas --with-lapack \
--with-blas-includes=/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers \
--with-lapack-includes=/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers \
--with-motif --with-motif-includes=/sw/include --with-motif-libs=/sw/lib --with-glw


--with-freetype-includes=/Library/Frameworks/FreeType.framework/unix/include
make
sudo make install
</pre>


--with-freetype-libs=/Library/Frameworks/FreeType.framework/unix/lib
'''COMPILING GRASS ON MAC OSX 10.8 TO RUN ON OSX 10.6 AND UP 64 BIT'''


--with-gdal=/Library/Frameworks/GDAL.framework/Versions/1.4/Programs/gdal-config
Here are instructions on how to compile GRASS 6 and 7 on Mac OS X 10.8 so that it also runs in GRASS OS X 10.6 and up in 64 bit (but with 32 bit wxPython).


--with-proj-includes=/Library/Frameworks/PROJ.framework/unix/include
You must have Apple's developer tools installed, including the MacOSX10.6.sdk if you want your binary to run on OS X 10.6 as well as later versions of the OS


--with-proj-libs=/Library/Frameworks/PROJ.framework/unix/lib
'''PREPARATION TO COMPILE (you only need to do this once)'''


--with-proj-share=/Library/Frameworks/PROJ.framework/Versions/4.5/unix/share/
''Step 1'': Python and wxPython:


--with-jpeg --with-jpeg-includes=/Library/Frameworks/UnixImageIO.framework/unix/include
Currently, do NOT install a 3rd party Python (e.g., from python.org) unless you know how to configure PYTHONPATH appropriately for GRASS and wxPython.  


--with-jpeg-libs=/Library/Frameworks/UnixImageIO.framework/unix/lib
Mac OS X comes with Python 2.6 and OS X 10.7/10.8 comes with Python 2.6 and 2.7. This set up will use whatever your system comes with, but compiles wxPython to use Python 2.6


--with-tiff --with-tiff-includes=/Library/Frameworks/UnixImageIO.framework/unix/include
Install wxPython 2.8.12.1 for Python 2.6 (note that the installation directory must be correctly referenced in the configure script)


--with-tiff-libs=/Library/Frameworks/UnixImageIO.framework/unix/lib
Create a script named "python" with the following in it and put it somewhere so it can be added to your path at compile time. For example, I put it in /Applications/python/bin32


--with-png-includes=/Library/Frameworks/UnixImageIO.framework/unix/include
<pre>
#!/bin/sh
exec arch -i386 pythonw2.6 "$@"
</pre>


--with-png-libs=/Library/Frameworks/UnixImageIO.framework/unix/lib
This is to force python to run 32bit so wxpython tests work in configure (it also references the system python 2.6 and not 2.7).


--with-sqlite --with-sqlite-libs=/Library/Frameworks/SQLite3.framework/unix/lib
''Step 2'': edit bundling code in ../grass7/macosx/


--with-sqlite-includes=/Library/Frameworks/SQLite3.framework/unix/include
Make a script named "bundle.sh" with the following code:


--with-fftw --with-fftw-includes=/Library/Frameworks/FFTW3.framework/unix/include
<pre>
# DYLD_FRAMEWORK_PATH for bundled frameworks


--with-fftw-libs=/Library/Frameworks/FFTW3.framework/unix/lib
sed -i '' -e 's,^export DYLD_LIBRARY_PATH$,&\
export DYLD_FRAMEWORK_PATH="\$GISBASE/lib",' \
${INST_DIR_TARGET}/grass.sh
</pre>


--with-postgres-includes=/usr/local/pgsql/include --with-postgres-libs=/usr/local/pgsql/lib
''Step 3'': Set up bundling to make GRASS binary package for distribution


--with-freetype --with-freetype-includes=/Library/Frameworks/FreeType.framework/unix/include
Edit bundle.make to reference wxPython. This includes a copy of wxPython with the GRASS binary so it will run regardless of what version of wxPython the user has installed separately. It also bundles fftw3.


--with-freetype-libs=/Library/Frameworks/FreeType.framework/unix/lib --with-python --with-readline
<pre>
...


--with-readline-includes=/sw/include/readline --with-readline-libs=/sw/lib --with-tcltk-includes=/usr/local/include
WXPREFIX=/usr/local/lib/wxPython-unicode-2.8.12.1


--with-tcltk-libs=/usr/local/lib
bundle-macosx:
${INSTALL} ${WXPREFIX}/lib/libwx_macud-2.8.0.dylib ${INST_DIR_TARGET}/lib
${INSTALL} ${WXPREFIX}/lib/libwx_macud_gl-2.8.0.dylib ${INST_DIR_TARGET}/lib
${INSTALL} ${WXPREFIX}/lib/libwx_macud_stc-2.8.0.dylib ${INST_DIR_TARGET}/lib
${INSTALL} ${WXPREFIX}/lib/libwx_macud_gizmos-2.8.0.dylib ${INST_DIR_TARGET}/lib
${INSTALL} ${WXPREFIX}/lib/libwx_macud_gizmos_xrc-2.8.0.dylib ${INST_DIR_TARGET}/lib
cp -Rf ${WXPREFIX}/lib/python2.6/site-packages/wx-2.8-mac-unicode/wx ${INST_DIR_TARGET}/etc/python
cp -Rf ${WXPREFIX}/lib/python2.6/site-packages/wx-2.8-mac-unicode/wxPython ${INST_DIR_TARGET}/etc/python
cp -f ${WXPREFIX}/lib/python2.6/site-packages/wxversion.py ${INST_DIR_TARGET}/etc/python
sed -i '' -e 's/^GRASS_WXBUNDLED=.*/GRASS_WXBUNDLED=1/' ${INST_DIR_TARGET}/grass.sh
cp -Rf /Library/Frameworks/FFTW3.framework ${INST_DIR_TARGET}/lib/FFTW3.framework
/usr/bin/env INST_DIR_TARGET="${INST_DIR_TARGET}" ./bundle.sh
</pre>


--with-blas --with-blas-libs=/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/
You can bundle additional code if you desire. I also bundle gettext and LAS tools.


--with-lapack --with-lapack-libs=/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/


--with-motif --with-motif-includes=/sw/include --with-motif-libs=/sw/lib --with-glw
'''AT THE TIME OF COMPILATION (do this each time you compile)'''
 
''Step 1'': export the following prior to configuration. This makes GRASS run on OSX 10.6 as well as 10.7 and 10.8
 
<pre>
export MACOSX_DEPLOYMENT_TARGET=10.6
 
export PATH="/Applications/python/bin32:/System/Library/Frameworks/Python.framework/Versions/2.6/bin:$PATH"
 
export CXX=g++
</pre>
 
''Step 2'': configuration. Here is my configure script. This configures for both 32 and 64 bit. Because wxPython 2.8.x only runs 32 bit, it is configured to run in Python 2.6 32 bit. But the rest of GRASS will take advantage of the Mac 64 bit processing.
 
Here is my configuration script
 
<pre>
./configure --with-macosx-sdk=/Developer/SDKs/MacOSX10.6.sdk --with-freetype --with-freetype-includes="/Library/Frameworks/FreeType.framework/unix/include/freetype2 /Library/Frameworks/FreeType.framework/unix/include" --with-freetype-libs=/Library/Frameworks/FreeType.framework/unix/lib --with-gdal=/Library/Frameworks/GDAL.framework/Programs/gdal-config --with-proj --with-proj-includes=/Library/Frameworks/PROJ.framework/unix/include --with-proj-libs=/Library/Frameworks/PROJ.framework/unix/lib --with-proj-share=/Library/Frameworks/PROJ.framework/Resources/proj --with-geos=/Library/Frameworks/GEOS.framework/Versions/3/unix/bin/geos-config --with-jpeg-includes=/Library/Frameworks/UnixImageIO.framework/unix/include --with-jpeg-libs=/Library/Frameworks/UnixImageIO.framework/unix/lib --with-png-includes=/Library/Frameworks/UnixImageIO.framework/unix/include --with-png-libs=/Library/Frameworks/UnixImageIO.framework/unix/lib --with-tiff-includes=/Library/Frameworks/UnixImageIO.framework/unix/include --with-tiff-libs=/Library/Frameworks/UnixImageIO.framework/unix/lib --with-cairo --with-cairo-includes="/Library/Frameworks/cairo.framework/unix/include/cairo /Library/Frameworks/cairo.framework/unix/include" --with-cairo-libs=/Library/Frameworks/cairo.framework/unix/lib --with-cairo-ldflags="-lcairo" --without-postgres --without-mysql --with-odbc --with-sqlite --with-sqlite-libs=/Library/Frameworks/SQLite3.framework/unix/lib --with-sqlite-includes=/Library/Frameworks/SQLite3.framework/unix/include --with-fftw-includes=/Library/Frameworks/FFTW3.framework/unix/include --with-fftw-libs=/Library/Frameworks/FFTW3.framework/unix/lib --with-x --with-cxx --with-opengl=aqua --without-readline --prefix=/Applications/GRASS --enable-macosx-app --with-python --with-wxwidgets=/usr/local/lib/wxPython-unicode-2.8.12.1/bin/wx-config --with-tcltk-includes="/Library/Frameworks/Tcl.framework/Headers /Library/Frameworks/Tk.framework/Headers /Library/Frameworks/Tk.framework/PrivateHeaders" --with-tcltk-libs="/usr/local/tcltk_active/lib" --with-macosx-archs="i386 x86_64"
</pre>
 
''Step 3'': make
 
<pre>
make GDAL_DYNAMIC=
 
for GRASS 6, simply use make
</pre>
 
''Step 4'': create installation bundle
 
<pre>
make bindist
</pre>
 
[[Category:Development]]
[[Category:Documentation]]
[[Category:Installation]]

Latest revision as of 06:35, 14 May 2020

GRASS GIS 7

GRASS GIS 6

Up-to-date compilation instructions are maintained in the source macosx/ReadMe.rtf. This builds a double-clickable application with "aqua" options where possible (Tcl/Tk, Python, OpenGL,...) and leaves out obscure X11-only-based features that have newer system-agnostic options (like motif/xganim), though these newer features may not be quite as fully-featured, yet. The X11 display system is included, since it is simple to include and is still quite useful.

The method below is for the older X11-based compilation, and includes the X11 motif-based xganim.

To build Grass from source you can use the frameworks that are on : http://www.kyngchaos.com/software:frameworks great thanks to W.Kyngesburye.

After installing all the frameworks you can add some library such "motif" needed by Xganim, using fink or build the source code

Install from source the tcl-tk library : http://www.tcl.tk/software/tcltk/downloadnow84.tml in /usr/local

Postgres can be easily compiled from source.

Download a SVN version http://grass.osgeo.org/download/index.php

Then configure and make GRASS from SVN/source code snapshot :

cd /path_to_grass_source

./configure --enable-sysv --with-x --with-opengl=x11 --without-odbc --with-cxx --with-freetype \
--with-freetype-includes=/Library/Frameworks/FreeType.framework/unix/include \
--with-freetype-libs=/Library/Frameworks/FreeType.framework/unix/lib \
--with-gdal=/Library/Frameworks/GDAL.framework/Versions/1.5/Programs/gdal-config \
--with-proj-includes=/Library/Frameworks/PROJ.framework/unix/include \
--with-proj-libs=/Library/Frameworks/PROJ.framework/unix/lib \
--with-proj-share=/Library/Frameworks/PROJ.framework/Versions/4.5/unix/share/ \
--with-tiff --with-tiff-includes=/Library/Frameworks/UnixImageIO.framework/unix/include \
--with-tiff-libs=/Library/Frameworks/UnixImageIO.framework/unix/lib \
--with-png-includes=/Library/Frameworks/UnixImageIO.framework/unix/include \
--with-png-libs=/Library/Frameworks/UnixImageIO.framework/unix/lib \
--with-sqlite --with-sqlite-libs=/Library/Frameworks/SQLite3.framework/unix/lib \
--with-sqlite-includes=/Library/Frameworks/SQLite3.framework/unix/include \
--with-fftw --with-fftw-includes=/Library/Frameworks/FFTW3.framework/unix/include \
--with-fftw-libs=/Library/Frameworks/FFTW3.framework/unix/lib \
--with-postgres-includes=/usr/local/pgsql/include --with-postgres-libs=/usr/local/pgsql/lib \
--with-freetype --with-freetype-includes=/Library/Frameworks/FreeType.framework/unix/include \
--with-freetype-libs=/Library/Frameworks/FreeType.framework/unix/lib --with-python --with-readline \
--with-readline-includes=/sw/include/readline --with-readline-libs=/sw/lib --with-tcltk-includes=/usr/local/include \
--with-tcltk-libs=/usr/local/lib --with-blas --with-lapack \
--with-blas-includes=/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers \
--with-lapack-includes=/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers \
--with-motif --with-motif-includes=/sw/include --with-motif-libs=/sw/lib --with-glw

make
sudo make install

COMPILING GRASS ON MAC OSX 10.8 TO RUN ON OSX 10.6 AND UP 64 BIT

Here are instructions on how to compile GRASS 6 and 7 on Mac OS X 10.8 so that it also runs in GRASS OS X 10.6 and up in 64 bit (but with 32 bit wxPython).

You must have Apple's developer tools installed, including the MacOSX10.6.sdk if you want your binary to run on OS X 10.6 as well as later versions of the OS

PREPARATION TO COMPILE (you only need to do this once)

Step 1: Python and wxPython:

Currently, do NOT install a 3rd party Python (e.g., from python.org) unless you know how to configure PYTHONPATH appropriately for GRASS and wxPython.

Mac OS X comes with Python 2.6 and OS X 10.7/10.8 comes with Python 2.6 and 2.7. This set up will use whatever your system comes with, but compiles wxPython to use Python 2.6

Install wxPython 2.8.12.1 for Python 2.6 (note that the installation directory must be correctly referenced in the configure script)

Create a script named "python" with the following in it and put it somewhere so it can be added to your path at compile time. For example, I put it in /Applications/python/bin32

#!/bin/sh
exec arch -i386 pythonw2.6 "$@"

This is to force python to run 32bit so wxpython tests work in configure (it also references the system python 2.6 and not 2.7).

Step 2: edit bundling code in ../grass7/macosx/

Make a script named "bundle.sh" with the following code:

# DYLD_FRAMEWORK_PATH for bundled frameworks

sed -i '' -e 's,^export DYLD_LIBRARY_PATH$,&\
export DYLD_FRAMEWORK_PATH="\$GISBASE/lib",' \
	${INST_DIR_TARGET}/grass.sh

Step 3: Set up bundling to make GRASS binary package for distribution

Edit bundle.make to reference wxPython. This includes a copy of wxPython with the GRASS binary so it will run regardless of what version of wxPython the user has installed separately. It also bundles fftw3.

...

WXPREFIX=/usr/local/lib/wxPython-unicode-2.8.12.1

bundle-macosx:
	${INSTALL} ${WXPREFIX}/lib/libwx_macud-2.8.0.dylib ${INST_DIR_TARGET}/lib
	${INSTALL} ${WXPREFIX}/lib/libwx_macud_gl-2.8.0.dylib ${INST_DIR_TARGET}/lib
	${INSTALL} ${WXPREFIX}/lib/libwx_macud_stc-2.8.0.dylib ${INST_DIR_TARGET}/lib
	${INSTALL} ${WXPREFIX}/lib/libwx_macud_gizmos-2.8.0.dylib ${INST_DIR_TARGET}/lib
	${INSTALL} ${WXPREFIX}/lib/libwx_macud_gizmos_xrc-2.8.0.dylib ${INST_DIR_TARGET}/lib
	cp -Rf ${WXPREFIX}/lib/python2.6/site-packages/wx-2.8-mac-unicode/wx ${INST_DIR_TARGET}/etc/python
	cp -Rf ${WXPREFIX}/lib/python2.6/site-packages/wx-2.8-mac-unicode/wxPython ${INST_DIR_TARGET}/etc/python
	cp -f ${WXPREFIX}/lib/python2.6/site-packages/wxversion.py ${INST_DIR_TARGET}/etc/python
	sed -i '' -e 's/^GRASS_WXBUNDLED=.*/GRASS_WXBUNDLED=1/' ${INST_DIR_TARGET}/grass.sh
	cp -Rf /Library/Frameworks/FFTW3.framework ${INST_DIR_TARGET}/lib/FFTW3.framework
	/usr/bin/env INST_DIR_TARGET="${INST_DIR_TARGET}" ./bundle.sh

You can bundle additional code if you desire. I also bundle gettext and LAS tools.


AT THE TIME OF COMPILATION (do this each time you compile)

Step 1: export the following prior to configuration. This makes GRASS run on OSX 10.6 as well as 10.7 and 10.8

export MACOSX_DEPLOYMENT_TARGET=10.6

export PATH="/Applications/python/bin32:/System/Library/Frameworks/Python.framework/Versions/2.6/bin:$PATH"

export CXX=g++

Step 2: configuration. Here is my configure script. This configures for both 32 and 64 bit. Because wxPython 2.8.x only runs 32 bit, it is configured to run in Python 2.6 32 bit. But the rest of GRASS will take advantage of the Mac 64 bit processing.

Here is my configuration script

./configure --with-macosx-sdk=/Developer/SDKs/MacOSX10.6.sdk --with-freetype --with-freetype-includes="/Library/Frameworks/FreeType.framework/unix/include/freetype2 /Library/Frameworks/FreeType.framework/unix/include" --with-freetype-libs=/Library/Frameworks/FreeType.framework/unix/lib --with-gdal=/Library/Frameworks/GDAL.framework/Programs/gdal-config --with-proj --with-proj-includes=/Library/Frameworks/PROJ.framework/unix/include --with-proj-libs=/Library/Frameworks/PROJ.framework/unix/lib --with-proj-share=/Library/Frameworks/PROJ.framework/Resources/proj --with-geos=/Library/Frameworks/GEOS.framework/Versions/3/unix/bin/geos-config --with-jpeg-includes=/Library/Frameworks/UnixImageIO.framework/unix/include --with-jpeg-libs=/Library/Frameworks/UnixImageIO.framework/unix/lib --with-png-includes=/Library/Frameworks/UnixImageIO.framework/unix/include --with-png-libs=/Library/Frameworks/UnixImageIO.framework/unix/lib --with-tiff-includes=/Library/Frameworks/UnixImageIO.framework/unix/include --with-tiff-libs=/Library/Frameworks/UnixImageIO.framework/unix/lib --with-cairo --with-cairo-includes="/Library/Frameworks/cairo.framework/unix/include/cairo /Library/Frameworks/cairo.framework/unix/include" --with-cairo-libs=/Library/Frameworks/cairo.framework/unix/lib --with-cairo-ldflags="-lcairo" --without-postgres --without-mysql --with-odbc --with-sqlite --with-sqlite-libs=/Library/Frameworks/SQLite3.framework/unix/lib --with-sqlite-includes=/Library/Frameworks/SQLite3.framework/unix/include --with-fftw-includes=/Library/Frameworks/FFTW3.framework/unix/include --with-fftw-libs=/Library/Frameworks/FFTW3.framework/unix/lib --with-x --with-cxx --with-opengl=aqua --without-readline --prefix=/Applications/GRASS --enable-macosx-app --with-python --with-wxwidgets=/usr/local/lib/wxPython-unicode-2.8.12.1/bin/wx-config --with-tcltk-includes="/Library/Frameworks/Tcl.framework/Headers /Library/Frameworks/Tk.framework/Headers /Library/Frameworks/Tk.framework/PrivateHeaders" --with-tcltk-libs="/usr/local/tcltk_active/lib" --with-macosx-archs="i386 x86_64" 

Step 3: make

make GDAL_DYNAMIC=

for GRASS 6, simply use make

Step 4: create installation bundle

make bindist