Download presentation
Presentation is loading. Please wait.
1
Software Package development and management
An example of usage of the GNU autotools kit Flavia Donno LCG EIS Team Autotools Seminar CHEP 2003 – March – no. (1)
2
Talk Outline Motivation Package Structure The autotools
A practical example bootstrap configure.in Makefile.am The commands sequence
3
Motivations Establishing agreed package structure and management tools helps developers understanding the software The autotools kit make easier the burden of building, distributing, installing software packages It helps in writing multi-platform code It helps managing multi-component packages It relieves the developers from deep knowledge of system dependent features It make easier to build maintenance package infrastructure …
4
Package Structure Building Tree Installation Tree Distribution Tree
-rw-r--r-- flavia zh AUTHORS -rw-r--r-- flavia zh CHANGES -rw-r--r-- flavia zh COPYING drwxr-xr-x flavia zh CVS -rw-r--r-- flavia zh INSTALL -rw-r--r-- flavia zh LICENCE -rw-r--r-- flavia zh Makefile.am -rw-r--r-- flavia zh README -rwxr-xr-x flavia zh bootstrap -rwxr-xr-x flavia zh clean.sh.in -rw-r--r-- flavia zh configure.in -rw-r--r-- flavia zh package.spec.in drwxr-xr-x flavia zh lib -rw-r--r-- flavia zh makefile_header drwxr-xr-x flavia zh src drwxr-xr-x flavia zh test drwxr-xr-x flavia zh doc drwxr-xr-x flavia zh bin drwxr-xr-x flavia zh etc drwxr-xr-x flavia zh include drwxr-xr-x flavia zh lib drwxr-xr-x flavia zh sbin/test drwxr-xr-x flavia zh share/doc Installation Tree Similar to the building tree. Contains system specific configure, spec, etc files Does not usually contains autotools file to modify autotools configuration Distribution Tree
5
The autotools The kit is composed by various tools:
Autoconf Automake Libtool Other packages are GNU m4 and Perl Autoconf: is a tool for producing shell scripts that automatically configure software source code packages to adapt to many kinds of UNIX-like systems. The scripts produced do not need autoconf when they run. Scripts are produced from template files. It reliably discovers system-specific build and run-time information. Automake: it supports dependency tracking, recursive builds in subdirectories, reliable timestamps, etc. It builds a Makefile.in starting from Makefile.am. Autoconf then process the Makefile.in. Libtool: it handles all the requirements of building shared libraries with portability.
6
A practical example The autotools have been used for the EDG GDMP package. The description of the steps performed are described in:
7
bootstrap It is a startup procedure that creates primary scripts such as configure starting from the configure.in template #!/bin/sh # $Id$ ## ******************************************************* ## * Author: …. ## * Copyright © 2004 CERN and INFN on behalf of the LCG project ## * For License conditions see LICENSE file or ## * ## * set –x if [ ! –x ./config ] ; then mkdir ./config fi rm –f config.cache aclocal –I config 2>/dev/null autoheader libtoolize –c –automake automake –foreign –add-missing –copy 2>/dev/null autoconf Collect M4 macro definitions to be used later on by autoconf Place config files in config dir Creates config.h.in Add libtool support configure Creates Makefile.in from Makefile.am
8
configure.in It is the main script. It can be generated using autoscan
dnl This is a comment AC_INIT(src/BrokerInfo.C) dnl Set config options AC_CONFIG_AUX_DIR(config) AM_CONFIG_HEADER(config.h) AM_INIT_AUTOMAKE(edg-brokerinfo, 2.1) AC_PREFIX_DEFAULT(/opt/edg) if test “x$prefix” = “xNONE”; then prefix=$ac_default_prefix ac_configure_args=“$ac_configure_args –prefix $prefix” fi
9
configure.in shell directives are mixed up with M4 macros
dnl Define patchlevel BIPATCHLVL=5 dnl Check for gcc3.2 compiler GCCVER=$EDG_RPM_RELEASE_VERSION dnl Check for programs. AC_PROG_CXX dnl Disable creation of static libraries by default AC_DISABLE_STATIC dnl Check for use of libtool AM_PROG_LIBTOOL dnl Check for libraries AC_CHEK_LIB(pthread)
10
configure.in shell directives are mixed up with M4 macros
dnl Check for header files AC_HEADER_DIRENT AC_HEADER_STDC dnl Check for typedefs, structures, and compiler characteristics AC_C_CONST AC_TYPE_SIZE_T dnl Check for library functions AC_FUNC_UTIME_NULL AC_CHECK_FUNCS(getenv)
11
configure.in check for a specific library dnl Check for ClassAds
AC_MSG_CHECKING([for ClassAds directory]) AC_ARG_WITH(classads-install, [--with-classads-install=<dir> Default is \$CLASSADS_INSTALL_PATH], classads_dir=“$withval”,classads_dir=“$CLASSADS_INSTALL_PATH”) if test –d “$classads_dir”; then AC_MSG_RESULT([$classads_dir found]) export CLASSADS_INSTALL_PATH=$classads_dir else AC_MSG_ERROR([no such directory $classads_dir]) fi
12
configure.in check for a specific library …continues
dnl Check for ClassAds option AC_MSG_CHECKING([for ClassAds namespace]) AC_ARG_ENABLE(classads-namespace, [--enable-classads-namespace=<option> Default is no], classadsopt=“$enableval”,classadsopt=“no”) if test “x$classadsopt” = “xyes”; then AC_MSG_RESULT([enabling ClassAds C++ namespace]) CLASSADS_FLAGS=“-DWANT_NAMESPACE” else AC_MSG_RESULT([no ClassAds C++ namespace]) CLASSADS_FLAGS=“” fi
13
configure.in check for a specific library …continues
dnl Enable namespace if gcc 3.2 if test “x$GCCVER” = “x_gcc_3_2_2”; then AC_MSG_RESULT([enabling ClassAds C++ namespace]) CLASSADS_FLAGS=“-DWANT_NAMESPACE” CC=gcc-3.2.2 CXX=c –Wno-deprecated” fi
14
configure.in What about rpms ? dnl Check rpm dir RPMD=`pwd`
AC_MSG_CHECKING([for directory where to create rpms]) AC_ARG_WITH(rpm-dir,[ --with-rpm-dir=<dir> Default is \$RPMD/], rpm-dir=“$withval”, rpm_dir=“$RPMD”) if test –d “$rpm_dir” ; then AC_MSG_RESULT([found $rpm_dir]) else AC_MSG_RESULT([no such directory $rpm_dir]) AC_MSG_RESULT([the directory $rpm_dir will be created for you if possible]) fi RPM_DIR=$rpm_dir
15
configure.in Export environments dnl Define required variables
AC_SUBST(BIPATCHLVL) AC_SUBST(CLASSAD_INSTALL_PATH) AC_SUBST(CLASSAD_FLAGS) AC_SUBST(RPM_DIR) AC_SUBST(GCCVER) AC_SUBST(CC) AC_SUBST(CXX)
16
configure.in Produce necessary files dnl Create files
AC_OUTPUT(src/Makefile lib/Makefile Makefile doc/Makefile test/Makefile \ edg-brokerinfo.spec clean.sh)
17
Makefile.am This is the top Makefile.am # $Id:$
## ********************************* ## * SUBDIRS = src lib test doc BI_SPEC = edg-brokerinfo.spec EXTRA_DIST = edg-brokerinfo.spec.in clean.sh.in makefile_header bootstrap \ LICENSE README MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure config.h.in \ stamp-h.in
18
Makefile.am This is the top Makefile.am RPM_SPEC_PATH=@RPM_DIR@/SPECS
rpm: $(BI_SPEC) gmake –i dist; \ /bin/mkdir –p \ \ \ \ /bin/cp –u \ \ for file in $(BI_SPEC) ; do /bin/cp $$file $(RPM_SPEC_PATH); \ done cd $(RPM_SPEC_PATH); \ rpm –define “_topdir –ba $$file;
19
Makefile.am This is the top Makefile.am – other targets dist-hook:
cd $(distdir) \ for file in $(MAINTAINERCLEANFILES); do \ /bin/rm $(distdir)/$$file; \ done /bin/cp $(srcdir)/doc/edg-brokerinfo-user-guide-v2.pdf \ $(distdir)/doc userdoc: gmake –C doc clean-tree: chmod a+rx ./clean.sh ./clean.sh
20
Makefile.am This is the src/Makefile.am
include $(top_srcdir)/makefile_header edg_brokerinfoincdir = $(prefix)/include/edg-brokerinfo edg_brokerinfoinc_HEADERS = BrokerInfo.h bi_result.h noinst_LTLIBRARIES = libedg-brokerinfo.la libedg_brokerinfo_la_SOURCES = BrokerInfo.C BrokerInfo.h bi_result.h bin_PROGRAMS = edg-brokerinfo edg_brokerinfo_SOURCES = BrokerCLI.C edg_brokerinfo_LDADD = BrokerInfo.o ($BROKERINFOLIBS) edg_brokerinfo_LDFLAGS = $(BROKERINFOLDFLAGS) MAINTAINERCLEANFILES = Makefile.in dist-hook: cd $(distdir) \ for file in $(MAINTAINERCLEANFILES); do \ /bin/rm $(distdir)/$$file; \ done
21
Makefile.am This is the lib/Makefile.am
lib_LTLIBRARIES = libedg-brokerinfo.la libedg_brokerinfo_la_SOURCES = libedg_brokerinfo_la_LDFLAGS = --version-info 1:0:1 libedg_brokerinfo_la_LIBADD = ../src/libedg-brokerinfo.la MAINTAINERCLEANFILES = Makefile.in dist-hook: cd $(distdir) \ for file in $(MAINTAINERCLEANFILES); do \ /bin/rm $(distdir)/$$file; \ done
22
Makefile.am This is the test/Makefile.am
include $(top_srcdir)/makefile_header bitestdir = $(prefix)/sbin/test Bitest_DATA = example.BrokerInfo bin_PROGRAMS = edg-brokerinfo-test edg_brokerinfo_test_SOURCES = BrokerTester.C edg_brokerinfo_test_LDADD = ../src/BrokerInfo.o ($BROKERINFOLIBS) edg_brokerinfo_test_LDFLAGS = $(BROKERINFOLDFLAGS) EXTRA_DIST = example.BrokerInfo MAINTAINERCLEANFILES = Makefile.in install-data-hook: edg-brokerinfo-test example.BrokerInfo if test –d $(DESTDIR)$(bitestdir) ; then \ $(mkinstalldirs) $(DESTDIR)$(bitestdir); \ fi /bin/mv $(DESTDIR)$(bindir)/edg-brokerinfo-test $(DESTDIR)$(bitestdir)/edg-brokerinfo-test; dist-hook: cd $(distdir) \ for file in $(MAINTAINERCLEANFILES); do \ /bin/rm $(distdir)/$$file; \ done This is the test/Makefile.am
23
The commands sequence rpm implies dist ./bootstrap
./configure –prefix=/opt/flavia –with-classads-install=/opt/classads \ –enable-classad-namespace –with-rpm-dir=/home/flavia/rpms gmake gmake userdoc gmake install gmake dist gmake rpm gmake clean-tree rpm implies dist
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.