Re: Installing Isis on Macbook

From: Michael Nowak <mnowak_at_email.domain.hidden>
Date: Wed, 20 Nov 2013 15:45:16 -0500
On Nov 20, 2013, at 1:20 PM, John Houck <houck_at_email.domain.hidden
> Mike Nowak recently gave somewhat different advice here:
>   http://space.mit.edu/cxc/isis/archive/2013/0911.html

My, possibly outdated advice (it was one Mac OS ago, and one major
version number ago on Xcode, despite this being just last August) is
appended below.

It's very easy these days to get 32 bit/64 bit accidentally mixed on an
Apple system.  Apple's really are going whole hog into 64 bit, so I think
it's a matter of sooner or later that HEASOFT will have to follow suit
and finally commit to 64 bit on Apple.  In the meantime, I've just found
it easier to maintain an XSPEC only 64 bit build, and a whole of 
HEASOFT 32 bit build, and have everything else on my Apple build
64 bit.

Let me know if anything is unclear in the appended.

Cheers,

Mike

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

August 18, 2013

How I Built HEASOFT (v6.14) and ISIS (v1.6.2-26) on my Apple Laptop
=================================================================
(Running OS X 10.8.4), Such That They Play Nicely Together
=========================================================

General Comments:

Getting a consistent set of astrophysical software working on an Apple
machine can be tricky.  It is often made more complicated by users
having downloaded a number of different packages (via Fink, Macports,
various different astrophysical packages, etc.) that may include
incompatible versions of libraries.  Problems are more likely to arise
if links to these software packages/libraries are automatically placed
in a user's path when starting up a terminal window.

A general rule of thumb is this: be aware of what you have downloaded,
know where it has been placed on your computer, and don't
automatically place these packages into your path until you actually
need them.

For example, when I open a terminal window on my laptop, I do not
automatically place any of the HEASOFT or CIAO software into my paths.
Instead I have a command:

   %> setxspec

which invokes:

   #! /bin/csh -f
   setenv  HEADAS /usr/local/xspec_only/heasoft-6.14/x86_64-apple-darwin12.4.0
   source $HEADAS/headas-init.csh
   setenv LMODDIR /usr/local/xspec_lmodels/heasoft_6.14

The same is true for when I use the CIAO software. (In the above, and
in what follows below, %> refers to a command line prompt in an Xterm
terminal window.)

The advice below is written for Apple Mountain Lion.  I realize that
many people are still running Snow Leopard (since Snow Leopard
maintains backwards compatibility with PPC architecture via running an
emulator).  A lot of astrophysical software was becoming more
difficult to maintain for Snow Leopard, so about 6 months ago I
switched to Mountain Lion.  I do *not* recommend switching from Snow
Leopard to Lion - go all the way to Mountain Lion if you are going to
make the switch.  It is likely that a lot of astrophysical software
will become "Mountain Lion" only in the not too distant future.

(Side note: These instructions, however, were successfully followed by
someone who built the software on an Apple Lion, OS X 10.7.x system.)

%%%%%%

1. Getting started: Make sure that your Apple Xcode is up to date, and
that you have installed *all* of the Xcode developer tools.  (The
developer tools are not automatically installed when installing
Xcode.)  Currently, I am running Xcode v.4.6.3.

Likewise, Apple no longer ships with an Xterm program, so make sure
that you have Xquartz installed:

   http://xquartz.macosforge.org/landing/

I am currently running Xquartz v2.7.4 (xorg-server 1.13.0).

(I am unsure whether or not Lion, OS X 10.7.x, still have Apple
supplied Xterm programs.)

Further, make sure that you have a working set of compilers.  The ones
that you need will be the Apple version of gcc and g++, found in
/usr/bin:

   %> /usr/bin/gcc --version
 i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
 Copyright (C) 2007 Free Software Foundation, Inc.
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

   %> /usr/bin/g++ --version
 i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
 Copyright (C) 2007 Free Software Foundation, Inc.
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

For Fortran, I have been using the Lion/Mountain Lion compatible
gfortran 4.7 version obtained from Sourceforge:

   http://hpc.sourceforge.net/

specifically,
http://prdownloads.sourceforge.net/hpc/gfortran-4.7-bin.tar.gz?download
which I have installed in /usr/local/bin:

   %> /usr/local/bin/gfortran --version
 GNU Fortran (GCC) 4.7.1
 Copyright (C) 2012 Free Software Foundation, Inc.

 GNU Fortran comes with NO WARRANTY, to the extent permitted by law.
 You may redistribute copies of GNU Fortran
 under the terms of the GNU General Public License.
 For more information about these matters, see the file named COPYING

With those preliminaries out of the way, you can now begin to build
XSPEC, S-lang, and ISIS.

%%%%%%

1. Download the XSPEC source code from:

   http://heasarc.gsfc.nasa.gov/lheasoft/download.html

On this web page under "STEP 1- Select the type of software:" choose
"Source code distribution".  Then, underneath "STEP 2 - Download the
desired packages:", select *only* Xspec.  Do not choose any other
packages.  

Then click "Submit".

This will create a gzipped tar file on your machine with a name, e.g.,
"heasoft-6.14src.tar.gz".

%%%%%%

2. Move and unpack this tar file into a directory.  On my laptop, I
build in directories only accessible to the root account, so I first
switch into the root account (%> sudo su), and then I switch to using
the csh (%> csh).  The software can just as easily be built in a bash
shell.  Usually this means replacing "%> setenv CC /usr/bin/gcc" with
"%> export CC=/usr/bin/gcc" in the instructions below.

*** WARNING: If you do build as root in the /usr/local directory, be
be very careful, especially when unpacking and deleting files.  For
example, I often add the -i option when deleting, e.g., %> rm -i
heasoft-6.14src.tar.gz, when working in the root directory.  I try to
stay away from using the wild card, *, in any commands, etc.  You can
build this software in other directories, usually by adding paths to
the ./configure options below.  Running the command %>./configure
--help will show you what options are available. ***

For my set up, I have unpacked the software into a directory:

   /usr/local/xspec_only

E.g.,

   %> cd /usr/local/xspec_only
   %> mv /Users/mnowak/Desktop/heasoft-6.14src.tar.gz .
   %> tar zxvf heasoft-6.14src.tar.gz

You can, of course, unpack the software into any directory you wish.

%%%%%%

3. Remove the heagen package - it cannot be built 64-bit.

   %> cd /usr/local/xspec_only/heasoft-6.14
   %> rm -Rf heagen

*** If you accidentally leave this library in the distribution, you
will automatically build a 32-bit version of the library.  This will
cause problems with ISIS and with some XSPEC "local models".  See the
warning in step 5 below. ***

%%%%%%

4. Explicitly set the compilers that you will use for the build.  In
this case, these are the Apple gcc & c++, and the sourceforge gfortran
v4.7.1.  (Contrary to what it says on the XSPEC page, I have had
little luck with any versions of g95, and I have not tried compilers
from Macports, nor have I extensively tried gfortran v4.8.)

   %> setenv CC /usr/bin/gcc
   %> setenv CXX /usr/bin/g++
   %> setenv FC /usr/local/bin/gfortran

%%%%%%

5. Move to the BUILD_DIR directory:

   %> cd /usr/local/xspec_only/heasoft-6.14/BUILD_DIR

and then build XSPEC via the instructions outlined below.  Note that
you have to explicitly identify the paths to the X11 libraries.  Each
step below may take a while to run.  *** Be sure that the previous
command has finished before starting the next command. *** (To see if
a command has finished, type, for example, "%> tail build.log".  You
should see a statement saying "Finished" if the command has
successfully completed.)

   %> ./configure --x-libraries=/usr/X11/lib --x-includes=/usr/X11/include >& config.out &
   %> make >& build.log &
   %> make install >& install.log &

The above build should have automatically occurred in 64-bit, and
should have been placed in a directory such as:

   /usr/local/xspec_only/heasoft-6.14/x86_64-apple-darwin12.4.0

If you see "i386" anywhere in that path name, something has gone wrong
and you have accidentally built a 32-bit version of the library!  (The
name of the created directory might be slightly different on your
machine, but should have x86_64 as part of it, *not* i386)

%%%%%%

6. We are now going to make use of some of the libraries that we just
built in this version of XSPEC, so set up an environment variable
pointing to this build (CHECK FOR THE NAME OF THE PATH ON YOUR
SPECIFIC MACHINE):

   %> setenv HEADAS /usr/local/xspec_only/heasoft-6.14/x86_64-apple-darwin12.4.0

%%%%%%

7.  Now we build S-lang.  The source code can be obtained from 
   
   http://jedsoft.org/slang/

The current version is 2.2.4 (do *not* get any "pre-release" version),
which on my machine I have unpacked into the directory:

   /usr/local/slang-2.2.4

Changing to that directory, we first run a configure script, using
readline from the XSPEC build, and making sure to explicitly point to
the X11 libraries.  (I am also building without a number of libraries
that are not necessary for use in ISIS.  A number of these are very
useful libraries for more advanced scripting using S-lang.)  We then
build and install the S-lang library. 

   %> cd /usr/local/slang-2.2.4
   %> ./configure --without-pcre --without-png --without-z --without-iconv --with-readline=$HEADAS --x-libraries=/usr/X11/lib --x-includes=/usr/X11/include
   %> make
   %> make install
   %> make clean

%%%%%%

8. Now we install ISIS.  The current version, 1.6.2-26, can be found
here:

   http://space.mit.edu/ASC/ISIS/download.html

(ISIS is updated frequently, so don't worry if it's several sub-minor
versions greater than -26 when you download it.  Such minor
sub-versions are usually small enhancements to the functionality, or
very minor bug fixes.  Nothing should change that affects the build
properties.)  On my machine, I have unpacked the program into the
directory:

   /usr/local/isis-1.6.2-26

The build is very similar to the S-lang build in that we have to make
sure we explicitly point to the X11 libraries, and use the readline,
PGPLOT, and CFITSIO libraries found in the XSPEC build.

   %> cd /usr/local/isis-1.6.2-26
   %> ./configure --x-libraries=/usr/X11/lib --x-includes=/usr/X11/include --with-readline=$HEADAS --with-headas=$HEADAS
   %> make
   %> make install
   %> make clean

And you're done!  You should now have a working, 64 bit version of
both XSPEC and ISIS.  The ISIS executable will be in /usr/local/bin,
while XSPEC can be added to your path via:

   %> setenv  HEADAS /usr/local/xspec_only/heasoft-6.14/x86_64-apple-darwin12.4.0
   %> source $HEADAS/headas-init.csh

%%%%%%

9. In order to get the rest of HEASOFT setup on your Apple laptop, you
must create a separate installation *using 32-bit flags* on the
compilers.  

Again, go to the HEASOFT download web site:

   http://heasarc.gsfc.nasa.gov/lheasoft/download.html

and this time download the *entire* HEASOFT package by clicking "all".
This will again give you a gzipped tar file: heasoft-6.14src.tar.gz

In this case, I have moved the package to the /usr/local directory, and
have built it in /usr/local/heasoft-6.14

   %> cd /usr/local/
   %> mv /Users/mnowak/Desktop/heasoft-6.14src.tar.gz .
   %> tar zxvf heasoft-6.14src.tar.gz
   %> cd /usr/local/heasoft-6.14/BUILD_DIR

The compilers have to be set to explicitly use their 32-bit modes:

   %> setenv CC "/usr/bin/gcc -m32"
   %> setenv CXX "/usr/bin/g++ -m32"
   %> setenv FC "/usr/local/bin/gfortran -m32"

The build then proceeds as normal:

   %> ./configure --x-libraries=/usr/X11/lib --x-includes=/usr/X11/include >& config_32bit.out &
   %> make >& build_32bit.log &
   %> make install >& install_32bit.log &

The above build should have been placed in a directory such as:

   /usr/local/heasoft-6.14/i386-apple-darwin12.4.0

This 32-bit version of HEASOFT can now be placed into your path by:

   %> setenv HEADAS /usr/local/heasoft-6.14/i386-apple-darwin12.4.0
   %> source $HEADAS/headas-init.csh

%%%%%%

10.  Getting help: If you run into any problems installing ISIS,
please send an e-mail to the ISIS users mail group:

   isis-users_at_email.domain.hidden
Please give as much detail as possible about how you attempted to
build the code, and please include copies of your
/usr/local/isis-1.6.2-26/config.log and
/usr/local/isis/-1.6.2-26/config.status files.




----
You received this message because you are
subscribed to the isis-users list.
To unsubscribe, send a message to
isis-users-request_at_email.domain.hiddenwith the first line of the message as:
unsubscribe
Received on Wed Nov 20 2013 - 15:45:48 EST

This archive was generated by hypermail 2.3.0 : Fri May 02 2014 - 08:35:47 EDT