CERNLIB for Mac OS X 10.2

This site describes how to build the CERNLIB 2002 from the sources on Mac OS X 10.2. Please note that these instructions are for the brave going to build CERNLIB by her/him-self. I recommend to use fink to compile CERNLIB unless you have a good reason not to do.

Pre-requisites

This description for the compilation of the CERNLIB on Mac OS X 10.2 (aka Jaguar) uses as much as possible the fink tools. Keisuke Fujii has a site for installing the CERNLIB compiled under Mac OS 10.2 which uses a ported version of rpm for package management.

  1. Install a X11 environment (either from Apple or from XFree86).
  2. Install the Apple Developer Tools available from your Mac OS X CDs or download them after a free registration.
  3. Install the g77 compiler from gcc.gnu.org. Please note that there are problems getting correct compiles with g77 3.3. You have to use either g77 3.1 (together with gcc 3.1) or g77 3.4 (together with gcc 3.3).

Missing Libraries

The Fortran 77 LAPACK (Linear Algebra PACKage) is no longer part of the CERNLIB because it exists in optimized versions for various operating systems.

  1. I got the compiled version of LAPACK from http://gravity.psu.edu/~khanna/hpc.html (close to the bottom of the page).
  2. Install the tar file to /usr/local/lib
  3. Provide softlinks for the old naming of the libs used by CERNLIB
    ln -s libf77blas.a libblas.a
    ln -s liblapack.a liblapack3.a
  4. The final missing piece is a symbol called _cuserid which is normally found in libcompat.c. I was not able to find this library for Mac OS X. Therefore I took the source code and made a libcompat.a lib out of it. I installed it into /usr/local/lib, too.

CERNLIB itself

  1. Download the source files (src_*tar.gz) and the Imakefile from http://wwwinfo.cern.ch/asd/cernlib/download/2002_source/tar/ to any local directory <LOCAL_DIR>.
  2. Extract all tar files. The easiest command to achieve this is
    ls -1 src_*.tar.gz | xargs -n1 tar xzf
  3. Move the Imakefile to the into the now existing 2002/src directory
    mv Imakefile 2002/src
  4. Apply the cernlib-2002-macosx.patch patch which is based on Keisuke Fujii patch for cernlib 2001.
    cd <LOCAL_DIR>/2002/src; patch -p0 < cernlib-2002-macosx.patch
  5. Create the install directories and set the environment accordingly
    mkdir -p /cern/2002; setenv CERN /cern; setenv CERN_LEVEL 2002; setenv PATH ${CERN}/${CERN_LEVEL}/bin:${PATH}
    You should include these environment variables in your .cshrc in order to find the CERNLIB later on.
  6. Next set the CVSCOSRC environment to the root of the src files and start the boot strap
    setenv CVSCOSRC <LOCAL_DIR>/2002/src; $CVSCOSRC/config/imake_boot
  7. Keep your fingers crossed and type make. This produces all libraries and installs them into $CERN/$CERN_LEVEL
  8. Next build kuipc with make bin/kuipc
  9. Next install the scripts with make scripts/Makefile; cd scripts; make install.bin
  10. Then build the packlib executables: cd ../packlib; make install.bin
  11. And graflib executables: cd ../graflib; make install.bin
  12. Finally build the paw executable cd ../pawlib; make install.bin
  13. And for future s/w development we install the include files with cd ..; make install.include CERN_INCLUDEDIR=$CERN/$CERN_LEVEL/include
  14. A sensible thing to do is to run the tests on your new built CERNLIB:
    1. First on packlib:
      cd packlib; make test
      At the end of the output you should see KERNNUM CHECK HAS BEEN SUCCESSFUL.
    2. Then on mathlib:
      cd ../mathlib; make test
      If everything is fine, all test except C327 should be completed successfully
    3. Next in turn is mclibs:
      cd ../mclibs; make test
      HERWIG seems to have a problem and loops indefinitely on one event. I'm not using HERWIG and I'm not an expert. Thus use HERWIG with caution.
    4. Then on phtools:
      cd ../phtools; make test
      wicot prints some output to the screen and finishes gracefully.
    5. The last lib is geant321:
      cd ../geant321; make test
      This should print a lot of tables and histos onto the screen, but no error messages!
    6. Next is higz:
      cd ../graflib/higz; make examples/Makefile
      cd examples; make higzex
      ./higzex

      The higzex executable should return 6 example screens.
    7. And finally paw:
      cd ../../../pawlib/paw/demo; paw all.kumac
      paw will run over a set of test kumacs once you give the go command. If everything works as expected you have successfully compiled the CERNLIB.
  15. Finally set the correct permissions on your /cern/2002 directory:
    cd /cern; sudo chown -R root:staff 2002

Please report any improvements to, corrections for and problems with the above recipe. However, I cannot guarantee any support.

Valid HTML 4.01! Valid CSS!