diff -ruN ccp4-6.1.13-dist/ccp4i/bin/imosflm ccp4-6.1.13/ccp4i/bin/imosflm
--- ccp4-6.1.13-dist/ccp4i/bin/imosflm	2009-02-17 05:34:02.000000000 -0800
+++ ccp4-6.1.13/ccp4i/bin/imosflm	2010-06-14 14:19:56.000000000 -0700
@@ -1,3 +1,15 @@
 #!/bin/sh
 # Start iMosflm interface
+if [[ $(uname) == Darwin  ]];then
+
+	CCP4_BROWSER=""
+	export CCP4_BROWSER="Safari"
+
+	if [[ $(sw_vers -productVersion) < 10.6 ]]; then
+	    true
+	else
+	    export MOSFLM_WISH=/usr/bin/wish8.4
+	fi
+fi
+
 exec $CCP4I_TOP/imosflm/src/imosflm
diff -ruN ccp4-6.1.13-dist/ccp4i/etc/configure.def.dist ccp4-6.1.13/ccp4i/etc/configure.def.dist
--- ccp4-6.1.13-dist/ccp4i/etc/configure.def.dist	2009-08-26 10:50:10.000000000 -0700
+++ ccp4-6.1.13/ccp4i/etc/configure.def.dist	2010-06-14 14:26:32.000000000 -0700
@@ -61,8 +61,8 @@
 MESSAGE                   _text				""
 BLT_LIBRARY               _text                     ""
 MENU_LENGTH               _positiveint              25
-HYPERTEXT_VIEWER          _text                     firefox
-START_NETSCAPE	          _text			    netscape
+HYPERTEXT_VIEWER          _text                     safari
+START_NETSCAPE	          _text			            open
 O_MAPMAN                  _text                     mapman
 MAPMAN_MAXSIZE		  _positiveint		    4194304
 QUANTA_MBKALL             _text                     mbkall
diff -ruN ccp4-6.1.13-dist/ccp4i/etc/osx_ccp4_mail ccp4-6.1.13/ccp4i/etc/osx_ccp4_mail
--- ccp4-6.1.13-dist/ccp4i/etc/osx_ccp4_mail	1969-12-31 16:00:00.000000000 -0800
+++ ccp4-6.1.13/ccp4i/etc/osx_ccp4_mail	2010-06-14 14:27:10.000000000 -0700
@@ -0,0 +1,164 @@
+#!/usr/bin/perl
+# Drop-in replacement for /usr/bin/mail that uses Mail.app (via an
+# applescript) rather than sendmail to send mail.  Unlike /usr/bin/mail,
+# you can't use it for reading mail.
+#
+# usage: mail [<options>] <recipients>
+#     options:
+#         -v           be verbose
+#         -g           activate Mail.app to approve the message
+#         -F <from>    specify the From: address
+#         -b <bcc>     specify Bcc: recipients in a comma-separated list
+#         -c <cc>      specify Cc: recipients in a comma-separated list
+#         -s <subject> specify the message subject
+#
+# The body of the message is read from standard input.
+#
+# Author: Nathaniel Nystrom <nystrom@cs.cornell.edu>
+# This software is in the public domain.
+#
+# Version 1.0,   21 Aug 2003 -- initial version
+# Version 1.0.1, 22 Aug 2003 -- fixes some quoting problems
+# Version 1.0.2, 23 Aug 2003 -- removed -R <reply-to> option; |reply to|
+#                               is a property of _incoming_ messages
+# Version 1.0.3, 17 Sep 2003 -- fixed escaping of \ in message body;
+#                               escape the subject too
+
+use strict;
+$|++;
+
+my ($verbose, $gui);
+my ($from, @to, @cc, @bcc, $subject, $body);
+my $prog;
+($prog = $0) =~ s|.*/||;
+
+while (@ARGV) {
+    my $arg = shift @ARGV;
+
+    if ($arg eq '-v') {
+        $verbose++;
+    }
+    elsif ($arg eq '-g') {
+        $gui++;
+    }
+    elsif ($arg eq '-F') {
+        $from = shift @ARGV || &usage("missing sender");
+    }
+    elsif ($arg eq '-i' || $arg eq '-l' || $arg eq '-n') {
+        # ignore; for /usr/bin/mail compatibility
+    }
+    elsif ($arg eq '-N' || $arg eq '-f' || $arg eq '-u') {
+        &usage("invalid option $arg; $prog cannot be used for reading mail");
+    }
+    elsif ($arg eq '-s') {
+        $subject = shift @ARGV || &usage("missing subject");
+    }
+    elsif ($arg eq '-c') {
+        my $list = shift @ARGV || &usage("missing Cc list");
+        @cc = split /\s*,\s*/, $list;
+    }
+    elsif ($arg eq '-b') {
+        my $list = shift @ARGV || &usage("missing Bcc list");
+        @bcc = split /\s*,\s*/, $list;
+    }
+    elsif ($arg =~ /^-/) {
+        &usage("invalid option $arg");
+    }
+    else {
+        @to = ($arg, @ARGV);
+        last;
+    }
+}
+
+&usage("missing recipients") unless @to;
+
+unless (defined $subject) {
+    print "Subject: ";
+    $subject = <STDIN> || '';
+    chomp $subject;
+}
+
+$body = '';
+
+while (<STDIN>) {
+    $body .= $_;
+}
+
+$body = &escape($body);
+$subject = &escape($subject);
+
+my $script = <<"EOS";
+tell application "Mail"
+    set newMessage to make new outgoing message
+    tell newMessage
+        set subject to "$subject"
+        set content to "$body"
+EOS
+
+for (@to)  { $script .= &recipient('to', $_); }
+for (@cc)  { $script .= &recipient('cc', $_); }
+for (@bcc) { $script .= &recipient('bcc', $_); }
+
+my $visible = $gui ? "true" : "false";
+my $activate = $gui ? "activate" : "send newMessage";
+my $fromln = $from ? "set sender to \"$from\"" : "";
+
+$script .= <<"EOS";
+        $fromln
+        set visible to $visible
+    end tell
+    $activate
+end tell
+EOS
+
+if ($verbose >= 1) {
+    print "From: $from\n" if $from;
+    print "To: ", join(',', @to), "\n" if @to;
+    print "Cc: ", join(',', @cc), "\n" if @cc;
+    print "Bcc: ", join(',', @bcc), "\n" if @bcc;
+
+    if ($verbose >= 2) {
+        print "Script >>>\n";
+        print $script;
+        print "<<<\n";
+        print "\n";
+        print $body;
+    }
+}
+
+open(SCRIPT, "| osascript > /dev/null") || die "Couldn't fork osascript: $!\n";
+print SCRIPT $script;
+close SCRIPT;
+
+exit 0;
+
+sub escape {
+    my $x = shift;
+    $x =~ s/\\/\\\\/gm;
+    $x =~ s/"/\\"/gm;
+    $x =~ s/\n/\\n/gm;
+    $x;
+}
+
+sub recipient {
+    my ($type,$addr) = @_;
+    return <<"EOS"
+        make new $type recipient at end of $type recipients with properties {address: "$addr"}
+EOS
+}
+
+sub usage {
+    my $error = shift;
+    print STDERR "Error: $error\n" if $error;
+    print STDERR <<"EOS";
+usage: $prog [<options>] <recipients>
+    options:
+        -v           be verbose
+        -g           activate Mail.app to approve the message
+        -F <from>    specify the From: address
+        -b <bcc>     specify Bcc: recipients in a comma-separated list
+        -c <cc>      specify Cc: recipients in a comma-separated list
+        -s <subject> specify the message subject
+EOS
+    exit 1;
+}
diff -ruN ccp4-6.1.13-dist/ccp4i/src/local.tcl ccp4-6.1.13/ccp4i/src/local.tcl
--- ccp4-6.1.13-dist/ccp4i/src/local.tcl	2009-03-09 09:41:35.000000000 -0700
+++ ccp4-6.1.13/ccp4i/src/local.tcl	2010-06-14 14:28:46.000000000 -0700
@@ -34,7 +34,7 @@
 #d_arg mail_address Mail addressee
 
 return [expr {1 - [catch \
-   "exec Mail -s \"$subject\" $mail_address < $tmp_file"  ]}]
+   "exec osx_ccp4_mail -s \"$subject\" $mail_address < $tmp_file"  ]}]
 }
 
 #d_index_title Interaction with Netscape
diff -ruN ccp4-6.1.13-dist/configure ccp4-6.1.13/configure
--- ccp4-6.1.13-dist/configure	2010-03-08 06:35:46.000000000 -0800
+++ ccp4-6.1.13/configure	2010-06-14 14:33:32.000000000 -0700
@@ -2452,7 +2452,7 @@
   XMKMF="IMAKECPP=/usr/bin/cpp xmkmf"
   if test "$shared_lib" = yes; then
     SHARED_LIB_CFLAGS=${SHARED_LIB_CFLAGS:-'-fPIC -fno-common'}
-    SHARE_LIB='${CC} -dynamiclib -flat_namespace -undefined suppress ${SHARED_LIB_CFLAGS} -install_name ${libdir}/libmmdb.dylib -o libmmdb.dylib ${MMDBOBJS} -lstdc++; ${CC} -dynamiclib -flat_namespace -undefined suppress ${SHARED_LIB_CFLAGS} -install_name ${libdir}/libccp4c.dylib -o libccp4c.dylib ${CORELIBOBJS} ${CGENERALOBJS} ${CUCOBJS} ${CMTZOBJS} ${CMAPOBJS} ${CSYMOBJS}'
+  	SHARE_LIB='${CC} -dynamiclib -flat_namespace -undefined suppress ${SHARED_LIB_CFLAGS} -install_name ${rpath}/libmmdb.dylib -o libmmdb.dylib ${MMDBOBJS} -lstdc++; ${CC} -dynamiclib -flat_namespace -undefined suppress ${SHARED_LIB_CFLAGS} -install_name ${rpath}/libccp4c.dylib -o libccp4c.dylib ${CORELIBOBJS} ${CGENERALOBJS} ${CUCOBJS} ${CMTZOBJS} ${CMAPOBJS} ${CSYMOBJS}'
     SHARE_INST='${INSTALL_DATA} `pwd`/libmmdb.dylib ${libdir}/libmmdb.dylib; ${INSTALL_DATA} `pwd`/libccp4c.dylib ${libdir}/libccp4c.dylib'
   fi     
 #need -lcc_dynamic to get restFP and saveFP for g77 3.4 under darwin 7
@@ -2584,7 +2584,7 @@
   if test "$shared_lib" = yes; then
     LD=${LD:-"ld"}
     XLDFLAGS="-limf -lirc"
-    SHARE_LIB=${SHARE_LIB:-'${LD} -dylib -dynamic -flat_namespace -undefined suppress -dylib_install_name ${libdir}/libmmdb.dylib -o libmmdb.dylib ${MMDBOBJS} ${CXX_LIBS} -limf -ldylib1.o; ${LD} -dylib -dynamic -flat_namespace -undefined suppress -dylib_install_name ${libdir}/libccp4c.dylib -o libccp4c.dylib ${CORELIBOBJS} ${CGENERALOBJS} ${CUCOBJS} ${CMTZOBJS} ${CMAPOBJS} ${CSYMOBJS} -ldylib1.o;'}
+ 	SHARE_LIB=${SHARE_LIB:-'${LD} -dylib -dynamic -flat_namespace -undefined suppress -dylib_install_name ${rpath}/libmmdb.dylib -o libmmdb.dylib ${MMDBOBJS} -lirc -limf -ldylib1.o; ${LD} -dylib -dynamic -flat_namespace -undefined suppress -dylib_install_name ${rpath}/libccp4c.dylib -o libccp4c.dylib ${CORELIBOBJS} ${CGENERALOBJS} ${CUCOBJS} ${CMTZOBJS} ${CMAPOBJS} ${CSYMOBJS} -ldylib1.o;'}
     SHARE_INST='$(INSTALL_DATA) `pwd`/libmmdb.dylib $(libdir)/libmmdb.dylib; $(INSTALL_DATA) `pwd`/libccp4c.dylib $(libdir)/libccp4c.dylib;'
     LDCXXFLAGS="-lccp4c -lmmdb \$(XCIF_LIB) \$(XLAPACK_LIB) \$(C_LIBS) \$(XLDFLAGS) -lstdc++"
   fi     
@@ -4058,7 +4058,8 @@
   CFLAGS="${COPTIM} ${XCFLAGS}"
   FFTW_LIBS="-L${prefix}/lib -lrfftw -lfftw"
   FFTW_CXXFLAGS="-I${prefix}/lib/fftw/fftw -I${prefix}/lib/fftw/rfftw -I${prefix}/include"
-  export CFLAGS
+  FLIBS="-L@PREFIX@/lib/gcc4.4/lib -lgfortran"
+  export CFLAGS FLIBS 
 # must use --enable-float
   xopts="--enable-float"
   if test "$shared_lib" = yes; then
diff -ruN ccp4-6.1.13-dist/etc/xloggraph ccp4-6.1.13/etc/xloggraph
--- ccp4-6.1.13-dist/etc/xloggraph	1969-12-31 16:00:00.000000000 -0800
+++ ccp4-6.1.13/etc/xloggraph	2010-06-14 14:34:17.000000000 -0700
@@ -0,0 +1,6 @@
+#!/bin/zsh
+export XUSERFILESEARCHPATH=$CLIB/X11/app-defaults/XCCPJiffy
+xloggraph.exe "$@" &
+export XUSERFILESEARCHPATH=""
+print "Plot button sends pdf to Preview.  Print or save pdf in Preview window."
+exit 0
diff -ruN ccp4-6.1.13-dist/etc/xplot84 ccp4-6.1.13/etc/xplot84
--- ccp4-6.1.13-dist/etc/xplot84	1969-12-31 16:00:00.000000000 -0800
+++ ccp4-6.1.13/etc/xplot84	2010-06-14 14:35:00.000000000 -0700
@@ -0,0 +1,6 @@
+#!/bin/zsh
+export XUSERFILESEARCHPATH=$CLIB/X11/app-defaults/XCCPJiffy
+xplot84driver.exe "$@" &
+export XUSERFILESEARCHPATH=""
+print "Plot button sends pdf to Preview.  Print or save pdf in Preview window."
+exit 0
diff -ruN ccp4-6.1.13-dist/etc/xplot84driver ccp4-6.1.13/etc/xplot84driver
--- ccp4-6.1.13-dist/etc/xplot84driver	1969-12-31 16:00:00.000000000 -0800
+++ ccp4-6.1.13/etc/xplot84driver	2010-06-14 14:34:54.000000000 -0700
@@ -0,0 +1,6 @@
+#!/bin/zsh
+export XUSERFILESEARCHPATH=$CLIB/X11/app-defaults/XCCPJiffy
+xplot84driver.exe "$@" &
+export XUSERFILESEARCHPATH=""
+print "Plot button sends pdf to Preview.  Print or save pdf in Preview window."
+exit 0
diff -ruN ccp4-6.1.13-dist/include/ccp4.setup-bash ccp4-6.1.13/include/ccp4.setup-bash
--- ccp4-6.1.13-dist/include/ccp4.setup-bash	2010-03-04 07:18:38.000000000 -0800
+++ ccp4-6.1.13/include/ccp4.setup-bash	2010-06-14 14:59:08.000000000 -0700
@@ -1,9 +1,64 @@
 #!/bin/bash
-# CCP4 setup file for bash or ksh (untested) users.  -*- shell-script -*-
-# Actually, the aliases can't work asis in ksh.  Should use builtins instead
-# and not worry about ease of keeping in step with the csh one.
+# [The above is just for emacs -- this file should not be executed.]
+
+# CCP4 setup file for bash users.  -*- shell-script -*-
+# $Id: ccp4.setup-bash,v 1.91.2.3 2008/06/09 08:51:17 ccb Exp $
+
+###############################################################################
+
+# Edit this for the current version of ccp4:
+   # if [[ -z $CCP4_VERSION ]];then
+        CCP4_VERSION="ccp4-6.1.13"
+   # fi
+
+###############################################################################
+
+# NOTE: You should not need to edit the rest of this file unless you want to over-ride the 
+# following assignments of $CCP4_MASTER and $BLTWISHPREFIX
+
+# NOTE:  If you have installed ccp4 on OS X with fink, you should not need to
+# change this file or to source it (fink takes care of sourcing it for you).
+
+    # CCP4_MASTER is the location of the top-level directory containing `ccp4'.  
+    # Set it manually by uncommenting and editing the following line:
+    
+    # export CCP4_MASTER="@PREFIX@/share/xtal"
+    
+    # or discover it from the source command if we have a current version of the bash shell
+    
+      #  if [[ -z "$CCP4_MASTER"  ]];then
+            if [[ ${BASH_VERSION} > 3 ]];then
+                CCP4_MASTER="$(dirname $(dirname $(dirname ${BASH_SOURCE} )))"  
+            else
+                # Attempt to this the hard way for older versions of bash
+                if [[ -d "@PREFIX@/share/xtal/${CCP4_VERSION}" ]]; then
+                    CCP4_MASTER="@PREFIX@/share/xtal"
+                elif [[ -d "@PREFIX@/share/xtal/${CCP4_VERSION}" ]]; then
+                    CCP4_MASTER="@PREFIX@/share/xtal" 
+                elif [[ -d "/usr/local/${CCP4_VERSION}" ]]; then
+                    CCP4_MASTER="/usr/local"    
+                elif [[ -d "/usr/local/ccp4/${CCP4_VERSION}" ]]; then
+                    CCP4_MASTER="/usr/local/ccp4"   
+                elif [[ -d "@PREFIX@/share/xtal/ccp4/${CCP4_VERSION}" ]]; then
+                    CCP4_MASTER="@PREFIX@/share/xtal/ccp4"
+                else
+                    CCP4_MASTER="@PREFIX@/share/xtal"
+                fi
+            fi
+      #  fi
+        
+        export CCP4_MASTER
+
+
+    # Discover where bltwish executable is located
+
+    if [[ -z $BLTWISHPREFIX &&  -x $(which bltwish) ]];then
+        BLTWISHPREFIX=$( dirname $( which bltwish )  )
+    fi
+ 
+###############################################################################
+
 
-# $Id: ccp4.setup-bash,v 1.102.2.8 2010/03/04 15:18:38 ccb Exp $
 
 # This file is site specific and may also contain machine-specifics.  The CCP4
 # administrator will have to edit this file and then have anyone who wants to
@@ -20,16 +75,6 @@
 # three sections. You MUST check the first section. You may want to check
 # the second. You don't need to look at the third.
 
-################### THIS SECTION SHOULDN'T NEED EDITING #####################
-
-# first emulate csh setenv and alias so we can keep the bash and csh
-# versions as similar as possible
-setenv  () { export $1="$2" ; }
-# Note that bash has a (different) alias command so we need to undo this
-# later.  I wonder if it is robust :-)
-if [ "`basename $SHELL`" != "ksh" ]; then # can't redefine alias in ksh
-alias () { eval `echo 'function '; echo $1; shift; echo '{ ' $*; echo '; }'` ; }
-fi
 
 ################### THIS SECTION MUST BE EDITED #####################
 
@@ -37,51 +82,66 @@
 # This is usually the directory in which you ran the tar command to unpack the
 # code, and is assumed to be shared between machines at a multi-machine site.
 
-setenv CCP4_MASTER	/xtal                    
-setenv CCP4		$CCP4_MASTER/ccp4-6.1.13
+# CCP4_MASTER="@PREFIX@/share/xtal"; export CCP4_MASTER  
+# CCP4="$CCP4_MASTER/ccp4-6.1.13"  ; export CCP4
 
 # Check for existence of CCP4_MASTER
-if (! test -d $CCP4_MASTER) ; then
+if [[ ! -d $CCP4_MASTER ]] ; then
     echo "********************* WARNING **********************"
     echo "The directory $CCP4_MASTER"
     echo "(assigned to CCP4_MASTER) does not exist."
     echo "The CCP4 programs will not run correctly, and any"
     echo "installation attempt will have errors or will fail."
     echo "********************* WARNING **********************"
+else
+    if [[ -d "$CCP4_MASTER/$CCP4_VERSION"  ]];then                 
+        CCP4="$CCP4_MASTER/$CCP4_VERSION" ; export CCP4
+    else
+        echo "The directory "$CCP4_MASTER/$CCP4_VERSION" cannot be found."
+        echo " Please check that "$CCP4_VERSION" is the right ccp4 version. "
+    fi
 fi
 
+
 # CCP4_SCR: a per-user directory for run-time-generated scratch
 # files. A dedicated scratch filesystem is probably better than (/usr)/tmp
 # BINSORT_SCR: a scratch directory for binsort's use; normally same as CCP4_SCR
 
-setenv CCP4_SCR      /tmp/$USER	
+export CCP4_SCR="/tmp/$USER"    
 # check to see if this exists and if not try to make it
 test -d $CCP4_SCR || mkdir $CCP4_SCR
 test -d $CCP4_SCR || \
     echo "Unable to make CCP4_SCR. CCP4 progs will not run correctly."
 
-setenv BINSORT_SCR   $CCP4_SCR
+export BINSORT_SCR="$CCP4_SCR"
 
 ### CCP4i setup - you may need to edit CCP4I_TCLTK ###
 # CCP4I_TOP - the top directory of the interface
-setenv CCP4I_TOP ${CCP4}/ccp4i
+export CCP4I_TOP="${CCP4}/ccp4i"
 # CCP4I_TCLTK - directory containing tclsh,wish and bltwish executables
 #               as used in $CCP4I_TOP/bin/ccp4i,ccp4ish,loggraph
-#               For 'standard' installations this is /usr/local/bin
+#               For 'standard' installations this is @PREFIX@/bin
 #               but note the SGI distributed version of Tcl/Tk is not 
 #               appropriate version
-setenv CCP4I_TCLTK /usr/local/bin        
+#  export CCP4I_TCLTK="@PREFIX@/bin"    
+if [[ -d "$BLTWISHPREFIX"  &&  -x "$BLTWISHPREFIX/bltwish" ]]; then
+    export CCP4I_TCLTK="$BLTWISHPREFIX"
+else
+    echo " Cannot find bltwish executable. Please make sure it is in your \$PATH "
+fi
+
+    
 # CCP4I_HELP - directory contain ccp4i help - default is $CCP4I_TOP/help
-setenv CCP4I_HELP ${CCP4I_TOP}/help
+export CCP4I_HELP="${CCP4I_TOP}/help"
 
 ### Optional - setting http_proxy environment
-# The commented out 'setenv' line below may have to be declared to download
+# The commented out 'export' line below may have to be declared to download
 # and edit protein sequences using the new "Import/Edit Protein Sequences"
 # (This may also be required for remote job submission in arp/warp.)
 # task. If so, uncomment this line and replace the example proxy URL with your
 # relevant URL
 
-#setenv HTTP_PROXY wwwblah.blah.ac.uk:xxxx/blah.blah
+#export HTTP_PROXY wwwblah.blah.ac.uk:xxxx/blah.blah
 
 ################### NOVICE USERS STOP HERE #####################
 
@@ -93,17 +153,16 @@
 # When deciding local policy, bear in mind the possible existence of
 # other CCP4 installations, and the possibility of non-CCP4 programs
 # with conflicting names.
-ccp4_first_in_path=1
+ccp4_first_in_path=0
 
 # The following checks the CCP4 server for available updates, and reports back.
-# Uncomment this line if you want to know about available updates.
-
-#eval python -V >& /dev/null && python $CCP4/etc/ccp4_updates.py -l
+# Comment this line out if you find it annoying.
+# eval python -V >& /dev/null && python $CCP4/etc/ccp4_updates.py -l
 
 # Set GFORTRAN_UNBUFFERED_ALL to either 1 or Y to ensure that the logfile
 # output from programs compiled with Gfortran is in the correct order.
 # Note that there will be some performance penalty for this.
-setenv GFORTRAN_UNBUFFERED_ALL Y
+# # # # export GFORTRAN_UNBUFFERED_ALL="Y"
 
 # The commented-out switch statement below provides an example of how
 # to use this file for several machines/architectures sharing $CCP4_MASTER.
@@ -120,92 +179,69 @@
 #   MCTYPE: used for LAUE make -- see LAUE documentation
 #   CCP4_BROWSER: set this if you intend to use the html documentation
 #      (recommended).  It should have the path and name of a html browser eg
-#      /usr/bin/X11/mozilla or /usr/local/bin/lynx. The browser will be
+#      /usr/bin/X11/mozilla or @PREFIX@/bin/lynx. The browser will be
 #      started with the alias ccp4help and will open the file
 #      $CHTML/INDEX.html.
 
-#   case `hostname` in			# edit this case statement if used
-#                                       # for multiple systems
-#   foo)
-    setenv CBIN      $CCP4/bin		
-    setenv CLIB      $CCP4/lib	
+ 
+    export CBIN="$CCP4/bin"        
+    export CLIB="$CCP4/lib"    
 
-    setenv CCP4_BROWSER  firefox             
+    CCP4_BROWSER=""; export CCP4_BROWSER="Safari"             
 
     if test "$MANPATH"; then
-      if [ $ccp4_first_in_path -eq 1 ]; then
-        setenv MANPATH ${CCP4}/man:${MANPATH}
+      if [[ $ccp4_first_in_path -eq 1 ]]; then
+        export MANPATH="${CCP4}/man:${MANPATH}"
       else
-        setenv MANPATH ${MANPATH}:${CCP4}/man
+        export MANPATH="${MANPATH}:${CCP4}/man"
       fi
     else
       if [ $ccp4_first_in_path -eq 1 ]; then
-        setenv MANPATH ${CCP4}/man:/usr/share/man
+        export MANPATH="${CCP4}/man:/usr/share/man"
       else
-        setenv MANPATH /usr/share/man:${CCP4}/man
+        export MANPATH="/usr/share/man:${CCP4}/man"
       fi
     fi
+    export MCTYPE="unix"             # (only for Laue)
+ 
 
-    if test -d $CCP4_MASTER/laue
-    then
-      setenv MCTYPE        unix 			# (only for Laue)
+    if [[   $(uname) == Darwin && $(sw_vers -productVersion) < 10.5 ]];then
+        ulimit -s 65536
     fi
-
-#     ;;
-#   *)
-#     echo "CCP4 not implemented on this system"
-#     exit 1
-#     ;;
-# esac
-
-case `uname` in
-*Darwin* )
-  ulimit -s 65536
-  ;;
-* )
-  ;;
-esac
+ 
 
 # The following are for all systems
-setenv CCP4_LIB $CLIB
-setenv CCP4_BIN $CBIN
+export CCP4_LIB="$CLIB"
+export CCP4_BIN="$CBIN"
 
 # CLASSPATH for Java
 if test "$CLASSPATH"; then
-  if [ $ccp4_first_in_path -eq 1 ]; then
-    setenv CLASSPATH ${CBIN}:${CLASSPATH}
+  if [[ $ccp4_first_in_path -eq 1 ]]; then
+    export CLASSPATH="${CBIN}:${CLASSPATH}"
   else
-    setenv CLASSPATH ${CLASSPATH}:${CBIN}
+    export CLASSPATH="${CLASSPATH}:${CBIN}"
   fi
 else
   if [ $ccp4_first_in_path -eq 1 ]; then
-    setenv CLASSPATH ${CBIN}:.
+    export CLASSPATH="${CBIN}:."
   else
-    setenv CLASSPATH .:${CBIN}
+    export CLASSPATH=".:${CBIN}"
   fi
 fi
 
-#Python path for the subprocess fixed module
-
-if [ $ccp4_first_in_path -eq 1 ]; then
-    setenv PYTHONPATH ${CCP4}/share/python:${PYTHONPATH}
-else
-    setenv PYTHONPATH ${PYTHONPATH}:${CCP4}/share/python
-fi
-
 ### PLOT_COMMAND PRINT_COMMAND for the XCCPJIFFY programs to compile ###
-setenv PLOT_COMMAND   'lp -s -dmicrolaser'  
-setenv PRINT_COMMAND  'lp -s -denscript'    
+export PLOT_COMMAND='lp -s -dmicrolaser'  
+export PRINT_COMMAND='lp -s -denscript'    
 
 # HARVESTHOME specifies location of harvesting files (defaults to $HOME)
-#setenv HARVESTHOME     
+#export HARVESTHOME     
 
 ### CCP4_OPEN ###
 # CCP4_OPEN may be set to 'UNKNOWN' to stop open failures for files opened 
 # as NEW that already exist.  Novices should use 'NEW' to avoid inadvertant 
 # over-writing of existing files, which is then treated as a fatal error.
 
-setenv CCP4_OPEN        UNKNOWN	
+export CCP4_OPEN="UNKNOWN"    
 
 ### BINSORT_MEM ###
 # BINSORT_MEM is workspace used by the binsort program.  In principle this
@@ -215,76 +251,64 @@
 # values -- 102400 (bytes) is the default.  csh's `time' command can tell you
 # about paging.
 #
-#  setenv BINSORT_MEM     8388608
+#  export BINSORT_MEM="8388608"
 
 # LD_LIBRARY_PATH specifies where to find dynamic libraries (e.g. libccp4.so)
 # at runtime
-if test "$LD_LIBRARY_PATH"; then
-  if [ $ccp4_first_in_path -eq 1 ]; then
-    setenv LD_LIBRARY_PATH ${CLIB}:${LD_LIBRARY_PATH}
-  else
-    setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:${CLIB}
-  fi
-else
-  setenv LD_LIBRARY_PATH ${CLIB}
-fi
-
-# DYLD_LIBRARY_PATH specifies where to find dynamic libraries (e.g. libccp4.dylib)
-# at runtime (used on Mac OS X)
-if test "$DYLD_LIBRARY_PATH"; then
-  if [ $ccp4_first_in_path -eq 1 ]; then
-    setenv DYLD_LIBRARY_PATH ${CLIB}:${DYLD_LIBRARY_PATH}
-  else
-    setenv DYLD_LIBRARY_PATH ${DYLD_LIBRARY_PATH}:${CLIB}
-  fi
-else
-  setenv DYLD_LIBRARY_PATH ${CLIB}
-fi
-
-### XAPPLRESDIR ###
-
-# If you want to use xloggraph/xplot84driver, you need to get the application
-# defaults picked up somehow.  As distributed, the file can't just live in an
-# application defaults directory since it requires reading by xrdb to sort out
-# the differences for monochrome displays.  At Daresbury a version of the file
-# assuming a monochrome display is kept in the directory
-# $CCP4_LIB/X11/app-defaults and this is picked up through the
-# XUSERFILESEARCHPATH environment variable.  That means you only see black and
-# white on a colour display.  Alternatively you might make sure that it is
-# read by xrdb on startup of the X Windows system or delegate the
-# responsibility to users to run it.  There are disadvantages to putting an
-# invocation of xrdb in here, one being that the correct value of DISPLAY may
-# not be set at the time this file is read.  Thus edit this part as
-# appropriate.  (SunOS will normally want to use /usr/openwin or $OPENWINHOME
-# instead of /usr; others may want /usr/local/lib or some such):
-
-# bug # 3274 - only append this to the path if the directory exists
-
-if test -d $CCP4_LIB/X11/app-defaults ; then
-  if test "$XUSERFILESEARCHPATH"; then
-    setenv XUSERFILESEARCHPATH $CCP4_LIB/X11/app-defaults/%N:$XUSERFILESEARCHPATH
-  else
-    setenv XUSERFILESEARCHPATH $CCP4_LIB/X11/app-defaults/%N:/usr/lib/X11/app-defaults
-  fi
-fi
-
-### TRAPPFE ###
-# TRAPFPE is set to ensure (in collaboration with -lfpe) an abort on floating
-# point exceptions under IRIX.  It shouldn't cause harm on other systems, but
-# edit this to comment it out if necessary. Have now added case statement.
-
-case `uname` in
-*IRIX* )
-  setenv TRAP_FPE "OVERFL=ABORT; DIVZERO=ABORT; INVALID=ABORT"
-  ;;
-* )
-  ;;
-esac
-
-# The following can be used to put a message of the day to announce news about
-# CCP4 or whatever to CCP4 users.  You might also want to edit this part to
-# have machine-specific messages dependent on `hostname`.
-test -r $CCP4/include/ccp4.msg && cat $CCP4/include/ccp4.msg
+#####     if test "$LD_LIBRARY_PATH"; then
+#####       if [[ $ccp4_first_in_path -eq 1 ]]; then
+#####         export LD_LIBRARY_PATH="${CLIB}:${LD_LIBRARY_PATH}"
+#####       else
+#####         export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${CLIB}"
+#####       fi
+#####     else
+#####       export LD_LIBRARY_PATH="${CLIB}"
+#####     fi
+#####     
+#####     # DYLD_LIBRARY_PATH specifies where to find dynamic libraries (e.g. libccp4.dylib)
+#####     # at runtime (used on Mac OS X)
+#####     if test "$DYLD_LIBRARY_PATH"; then
+#####       if [[ $ccp4_first_in_path -eq 1 ]]; then
+#####         export DYLD_LIBRARY_PATH="${CLIB}:${DYLD_LIBRARY_PATH}"
+#####       else
+#####         export DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH}:${CLIB}"
+#####       fi
+#####     else
+#####       export DYLD_LIBRARY_PATH="${CLIB}"
+#####     fi
+#####     
+#####     ### XAPPLRESDIR ###
+#####     
+#####     # If you want to use xloggraph/xplot84driver, you need to get the application
+#####     # defaults picked up somehow.  As distributed, the file can't just live in an
+#####     # application defaults directory since it requires reading by xrdb to sort out
+#####     # the differences for monochrome displays.  At Daresbury a version of the file
+#####     # assuming a monochrome display is kept in the directory
+#####     # $CCP4_LIB/X11/app-defaults and this is picked up through the
+#####     # XUSERFILESEARCHPATH environment variable.  That means you only see black and
+#####     # white on a colour display.  Alternatively you might make sure that it is
+#####     # read by xrdb on startup of the X Windows system or delegate the
+#####     # responsibility to users to run it.  There are disadvantages to putting an
+#####     # invocation of xrdb in here, one being that the correct value of DISPLAY may
+#####     # not be set at the time this file is read.  Thus edit this part as
+#####     # appropriate.  (SunOS will normally want to use /usr/openwin or $OPENWINHOME
+#####     # instead of /usr; others may want /usr/local/lib or some such):
+#####     if test "$XUSERFILESEARCHPATH"; then
+#####       export XUSERFILESEARCHPATH="$CCP4_LIB/X11/app-defaults/%N:$XUSERFILESEARCHPATH"
+#####     else
+#####       export XUSERFILESEARCHPATH="$CCP4_LIB/X11/app-defaults/%N:/usr/lib/X11/app-defaults"
+#####     fi
+#####     
+#####     ### TRAPPFE ###
+#####     # TRAPFPE is set to ensure (in collaboration with -lfpe) an abort on floating
+#####     # point exceptions under IRIX.  It shouldn't cause harm on other systems, but
+#####     # edit this to comment it out if necessary. 
+#####     export TRAP_FPE="OVERFL=ABORT" ; export DIVZERO="ABORT" ; export INVALID="ABORT"
+#####     
+#####     # The following can be used to put a message of the day to announce news about
+#####     # CCP4 or whatever to CCP4 users.  You might also want to edit this part to
+#####     # have machine-specific messages dependent on `hostname`.
+#####     [[ -f "$CCP4/include/ccp4.msg" ]] && cat "$CCP4/include/ccp4.msg"
 
 ################### EXPERIENCED USERS STOP HERE #####################
 
@@ -292,161 +316,151 @@
 
 ### dbCCP4i database handler setup ###
 
-setenv DBCCP4I_TOP ${CCP4}/share/dbccp4i
+export DBCCP4I_TOP="${CCP4}/share/dbccp4i"
 
 ### IMOSFLM environment is now defined here
 
-setenv MOSFLM_EXEC ${CBIN}/ipmosflm
-setenv MOSFLM_WISH ${CCP4I_TCLTK}/wish
-setenv IMOSFLM_VERSION "1.0.0"
+export MOSFLM_EXEC="${CBIN}/ipmosflm"
+export MOSFLM_WISH="${CCP4I_TCLTK}/wish"
+export IMOSFLM_VERSION="0.6.1"
 
 
 ### MMCIFDIC is now defined here. cif_mmdic.lib is a binary file ===
 # so on multiple installs it need to be unique and not in $CLIBD
 
-setenv MMCIFDIC $CLIB/cif_mmdic.lib
+export MMCIFDIC="$CLIB/cif_mmdic.lib"
 
 ### MOLREPLIB Point to the location of the files bs-zeros.dat  ps.resource  symlib.blc
 # They are distributed with CCP4 in $CLIBD. This env must have the trailing \ or /
 
-setenv MOLREPLIB $CCP4/lib/data/monomers/
+export MOLREPLIB="$CCP4/lib/data/monomers/"
 
 ### CRANK points to location of Crank automation suite within ccp4i
 
-setenv CRANK $CCP4/ccp4i/crank
-setenv CCP4_CRANK 1
-
-### XIA2 setup
-# XIAROOT directory (default is under the share folder)
-
-if test -e $CCP4/share/XIAROOT/setup.sh
-then
-. $CCP4/share/XIAROOT/setup.sh
-fi
+export CRANK="$CCP4/ccp4i/crank"
+export CCP4_CRANK="1"
 
+#  ### XIA2 setup
+#  # XIAROOT directory (default is under the share folder)
+#  
+#  if [[ -f "$CCP4/share/XIAROOT/setup.sh" ]]; then
+#      source "$CCP4/share/XIAROOT/setup.sh"
+#  fi
+#  
 # Note: The PATH is updated with the xia2 Applications directory in the 
 # construct below.
 
 ### PISA_CONF_FILE is the config file needed to run the stand-alone PISA,
 #   though this can be set on the command line too.
 
-if test -e $CCP4/share/pisa/pisa.cfg
-then
-  setenv PISA_CONF_FILE $CCP4/share/pisa/pisa.cfg
-fi
+export PISA_CONF_FILE="$CCP4/share/pisa/pisa.cfg"
 
 ### CLIBD_MON Point to the location of the dictionary files for REFMAC5
 # They are distributed with CCP4 in $CLIBD/monomers. This env must have 
 # the trailing \ or /
 
-setenv CLIBD_MON $CCP4/lib/data/monomers/
+export CLIBD_MON="$CCP4/lib/data/monomers/"
 
 ### PUBLIC_FONT84, CCP4_HELPDIR, HELPDIR, MOSHELPFILE ###
 # (essential for the relevant programs)
-setenv PUBLIC_FONT84   $CLIB/font84.dat  # plot84 fonts [used by plot84lib]
+export PUBLIC_FONT84="$CLIB/font84.dat"  # plot84 fonts [used by plot84lib]
 
 # location of VMS-style help files required for mosflm [used by hlplib, chelp,
 #   chlp, (ip)mosflm]:
-setenv CCP4_HELPDIR    $CCP4/help/            # NB trailing /
+export CCP4_HELPDIR="$CCP4/help/"            # NB trailing /
 
 # Rasmol path. Needed for prog. to find rasmol.hlp
-setenv RASMOLPATH $CCP4/x-windows/RasMol/src
+export RASMOLPATH="$CCP4/x-windows/RasMol/src"
 
-# CCP4 executables and scripts live in $CBIN and $CETC respectively; put them
-# on the path in an appropriate order for scripts to be used as wrappers for
-# binaries of the same name.  Put ccp4 stuff after the current path to avoid
-# confusion with `.' or whatever in the path:
-#
-# This construct prevents the path getting longer each time ccp4.setup is
-# executed (A. Perrakis)
-ccp4pathlist="${CCP4}/etc ${CBIN} ${CCP4I_TOP}/bin ${DBCCP4I_TOP}/bin"
-#
-for dir in ${ccp4pathlist}; do
-  if [ `expr ":${PATH}:" : ".*:${dir}:"` -eq 0 ]; then
-    if [ $ccp4_first_in_path -eq 1 ]; then
-      setenv PATH ${dir}:${PATH}
-    else
-      setenv PATH ${PATH}:${dir}
-    fi
-  fi
-done
+if [[ $ZSH_NAME != "zsh" ]];then
 
-# Optional (useful) additional environment variables
-  setenv CCP4             $CCP4
-  setenv CDOC             $CCP4/doc
-  setenv CHTML            $CCP4/html
-  setenv CETC             $CCP4/etc
-  setenv CEXAM            $CCP4/examples
-  setenv CINCL            $CCP4/include
-  setenv CLIBD            $CCP4/lib/data
-  setenv CLIBS            $CCP4/lib/src
-  setenv CPROG            $CCP4/src
+    # This is specific to bash, so protect it from zsh users
 
-if [ "`basename $SHELL`" != "ksh" ]; then
-# useful aliases, at least for developers
-  alias ccp4   'pushd $CCP4>/dev/null'
-  alias xtal   'pushd $CCP4_MASTER>/dev/null'
-  alias cbin   'pushd $CBIN>/dev/null'
-  alias cetc   'pushd $CETC>/dev/null'
-  alias cprog  'pushd $CPROG>/dev/null'
-  alias cincl  'pushd $CINCL>/dev/null'
-  alias clib   'pushd $CLIB>/dev/null'
-  alias clibd  'pushd $CLIBD>/dev/null'
-  alias clibs  'pushd $CLIBS>/dev/null'
-  alias cbin   'pushd $CBIN>/dev/null'
-  alias cexam  'pushd $CEXAM>/dev/null'
-  alias cdoc   'pushd $CDOC>/dev/null'
-  alias chtml  'pushd $CHTML>/dev/null'
-  alias ccp4help '$CCP4_BROWSER $CHTML/INDEX.html \&'
+    # CCP4 executables and scripts live in $CBIN and $CETC respectively; put them
+    # on the path in an appropriate order for scripts to be used as wrappers for
+    # binaries of the same name.  Put ccp4 stuff after the current path to avoid
+    # confusion with `.' or whatever in the path:
+    #
+    # This construct prevents the path getting longer each time ccp4.setup is
+    # executed (A. Perrakis)
+    # 
+    ccp4pathlist="${CCP4}/etc ${CBIN} ${CCP4I_TOP}/bin ${DBCCP4I_TOP}/bin ${CCP4}/share/XIAROOT/xia2/Applications"
+    #
+    for dir in ${ccp4pathlist}; do
+      if [[ `expr ":${PATH}:" : ".*:${dir}:"` -eq 0 ]]; then
+        if [[ $ccp4_first_in_path -eq 1 ]]; then
+          export PATH="${dir}:${PATH}"
+        else
+          export PATH="${PATH}:${dir}"
+        fi
+      fi
+    done
 
-### laue, lget, linkimages ###
+fi
 
-### only if we have the Laue software suite...
+# Optional (useful) additional environment variables
+  #export CCP4="$CCP4"
+  export CDOC="$CCP4/doc"
+  export CHTML="$CCP4/html"
+  export CETC="$CCP4/etc"
+  export CEXAM="$CCP4/examples"
+  export CINCL="$CCP4/include"
+  export CLIBD="$CCP4/lib/data"
+  export CLIBS="$CCP4/lib/src"
+  export CPROG="$CCP4/src"
 
-  if test -d $CCP4_MASTER/laue
-  then
+if [[ "`basename $SHELL`" != "ksh" ]]; then
+# useful aliases, at least for developers
+  alias ccp4='pushd $CCP4>/dev/null'
+  alias xtal='pushd $CCP4_MASTER>/dev/null'
+  alias cbin='pushd $CBIN>/dev/null'
+  alias cetc='pushd $CETC>/dev/null'
+  alias cprog='pushd $CPROG>/dev/null'
+  alias cincl='pushd $CINCL>/dev/null'
+  alias clib='pushd $CLIB>/dev/null'
+  alias clibd='pushd $CLIBD>/dev/null'
+  alias clibs='pushd $CLIBS>/dev/null'
+  alias cbin='pushd $CBIN>/dev/null'
+  alias cexam='pushd $CEXAM>/dev/null'
+  alias cdoc='pushd $CDOC>/dev/null'
+  alias chtml='pushd $CHTML>/dev/null'
+  alias ccp4help='$CCP4_BROWSER $CHTML/INDEX.html \&'
 
+### laue, lget, linkimages ###
 # Essential aliases for the Laue software suite
-
-    alias laue '$CCP4_MASTER/laue/cmd/laue.cmd'
-    alias lget '$CCP4_MASTER/laue/cmd/lget.cmd'
-    alias linkimages '$CCP4_MASTER/laue/cmd/linkimages.cmd'
+  alias laue='$CCP4_MASTER/laue/cmd/laue.cmd'
+  alias lget='$CCP4_MASTER/laue/cmd/lget.cmd'
+  alias linkimages='$CCP4_MASTER/laue/cmd/linkimages.cmd'
 
 # additional useful aliases for Laue directories
-    alias llaue  'pushd $CCP4_MASTER/laue'
-    alias lsrc   'pushd $CCP4_MASTER/laue/src>/dev/null'
-    alias llib   'pushd $CCP4_MASTER/laue/lib>/dev/null'
-    alias llibs  'pushd $CCP4_MASTER/laue/lib/src>/dev/null'
-    alias ldoc   'pushd $CCP4_MASTER/laue/doc>/dev/null'
-    alias lmak   'pushd $CCP4_MASTER/laue/make>/dev/null'
-    alias lutils 'pushd $CCP4_MASTER/laue/utils>/dev/null'
-    alias lcmd   'pushd $CCP4_MASTER/laue/cmd>/dev/null'
-    alias ldl    'pushd $CCP4_MASTER/laue/dl>/dev/null'
-    alias ltestd 'pushd $CCP4_MASTER/laue/testdata>/dev/null'
-    alias lxdl   'pushd $CCP4_MASTER/laue/xdl_view>/dev/null'
-    alias lxdls  'pushd $CCP4_MASTER/laue/xdl_view/src>/dev/null'
-    alias lgnom  'pushd $CCP4_MASTER/laue/gnom>/dev/null'
-    alias lgnoms 'pushd $CCP4_MASTER/laue/gnom/src>/dev/null'
-    alias lbin   'pushd $CBIN>/dev/null'
-
-  fi
+  alias llaue='pushd $CCP4_MASTER/laue'
+  alias lsrc='pushd $CCP4_MASTER/laue/src>/dev/null'
+  alias llib='pushd $CCP4_MASTER/laue/lib>/dev/null'
+  alias llibs='pushd $CCP4_MASTER/laue/lib/src>/dev/null'
+  alias ldoc='pushd $CCP4_MASTER/laue/doc>/dev/null'
+  alias lmak='pushd $CCP4_MASTER/laue/make>/dev/null'
+  alias lutils='pushd $CCP4_MASTER/laue/utils>/dev/null'
+  alias lcmd='pushd $CCP4_MASTER/laue/cmd>/dev/null'
+  alias ldl='pushd $CCP4_MASTER/laue/dl>/dev/null'
+  alias ltestd='pushd $CCP4_MASTER/laue/testdata>/dev/null'
+  alias lxdl='pushd $CCP4_MASTER/laue/xdl_view>/dev/null'
+  alias lxdls='pushd $CCP4_MASTER/laue/xdl_view/src>/dev/null'
+  alias lgnom='pushd $CCP4_MASTER/laue/gnom>/dev/null'
+  alias lgnoms='pushd $CCP4_MASTER/laue/gnom/src>/dev/null'
+  alias lbin='pushd $CBIN>/dev/null'
 
-  unset alias  # clean up
 fi             # ksh test
 
-# Set-up cctbx environment
-test -r $CCP4/lib/cctbx/cctbx_build/setpaths.sh && . $CCP4/lib/cctbx/cctbx_build/setpaths.sh
-
-# Set-up phaser environment
-if ( test -d $CCP4/src/phaser) ; then
-  phaser_mtype=`$CCP4/src/phaser/bin/machine_type`
-  phaser_version=`grep PHASER_VERSION $CCP4/src/phaser/conf/version.sh | awk '{print $3}'`
-  phaser_setup_file="${CCP4}/src/phaser/phaser-${phaser_version}/build/${phaser_mtype}/setpaths.sh"
-  test -r $phaser_setup_file && . $phaser_setup_file
-fi
-
+####    # Set-up cctbx environment
+####    [[ -f "$CCP4/lib/cctbx/cctbx_build/setpaths.sh" ]] && source "$CCP4/lib/cctbx/cctbx_build/setpaths.sh"
+####    
+####    # Set-up phaser environment
+####    if [[ -d $CCP4/src/phaser ]] ; then
+####      export phaser_mtype=`$CCP4/src/phaser/bin/machine_type`
+####      export phaser_version=`grep PHASER_VERSION $CCP4/src/phaser/conf/version | awk '{print $3}'`
+####      export phaser_setup_file="${CCP4}/src/phaser/phaser-${phaser_version}/build/${phaser_mtype}/setpaths.sh"
+####      [[ -f "$phaser_setup_file" ]] && source "$phaser_setup_file"
+####    fi
+####    
 #BALBES root configuration
-if ( test -d $CCP4/share/balbes/BALBES_0.0.1)
-then
-  setenv BALBES_ROOT $CCP4/share/balbes/BALBES_0.0.1
-fi
+export BALBES_ROOT="$CCP4/share/balbes/BALBES_0.0.1"
diff -ruN ccp4-6.1.13-dist/include/ccp4.setup-dist ccp4-6.1.13/include/ccp4.setup-dist
--- ccp4-6.1.13-dist/include/ccp4.setup-dist	1969-12-31 16:00:00.000000000 -0800
+++ ccp4-6.1.13/include/ccp4.setup-dist	2010-06-14 14:37:21.000000000 -0700
@@ -0,0 +1,431 @@
+#!/bin/csh
+# CCP4 setup file for C-shell (or tcsh) users.  -*- shell-script -*-
+
+# $Id: ccp4.setup-dist,v 1.116.2.3 2008/11/20 15:19:24 rmk65 Exp $
+
+# This file is site specific and may also contain machine-specifics.  The CCP4
+# administrator will have to edit this file and then have anyone who wants to
+# use CCP4 source it from their .login file.  They will require the full path
+# name since no environment variables relevant to CCP4 are known until this is
+# executed.
+
+# For sites with more than one machine, it is recommended that the suite is
+# installed on a single machine and other machines access the source code, and
+# shareable files (such as this one) via shared file systems with NFS, RFS
+# etc.  Non-shareable files reside in $CBIN and $CLIB (see below).
+
+# Copy this file to ccp4.setup and customise it for your needs. There are
+# three sections. You MUST check the first section. You may want to check
+# the second. You don't need to look at the third.
+
+################### THIS SECTION MUST BE EDITED #####################
+
+# CCP4_MASTER is the location of the top-level directory containing `ccp4-<version>'
+# This is usually the directory in which you ran the tar command to unpack the
+# code, and is assumed to be shared between machines at a multi-machine site.
+
+setenv CCP4_MASTER	@PREFIX@/share/xtal                  
+setenv CCP4		$CCP4_MASTER/ccp4-6.1.13
+
+# Check for existence of CCP4_MASTER
+if (! -e $CCP4_MASTER) then
+    echo "********************* WARNING **********************"
+    echo "The directory $CCP4_MASTER"
+    echo "(assigned to CCP4_MASTER) does not exist."
+    echo "The CCP4 programs will not run correctly, and any"
+    echo "installation attempt will have errors or will fail."
+    echo "********************* WARNING **********************"
+endif 
+
+# CCP4_SCR: a per-user directory for run-time-generated scratch
+# files. A dedicated scratch filesystem is probably better than (/usr)/tmp
+# BINSORT_SCR: a scratch directory for binsort's use; normally same as CCP4_SCR
+
+setenv CCP4_SCR      /tmp/$USER	
+# check to see if this exists and if not try to make it
+if (! -e $CCP4_SCR) mkdir $CCP4_SCR
+if (! -e $CCP4_SCR) \
+    echo "Unable to make CCP4_SCR. CCP4 progs will not run correctly."
+
+setenv BINSORT_SCR   $CCP4_SCR
+
+### CCP4i setup - you may need to edit CCP4I_TCLTK ###
+# CCP4I_TOP - the top directory of the interface
+setenv CCP4I_TOP ${CCP4}/ccp4i
+# CCP4I_TCLTK - directory containing tclsh,wish and bltwish executables
+#               as used in $CCP4I_TOP/bin/ccp4i,ccp4ish,loggraph
+#               For 'standard' installations this is @PREFIX@/bin
+#               but note the SGI distributed version of Tcl/Tk is not 
+#               appropriate version
+setenv CCP4I_TCLTK @PREFIX@/bin        
+# CCP4I_HELP - directory contain ccp4i help - default is $CCP4I_TOP/help
+setenv CCP4I_HELP ${CCP4I_TOP}/help
+
+### Optional - setting http_proxy environment
+# The commented out 'setenv' line below may have to be declared to download
+# and edit protein sequences using the new "Import/Edit Protein Sequences"
+# (This may also be required for remote job submission in arp/warp.)
+# task. If so, uncomment this line and replace the example proxy URL with your
+# relevant URL
+
+#setenv HTTP_PROXY wwwblah.blah.ac.uk:xxxx/blah.blah
+
+################### NOVICE USERS STOP HERE #####################
+
+################### OPTIONS TO CUSTOMISE CCP4 #####################
+
+# By default, CCP4 directories are prepended to the beginning of paths (PATH,
+# LD_LIBRARY_PATH, and DYLD_LIBRARY_PATH). If ccp4_first_in_path is set
+# to 0, then they will be appended to the end of paths.
+# When deciding local policy, bear in mind the possible existence of
+# other CCP4 installations, and the possibility of non-CCP4 programs
+# with conflicting names.
+set ccp4_first_in_path = 0
+
+# The following checks the CCP4 server for available updates, and reports back.
+# Uncomment this line if you want to know about available updates.
+
+#eval python -V >& /dev/null && python $CCP4/etc/ccp4_updates.py -l
+
+# Set GFORTRAN_UNBUFFERED_ALL to either 1 or Y to ensure that the logfile
+# output from programs compiled with Gfortran is in the correct order.
+# Note that there will be some performance penalty for this.
+# # # setenv GFORTRAN_UNBUFFERED_ALL Y
+
+# The commented-out switch statement below provides an example of how
+# to use this file for several machines/architectures sharing $CCP4_MASTER.
+# If necessary, uncomment and edit this.  Otherwise, if you're only supporting
+# a single system alter the uncommented part as necessary.
+#
+# The significance of the environment variables is as follows:
+#   CBIN: location of the executables -- must be on your path (see below);
+#   CLIB: location of (binary) library files such as libccp4.a and libccp4.so;
+#   MANPATH: set this if your system's `man' looks at such an environment
+#      variable to determine where to look for man pages.  By adding 
+#      $CCP4/man to the normal path you get the CCP4 man pages 
+#      with keyword searching as system ones.  
+#   MCTYPE: used for LAUE make -- see LAUE documentation
+#   CCP4_BROWSER: set this if you intend to use the html documentation
+#      (recommended).  It should have the path and name of a html browser eg
+#      /usr/bin/X11/mozilla or @PREFIX@/bin/lynx. The browser will be
+#      started with the alias ccp4help and will open the file
+#      $CHTML/INDEX.html.
+
+#   switch (`hostname`)			# edit this switch statement if used
+#                                       # for multiple systems
+#   case 'foo':
+    setenv CBIN      $CCP4/bin		
+    setenv CLIB      $CCP4/lib	
+
+    setenv CCP4_BROWSER  Safari          
+
+    if (${?MANPATH}) then
+      if ($ccp4_first_in_path) then
+        setenv MANPATH ${CCP4}/man:${MANPATH}
+      else
+        setenv MANPATH ${MANPATH}:${CCP4}/man
+      endif
+    else
+      if ($ccp4_first_in_path) then
+        setenv MANPATH ${CCP4}/man:/usr/share/man
+      else
+        setenv MANPATH /usr/share/man:${CCP4}/man
+      endif
+    endif
+    if (-d $CCP4_MASTER/laue) then 
+      setenv MCTYPE        unix 			# (only for Laue)
+    endif
+#     breaksw
+#   default:
+#     echo "CCP4 not implemented on this system"
+#     exit 1
+#     breaksw
+# endsw
+
+switch (`uname`)
+case 'Darwin': 
+  limit stacksize unlimited
+  breaksw
+default:
+  breaksw
+endsw
+
+# The following are for all systems
+setenv CCP4_LIB $CLIB
+setenv CCP4_BIN $CBIN
+
+# CLASSPATH for Java
+if (${?CLASSPATH}) then
+  if ($ccp4_first_in_path) then
+    setenv CLASSPATH ${CBIN}:${CLASSPATH}
+  else
+    setenv CLASSPATH ${CLASSPATH}:${CBIN}
+  endif
+else
+  if ($ccp4_first_in_path) then
+    setenv CLASSPATH ${CBIN}:.
+  else
+    setenv CLASSPATH .:${CBIN}
+  endif
+endif
+
+#  #Python path for the subprocess fixed module
+#  if (${?PYTHONPATH}) then
+#    if ($ccp4_first_in_path) then
+#        setenv PYTHONPATH ${CCP4}/share/python:${PYTHONPATH}
+#    else
+#        setenv PYTHONPATH ${PYTHONPATH}:${CCP4}/share/python
+#    endif
+#  else
+#      setenv PYTHONPATH ${CCP4}/share/python
+#  endif
+
+### PLOT_COMMAND PRINT_COMMAND for the XCCPJIFFY programs to compile ###
+setenv PLOT_COMMAND   'lpr'  
+setenv PRINT_COMMAND  'lpr'    
+
+# HARVESTHOME specifies location of harvesting files (defaults to $HOME)
+#setenv HARVESTHOME     
+
+### CCP4_OPEN ###
+# CCP4_OPEN may be set to 'UNKNOWN' to stop open failures for files opened 
+# as NEW that already exist.  Novices should use 'NEW' to avoid inadvertant 
+# over-writing of existing files, which is then treated as a fatal error.
+
+setenv CCP4_OPEN        UNKNOWN	
+
+### BINSORT_MEM ###
+# BINSORT_MEM is workspace used by the binsort program.  In principle this
+# value is machine-dependent.  It may benefit from being enlarged, but values
+# higher than 2M have been reported to cause excessive paging on some systems.
+# You might like to experiment with a program such as fft with different
+# values -- 102400 (bytes) is the default.  csh's `time' command can tell you
+# about paging.
+#
+#  setenv BINSORT_MEM     8388608
+
+#  # LD_LIBRARY_PATH specifies where to find dynamic libraries (e.g. libccp4.so)
+#  # at runtime
+#  if (${?LD_LIBRARY_PATH}) then
+#    if ($ccp4_first_in_path) then
+#      setenv LD_LIBRARY_PATH ${CLIB}:${LD_LIBRARY_PATH}
+#    else
+#      setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:${CLIB}
+#    endif
+#  else
+#    setenv LD_LIBRARY_PATH ${CLIB}
+#  endif
+#  
+#  # DYLD_LIBRARY_PATH specifies where to find dynamic libraries (e.g. libccp4.dylib)
+#  # at runtime (used on Mac OS X)
+#  if (${?DYLD_LIBRARY_PATH}) then
+#    if ($ccp4_first_in_path) then
+#      setenv DYLD_LIBRARY_PATH ${CLIB}:${DYLD_LIBRARY_PATH}
+#    else
+#      setenv DYLD_LIBRARY_PATH ${DYLD_LIBRARY_PATH}:${CLIB}
+#    endif
+#  else
+#    setenv DYLD_LIBRARY_PATH ${CLIB}
+#  endif
+#  
+### XAPPLRESDIR ###
+
+# If you want to use xloggraph/xplot84driver, you need to get the application
+# defaults picked up somehow.  As distributed, the file can't just live in an
+# application defaults directory since it requires reading by xrdb to sort out
+# the differences for monochrome displays.  At Daresbury a version of the file
+# assuming a monochrome display is kept in the directory
+# $CCP4_LIB/X11/app-defaults and this is picked up through the
+# XUSERFILESEARCHPATH environment variable.  That means you only see black and
+# white on a colour display.  Alternatively you might make sure that it is
+# read by xrdb on startup of the X Windows system or delegate the
+# responsibility to users to run it.  There are disadvantages to putting an
+# invocation of xrdb in here, one being that the correct value of DISPLAY may
+# not be set at the time this file is read.  Thus edit this part as
+# appropriate.  (SunOS will normally want to use /usr/openwin or $OPENWINHOME
+# instead of /usr; others may want /usr/local/lib or some such):
+#  if (-d $CCP4_LIB/X11/app-defaults) then
+#    if ($?XUSERFILESEARCHPATH) then
+#      setenv XUSERFILESEARCHPATH $CCP4_LIB/X11/app-defaults/%N:$XUSERFILESEARCHPATH
+#    else
+#      setenv XUSERFILESEARCHPATH $CCP4_LIB/X11/app-defaults/%N:/usr/lib/X11/app-defaults
+#    endif
+#  endif
+
+### TRAPPFE ###
+# TRAPFPE is set to ensure (in collaboration with -lfpe) an abort on floating
+# point exceptions under IRIX.  It shouldn't cause harm on other systems, but
+# edit this to comment it out if necessary. 
+
+switch (`uname`)
+case '*IRIX*': 
+  setenv TRAP_FPE "OVERFL=ABORT; DIVZERO=ABORT; INVALID=ABORT"
+  breaksw
+default:
+  breaksw
+endsw
+
+# The following can be used to put a message of the day to announce news about
+# CCP4 or whatever to CCP4 users.  You might also want to edit this part to
+# have machine-specific messages dependent on `hostname`.
+if (-e $CCP4/include/ccp4.msg) cat $CCP4/include/ccp4.msg
+
+################### EXPERIENCED USERS STOP HERE #####################
+
+################### THE REST SHOULDN'T NEED EDITING #####################
+
+### dbCCP4i database handler setup ###
+
+setenv DBCCP4I_TOP ${CCP4}/share/dbccp4i
+
+### IMOSFLM environment is now defined here
+
+setenv MOSFLM_EXEC ${CBIN}/ipmosflm
+setenv MOSFLM_WISH ${CCP4I_TCLTK}/wish
+setenv IMOSFLM_VERSION "0.6.1"
+
+### MMCIFDIC is now defined here. cif_mmdic.lib is a binary file ===
+# so on multiple installs it need to be unique and not in $CLIBD
+
+setenv MMCIFDIC $CLIB/cif_mmdic.lib
+
+### MOLREPLIB Point to the location of the files bs-zeros.dat  ps.resource  symlib.blc
+# They are distributed with CCP4 in $CLIBD. This env must have the trailing \ or /
+
+setenv MOLREPLIB $CCP4/lib/data/monomers/
+
+### CRANK points to location of Crank automation suite within ccp4i
+
+setenv CRANK $CCP4/ccp4i/crank
+setenv CCP4_CRANK 1
+#  
+#  ### XIA2 setup
+#  # XIAROOT directory (default is under the share folder)
+#  
+#  if (-e $CCP4/share/XIAROOT/setup.csh) then
+#     source $CCP4/share/XIAROOT/setup.csh
+#  endif
+
+# Note: The PATH is updated with the xia2 Applications directory in the 
+# construct below.
+
+### PISA_CONF_FILE is the config file needed to run the stand-alone PISA,
+#   though this can be set on the command line too.
+
+if (-e $CCP4/share/pisa/pisa.cfg) then
+  setenv PISA_CONF_FILE $CCP4/share/pisa/pisa.cfg
+endif
+
+### CLIBD_MON Point to the location of the dictionary files for REFMAC5
+# They are distributed with CCP4 in $CLIBD/monomers. This env must have 
+# the trailing \ or /
+
+setenv CLIBD_MON $CCP4/lib/data/monomers/
+
+### PUBLIC_FONT84, CCP4_HELPDIR, HELPDIR, MOSHELPFILE ###
+# (essential for the relevant programs)
+setenv PUBLIC_FONT84   $CLIB/font84.dat  # plot84 fonts [used by plot84lib]
+
+# location of VMS-style help files required for mosflm [used by hlplib, chelp,
+#   chlp, (ip)mosflm]:
+setenv CCP4_HELPDIR    $CCP4/help/            # NB trailing /
+
+# Rasmol path. Needed for prog. to find rasmol.hlp
+setenv RASMOLPATH $CCP4/x-windows/RasMol/src
+
+# CCP4 executables and scripts live in $CBIN and $CETC respectively; put them
+# on the path in an appropriate order for scripts to be used as wrappers for
+# binaries of the same name.  Put ccp4 stuff after the current path to avoid
+# confusion with `.' or whatever in the path:
+#
+# This construct prevents the path getting longer each time ccp4.setup is
+# executed (A. Perrakis)
+set ccp4pathlist = "${CCP4}/etc ${CBIN} ${CCP4I_TOP}/bin ${DBCCP4I_TOP}/bin ${CCP4}/share/XIAROOT/xia2/Applications"
+#
+foreach dir ( ${ccp4pathlist} )
+  if ( ${?PATH} ) then
+    if ( :${PATH}: !~ *:${dir}:* ) then
+      if ($ccp4_first_in_path) then
+        setenv PATH ${dir}:${PATH}
+      else
+        setenv PATH ${PATH}:${dir}
+      endif
+    endif
+  else
+    setenv PATH ${dir}
+  endif
+end
+
+# Optional (useful) additional environment variables
+  setenv CCP4             $CCP4
+  setenv CDOC             $CCP4/doc
+  setenv CHTML            $CCP4/html
+  setenv CETC             $CCP4/etc
+  setenv CEXAM            $CCP4/examples
+  setenv CINCL            $CCP4/include
+  setenv CLIBD            $CCP4/lib/data
+  setenv CLIBS            $CCP4/lib/src
+  setenv CPROG            $CCP4/src
+
+# useful aliases, at least for developers
+  alias ccp4   'pushd $CCP4>/dev/null'
+  alias xtal   'pushd $CCP4_MASTER>/dev/null'
+  alias cbin   'pushd $CBIN>/dev/null'
+  alias cetc   'pushd $CETC>/dev/null'
+  alias cprog  'pushd $CPROG>/dev/null'
+  alias cincl  'pushd $CINCL>/dev/null'
+  alias clib   'pushd $CLIB>/dev/null'
+  alias clibd  'pushd $CLIBD>/dev/null'
+  alias clibs  'pushd $CLIBS>/dev/null'
+  alias cbin   'pushd $CBIN>/dev/null'
+  alias cexam  'pushd $CEXAM>/dev/null'
+  alias cdoc   'pushd $CDOC>/dev/null'
+  alias chtml  'pushd $CHTML>/dev/null'
+  alias ccp4help '$CCP4_BROWSER $CHTML/INDEX.html &'
+
+### laue, lget, linkimages ###
+
+### only if we have the Laue software suite...
+
+  if (-d $CCP4_MASTER/laue) then 
+
+# Essential aliases for the Laue software suite
+    alias laue '$CCP4_MASTER/laue/cmd/laue.cmd'
+    alias lget '$CCP4_MASTER/laue/cmd/lget.cmd'
+    alias linkimages '$CCP4_MASTER/laue/cmd/linkimages.cmd'
+
+# additional useful aliases for Laue directories
+    alias llaue  'pushd $CCP4_MASTER/laue'
+    alias lsrc   'pushd $CCP4_MASTER/laue/src>/dev/null'
+    alias llib   'pushd $CCP4_MASTER/laue/lib>/dev/null'
+    alias llibs  'pushd $CCP4_MASTER/laue/lib/src>/dev/null'
+    alias ldoc   'pushd $CCP4_MASTER/laue/doc>/dev/null'
+    alias lmak   'pushd $CCP4_MASTER/laue/make>/dev/null'
+    alias lutils 'pushd $CCP4_MASTER/laue/utils>/dev/null'
+    alias lcmd   'pushd $CCP4_MASTER/laue/cmd>/dev/null'
+    alias ldl    'pushd $CCP4_MASTER/laue/dl>/dev/null'
+    alias ltestd 'pushd $CCP4_MASTER/laue/testdata>/dev/null'
+    alias lxdl   'pushd $CCP4_MASTER/laue/xdl_view>/dev/null'
+    alias lxdls  'pushd $CCP4_MASTER/laue/xdl_view/src>/dev/null'
+    alias lgnom  'pushd $CCP4_MASTER/laue/gnom>/dev/null'
+    alias lgnoms 'pushd $CCP4_MASTER/laue/gnom/src>/dev/null'
+    alias lbin   'pushd $CBIN>/dev/null'
+#
+
+  endif 
+
+# Set-up cctbx environment
+# if (-e $CCP4/lib/cctbx/cctbx_build/setpaths.csh) source $CCP4/lib/cctbx/cctbx_build/setpaths.csh
+
+#  # Set-up phaser environment
+#  if (-d $CCP4/src/phaser) then
+#    set phaser_mtype = `$CCP4/src/phaser/bin/machine_type`
+#    set phaser_version = `grep PHASER_VERSION $CCP4/src/phaser/conf/version | awk '{print $3}'`
+#    set phaser_setup_file = "${CCP4}/src/phaser/phaser-${phaser_version}/build/${phaser_mtype}/setpaths.csh"
+#    if (-e $phaser_setup_file) source $phaser_setup_file
+#  endif
+#  
+#  #BALBES root configuration
+  if ( -d $CCP4/share/balbes/BALBES_0.0.1) then
+    setenv BALBES_ROOT $CCP4/share/balbes/BALBES_0.0.1
+  endif
diff -ruN ccp4-6.1.13-dist/include/ccp4.setup-zsh ccp4-6.1.13/include/ccp4.setup-zsh
--- ccp4-6.1.13-dist/include/ccp4.setup-zsh	2010-03-04 07:18:40.000000000 -0800
+++ ccp4-6.1.13/include/ccp4.setup-zsh	2010-06-14 14:23:22.000000000 -0700
@@ -1,24 +1,46 @@
 #! /bin/zsh -f
 # [The above is just for emacs -- this file should not be executed.]
+# $Id: ccp4.setup-zsh,v 1.30.2.3 2008/06/09 08:51:18 ccb Exp $
 
-if [[ -z $ZSH_VERSION ]];then
-    echo "This file is specific to the Z-shell, and it appears that you"
-    echo "are not running a (properly configured?) zsh."
-    return 1
-fi
+###############################################################################
+
+# Edit this for the current version of ccp4:
+   # if [[ -z $CCP4_VERSION ]];then
+        CCP4_VERSION="ccp4-6.1.13"
+   # fi
+
+###############################################################################
+
+# NOTE: You should not need to edit the rest of this file unless you want to over-ride the 
+# following assignments of $CCP4_MASTER and $BLTWISHPREFIX
 
 # NOTE:  If you have installed ccp4 on OS X with fink, you should not need to
 # change this file or to source it (fink takes care of sourcing it for you).
 
-# CCP4 setup file for bash or zsh users.  zsh is similar to ksh so should work
-# with ksh.
+    # CCP4_MASTER is the location of the top-level directory containing `ccp4'.  
+    # Set it manually by uncommenting and editing the following line:
+    
+     # export CCP4_MASTER="@PREFIX@/share/xtal"
+    
+    # or discover it from the source command
+    
+       # if [[ -z "$CCP4_MASTER"  ]];then
+              CCP4_MASTER="$(dirname $(dirname $(dirname $0)))"  
+       # fi
+        
+        export CCP4_MASTER
 
-# Contains some hacks by W G Scott to facilitate OS X fink installation, but
-# should work with any zsh with appropriate prefixes
 
-# Also contains a few zsh-specific functions and command-completions
+    # Discover where bltwish executable is located
+    if [[ -z $BLTWISHPREFIX &&  -x $(which bltwish) ]];then
+        BLTWISHPREFIX=$( dirname $( which bltwish )  )
+    fi
+ 
+############################################################################### 
+ 
+# CCP4 setup file for zsh users.   
 
-# $Id: ccp4.setup-zsh,v 1.41.2.10 2010/03/04 15:18:40 ccb Exp $
+# Also contains a few zsh-specific functions and command-completions.
 
 # This file is site specific and may also contain machine-specifics.  The CCP4
 # administrator will have to edit this file and then have anyone who wants to
@@ -35,42 +57,52 @@
 # three sections. You MUST check the first section. You may want to check
 # the second. You don't need to look at the third.
 
-################### THIS SECTION MUST BE EDITED #####################
-
-# CCP4_MASTER is the location of the top-level directory containing `ccp4'.  
-# This is assumed to be shared between machines at a multi-machine site.
+###############################################################################
+     
 
-export CCP4_MASTER=/xtal                    
-export CCP4=$CCP4_MASTER/ccp4-6.1.13
+if [[ -d "$CCP4_MASTER/$CCP4_VERSION"  ]];then                 
+    CCP4="$CCP4_MASTER/$CCP4_VERSION" ; export CCP4
+else
+    print ""
+    print "\e[1m The directory "$CCP4_MASTER/$CCP4_VERSION" cannot be found."
+    print " Please check that "$CCP4_VERSION" is the right ccp4 version.  "
+    print " Edit the file \e[0m $0 \e[1m accordingly. \e[0m"
+    print ""
+fi
 
 # CCP4_SCR: a per-user directory for run-time-generated scratch
 # files. A dedicated scratch filesystem is probably better than (/usr)/tmp
 # BINSORT_SCR: a scratch directory for binsort's use; normally same as CCP4_SCR
 
-export CCP4_SCR=/tmp/$USER	
+export CCP4_SCR="/tmp/$USER"    
 
 # check to see if this exists and if not try to make it
 
-if [[ ! -d $CCP4_SCR ]];then
-    mkdir -p $CCP4_SCR
+if [[ ! -d "$CCP4_SCR" ]];then
+    mkdir -p "$CCP4_SCR"
 fi
 
-if [[ ! -d $CCP4_SCR ]];then
+if [[ ! -d "$CCP4_SCR" ]];then
     echo "Unable to assign CCP4_SCR. This will cause probs."
 fi
 
-export BINSORT_SCR=$CCP4_SCR
+export BINSORT_SCR="$CCP4_SCR"
 
 ### CCP4i setup - you may need to edit CCP4I_TCLTK ###
 # CCP4I_TOP - the top directory of the interface
-export CCP4I_TOP=$CCP4/ccp4i
+export CCP4I_TOP="$CCP4/ccp4i"
+
 # CCP4I_TCLTK - directory containing tclsh,wish and bltwish executables
 #               as used in $CCP4I_TOP/bin/ccp4i,ccp4ish,loggraph
-#               For 'standard' installations this is /usr/local/bin
+#               For 'standard' installations this is @PREFIX@/bin
 #               but note the SGI distributed version of Tcl/Tk is not 
 #               appropriate version
 
-export CCP4I_TCLTK=/prefix/bin
+if [[ -d "$BLTWISHPREFIX"  &&  -x "$BLTWISHPREFIX/bltwish" ]]; then
+    export CCP4I_TCLTK="$BLTWISHPREFIX"
+else
+    print "\e[1m Cannot find bltwish executable. Please make sure it is in your \$PATH \e[0m"
+fi
     
 # CCP4I_HELP - directory contain ccp4i help - default is $CCP4I_TOP/help
 export CCP4I_HELP=$CCP4I_TOP/help
@@ -93,17 +125,16 @@
 # When deciding local policy, bear in mind the possible existence of
 # other CCP4 installations, and the possibility of non-CCP4 programs
 # with conflicting names.
-ccp4_first_in_path=1
+ccp4_first_in_path=0
 
 # Set GFORTRAN_UNBUFFERED_ALL to either 1 or Y to ensure that the logfile
 # output from programs compiled with Gfortran is in the correct order.
 # Note that there will be some performance penalty for this.
-export GFORTRAN_UNBUFFERED_ALL=Y
+# # # # export GFORTRAN_UNBUFFERED_ALL=Y
 
 # The following checks the CCP4 server for available updates, and reports back.
-# Uncomment this line if you want to know about available updates.
-
-#eval python -V >& /dev/null && python $CCP4/etc/ccp4_updates.py -l
+# Comment this line out if you find it annoying.
+# eval python -V >& /dev/null && python $CCP4/etc/ccp4_updates.py -l
 
 # The commented-out switch statement below provides an example of how
 # to use this file for several machines/architectures sharing $CCP4_MASTER.
@@ -120,30 +151,26 @@
 #   MCTYPE: used for LAUE make -- see LAUE documentation
 #   CCP4_BROWSER: set this if you intend to use the html documentation
 #      (recommended).  It should have the path and name of a html browser eg
-#      /usr/bin/X11/mozilla or /usr/local/bin/lynx. The browser will be
+#      /usr/bin/X11/mozilla or @PREFIX@/bin/lynx. The browser will be
 #      started with the alias ccp4help and will open the file
 #      $CHTML/INDEX.html.
 
-#   case `hostname` in			        # edit this case statement if used
-#                                       # for multiple systems
-#   foo)
-    export CBIN=$CCP4/bin		
-    export CLIB=$CCP4/lib	
+    export CBIN=$CCP4/bin        
+    export CLIB=$CCP4/lib    
 
-    export  CCP4_BROWSER=firefox
+    CCP4_BROWSER=""
+    if [[ $(uname) == Darwin ]]; then
+        export  CCP4_BROWSER="Safari"
+    elif [[ -x $(which firefox) ]]; then
+        export CCP4_BROWSER="firefox"
+    else 
+        export CCP4_BROWSER="mozilla"
+    fi
     
     MANPATH=$CCP4/man:$MANPATH           # edit this if necessary
     export MANPATH
-    if test -d $CCP4_MASTER/laue
-    then
-      export MCTYPE=unix 			# (only for Laue)
-    fi
-#     ;;
-#   *)
-#     echo "CCP4 not implemented on this system"
-#     exit 1
-#     ;;
-# esac
+    export MCTYPE=unix             # (only for Laue)
+ 
 
 # The following are for all systems
 
@@ -154,16 +181,6 @@
 CLASSPATH=$CBIN:$CLASSPATH               # edit this if necessary
 export CLASSPATH
 
-#Python path for the subprocess fixed module
-
-if ($ccp4_first_in_path) then
-    PYTHONPATH=${CCP4}/share/python:${PYTHONPATH}
-    export PYTHONPATH
-else
-    PYTHONPATH=${PYTHONPATH}:${CCP4}/share/python
-    export PYTHONPATH
-fi
-
 ### PLOT_COMMAND PRINT_COMMAND for the XCCPJIFFY programs to compile ###
 export PLOT_COMMAND='lpr'  
 export PRINT_COMMAND='lpr'    
@@ -176,7 +193,7 @@
 # as NEW that already exist.  Novices should use 'NEW' to avoid inadvertant 
 # over-writing of existing files, which is then treated as a fatal error.
 
-export CCP4_OPEN=UNKNOWN	
+export CCP4_OPEN=UNKNOWN    
 
 ### BINSORT_MEM ###
 # BINSORT_MEM is workspace used by the binsort program.  In principle this
@@ -189,124 +206,83 @@
 #  export BINSORT_MEM=8388608
 
 
-# If installed via fink, skip this bit:
-
-if [[ -z $SWPREFIX ]];then
-  if [[ -d /sw/bin/fink-virtual-pkgs ]];then
-    SWPREFIX=$(dirname $(dirname $(which /sw/bin/fink-virtual-pkgs)))
-  fi
-fi
-
-if [[ -z $SWPREFIX || $CCP4_MASTER != $SWPREFIX/share/xtal ]];then 
-    
-    # LD_LIBRARY_PATH specifies where to find dynamic libraries (e.g. libccp4.so)
-    # at runtime
-    
-    if test "$LD_LIBRARY_PATH"; then
-      if [[ $ccp4_first_in_path == 1 ]]; then
-        export LD_LIBRARY_PATH=$CLIB:$LD_LIBRARY_PATH
-      else
-        export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CLIB
-      fi
-    else
-      export LD_LIBRARY_PATH=$CLIB
-    fi
-    # DYLD_LIBRARY_PATH specifies where to find dynamic libraries
-    # (e.g. libccp4.dylib) at runtime
-    if test "$DYLD_LIBRARY_PATH"; then
-      if [[ $ccp4_first_in_path == 1 ]]; then
-        export DYLD_LIBRARY_PATH=$CLIB:$DYLD_LIBRARY_PATH
-      else
-        export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$CLIB
-      fi
-    else
-      export DYLD_LIBRARY_PATH=$CLIB
-    fi
-    
-    ### XAPPLRESDIR ###
-    
-    # If you want to use xloggraph/xplot84driver, you need to get the application
-    # defaults picked up somehow.  As distributed, the file can't just live in an
-    # application defaults directory since it requires reading by xrdb to sort out
-    # the differences for monochrome displays.  At Daresbury a version of the file
-    # assuming a monochrome display is kept in the directory
-    # $CCP4_LIB/X11/app-defaults and this is picked up through the
-    # XUSERFILESEARCHPATH environment variable.  That means you only see black and
-    # white on a colour display.  Alternatively you might make sure that it is
-    # read by xrdb on startup of the X Windows system or delegate the
-    # responsibility to users to run it.  There are disadvantages to putting an
-    # invocation of xrdb in here, one being that the correct value of DISPLAY may
-    # not be set at the time this file is read.  Thus edit this part as
-    # appropriate.  (SunOS will normally want to use /usr/openwin or $OPENWINHOME
-    # instead of /usr; others may want /usr/local/lib or some such):
-
-    if test -d $CCP4_LIB/X11/app-defaults; then
-
-      if [[ -n "$XUSERFILESEARCHPATH" ]]; then
-          XUSERFILESEARCHPATH=$CCP4_LIB/X11/app-defaults/%N:$XUSERFILESEARCHPATH
-      else
-          XUSERFILESEARCHPATH=$CCP4_LIB/X11/app-defaults/%N:/usr/lib/X11/app-defaults
-      fi
-    
-      export XUSERFILESEARCHPATH
-
-      fi
-fi
-
-### TRAPPFE ###
-# TRAPFPE is set to ensure (in collaboration with -lfpe) an abort on floating
-# point exceptions under IRIX.  It shouldn't cause harm on other systems, but
-# edit this to comment it out if necessary. Have now added a case statement.
-
-case `uname` in
-*IRIX* )
-  export TRAP_FPE="OVERFL=ABORT; DIVZERO=ABORT; INVALID=ABORT"
-  ;;
-* )
-  ;;
-esac
-
-# The following can be used to put a message of the day to announce news about
-# CCP4 or whatever to CCP4 users.  You might also want to edit this part to
-# have machine-specific messages dependent on `hostname`.
-test -r $CCP4/include/ccp4.msg && cat $CCP4/include/ccp4.msg
-
 ################### EXPERIENCED USERS STOP HERE #####################
 
 ################### THE REST SHOULDN'T NEED EDITING #####################
 
 ### dbCCP4i database handler setup ###
 
-export DBCCP4I_TOP=${CCP4}/share/dbccp4i
+export DBCCP4I_TOP="${CCP4}/share/dbccp4i"
 
 ### IMOSFLM environment is now defined here
 
-export MOSFLM_EXEC=${CBIN}/ipmosflm
-export MOSFLM_WISH=${CCP4I_TCLTK}/wish
-export IMOSFLM_VERSION="1.0.0"
+export MOSFLM_EXEC="${CBIN}/ipmosflm"
+export MOSFLM_WISH="${CCP4I_TCLTK}/wish"
+export IMOSFLM_VERSION="0.6.1"
 
 ### MMCIFDIC is now defined here. cif_mmdic.lib is a binary file ===
 # so on multiple installs it need to be unique and not in $CLIBD
 
-export MMCIFDIC=$CLIB/cif_mmdic.lib
+export MMCIFDIC="$CLIB/cif_mmdic.lib"
 
 ### MOLREPLIB Point to the location of the files bs-zeros.dat  ps.resource  symlib.blc
 # They are distributed with CCP4 in $CLIBD. This env must have the trailing \ or /
 
-export MOLREPLIB=$CCP4/lib/data/monomers/
+export MOLREPLIB="$CCP4/lib/data/monomers/"
 
 ### CRANK points to location of Crank automation suite within ccp4i
 
-export CRANK=$CCP4/ccp4i/crank
-export CCP4_CRANK=1
-
-### XIA2 setup
-# XIAROOT directory (default is under the share folder)
+export CRANK="$CCP4/ccp4i/crank"
+export CCP4_CRANK="1"
 
-if test -e $CCP4/share/XIAROOT/setup.sh
-then
-   . $CCP4/share/XIAROOT/setup.sh
-fi
+#  ### XIA2 setup
+#  # XIAROOT directory (default is under the share folder)
+#  
+#  if [[ -f  "$CCP4/share/XIAROOT/setup.sh" ]]; then
+#      # source "$CCP4/share/XIAROOT/setup.sh"  #has bad zsh syntax
+#      # so let us just do this here instead.
+#      export XIA2_HOME=${CCP4}/share/XIAROOT
+#  
+#      export XIA2CORE_ROOT=${XIA2_HOME}/xia2core
+#      export XIA2_ROOT=${XIA2_HOME}/xia2
+#      export XIA2_CCP4_61=1
+#      # add the test programs to the path
+#      if [[ $ccp4_first_in_path == 1 ]]; then
+#          PATH=${XIA2CORE_ROOT}/Test:${PATH}
+#      else
+#          PATH=${PATH}:${XIA2CORE_ROOT}/Test
+#      fi
+#      # check now according to platform
+#      if [[ "$(uname)" = "Darwin" ]]; then
+#          if [[ "$(uname -p)" == "powerpc" ]]; then
+#              if [[ $ccp4_first_in_path == 1 ]]; then
+#                  PATH=${XIA2_ROOT}/binaries/mac_ppc:${XIA2CORE_ROOT}/Test/Compiled/mac_ppc:${PATH}
+#              else
+#                  PATH=${PATH}:${XIA2_ROOT}/binaries/mac_ppc:${XIA2CORE_ROOT}/Test/Compiled/mac_ppc        
+#              fi
+#              if [[ -z $SWPREFIX || $CCP4_MASTER != @PREFIX@/share/xtal ]];then 
+#                  DYLD_LIBRARY_PATH=${XIA2_ROOT}/binaries/mac_ppc:${DYLD_LIBRARY_PATH}
+#                  export DYLD_LIBRARY_PATH
+#              fi
+#          elif [[ "$(uname -p)" == "i386" ]]; then
+#              if [[ $ccp4_first_in_path == 1 ]]; then
+#                  PATH=${XIA2_ROOT}/binaries/mac_386:${XIA2CORE_ROOT}/Test/Compiled/mac_386:${PATH}
+#              else
+#                  PATH=${PATH}:${XIA2_ROOT}/binaries/mac_386:${XIA2CORE_ROOT}/Test/Compiled/mac_386
+#              fi
+#              if [[ -z $SWPREFIX || $CCP4_MASTER != @PREFIX@/share/xtal ]];then 
+#                  DYLD_LIBRARY_PATH=${XIA2_ROOT}/binaries/mac_386:${DYLD_LIBRARY_PATH}
+#                  export DYLD_LIBRARY_PATH
+#              fi
+#          fi
+#      elif [[ "$(uname)" = "Linux" ]]; then
+#          if [[ $ccp4_first_in_path == 1 ]]; then
+#              PATH=${XIA2_ROOT}/binaries/linux_386:${XIA2CORE_ROOT}/Test/Compiled/linux_386:${PATH}
+#          else
+#              PATH=${PATH}:${XIA2_ROOT}/binaries/linux_386:${XIA2CORE_ROOT}/Test/Compiled/linux_386
+#          fi
+#      fi
+#  fi
 
 # Note: The PATH is updated with the xia2 Applications directory in the 
 # construct below.
@@ -314,27 +290,24 @@
 ### PISA_CONF_FILE is the config file needed to run the stand-alone PISA,
 #   though this can be set on the command line too.
 
-if test -e $CCP4/share/pisa/pisa.cfg 
-then
-  export PISA_CONF_FILE=$CCP4/share/pisa/pisa.cfg
-fi
+export PISA_CONF_FILE=$CCP4/share/pisa/pisa.cfg
 
 ### CLIBD_MON Point to the location of the dictionary files for REFMAC5
 # They are distributed with CCP4 in $CLIBD/monomers. This env must have 
 # the trailing \ or /
 
-export CLIBD_MON=$CCP4/lib/data/monomers/
+export CLIBD_MON="$CCP4/lib/data/monomers/"
 
 ### PUBLIC_FONT84, CCP4_HELPDIR, HELPDIR, MOSHELPFILE ###
 # (essential for the relevant programs)
-export PUBLIC_FONT84=$CLIB/font84.dat  # plot84 fonts [used by plot84lib]
+export PUBLIC_FONT84="$CLIB/font84.dat"  # plot84 fonts [used by plot84lib]
 
 # location of VMS-style help files required for mosflm [used by hlplib, chelp,
 #   chlp, (ip)mosflm]:
-export CCP4_HELPDIR=$CCP4/help/            # NB trailing /
+export CCP4_HELPDIR="$CCP4/help/"            # NB trailing /
 
 # Rasmol path. Needed for prog. to find rasmol.hlp
-export RASMOLPATH=$CCP4/x-windows/RasMol
+export RASMOLPATH="$CCP4/x-windows/RasMol"
 
 # CCP4 executables and scripts live in $CBIN and $CETC respectively; put them
 # on the path in an appropriate order for scripts to be used as wrappers for
@@ -343,9 +316,9 @@
 #
 
 if [[ $ccp4_first_in_path == 1 ]]; then
-    PATH=${CCP4}/etc:${CBIN}:${CCP4I_TOP}/bin:${DBCCP4I_TOP}/bin:$PATH
+    PATH=${CCP4}/etc:${CBIN}:${CCP4I_TOP}/bin:${DBCCP4I_TOP}/bin:${CCP4}/share/XIAROOT/xia2/Applications:$PATH
 else
-    PATH=$PATH:${CCP4}/etc:${CBIN}:${CCP4I_TOP}/bin:${DBCCP4I_TOP}/bin:${XIA2_ROOT}/Applications
+    PATH=$PATH:${CCP4}/etc:${CBIN}:${CCP4I_TOP}/bin:${DBCCP4I_TOP}/bin:${CCP4}/share/XIAROOT/xia2/Applications
 fi
 typeset -U path   # This construct prevents the path getting longer each time 
                   # ccp4.setup is executed in zsh.
@@ -379,34 +352,28 @@
   alias ccp4help='$CCP4_BROWSER $CHTML/INDEX.html'
 
 ### laue, lget, linkimages ###
-
-### only if we have the Laue software suite
-  if test -d $CCP4_MASTER/laue
-
 # Essential aliases for the Laue software suite
-    alias laue='$CCP4_MASTER/laue/cmd/laue.cmd'
-    alias lget='$CCP4_MASTER/laue/cmd/lget.cmd'
-    alias linkimages='$CCP4_MASTER/laue/cmd/linkimages.cmd'
+  alias laue='$CCP4_MASTER/laue/cmd/laue.cmd'
+  alias lget='$CCP4_MASTER/laue/cmd/lget.cmd'
+  alias linkimages='$CCP4_MASTER/laue/cmd/linkimages.cmd'
 
 # additional useful aliases for Laue directories
-    alias llaue='pushd $CCP4_MASTER/laue'
-    alias lsrc='pushd $CCP4_MASTER/laue/src>/dev/null'
-    alias llib='pushd $CCP4_MASTER/laue/lib>/dev/null'
-    alias llibs='pushd $CCP4_MASTER/laue/lib/src>/dev/null'
-    alias ldoc='pushd $CCP4_MASTER/laue/doc>/dev/null'
-    alias lmak='pushd $CCP4_MASTER/laue/make>/dev/null'
-    alias lutils='pushd $CCP4_MASTER/laue/utils>/dev/null'
-    alias lcmd='pushd $CCP4_MASTER/laue/cmd>/dev/null'
-    alias ldl='pushd $CCP4_MASTER/laue/dl>/dev/null'
-    alias ltestd='pushd $CCP4_MASTER/laue/testdata>/dev/null'
-    alias lxdl='pushd $CCP4_MASTER/laue/xdl_view>/dev/null'
-    alias lxdls='pushd $CCP4_MASTER/laue/xdl_view/src>/dev/null'
-    alias lgnom='pushd $CCP4_MASTER/laue/gnom>/dev/null'
-    alias lgnoms='pushd $CCP4_MASTER/laue/gnom/src>/dev/null'
-    alias lbin='pushd $CBIN>/dev/null'
+  alias llaue='pushd $CCP4_MASTER/laue'
+  alias lsrc='pushd $CCP4_MASTER/laue/src>/dev/null'
+  alias llib='pushd $CCP4_MASTER/laue/lib>/dev/null'
+  alias llibs='pushd $CCP4_MASTER/laue/lib/src>/dev/null'
+  alias ldoc='pushd $CCP4_MASTER/laue/doc>/dev/null'
+  alias lmak='pushd $CCP4_MASTER/laue/make>/dev/null'
+  alias lutils='pushd $CCP4_MASTER/laue/utils>/dev/null'
+  alias lcmd='pushd $CCP4_MASTER/laue/cmd>/dev/null'
+  alias ldl='pushd $CCP4_MASTER/laue/dl>/dev/null'
+  alias ltestd='pushd $CCP4_MASTER/laue/testdata>/dev/null'
+  alias lxdl='pushd $CCP4_MASTER/laue/xdl_view>/dev/null'
+  alias lxdls='pushd $CCP4_MASTER/laue/xdl_view/src>/dev/null'
+  alias lgnom='pushd $CCP4_MASTER/laue/gnom>/dev/null'
+  alias lgnoms='pushd $CCP4_MASTER/laue/gnom/src>/dev/null'
+  alias lbin='pushd $CBIN>/dev/null'
   
-  fi
-
 # Get rid of the ccp4help alias and make a more useful function
 
     alias ccp4help="" ; unalias ccp4help
@@ -435,26 +402,26 @@
   compctl -g '*.plt' xplot84
   compctl -g '*.plt' xplot84driver
   
+    # Remove any instances of multiple colons
+    PATH=${PATH/::/:}
+
     # Avoid repeats in the path
- 
+
     typeset -U path
     typeset -U manpath
     typeset -U classpath
      
-# Set-up cctbx environment
-test -r $CCP4/lib/cctbx/cctbx_build/setpaths.sh && . $CCP4/lib/cctbx/cctbx_build/setpaths.sh
- 
-# Set-up phaser environment
-if ( test -d $CCP4/src/phaser) ; then
-  phaser_mtype=`$CCP4/src/phaser/bin/machine_type`
-  phaser_version=`grep PHASER_VERSION $CCP4/src/phaser/conf/version.sh | awk '{print $3}'`
-  phaser_setup_file="${CCP4}/src/phaser/phaser-${phaser_version}/build/${phaser_mtype}/setpaths.sh"
-  test -r $phaser_setup_file && . $phaser_setup_file
-fi
+####     # Set up cctbx environment
+####     [[ -f "$CCP4/lib/cctbx/cctbx_build/setpaths.sh" ]]  && source "$CCP4/lib/cctbx/cctbx_build/setpaths.sh"
+####      
+####     # Set up phaser environment
+####     if [[ -f $CCP4/src/phaser ]] ; then
+####       phaser_mtype=$( $CCP4/src/phaser/bin/machine_type )
+####       phaser_version=$(grep PHASER_VERSION $CCP4/src/phaser/conf/version | awk '{print $3}')
+####       phaser_setup_file="${CCP4}/src/phaser/phaser-${phaser_version}/build/${phaser_mtype}/setpaths.sh"
+####       [[ -f "$phaser_setup_file" ]] && source "$phaser_setup_file"
+####     fi
 
 #BALBES root configuration
-if ( test -d $CCP4/share/balbes/BALBES_0.0.1)
-then
-  export BALBES_ROOT=$CCP4/share/balbes/BALBES_0.0.1
-fi
+export BALBES_ROOT="$CCP4/share/balbes/BALBES_0.0.1"
 
diff -ruN ccp4-6.1.13-dist/lib/ccif/configure ccp4-6.1.13/lib/ccif/configure
--- ccp4-6.1.13-dist/lib/ccif/configure	2010-03-08 06:22:50.000000000 -0800
+++ ccp4-6.1.13/lib/ccif/configure	2010-06-14 14:41:19.000000000 -0700
@@ -5684,7 +5684,7 @@
          else
            SHARED_LIB_PATH='DYLD_LIBRARY_PATH=`pwd`'
          fi
-         SHARED_LIB_CMD='$(CC) $(SHARED_LIB_CFLAGS) -dynamiclib -flat_namespace -undefined suppress -install_name $(SHARED_LIB_NAME) -all_load $L -o $(SHARED_LIB_NAME)'
+         SHARED_LIB_CMD='$(CC) $(SHARED_LIB_CFLAGS) -dynamiclib -flat_namespace -undefined suppress -install_name @PREFIX@/lib/ccp4-6.1.13/$(SHARED_LIB_NAME)  -all_load $L -o $(SHARED_LIB_NAME)'
          SHARED_LIB_EXPORTS_CMD=''
          ;;
          esac
diff -ruN ccp4-6.1.13-dist/src/rapper/gc7.0/Makefile.in ccp4-6.1.13/src/rapper/gc7.0/Makefile.in
--- ccp4-6.1.13-dist/src/rapper/gc7.0/Makefile.in	2008-01-24 05:52:42.000000000 -0800
+++ ccp4-6.1.13/src/rapper/gc7.0/Makefile.in	2010-06-14 14:42:33.000000000 -0700
@@ -295,7 +295,7 @@
 CYGPATH_W = @CYGPATH_W@
 DARWIN_THREADS_FALSE = @DARWIN_THREADS_FALSE@
 DARWIN_THREADS_TRUE = @DARWIN_THREADS_TRUE@
-DEFS = @DEFS@
+DEFS = @DEFS@ -D_XOPEN_SOURCE
 DEPDIR = @DEPDIR@
 ECHO = @ECHO@
 ECHO_C = @ECHO_C@
diff -ruN ccp4-6.1.13-dist/src/rapper/libxml2/threads.c ccp4-6.1.13/src/rapper/libxml2/threads.c
--- ccp4-6.1.13-dist/src/rapper/libxml2/threads.c	2006-12-19 03:39:24.000000000 -0800
+++ ccp4-6.1.13/src/rapper/libxml2/threads.c	2010-06-14 14:48:16.000000000 -0700
@@ -619,7 +619,7 @@
 #ifdef HAVE_PTHREAD_H
     if (libxml_is_threaded == 0)
         return(0);
-    return((int) pthread_self());
+    return((int)(uintptr_t) pthread_self());
 #elif defined HAVE_WIN32_THREADS
     return GetCurrentThreadId();
 #elif defined HAVE_BEOS_THREADS
diff -ruN ccp4-6.1.13-dist/x-windows/Mosflm/src/dps/util/filec/namfil.c ccp4-6.1.13/x-windows/Mosflm/src/dps/util/filec/namfil.c
--- ccp4-6.1.13-dist/x-windows/Mosflm/src/dps/util/filec/namfil.c	2003-03-10 05:38:21.000000000 -0800
+++ ccp4-6.1.13/x-windows/Mosflm/src/dps/util/filec/namfil.c	2010-06-14 14:46:36.000000000 -0700
@@ -78,7 +78,7 @@
    *  Find first hash in FILNAM, it will hold sign if NUM is negative and
    *  there is room for it.
    */
-	fsthsh = (int) strchr(filnam, '#')- (int) filnam;
+	fsthsh = (int)(uintptr_t) strchr(filnam, '#')- (int)(uintptr_t) filnam;
 	if (fsthsh > 0)
 	{
 		for (i = len-1; i>=fsthsh; i--)
diff -ruN ccp4-6.1.13-dist/x-windows/Mosflm/src/dps/util/filec/rdbinary.c ccp4-6.1.13/x-windows/Mosflm/src/dps/util/filec/rdbinary.c
--- ccp4-6.1.13-dist/x-windows/Mosflm/src/dps/util/filec/rdbinary.c	2003-07-25 04:14:53.000000000 -0700
+++ ccp4-6.1.13/x-windows/Mosflm/src/dps/util/filec/rdbinary.c	2010-06-14 14:45:39.000000000 -0700
@@ -84,7 +84,7 @@
 
 		if ( global_debug )
 			printf ("Allocated %d bytes at location %d\n",
-			    *filesize, (int) a);
+			    *filesize, (int)(uintptr_t) a);
 
 		j = strlen(filename);
 		dskbor_ ( &lun, filename, &j, &istat);
diff -ruN ccp4-6.1.13-dist/x-windows/Mosflm/src/dps/util/filec/wrfile.c ccp4-6.1.13/x-windows/Mosflm/src/dps/util/filec/wrfile.c
--- ccp4-6.1.13-dist/x-windows/Mosflm/src/dps/util/filec/wrfile.c	2003-03-10 05:38:21.000000000 -0800
+++ ccp4-6.1.13/x-windows/Mosflm/src/dps/util/filec/wrfile.c	2010-06-14 14:50:00.000000000 -0700
@@ -15,6 +15,7 @@
  ****************************************************************/
 #include <string.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include "filec.h"
 
 int wrfile (char* filename, char* head, char* array, 
@@ -35,7 +36,7 @@
 	{
 		printf("Filename      : %s\n", filename);
 		printf("Header        : \n%s<END\n", head);
-		printf("Array address : %d\n", (int) array);
+		printf("Array address : %d\n", (int)(uintptr_t) array);
 		printf("Array dim     : %d\n", naxis);
 		for (i=0; i<naxis; i++)
 			printf("              : %d\n", axis[i]);
diff -ruN ccp4-6.1.13-dist/x-windows/Mosflm/src/dps/util/filec/wrmad.c ccp4-6.1.13/x-windows/Mosflm/src/dps/util/filec/wrmad.c
--- ccp4-6.1.13-dist/x-windows/Mosflm/src/dps/util/filec/wrmad.c	2003-03-10 05:38:22.000000000 -0800
+++ ccp4-6.1.13/x-windows/Mosflm/src/dps/util/filec/wrmad.c	2010-06-14 14:44:02.000000000 -0700
@@ -47,7 +47,7 @@
 	{
 		printf("Filename      : %s\n", filename);
 		printf("Header        : \n%s<END\n", head);
-		printf("Array address : %d\n", (int) array);
+		printf("Array address : %d\n", (int)(uintptr_t) array);
 		printf("Array size    : %d %d\n", as1, as2);
 		printf("Image size    : %d %d\n", is1, is2);
 	}
diff -ruN ccp4-6.1.13-dist/x-windows/XCCPJIFFY/EditString.c ccp4-6.1.13/x-windows/XCCPJIFFY/EditString.c
--- ccp4-6.1.13-dist/x-windows/XCCPJIFFY/EditString.c	2003-11-19 01:46:38.000000000 -0800
+++ ccp4-6.1.13/x-windows/XCCPJIFFY/EditString.c	2010-06-14 14:57:29.000000000 -0700
@@ -256,10 +256,10 @@
 WidgetClass editStringWidgetClass = (WidgetClass)&editStringClassRec;
 
 
-static char                   space_char [] = {' ',NULL};
+static char                   space_char [] = {' ',(uintptr_t)NULL};
 static XawTextBlock           new_input,
-                              no_input = {0, 0, NULL, NULL},
-                              space_input = {0, 1, space_char, NULL};
+                              no_input = {0, 0, NULL, (uintptr_t)NULL},
+                              space_input = {0, 1, space_char, (uintptr_t)NULL};
 
 /***********************************************************/
 static void
diff -ruN ccp4-6.1.13-dist/x-windows/XCCPJIFFY/ZDr2d.c ccp4-6.1.13/x-windows/XCCPJIFFY/ZDr2d.c
--- ccp4-6.1.13-dist/x-windows/XCCPJIFFY/ZDr2d.c	2003-07-01 09:57:00.000000000 -0700
+++ ccp4-6.1.13/x-windows/XCCPJIFFY/ZDr2d.c	2010-06-14 14:55:24.000000000 -0700
@@ -1007,7 +1007,7 @@
     return("Object alredy exists");
 
   gobj = XtNew(GR_OBJECT);
-  memset((void *)gobj, NULL, sizeof(GR_OBJECT));
+  memset((void *)gobj, (uintptr_t)NULL, sizeof(GR_OBJECT));
   gobj->objid = obj_id;
 
   if (!parent_obj_id) {                 /* object attached directly to scene */
@@ -1200,7 +1200,7 @@
 
   ppart = &(w->zDr2d);
   instr = XtNew(INSTRUCTION);
-  memset((void *)instr, NULL, sizeof(INSTRUCTION));
+  memset((void *)instr, (uintptr_t)NULL, sizeof(INSTRUCTION));
   instr->instruction_type = instruction_type;
 
   if (ppart->current_instr)
diff -ruN ccp4-6.1.13-dist/x-windows/XCCPJIFFY/log_file.c ccp4-6.1.13/x-windows/XCCPJIFFY/log_file.c
--- ccp4-6.1.13-dist/x-windows/XCCPJIFFY/log_file.c	2004-12-08 09:57:45.000000000 -0800
+++ ccp4-6.1.13/x-windows/XCCPJIFFY/log_file.c	2010-06-14 14:53:41.000000000 -0700
@@ -214,27 +214,27 @@
 
   log_file_tabs =
      (LOG_FILE_TABLE *)malloc(sizeof(LOG_FILE_TABLE) * (ntables+1));
-  memset((void *)log_file_tabs, NULL,
+  memset((void *)log_file_tabs, (uintptr_t)NULL,
 	 (size_t)sizeof(LOG_FILE_TABLE) * (ntables+1));
   table_list = (char **)XtMalloc(sizeof(char *) * (ntables + 1));
   table_list [ntables] = (char *)NULL;
 
   log_file_keytxts =
      (LOG_FILE_KEYTEXT *)malloc(sizeof(LOG_FILE_KEYTEXT) * (nkeytexts+1));
-  memset((void *)log_file_keytxts, NULL,
+  memset((void *)log_file_keytxts, (uintptr_t)NULL,
 	 (size_t)sizeof(LOG_FILE_KEYTEXT) * (nkeytexts+1));
   keytext_list = (char **)XtMalloc(sizeof(char *) * (nkeytexts + 1));
   keytext_list [nkeytexts] = (char *)NULL;
 
   log_file_txts = (LOG_FILE_TEXT *)malloc(sizeof(LOG_FILE_TEXT) * (ntexts+1));
-  memset((void *)log_file_txts, NULL,
+  memset((void *)log_file_txts, (uintptr_t)NULL,
 	 (size_t)sizeof(LOG_FILE_TEXT) * (ntexts+1));
   text_list = (char **)XtMalloc(sizeof(char *) * (ntexts + 1));
   text_list [ntexts] = (char *)NULL;
 
   log_file_summs =
      (LOG_FILE_SUMMARY *)malloc(sizeof(LOG_FILE_SUMMARY) * (nsumms+1));
-  memset((void *)log_file_summs, NULL,
+  memset((void *)log_file_summs, (uintptr_t)NULL,
 	 (size_t)sizeof(LOG_FILE_SUMMARY) * (nsumms+1));
   summary_list = (char **)XtMalloc(sizeof(char *) * (nsumms + 1));
   summary_list [nsumms] = (char *)NULL;
@@ -568,7 +568,7 @@
 
   /*** Play with absolute/relative scale ***/
 
-  memset((void *)(&scene), (int)NULL, sizeof(scene));
+  memset((void *)(uintptr_t)(&scene), (int)(uintptr_t)NULL, sizeof(scene));
 
   scale = 1.0;                              /* scaling done in plot widget */
 
@@ -756,7 +756,7 @@
     /*** Allocate entry & chain it ***/
 
     pgraph = XtNew(LOG_FILE_GRAPH);
-    memset((void *)pgraph, NULL, (size_t)sizeof(LOG_FILE_GRAPH));
+    memset((void *)pgraph, (uintptr_t)NULL, (size_t)sizeof(LOG_FILE_GRAPH));
     if (!table->graphs)
       table->graphs = pgraph;
     else {
diff -ruN ccp4-6.1.13-dist/x-windows/XCCPJIFFY/plot84_file.c ccp4-6.1.13/x-windows/XCCPJIFFY/plot84_file.c
--- ccp4-6.1.13-dist/x-windows/XCCPJIFFY/plot84_file.c	2004-07-08 08:29:48.000000000 -0700
+++ ccp4-6.1.13/x-windows/XCCPJIFFY/plot84_file.c	2010-06-14 14:49:05.000000000 -0700
@@ -148,7 +148,7 @@
     return("I/O error on plot84 file");
   }
 
-  memset((void *)(&scene), (int)NULL, sizeof(scene));
+  memset((void *)(uintptr_t)(&scene), (int)(uintptr_t)NULL, sizeof(scene));
 
   scale = 0.1;                          /* 10 dots per mm plot 84 convention */
 
