To build cernlib from the source files you need to install gcc, imake, motif, and the compatibility library.
$ sudo apt-get update
$ sudo apt-get install gcc imake motif-devel Libcompat
$ sudo apt-get clean
If you just want to use precompiled binary packages, go directly to Installation subsection.
MacOS14.7In order to compile it in 64-bit mode, we need extra paches. The patches for 64-bit support are largely due to Harald Vogt at DESY. Thanks to Remi Mommsen, the main cernlib mainteainer of Fink Project, these 64-bit paches have been assmbled with various MacOSX patches. The first patch I will use below is the result of hard work by these people.
gcc-14.2.0-1osx14
imake-1.0.10-14hepx2a
Libcompat-14.1-14hepx5a
motif-2.3.8-14hepx2a
[0] Preparation
In the following, <somewhere> stands for a directory into which you downloaded necessary tarballs or patches, while <user name> means your login name. Replace them as needed according to your environment.
$ cd /opt
$ sudo mkdir cern
$ cd cern
$ sudo tar -zxvf 2006_src.tar.gz
$ sudo ln -s 2006 new
$ sudo ln -s 2006 pro
$ sudo chown <user name> 2006
$ sudo chown -R <user name> 2006/src
$ cd 2006/src
$ patch -p1 -s < <somewhere>/cernlib2006-2006b-14.patch
In order to build cernlib on MacOS12/Monterey, I had to apply some private patches to work around remaining problems:
$ patch -p1 -s < <somewhere>/cernlib-2006-macosx10.9.patch
$ patch -p1 -s < <somewhere>/cernlib-2006-macosx10.11.patch
$ patch -p1 -s < <somewhere>/cernlib-2006-macos12.patch
$ patch -p1 -s < <somewhere>/cernlib-2006-test.patch
On my M1 Mac, I had to apply some more private patches:
$ patch -p1 -s < <somewhere>/cernlib-2006-arm64.patch
$ patch -p1 -s < <somewhere>/cernlib-2006-arm64-gfortran-bug.patch,
where the last patch is to work around a gfortran problem on M1 Macs, which happens when C/C++ functions call fortran subroutines/functions with "character*" arguments (see gfortran section).
On MacOS 14, I had to add four more patches:
$ patch -p1 -s < <somewhere>/cernlib-2006-nypatchy.patch
$ patch -p1 -s < <somewhere>/cernlib-2006-macos14.patch,
$ patch -p1 -s < <somewhere>/cernlib-2006-gtest.patch,
$ patch -p1 -s < <somewhere>/cernlib-2006-cscrexec.patch,
[1] Build
$ cd /opt/cern/2006/
$ mkdir bin lib work
$ cd lib
$ ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/liblapack.tbd liblapack3.a
$ ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libblas.tbd libblas.a
$ cd ../..
$ export CERN=`pwd`
$ cd 2006
$ export CVSCOSRC=$CERN/2006/src
$ pushd $CVSCOSRC/scripts
$ sed -e "s;/cern;/opt/cern;" -i cernlib
$ sed -e "s;/cern;/opt/cern;" -i gxint
$ sed -e "s;/cern;/opt/cern;" -i paw
$ popd
$ pushd graflib/dzdoc/dzedit
$ sed -e "s;/cern;/opt/cern;" -i dzedit.script
$ popd
$ pushd pawlib/paw/programs
$ sed -e "s;/cern;/opt/cern;" -i paw.script
$ popd
$ cp -p scripts/cernlib ../bin
$ cd ../work
$ ../src/config/imake_boot
$ export PATH=$PATH:$CERN/2006/bin
$ mkdir ../logs
$ make tree HAVE_MOTIF='YES' >& ../logs/tree.log &
$ tail -f ../logs/tree.log
^C
$ pushd packlib/kuip/programs/kuipc
$ make
$ make install.bin
$ popd
$ make HAVE_MOTIF='YES' >& ../logs/make.log &
$ tail -f ../logs/make.log
^C
$ cd packlib
$ make install.bin HAVE_MOTIF=YES >& ../../logs/packlib.bin.log &
$ tail -f ../../logs/packlib.bin.log
$ cd ../pawlib
$ make install.bin HAVE_MOTIF=YES EXTRA_INCLUDES="-I$CERN/2006/src/pawlib/comis" >&
../../logs/pawlib.bin.log &
$ tail -f ../../logs/pawlib.bin.log
^C
$ cd ../graflib
$ make install.bin HAVE_MOTIF=YES >& ../../logs/graflib.bin.log &
$ tail -f ../../logs/graflib.bin.log
$ cd ../scripts
$ make install.bin HAVE_MOTIF='YES' >& ../../logs/scripts.bin.log &
$ tail -f ../../logs/scripts.bin.log
^C
$ cd ..
$ make install.include CERN_INCLUDEDIR=/cern/new/include \
>& ../logs/install.include.log &
$ tail -f ../logs/install.include.log
[2] Tests
$ cd packlib
$ make test EXTRA_LOAD_FLAGS="-L$CERN/2006/lib -lpacklib -lgrafX11 -L/opt/X11/lib -lX11" \
>& ../../logs/packlib.test.log &
$ tail -f ../../logs/packlib.test.log
ALL TESTS PASSED
^C
$ cd ../mathlib
$ make test >& ../../logs/mathlib.test.log &
$ tail -f ../../logs/mathlib.test.log
ALL TESTS PASSED
^C
$ cd ../graflib/higz/examples
$ make higzex
$ ./higzex
OK!
$ cd ../../../../src/pawlib/paw/demo
$ printenv DISPLAY
$ cp -p higz_windows.dat higz_windows.dat.orig
$ vi higz_windows.dat
...
... adjust DISPLAY parameter
...
$ export MallocNanoZone=0
$ paw all.kumac
...
go
...
OK!
$ cd ../../../../work/mclibs
$ make test >& ../../logs/mclibs.test.log &
$ tail -f ../../logs/mclibs.test.log
ALL test PASSED
^C
$ cd ../phtools
$ make test >& ../../logs/phtools.test.log &
$ tail -f ../../logs/phtools.test.log
ALL TESTS
PASSED
^C
$ cd ../geant321
$ make test >& ../../logs/geant321.test.log &
$ tail -f ../../logs/geant321.test.log
ALL TESTS
PASSED
^C
$ sudo apt-get update
$ sudo apt-get install cernlib
$ sudo apt-get clean
$ sudo ln -s 2006 /opt/cern/pro
By default cernlib will be installed under /opt/cern. Add /opt/cern/pro/bin
to your PATH in order to use PAW, PAW++, etc.
Important Remark:
before using paw, do the following
$ export MallocNanoZone=0
or it will just abend.
This is a trick to keep paw within the 32-bit address space.
You can also use a setup script: /opt/cern/2006/bin/thiscernlib.sh as
$ source /opt/cern/2006/bin/thiscernlib.sh
paw and paw++ are not yet fully tested for M1 Macs in particular, so use them at your own risk.