1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659
|
# GRASS GIS Mac OS X Build
(and other Mac notes)
## Table of Contents
| :exclamation: Instructions below are not up-to-date. Update in progress. |
|---------------------------------------------------------------------------|
- Quickstart
- About
- Building GRASS
- Optimization
- Configure Example
- Leopard Notes
- Building an Installer Package
- Bundling Libraries and Programs
- Developer Notes
- Help Files
- Addon Modules
- Dependency Build Notes
- Universal Aqua Tcl/Tk
- Universal GPSBabel
- Universal NetPBM
- Universal FFMPEG
## Quickstart
To build a Mac OS X application, add this to your configure options:
`--prefix=/Applications --enable-macosx-app`
## About
This builds GRASS as a Mac OS X application, more or less.
The startup wrapper is a simple AppleScript that fires up a custom
grass.sh (instead of the standard grass6x) and quits, leaving grass.sh
running in a new Terminal window. The custom grass.sh takes care of some
default and required environment settings (so the user doesn't have to
fiddle with .bash_profile), makes sure X11 in running, then starts
init.sh.
## Building GRASS
Building GRASS as a Mac OS X application is pretty much the same as for
a unix build (see the [INSTALL.md](../INSTALL.md) document for details). For an
application, just add this option to configure:
`--enable-macosx-app`
With this option, the `--prefix` specified is the path where GRASS.app
will be installed. The default GRASS prefix is `/usr/local`, but for a Mac
OS X application it should be `/Applications`. It is not possible to have
alternative default prefixes in configure, so you must set
`--prefix=/Applications` yourself for configure.
The makefile tries to figure out the location of the GDAL programs, from
the configured GDAL libs. This is set in grass.sh, and if it doesn't
correctly figure it out (some GRASS commands fail to find needed GDAL
commands), set `GDAL_BIN` before running make:
`export GDAL_BIN=[/path/to/gdal/bin]`
### Universal Build
The GRASS build system is very friendly to a Universal build (unlike
libtool-based builds). *This applies to a standard unix build as well as
the app build.* First, a couple things to check:
**• The Universal SDK**. *This is only needed when building on OSX 10.4
PPC - the Intel system is all Universal, and so is 10.5 for both
architectures (though you may still want to use an SDK).* Using the SDK
forces GCC to use an alternate root for everything, so if a dependency
is not in the SDK (/usr/local is NOT in the SDK), you will get
configure, compile and link errors about missing stuff. To fix this,
create symlinks in the SDK to where you have your extra dependencies.
The SDKs in Leopard are mostly taken care of.
For example, /usr/local:
```sh
sudo ln -s /usr/local /Developer/SDKs/MacOSX10.4u.sdk/usr/local
```
For Leopard, there may be problems locating bin programs. Add the
following:
```sh
sudo ln -s /usr/local/bin /Developer/SDKs/MacOSX10.4u.sdk/usr/local/bin
sudo ln -s /usr/local/bin /Developer/SDKs/MacOSX10.5.sdk/usr/local/bin
```
If there are subfolders involved that are not already in the SDK, add
them first. Say you have some libraries in /Users/Shared/unix (I put my
static libraries there):
```sh
sudo mkdir -p /Developer/SDKs/MacOSX10.4u.sdk/Users/Shared
ln -s /Users/Shared/unix /Developer/SDKs/MacOSX10.4u.sdk/Users/Shared/unix
```
For /Library/Frameworks:
```sh
sudo mkdir -p /Developer/SDKs/MacOSX10.4u.sdk/Library
sudo ln -s /Library/Frameworks \
/Developer/SDKs/MacOSX10.4u.sdk/Library/Frameworks
```
**• Universal Dependencies**. Make sure all your extra dependencies are
Universal.
**• Tiger+**. This will NOT work on anything less than OSX 10.4.
If those check OK, here's what to do. Simply add the universal flags to
all compile and link commands. This is done by setting CFLAGS, CXXFLAGS
and LDFLAGS before configuring the build. The basic flags are:
`-arch ppc -arch i386`
If you are building on OSX 10.4 PPC only, also add this:
`-isysroot /Developer/SDKs/MacOSX10.4u.sdk`
Put it all together, for an Intel Mac on OSX 10.4 or any Mac on 10.5+:
```sh
export CFLAGS="-arch ppc -arch i386"
export CXXFLAGS="-arch ppc -arch i386"
export LDFLAGS="-arch ppc -arch i386"
```
Or for OSX 10.4 PPC:
```sh
export SDKROOT=/Developer/SDKs/MacOSX10.4u.sdk
export CFLAGS="-arch ppc -arch i386 -isysroot $SDKROOT"
export CXXFLAGS="-arch ppc -arch i386 -isysroot $SDKROOT"
export LDFLAGS="-arch ppc -arch i386 -isysroot $SDKROOT"
```
For OSX 10.5, you can also build for 64bit (all processors except the
first Intel Core Duo), just add:
`-arch ppc64 -arch x86_64`
### Optimization
By default, GRASS configures with debugging symbols turned on (the
"-g" flag), and level 2 optimization ("-O2"). If you don't want
debugging on (it greatly increases the binary size) or want to use a
different optimization, just add an optimization flag to the above
CFLAGS and CXXFLAGS exports. Specifying an optimization disables
debugging. Some common optimizations are (see the gcc man page for
complete details):
- `-O2` most optimizations, a common default
- `-O3` high
- `-Os` optimize for speed, also keep the binary size small (the Apple standard)
If you want debugging with a different optimization flag, use one of the above
optimization flags plus "-g".
Remember to separate all flags with spaces.
### Configure Example
As an example, to build GRASS using my frameworks and Tcl/Tk as built in
the build notes below, this should work *(for a standard unix build,
just remove the `--prefix` and `--enable-macosx-app` flags)*:
```bash
./configure \
--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-geos=/Library/Frameworks/GEOS.framework/Programs/geos-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-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 \
--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-cxx \
--with-tcltk-includes="/Library/Frameworks/Tcl.framework/Headers \
/Library/Frameworks/Tk.framework/Headers \
/Library/Frameworks/Tk.framework/PrivateHeaders" \
--with-tcltk-libs=/usr/local/lib \
--with-x \
--without-motif \
--without-glw \
--with-opengl=aqua \
--without-readline \
--prefix=/Applications \
--enable-macosx-app
```
That's a long line, but you have to be very explicit in the GRASS configure
(and yes, the UnixImageIO framework is used multiple times).
If you don't have the PROJ framework programs folder in your shell
PATH, it will fail to find nad2bin. To correct this set NAD2BIN before
running configure:
`export NAD2BIN=/Library/Frameworks/PROJ.framework/Programs/nad2bin`
Sometimes, for mysterious reasons so far, the automatic check for X11
fails. Depending on various conditions, you may immediately notice this
because configure stops. If X11 isn't found automatically, add this to
the configure line *(this applies to both the unix build and app
build)*:
`--x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib`
To install the new Python GUI (see [REQUIREMENTS.md](../REQUIREMENTS.md)
and [gui/wxpython/README](../gui/wxpython/README), wxpython installer
available at [wxpython.org](https://wxpython.org/)), add this to configure (fill
in the correct version at x.x.x.x for the wxpython you have installed):
```bash
--with-python
--with-wxwidgets=/usr/local/lib/wxPython-unicode-x.x.x.x/bin/wx-config
```
Note: as of wxpython 2.8.8.0 you can use an external wxpython with the
system Python on Leopard.
If you want ffmpeg support (see build instructions below), add this:
```bash
--with-ffmpeg \
--with-ffmpeg-includes="/usr/local/include \
/usr/local/include/libavcodec /usr/local/include/libavdevice \
/usr/local/include/libavformat /usr/local/include/libavutil \
/usr/local/include/libswscale" \
--with-ffmpeg-libs=/usr/local/lib
```
For cairo support (see build
instructions at
[kyngchaos.com](https://web.archive.org/web/20161112052733/http://www.kyngchaos.com/macosx/build/cairo/)),
add this:
```bash
--with-cairo \
--with-cairo-includes=/usr/local/include/cairo \
--with-cairo-libs=/usr/local/lib \
--with-cairo-ldflags=-lcairo
```
### Leopard Notes
• Linker Problem
The linker in Leopard's GCC from Xcode 3.0 has a bit of a problem with
some libraries, notably X11's libGL. When trying to link libGL (for
example), it spits back an error:
`ld: cycle in dylib re-exports with /usr/X11/lib/libGL.dylib for
architecture i386`
Xcode 3.1 does not have this problem. In other words, make sure to
install the latest Xcode.
### Building an Installer Package
After running make, make bindist will assemble an installer package.
This will have the name "GRASS-[version].pkg" and will be found in
the macosx folder in the GRASS source. On Tiger, there **will be** some
**non-fatal errors** - *this is normal* and the installer package is
still generated correctly.
The installer takes care of binary installation, and creating the
/Library/GRASS support folder and Help Viewer link.
This installer currently does NOT do any verification of installed
dependencies or system version.
### Bundling Libraries and Programs
Additional dependent libraries and programs can be bundled with the
application package to make a more portable and easily installed GRASS
application. See `macosx/pkg/bundle.make` for details.
GRASS uses `DYLD_LIBRARY_PATH`, which is set to the application's lib
folder, so it will find any libraries that are there that are not found
in their expected locations. It also adds the application bin folder to
the `PATH`, so helper programs installed there will be found.
There is NO need to bundle *everything*. Bundling readily available libraries
and programs installed in standard locations is not necessary. Some things
you might want to bundle include:
- GPSBabel (CLI)
- NetPBM programs (just what is used in GRASS)
- other support CLI programs for script modules
- ffmpeg libraries
- Postgres library (libpq)
Things to leave out:
- applications that duplicate the above items (ie GPSBabel.app)
- /Library/Frameworks stuff
## Developer Notes
The applescript startup and grass.sh can be customized if desired, ie
for a more complex startup that might give the user a dialog for startup
options. They just provide the basic core to build upon.
## Help Files
Help files are linked into the OSX help system. Independent of what
browser you choose to open help files (`GRASS_HTML_BROWSER`), you can
open Help Viewer from almost any application's Help menu (it's best to
use Mac Help from the Finder Help menu), and GRASS Help will be
available in the Library menu.
Since they are linked to the help system, if GRASS.app is moved or
renamed, the link will be broken. This may change in the future.
## Addon Modules
modbuild deprecated (not installed now). Makefile changes in progress to
allow compiling external modules.
## Dependency Build Notes
They apply to any OSX build, not just an application package build:
### Universal Aqua Tcl/Tk
The simplest way to install Tcl/Tk Aqua is to download
[ActiveTcl](https://www.activestate.com/products/tcl/) from
ActiveState. This will give you a universal 32bit Tcl/Tk Aqua (64bit is
currently not possible). Make sure to run the *convenience* commands
below.
To make it easier to configure for GRASS (and other software), run these
commands in a Terminal:
```sh
sudo ln -sf /Library/Frameworks/Tcl.framework/Versions/8.5/Tcl \
/usr/local/lib/libtcl.dylib
sudo ln -sf /Library/Frameworks/Tcl.framework/Versions/8.5/Tcl \
/usr/local/lib/libtcl8.5.dylib
sudo ln -sf \
/Library/Frameworks/Tcl.framework/Versions/8.5/libtclstub8.5.a \
/usr/local/lib/libtclstub8.5.a
sudo ln -sf /Library/Frameworks/Tk.framework/Versions/8.5/Tk \
/usr/local/lib/libtk.dylib
sudo ln -sf /Library/Frameworks/Tk.framework/Versions/8.5/Tk \
/usr/local/lib/libtk8.5.dylib
sudo ln -sf /Library/Frameworks/Tk.framework/Versions/8.5/libtkstub8.5.a \
/usr/local/lib/libtkstub8.5.a
```
### Universal GPSBabel
A universal GPSBabel CLI executable is now included in the OSX binary
from [www.gpsbabel.org](https://www.gpsbabel.org/). This does not need to
be 64bit.
### Universal NetPBM
NetPBM is not too hard to build, it's just weird. These instructions
use my UnixImageIO framework for the tiff, jpeg, png and jasper
libraries.
First, grab the [NetPBM](http://netpbm.sourceforge.net/) source and
unzip it. Now it gets strange - it's an interactive configuration, and
the various stages don't communicate with each other. Cd to the source
folder in a Terminal and:
`./configure` ↵
`Platform [darwin] ==>` ↵
`Netpbm shared library directory [default] ==>` **`/usr/local`**
choose where you will install it
default is NOT /usr/local or any location at all, so you MUST set this
`regular or merge [regular] ==>` ↵
`static or shared [shared] ==>` ↵
could use static, since GRASS only needs a few of the progs
`'#include' argument or NONE [<inttypes.h>] ==>` ↵
`What is your JPEG (graphics format) library?`
`library filename or 'none' [libjpeg.so] ==>`
**`/Library/Frameworks/UnixImageIO.framework/unix/lib/libjpeg.dylib`**
`JPEG header directory [default] ==>`
**`/Library/Frameworks/UnixImageIO.framework/Headers`**
`What is your TIFF (graphics format) library?`
`library filename or 'none' [libtiff.so] ==>`
**`/Library/Frameworks/UnixImageIO.framework/unix/lib/libtiff.dylib`**
`TIFF header directory [default] ==>`
**`/Library/Frameworks/UnixImageIO.framework/Headers`**
`What is your PNG (graphics format) library?`
`library filename or 'none' [libpng.so] ==>`
**`/Library/Frameworks/UnixImageIO.framework/unix/lib/libpng.dylib`**
`PNG header directory [default] ==>`
**`/Library/Frameworks/UnixImageIO.framework/Headers`**
`What is your Z (compression) library?`
`library filename or 'none' [libz.so] ==>` **`-lz`**
`Z header directory [default] ==>` ↵
`Documentation URL [http://netpbm.sourceforge.net/doc/] ==>` ↵
ignore warning about libz
```sh
echo "JASPERLIB = \
/Library/Frameworks/UnixImageIO.framework/unix/lib/libjasper.dylib" \
>> Makefile.config
echo "JASPERHDR_DIR = /Library/Frameworks/UnixImageIO.framework/Headers" \
>> Makefile.config
```
For Tiger:
```sh
echo "CC = /usr/bin/gcc -arch ppc -arch i386 \
-isysroot /Developer/SDKs/MacOSX10.4u.sdk" \
>> Makefile.config
```
For Leopard:
```sh
echo "CC = /usr/bin/gcc -arch ppc -arch i386 -arch ppc64 -arch x86\_64" \
>> Makefile.config
```
```sh
make
make package pkgdir=/path/to/some/temp/dir
```
it will create the folder and copy all binaries there
`sudo ./installnetpbm`
then answer some more questions:
`Where is the install package you created with 'make package'?`
`package directory (/tmp/netpbm) ==>` **`/path/to/some/temp/dir`**
same location as specified in the make package step (lack of
inter-communication!)
`install prefix (/usr/local/netpbm) ==>` **`/usr/local`**
same location used for the Netpbm shared library directory (again,
lack of inter-communication!)
(it may ask you if you want to create the dir)
It'll ask for subfolders for bin, lib, data, headers, man
For data, type: **`/usr/local/share/netpbm`**
For man, type: **`/usr/local/share/man`**
For the rest, use the defaults
don't create the manweb.conf file
And that's it.
### Universal FFMPEG
version: [0.5](http://www.ffmpeg.org/download.html)
FFMPEG is constantly changing, and release versions are rare. For
simplicity use the 0.5 release version. If you know anything about SVN
you can try for a more up-to-date FFMPEG. Some options used below are
not in more recent SVN versions, so if configure complains about an
invalid option, just remove it.
This will build a basic FFMPEG as dynamic libraries for use with GRASS.
The default static libraries don't work now because of reloc errors and
the need for extra link flags. No extra formats are included, such as
mp3lame and xvid. None of the ffmpeg programs are included either (GRASS
doesn't need them).
It's a multi-step build, 1 for each architecture. Create a folder
inside the source for each arch:
```sh
mkdir build-i386
mkdir build-ppc
```
and also for Leopard:
```sh
mkdir build-x86_64
mkdir build-ppc64
```
For i386 and ppc arches, if building on Tiger, you must add the
following to extra-cflags and extra-ldflags in the configure command:
`-isysroot /Developer/SDKs/MacOSX10.4u.sdk`
For i386:
```sh
cd build-i386
../configure --enable-shared --disable-static --disable-debug \
--disable-ffserver --disable-network --enable-gpl --enable-pthreads \
--enable-swscale --disable-vhook --disable-ffplay --disable-ffmpeg \
--disable-amd3dnow --arch=i386 --extra-cflags="-arch i386" \
--extra-ldflags="-arch i386"
```
If you are building *on* a PPC Mac, you need to add the flag
"`--enable-cross-compile`" to the above configure command.
```sh
make
sudo make install
```
Install at this point installs everything. We don't care about the
installed libraries yet, we just need the headers there.
Now, the PPC build:
```sh
cd ../build-ppc
../configure --enable-shared --disable-static --disable-debug \
--disable-ffserver --disable-network --enable-gpl --enable-pthreads \
--enable-swscale --disable-vhook --disable-ffplay --disable-ffmpeg \
--enable-altivec --arch=ppc --extra-cflags="-arch ppc" \
--extra-ldflags="-arch ppc"
make
```
Don't install this one, there is no need.
If you are building for Leopard, also do the 64bit varieties, otherwise
skip to the lipo step below.
For x86_64:
```sh
cd build-x86_64
../configure --enable-shared --disable-static --disable-debug \
--disable-ffserver --disable-network --enable-gpl --enable-pthreads \
--enable-swscale --disable-vhook --disable-ffplay --disable-ffmpeg \
--disable-amd3dnow --arch=x86_64 --extra-cflags="-arch x86\_64" \
--extra-ldflags="-arch x86_64"
```
Again, if you are building *on* a PPC Mac, you need to add the flag
"`--enable-cross-compile`" to the above configure command.
`make`
And ppc64:
```sh
cd ../build-ppc64
../configure --enable-shared --disable-static --disable-debug \
--disable-ffserver --disable-network --enable-gpl --enable-pthreads \
--enable-swscale --disable-vhook --disable-ffplay --disable-ffmpeg \
--enable-altivec --arch=ppc64 --extra-cflags="-arch ppc64" \
--extra-ldflags="-arch ppc64"
```
Here, if you are building *on* an Intel Mac, you need to add the flag
"`--enable-cross-compile`" to the above configure command. Also, it
will fail to completely identify it as 64bit, so you need to fix 2
files.
In **config.h**, find the `HAVE_PPC64` define and set it to 1:
`#define HAVE_PPC64 1`
In **config.mak**, add this line to the end of the file:
`HAVE_PPC64=yes`
Then finish:
`make`
Now use lipo to merge them together, first drop down to the ffmpeg
source folder:
`cd ..`
For each of the libraries:
libavcodec
libavdevice
libavformat
libavutil
libswscale
run the following lipo command (fill in the **`[LIBNAME]`** in all
places). For Leopard:
```sh
sudo lipo -create \
build-ppc/[LIBNAME]/[LIBNAME].dylib \
build-i386/[LIBNAME]/[LIBNAME].dylib \
build-ppc64/[LIBNAME]/[LIBNAME].dylib \
build-x86_64/[LIBNAME]/[LIBNAME].dylib \
-output /usr/local/lib/[LIBNAME].dylib
```
For Tiger:
```sh
sudo lipo -create \
build-ppc/[LIBNAME]/[LIBNAME].dylib \
build-i386/[LIBNAME]/[LIBNAME].dylib \
-output /usr/local/lib/[LIBNAME].dylib
```
Done.
© 2006-2008 by the GRASS Development Team
This program is free software under the GNU General Public License (>=v2).
\- William Kyngesburye
<kyngchaos@kyngchaos.com>
<https://www.kyngchaos.com/>
|