- Table of contents
- Building CDO against libs4cdo
This package contains every library CDO needs for full functionality including automated tasks for building and installing:
- file IO: netcdf, hdf5, grib_api
- file compression: szip, jasper, zlib
- complex projections: proj
- win32 threading: Pthreads-w32
Installation of libraries¶
After unpacking the tarball, there are two main targets ready to use for building and installing all libs:
libs4cdo: build and install all libraries, that are currently supported by the unix version of CDO.
win32libs4cdo: build and install all libraries, that are currently supported by the windows version of CDO. For the list of supported libraries, see the windows page.
The default actions on a UNIX-based machine after extraction are:
cd libs4cdo-x.x.x make libs4cdo
The default installation directory is called
build. Please set the
PREFIX variable on the command line for a different location, e.g.
make libs4cdo PREFIX=/usr/local. Relative paths are possible, because most version of make can figure out the absolute path. Be sure that
PREFIX has really made it into the
configure call. Variable handling depends on your version of
make. Therefor each call of
make starts with a short log message, which displays some settings, e.g.
make libs4cdo PREFIX=/usr/local/trash prints
make config all install LIB="zlib-1.2.3 szip-2.1 proj-4.6.1" CONFIGFILE=cdo.mk PREFIX=/usr/local/trash make: Entering directory `/home/ram/src/cdo/branches/libs4cdo' Global Target: config LIB: zlib-1.2.3 szip-2.1 proj-4.6.1 DEFAULT_LIBS: grib_api-1.8.0 hdf5-1.8.4 jasper-1.900.1 netcdf-3.6.3 netcdf-4.0.1 proj-4.6.1 pthreads-w32-2-8-0-release szip-2.1 win32/hdf5-1.8.4 zlib-1.2.3 if test -z "zlib-1.2.3 szip-2.1 proj-4.6.1"; then for lib in grib_api-1.8.0 hdf5-1.8.4 jasper-1.900.1 netcdf-3.6.3 netcdf-4.0.1 proj-4.6.1 pthreads-w32-2-8-0-release szip-2.1 win32/hdf5-1.8.4 zlib-1.2.3; do make $lib ACTION=config CROSS= PREFIX=/usr/local/trash; done; else make zlib-1.2.3 szip-2.1 proj-4.6.1 ACTION=config CROSS= PREFIX=/usr/local/trash; fi; make: Entering directory `/home/ram/src/cdo/branches/libs4cdo' LIBTARGET: zlib-1.2.3 LIBOPTS : LIBENV : --prefix=/usr/local/trash ACTION : config Start configuring zlib-1.2.3: Checking for gcc...
CROSSvariable for different cross compiler. The Makefile uses both variables, so just have a look into it if you need examples. For most recent documentation use
It is highly recommended, that the windows emulator Wine is installed and configured to handle
exefiles automatically. On Ubunutu systems, this is done by the package management system via setting mime-type rules. Otherwise, cross compiling will fail, e.g. hdf5 uses a self created binary to create further source code.
Avoid a library¶
UNIX_STAGE0 = $(SZIP) $(PROJ) UNIX_STAGE1 = $(HDF5) UNIX_STAGE2 = $(NETCDF4)
The configuration file
cdo.mkmust be updated:
$(NETCDF3_6_3)_CONFIGURE_OPTS += --enable-c-only --enable-shared $(NETCDF4)_CONFIGURE_OPTS += --enable-c-only --enable-shared --with-hdf5=$(PREFIX) --with-szlib=$(PREFIX) --enable-netcdf-4 $(HDF5)_CONFIGURE_OPTS += --with-zlib=/usr --with-szlib=$(PREFIX) --enable-shared --enable-hl --disable-cxx --disable-fortran --enable-threadsafe --with-pthread $(PROJ)_CONFIGURE_OPTS += --without-mutex --disable-jni $(JASPER)_CONFIGURE_OPTS += --enable-shared $(GRIBAPI)_CONFIGURE_OPTS += --with-jasper=$(PREFIX) --disable-fortran
Adding new library/Use Makefile for other library¶
The Makefile is designed for easy extension of libs4cdo or reuse for other projects. Most targets are generated on the fly, depending on how you call it. Lets say
lib-fancy is your project to impress your boss. It uses autoconf and supports different configuration settings for different purposes. Testing all theses settings can be a hard and you do not want to retype the configure statements all the time. Of course you could write a shell script, maybe you could write in assembler, Visual Basic, xslt or latex, but this is about dependencies. And that's what
make was designed for.
Put the Makefile in the parent directory of you
lib-fancy code. Without changing the Makefile
make config LIB=lib-fancyrun the default configure settings inside the
lib-fancydirectory. This could also be done by
make lib-fancy ACTION=config. Both variants have their purpose, but let's get back to that later.
To run a complete fresh build on
make config clean all install LIB=lib-fancyor with a different prefix
make config all install LIB=lib-fancy PREFIX=/usr/local/lib-fancy-default
If you need to check
lib-fancywith different compilers or configure options, create a file, let's say
lib-fancy.mk, that contains
$(LIB)_CONFIGURE_OPTS := --with-netcdf=$(PREFIX) --prefix=$(PREFIX) $(LIB)_CONFIGURE_ENV := CC='suncc'
make config CONFIGFILE=lib-fancy.mk LIB=lib-fancy
for applying that change. Need a separate
PREFIXfor this setting? Add this to
fancySun: make config LIB=$(LIB) CONFIGFILE=libfancy.mk PREFIX=/usr/local/lib-fancy-sun
and call the target:
make fancySun LIB=lib-fancy CONFIGFILE=libfancy.mk. Like predefined targets, additional ones can be combined with other targets:
make fancySun all install LIB=lib-fancy CONFIGFILE=libfancy.mk
PREFIXis a used for presets in the
Makefile, that's why it cannot be overwritten entirely by setting it in a config file. It has to be given on the command line (which can be saved in the config file).
And now for all, who love the command line too much to creating a file, here is the call which does the above in a single line:
make config all install LIB=lib-fancy lib-fancy_CONFIGURE_OPTS="--with-netcdf=$(pwd)/build-sun --prefix=$(pwd)/build-sun" lib-fancy_CONFIGURE_ENV="CC=suncc"
Building CDO against libs4cdo¶
make libs4cdo installs all libraries in the same directory. If the
PREFIX variable was not set on the command line, this directory is
/path-to-libs4cdo/build. If you extracted libs4cdo into you home directory, this would be
Building CDO with
libs4cdo is fairly easy now: Every of the configure options
--with-proj get the same directory as their argument:
./configure --with-szlib=$HOME/libs4cdo-0.0.7/build --with-hdf5=$HOME/libs4cdo-0.0.7/build --with-netcdf=$HOME/libs4cdo-0.0.7/build --with-proj=$HOME/libs4cdo-0.0.7/build
Same holds true for the
--with-threads should not be necessary on most unix platforms and cygwin, because
posix threads are available on almost every unix-like system. That's why these two things are not installed by default, when
make libs4cdois called.