Download presentation
Presentation is loading. Please wait.
Published byBethanie Wood Modified over 8 years ago
1
CLHEP Infrastructure Improvements CHEP 2004 Lynn Garren, FNAL and Andreas Pfeiffer, CERN
2
What is CLHEP? HEP-specific foundation and utility classes that provide – Random number generators – Physics vectors – Particle data table – Etc. Used by Geant4, ThePeg, …
3
The problem CLHEP has traditionally been distributed as one large package which builds one large library Some packages are updated more frequently than CLHEP releases Users may want only some of the packages Users may want to get single package updates
4
The solution Enable separate builds of each CLHEP package – Each package needs its own configure – Have to worry about dependencies Still build entire CLHEP – Default option – Use infrastructure in each package
5
Other changes Use namespace everywhere – Namespace CLHEP if no other namespace Add exception handling packages – Exceptions, Cast, Refcount – Disabled by default Geometry package substantially rewritten Updates to several packages
6
Code Structure Old source code: – CLHEP/ (*.cc, *.hh, *.h, *.icc) – CLHEP/ /doc – CLHEP/test (tests for all packages) New source code : – CLHEP/ / (*.h, *.hh, *.icc) – CLHEP/ /src (*.cc) – CLHEP/ /doc – CLHEP/ /test (tests for this package)
7
Concerns Backwards compatibility Headers invoked as “CLHEP/ /myheader.h” – Notice that this does not match the source code structure – Create a temporary header directory when building
8
Supported Compilers gcc 3.3 (all operating systems) gcc 2.95.2 (only for backwards compatibility) gcc 3.4 tested, but not yet officially supported Solaris CC 5.4 Windows VisualC++ 7.1 – Must compile under cygwin – Do not need to be in cygwin to use libraries
9
Releases Two concurrent releases – CLHEP 1.9.x.x is backwards compatible “using namespace CLHEP” in headers CLHEP.h and package defs.h headers Supports gcc 2.95.2 – CLHEP 2.0.x.x is NOT backwards compatible Otherwise identical to 1.9 No “using namespace” statements in headers CLHEP.h replaced by package defs.h headers Does not support gcc 2.95.2 Major source code changes in CLHEP 2.1.x.x
10
Using Autotools Take advantage of the power of autotools Recent versions required – support operating system and compiler configurations autoconf 2.59 or later – Configure automake 1.9.1 or later – Makefiles libtool 1.9b or later – Build shared and static libraries – Lots of knowledge about compilers
11
Infrastructure Files These files are used by developers, not installers CLHEP/bootstrap – Run autotools commands for this and all package directories CLHEP/ /bootstrap CLHEP/configure.in CLHEP/ /configure.in Makefile.am – In top directory and all subdirectories CLHEP/setup.cygwin-VC71 – For Windows VisualC++ 7.1
12
configure.in # Identify the package and initialize autotools: AC_INIT(CLHEP Vector, 1.9.1.1, CLHEP@cern.ch, Vector) AC_CONFIG_SRCDIR([src/AxisAngle.cc]) # tell autoconf the name of the configuration header AM_CONFIG_HEADER([Vector/defs.h]) # various files to be generated from xxx.in AC_CONFIG_FILES([Vector/Makefile])
13
configure.in – boilerplate for defs.h AH_TOP([#ifndef VECTOR_DEFS_H #define VECTOR_DEFS_H]) …. ## backwards compatibility AH_VERBATIM([ENABLE_BACKWARDS_COMPATIBILITY],[/* backwards compatibility will be enabled ONLY in CLHEP 1.9 */ #ifndef ENABLE_BACKWARDS_COMPATIBILITY #define ENABLE_BACKWARDS_COMPATIBILITY #endif]) AH_BOTTOM([#endif // VECTOR_DEFS_H])
14
configure.in – compiler section # Locate a C++ compiler: AC_PROG_CXX(cl g++ c++ aCC CC cxx cc++ FCC KCC RCC xlC_r xlC gpp) # Use it hereinafter: AC_LANG(C++)
15
configure.in – compiler flags case "$CXX" in g++) case "$target" in *-*-linux*) AM_CXXFLAGS="-O -ansi -pedantic -Wall -D_GNU_SOURCE";; *) AM_CXXFLAGS="-O -ansi -pedantic -Wall" esac;; cl) AM_CXXFLAGS="-EHsc" ;; *) echo UNEXPECTED CHOICE OF C++ COMPILER: $CXX esac # tell configure to use AM_CXXFLAGS when building the Makefile # must be called after defining AM_CXXFLAGS AC_SUBST(AM_CXXFLAGS)
16
configure.in - finalizing Checks already exist for most C++ deficiencies # Check for needed header files: AC_CHECK_HEADERS([sstream]) # Check for needed typedefs, structures, and compiler characteristics: AC_CHECK_TYPES([ptrdiff_t]) # Finish up: AC_OUTPUT
17
CLHEP/ /Makefile.am # Process this file with automake to produce Makefile.in includedir = $(prefix)/include/CLHEP # SUBDIRS order is very important – this is the processing order SUBDIRS = Vector. src test # list all subdirectories - for distribution and cleaning DIST_SUBDIRS = Vector. src test doc # create temporary CLHEP header tree all-local: $(top_builddir)/CLHEP # add rules to build documentation docs: cd doc; $(MAKE) $(AM_MAKEFLAGS)
18
CLHEP/ / /Makefile.am # makefile for the header subdirectory includedir = $(prefix)/include/CLHEP tempincludedir = $(TEMPDIR)/CLHEP/@PACKAGE@ # list each header explicitly # be sure to also list defs.h pkginclude_HEADERS = \ AxisAngle.h AxisAngle.icc … TwoVector.h defs.h # copy headers into $(tempincludedir) # this instruction is called by various CLHEP/ /Makefiles install-tmpHEADERS: …
19
CLHEP/ /src/Makefile.am INCLUDES = -I$(top_builddir) lib_LTLIBRARIES = libCLHEP-Vector-@VERSION@.la libCLHEP_Vector_@VERSION@_la_SOURCES = \ AxisAngle.cc Boost.cc \ ….. ThreeVector.cc ThreeVectorR.cc TwoVector.cc List each file explicitly Not much here configure generates final Makefile with compilation rules
20
Building CLHEP Get a source code tarball – bootstrap has already been run Create a separate build directory Identify your install directory cd build-directory …/CLHEP/configure –prefix=/fullpath/installdir [options] make make check make install make docs make install-docs
21
Updating a single package Get the source from a source code tarball cd build-directory Define $CLHEP_DIR – Allows you to get headers from standard installation – Choice of $CLHEP_DIR was arbitrary …/CLHEP/ /configure [options] make make check make install
22
configure options CXX=xyz (set the C++ compiler) CXXFLAGS=“some stuff” – Appends to compiler flags defined in configure.in --disable-shared (build only static libraries) --enable-exceptions (enable Exceptions package) --help Using environmental variables is not recommended
23
clheplib utility Lists individual package libraries needed for linking clheplib -L/fullpath/lib –lCLHEP-1.9.1.1 clheplib HepMC -L/fullpath/lib –lCLHEP-HepMC-1.9.1.1 –lCLHEP-Geometry-1.9.1.1 –lCLHEP-HepPDT-1.9.1.1 –lCLHEP-Vector-1.9.1.1 Also, clhep-config [--lib] [--include] …
24
Source code distribution Source code tarball – bootstrap has already been run – Do not need autotools – Recommended for installers Source code also available from cvs – Must have autotools and run bootstrap – Only recommended for code developers
25
Comments about Autotools Pro – Very smart – Allow lots of configuration – Build libraries cleanly and properly – Checks times and will reconfigure if necessary Con – Sometimes too smart for its own good – Libtool “knows everything” about building for various operating system and compiler combinations – Will sometimes reconfigure when unnecessary Has been very useful for CLHEP
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.