Introduction to Autotools and Cvs Dirk Vermeir Dept. of Computer - - PowerPoint PPT Presentation

introduction to autotools and cvs
SMART_READER_LITE
LIVE PREVIEW

Introduction to Autotools and Cvs Dirk Vermeir Dept. of Computer - - PowerPoint PPT Presentation

Introduction to Autotools and Cvs Dirk Vermeir Dept. of Computer Science Free University of Brussels, VUB Introduction to Autotools and Cvs p.1/77 Introduction Introduction to Autotools and Cvs p.2/77 Why Autotools Make it easier to


slide-1
SLIDE 1

Introduction to Autotools and Cvs

Dirk Vermeir

  • Dept. of Computer Science

Free University of Brussels, VUB

Introduction to Autotools and Cvs – p.1/77

slide-2
SLIDE 2

Introduction

Introduction to Autotools and Cvs – p.2/77

slide-3
SLIDE 3

Why Autotools

Make it easier to develop OS-indepedent systems by isolating and automating detection (autoconf). Also: provide a shared database of detection tools (autoconf macro’s). Same for compilers and linkers ( libtool). Standardize and simplify Makefiles while providing a rich set of targets (automake). PACKAGE=spmps-0.1 tar zxf ${PACKAGE}.tar.gz && cd ${PACKAGE} && ./configure && make && make check && make install

Introduction to Autotools and Cvs – p.3/77

slide-4
SLIDE 4

Autotools Architecture

configure.in autoscan acinclude.m4 aclocal config.h.in autoheader Makefile.in automake Makefile.am autoconf configure Makefile config.h

am ac ac am ac

aclocal.m4 (configure.scan)

Introduction to Autotools and Cvs – p.4/77

slide-5
SLIDE 5

Input

The developer must supply: The file configure.in describing tests to be done on the target system to define preprocessor symbols and other installation-dependent variables. A Makefile.am file for each directory containing a high level description of programs, libraries etc. to be produced.

Introduction to Autotools and Cvs – p.5/77

slide-6
SLIDE 6

End Products

The end products in the figure are A configure shell script that, at installation time, probes the target system and produces, from template config.h.in and file Makefile.in files,

  • 1. a proper Makefile, and a
  • 2. a file config.h that contains C or C++ definitions for

inclusion in various system-dependent source files. In addition, one can define ones own template files, e.g. header.html.in on which configure will perform variable substitution to obtain header.html.

Introduction to Autotools and Cvs – p.6/77

slide-7
SLIDE 7

Aclocal

Generates the aclocal.m4 macro file for input to autoconf. Collects the definitions of specific autoconf macros needed by automake and/or used in configure.in. Definitions are found in the file acinclude.m4, or in the directory /usr/[ local /] share/aclocal/ Part of the automake package.

Introduction to Autotools and Cvs – p.7/77

slide-8
SLIDE 8

Autoheader

Generates config.h.in from configure.in. Part of the autoconf package.

Introduction to Autotools and Cvs – p.8/77

slide-9
SLIDE 9

Autoscan

Recursively scans the source files in the current and lower directories to identify common portability problems. Generates configure.scan which can be used as a starting point for configure.in. Part of the autoconf package.

Introduction to Autotools and Cvs – p.9/77

slide-10
SLIDE 10

Autoconf

Generates the configure script from configure.in, which mainly consists of a sequence of m4 macro calls. Finds new macro definitions in the file aclocal.m4 (produced by aclocal).

Introduction to Autotools and Cvs – p.10/77

slide-11
SLIDE 11

Automake

Generates Makefile.in which will be transformed by configure into a proper Makefile at installation time. It is driven by a high level description of the various targets and components in several Makefile.am files corresponding to the Makefiles mentioned in the AC_CONFIG_FILES call in configure.in. For each Makefile.am it creates a Makefile.in (in the same directory) on which configure will perform substitutions (on @name@) to make a full-blown Makefile. The generated Makefile handles most dependencies automatically.

Introduction to Autotools and Cvs – p.11/77

slide-12
SLIDE 12

Configure

Generated by autoconf from configure.in. Largely self-contained and portable shell script. Runs the tests specified in configure.in to determine the value of a number of C preprocessor symbols and so-called output variables. Preprocessors symbol definitions go in config.h, e.g. for use by the compilers. Output variables are used to perform substitutions of @variable@ in template files such as Makefile.in.

Introduction to Autotools and Cvs – p.12/77

slide-13
SLIDE 13

Libtool

Using libtool frees the implementor of worrying about the details of the local compiler/linker command line

  • requirements. One set of simple options is automagically

translated to the proper target system command. This is especially useful for creating shared libraries.

Introduction to Autotools and Cvs – p.13/77

slide-14
SLIDE 14

Ifnames

Shows preprocessor symbols used in a set of source files. bash-2.05$ ifnames *.[hC] HAVE_ARPA_INET_H inetaddress.C serversocket.C HAVE_FUNC_GETHOSTBYADDR_R_7 inetaddress.C HAVE_FUNC_GETHOSTBYADDR_R_8 inetaddress.C HAVE_FUNC_GETHOSTBYNAME_R_3 inetaddress.C HAVE_FUNC_GETHOSTBYNAME_R_5 inetaddress.C HAVE_FUNC_GETHOSTBYNAME_R_6 inetaddress.C HAVE_NETDB_H inetaddress.C HAVE_SYS_SOCKET_H inetaddress.C HAVE_UNISTD_H inetaddress.C socket.C bash-2.05$

Introduction to Autotools and Cvs – p.14/77

slide-15
SLIDE 15

Example configure.in

Introduction to Autotools and Cvs – p.15/77

slide-16
SLIDE 16

Example configure.in

dnl Process this file with autoconf to produce dnl a configure script. dnl ========================================== dnl define @PACKAGE_NAME@, @PACKAGE_VERSION@, dnl @PACKAGE_BUGREPORT@ also as preprocessor dnl symbols AC_INIT(spms, 0.1, dvermeir@vub.ac.be) dnl sanity check: exit if file not present AC_CONFIG_SRCDIR([spms/project.C]) AM_INIT_AUTOMAKE dnl Ensure libtool is shipped with package AM_PROG_LIBTOOL dnl file where preprocessor symbols go AM_CONFIG_HEADER([config.h])

Introduction to Autotools and Cvs – p.16/77

slide-17
SLIDE 17

Example configure.in

dnl ========================================== dnl Checks for programs. dnl ========================================== AC_PROG_CXX AC_PROG_AWK AC_PROG_CC AC_PROG_CPP AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_MAKE_SET AC_PROG_RANLIB DV_REQUIRE_PROG(mysql,mysql, [/bin /usr/bin /usr/local/bin /usr/local/mysql/bin]) DV_REQUIRE_PROG(perl,perl, [/bin /usr/bin /usr/local/bin ])

Introduction to Autotools and Cvs – p.17/77

slide-18
SLIDE 18

Example configure.in

dnl ========================================== dnl Checks for libraries. dnl ========================================== DV_REQUIRE_DVMYSQL dnl ========================================== dnl Checks for header files. dnl ========================================== AC_CHECK_HEADERS(unistd.h) AC_HEADER_TIME AC_CHECK_FUNCS([gettimeofday]) dnl ========================================== dnl Checks for typedefs, structures, and compiler dnl ========================================== AC_C_CONST AC_TYPE_SIZE_T

Introduction to Autotools and Cvs – p.18/77

slide-19
SLIDE 19

Example configure.in

dnl ========================================== dnl Checks for library functions. dnl ========================================== DV_REQUIRE_CFUNC(pthread_mutex_init,pthread) dnl ========================================== dnl Make @DATE@ available in .in files in doc dnl ========================================== DATE=‘date +"%e %B, %Y"‘ dnl AC_SUBST ensures definition of @DATE@ AC_SUBST(DATE)

Introduction to Autotools and Cvs – p.19/77

slide-20
SLIDE 20

Example configure.in

dnl ========================================== dnl URL pointing to top directory for package dnl documentation, for use by dnl $(pkgdatadir)/package/html/installdox dnl ========================================== AC_ARG_WITH(doxyroot, [

  • -with-doxyroot=url

url for dv docs], doxyurl=$withval, doxyurl="http://tinf2.vub.ac.be/dv/") AC_SUBST(doxyurl)

Introduction to Autotools and Cvs – p.20/77

slide-21
SLIDE 21

Example configure.in

dnl ========================================== dnl substitute @name@ in all the files dnl below (each file.in must exist) dnl ========================================== AC_CONFIG_FILES([ Makefile spms/Makefile spms/createdb.sh spms/header.html spms/doxygen.conf spms/help.html doc/Makefile m4/Makefile m4/spms.m4 ]) AC_OUTPUT

Introduction to Autotools and Cvs – p.21/77

slide-22
SLIDE 22

Ouput of Autoscan

# Process this file with autoconf # to produce a configure script. AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS) AC_CONFIG_SRCDIR([config.h.in]) AC_CONFIG_HEADER([config.h]) # Checks for programs. AC_PROG_CXX AC_PROG_AWK AC_PROG_CC AC_PROG_CPP AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_MAKE_SET AC_PROG_RANLIB

Introduction to Autotools and Cvs – p.22/77

slide-23
SLIDE 23

Output of Autoscan

# Checks for libraries. # Checks for header files. AC_CHECK_HEADERS([limits.h]) # Checks for typedefs, structures, # and compiler characteristics. AC_C_CONST AC_TYPE_SIZE_T # Checks for library functions. AC_CHECK_FUNCS([select]) # AC_CONFIG_FILES([doc/Makefile Makefile spms/Makefile m4/Makefile]) AC_OUTPUT

Introduction to Autotools and Cvs – p.23/77

slide-24
SLIDE 24

Example File: header.html.in

<html> <head> <title>@PACKAGE_NAME@-@PACKAGE_VERSION@</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> <style type=text/css> a:link { text-decoration:none } a:active { text-decoration:none } a:visited { text-decoration:none } </style> </head> <body bgcolor="#ffffff">

Introduction to Autotools and Cvs – p.24/77

slide-25
SLIDE 25

Autoconf

Introduction to Autotools and Cvs – p.25/77

slide-26
SLIDE 26

Preset Directory Output Variables 1

prefix Installation prefix for architecture-independent files

(/usr/ local), exec_prefix is used as a prefix for architecture-dependent files (@prefix@).

bindir Executables that users run (@exec_prefix@/bin). datadir Read-only architecture-independent data

(@prefix@/share).

includedir Header files (@prefix@/include). infodir Documentation in info format (@prefix@/info). libdir Object code libraries (@exec_prefix@/lib). libexecdir Executables that other programs run

(@exec_prefix@/libexec).

Introduction to Autotools and Cvs – p.26/77

slide-27
SLIDE 27

Preset Directory Output Variables 2

state Modifiable single-machine data localstatedir in

(@prefix@/var); architecture-independent data in sharedstatedir (@exec_prefix@/com).

mandir Top-level manuals, e.g. @mandir@/man1

(@prefix@/man).

sbindir Executables that system administrators run

(@exec_prefix@/sbin).

srcdir Source code (this directory). sysconfdir Read-only single-machine data (@prefix@/etc). top srcdir Top-level source code directory for the package.

In Makefile.am, these variables are available as Make variables, e.g. $(bindir).

Introduction to Autotools and Cvs – p.27/77

slide-28
SLIDE 28

Other Preset Output Variables

CFLAGS C compiler options (set by AC_PROG_CC, also

used in tests run by configure.

CPPFLAGS C preprocessor flags (

  • I..), default value is

empty.

CXXFLAGS C++ compiler options (set by AC_PROG_CXX). FFLAGS idem for Fortran 77. DEFS define (

  • D) options to pass to the C compiler.

AM_CONFIG_HEADER replaces @DEFS@ with

  • DHAVE_CONFIG_H, not used in tests.

LDFLAGS linker flags. LIBS library options (

  • l,
  • L) to pass to the linker.

Introduction to Autotools and Cvs – p.28/77

slide-29
SLIDE 29

Existing Specific Test AC Macros

E.g.

AC PROG AWK Check for gawk, mawk, nawk, and awk, in

that order, and set output variable AWK to the first one that is found. It tries gawk first because that is reported to be the best implementation.

AC FUNC MMAP If the mmap function exists and works

correctly, define HAVE_MMAP. Only checks private fixed mapping of already-mapped memory.

Introduction to Autotools and Cvs – p.29/77

slide-30
SLIDE 30

Existing Specific Test AC Macros

AC HEADER TIME If a program may include both ‘time.h’ and

‘sys/time.h’, define TIME_WITH_SYS_TIME. It is best used in conjunction with HAVE_SYS_TIME_H, which can be checked for using AC_CHECK_HEADERS(sys/time.h). #if TIME_WITH_SYS_TIME # include <sys/time.h> # include <time.h> #else # if HAVE_SYS_TIME_H # include <sys/time.h> # else # include <time.h> # endif #endif

Introduction to Autotools and Cvs – p.30/77

slide-31
SLIDE 31

Writing AC Macros

dnl DV_FIND_FILE(file, dirlist, directory ) AC_DEFUN(DV_FIND_FILE, [ $3="" for i in $2; do for j in $1; do if test -r "$i/$j"; then $3=$i break 2 fi done done ])

Introduction to Autotools and Cvs – p.31/77

slide-32
SLIDE 32

Example AC Macro

DV CHECK LIB( Check for the availability of a C++ library

$4/lib$3.a and its header file $5/$1. Updates CXXINCLUDES, CXXLTLIBS if successful and ensures that they are substituted using AC_SUBST.

Parameters : $1 header file to find in $5, e.g. dvutil /props.h $2 test program, e.g. [Dv::Props props;] $3 library name, e.g. dvutil $4 library dir, e.g. /usr/ local / lib $5 include dir, e.g. /usr/ local /include

  • utput If found: AC_SUBST $3_LIB_DIR and

$3_INCLUDE_DIR, AC_DEFINE_UNQUOTED HAVE_$3, and dv_check_lib_ok=yes. Else dv_check_lib_ok=no.

Introduction to Autotools and Cvs – p.32/77

slide-33
SLIDE 33

DV_CHECK_LIB 1

AC_DEFUN(DV_CHECK_LIB, [ AC_LANG_PUSH(C++) dv_check_lib_ok=no; dnl default AC_REQUIRE([AC_PROG_CXX]) AC_MSG_CHECKING( [whether $4/lib$3.a is working]) dnl save old values to restore if failure ac_save_CXXLTLIBS="$CXXLTLIBS" ac_save_CXXINCLUDES="$CXXINCLUDES" DV_PREPEND_UNIQ([-I$5],CXXINCLUDES); DV_PREPEND_UNIQ([-L$4 -l$3],CXXLTLIBS);

Introduction to Autotools and Cvs – p.33/77

slide-34
SLIDE 34

DV_CHECK_LIB 2

dnl test in temporary subdir dv_tmp_dir=dv_tmp.$$ mkdir $dv_tmp_dir cd $dv_tmp_dir dv_lt=../libtool dv_compile="$dv_lt --mode=compile $CXX $CXXINCLUDES -c conftest.C" dv_link="$dv_lt --mode=link $CXX -o conftest

  • rpath / conftest.lo $CXXLTLIBS"

cat >conftest.C <<EOF #include <$1> int main(int,char**) { $2 } EOF

Introduction to Autotools and Cvs – p.34/77

slide-35
SLIDE 35

DV_CHECK_LIB 3

dnl Try to compile & link with library if AC_TRY_COMMAND($dv_compile) >/dev/null 2>&1; then if AC_TRY_COMMAND($dv_link) >/dev/null 2>&1; then dv_check_lib_ok=yes; fi; fi cd .. rm -fr $dv_tmp_dir AC_MSG_RESULT($dv_check_lib_ok)

Introduction to Autotools and Cvs – p.35/77

slide-36
SLIDE 36

DV_CHECK_LIB 4

if test $dv_check_lib_ok = no; then CXXINCLUDES="$ac_save_CXXINCLUDES" CXXLTLIBS="$ac_save_CXXLTLIBS" else eval "$3_LIB_DIR=$4" AC_SUBST($3_LIB_DIR) eval "$3_INCLUDE_DIR=$5" AC_SUBST($3_INCLUDE_DIR) AC_DEFINE_UNQUOTED(HAVE_$3, 1, [defined if the $3 library is available]) AC_SUBST(CXXINCLUDES) AC_SUBST(CXXLTLIBS) fi AC_LANG_POP(C++) ])

Introduction to Autotools and Cvs – p.36/77

slide-37
SLIDE 37

DV_CHECK_LIB Example

DV_CHECK_LIB(ssl.h,[SSL_CTX_free(0);], ssl, [/lib], [/usr/include]) Output of running configure:

... checking whether /lib/libssl.a is working... yes ..

Introduction to Autotools and Cvs – p.37/77

slide-38
SLIDE 38

Example Makefile.am

Introduction to Autotools and Cvs – p.38/77

slide-39
SLIDE 39

Makefile.am 1

# $Id: slides.tex,v 1.9 2002/05/12 08:43:52 dvermeir CXXFLAGS = -g -Wall INCLUDES = @CXXINCLUDES@ ############################################## # libraries ############################################## lib_LTLIBRARIES = libspms.la libspms_la_SOURCES = util.h util.C \ user.h user.C lastuser.h lastuser.C \ project.h project.C \ selection.h selection.C task.h task.C \ timechart.h timechart.C sql2env.h sql2env.C libspms_la_LDFLAGS = -r release @VERSION@ libspms_la_LIBADD = @LIBS@

Introduction to Autotools and Cvs – p.39/77

slide-40
SLIDE 40

Makefile.am 2

############################################## # programs ############################################## bin_PROGRAMS = spms.cgi spms_cgi_SOURCES = spms-cgi.C ############################################## # test programs ############################################## # common libraries needed by all test programs LDADD = libspms.la @CXXLTLIBS@ check_PROGRAMS = test-sql2env test_sql2env_SOURCES = test-sql2env.C

Introduction to Autotools and Cvs – p.40/77

slide-41
SLIDE 41

Makefile.am 3

############################################## # data ############################################## pkgdata_DATA = help.html spms.conf ############################################## # scripts ############################################## SUFFIXES = .sh .sh: cp $< $@ chmod ugo+x $@ pkgdata_SCRIPTS = createdb

Introduction to Autotools and Cvs – p.41/77

slide-42
SLIDE 42

Makefile.am 4

############################################## # EXTRA_DIST ############################################## EXTRA_DIST = $(pkgdata_DATA:%=%.in) \ $(pkgdata_SCRIPTS:%=%.sh.in) ############################################## # documentation ############################################## doc: header.html footer.html doxygen.conf doxygen doxygen.conf

Introduction to Autotools and Cvs – p.42/77

slide-43
SLIDE 43

Automake

Introduction to Autotools and Cvs – p.43/77

slide-44
SLIDE 44

Variables and Objects

An Makefile.am file consists mostly of variable definitions that determine which objects must be built. E.g. bin_PROGRAMS = hello goodbye defines two programs to be installed in $(bindir ). Attributes of an object determine how it is to be made: hello_SOURCES = hello.C foo.C foo.h hello_LDADD = -ldvutil # libraries hello_LDFLAGS = -all-static PROGRAMS is a primary, other primaries are LIBRARIES, LTLIBRARIES, SCRIPTS, DATA, HEADERS, . . .

Introduction to Autotools and Cvs – p.44/77

slide-45
SLIDE 45

Primaries, objects, attributes

destination attributes primary

  • bject

PROGRAMS bin hello hello_LDFLAGS hello_SOURCES

Introduction to Autotools and Cvs – p.45/77

slide-46
SLIDE 46

Primaries

destination_PRIMARY = ..

destination Indicates directory where the objects will be

installed, e.g. bin_PROGRAMS go to @bindir@. In general, xyz_PRIM go to @xyzdir@.

primary One of PROGRAMS, LIBRARIES (static),

LTLIBRARIES (shared, libtool), SCRIPTS, DATA, HEADERS, . . .

Introduction to Autotools and Cvs – p.46/77

slide-47
SLIDE 47

Destinations

PRIMARY destination PROGRAMS bin, sbin, libexec, pkglib, noinst, check LIBRARIES lib, pkglib, check, noinst LT_LIBRARIES lib, pkglib, check SCRIPTS bin, sbin, libexec, pkgdata, check, noinst HEADERS include, oldinclude, pkginclude, noinst DATA data, sysconf, sharedstate, localstate, pkgdata, check, noinst

Introduction to Autotools and Cvs – p.47/77

slide-48
SLIDE 48

Defining New Destinations

Example: htmldir = $(prefix)/html html_DATA = automake.html A prefix is valid if a variable with the same name with “dir” appended is defined.

Introduction to Autotools and Cvs – p.48/77

slide-49
SLIDE 49

PROGRAMS Attributes

hello_SOURCES = hello.C sub.c sub.h hello_LDADD = ./libxyz.a libuvq.la hello_DEPENDENCIES = abc.txt hello_LDFLAGS = -all-static

SOURCES list of source and header files LDADD libraries to link with program LDFLAGS linker flags (not -l, -L)

  • all
  • static Only link with static libraries.
  • static Do not link against uninstalled shared libtool

libraries.

  • rpath libdir or
  • R libdir Add libdir to runpath of

program.

DEPENDENCIES extra dependencies for program

Introduction to Autotools and Cvs – p.49/77

slide-50
SLIDE 50

LIBRARIES Attributes

libxyz_a_SOURCES = f.c f.h libxyz_a_LIBADD = @LIBS@ libxyz_a_DEPENDENCIES = abc.txt

SOURCES list of source and header files LIBADD extra objects to add to library DEPENDENCIES extra dependencies for library

Introduction to Autotools and Cvs – p.50/77

slide-51
SLIDE 51

LTLIBRARIES Attributes

libxyz_la_SOURCES = f.c f.h libxyz_la_LIBADD = @LIBS@ -labc libxyz_la_LDFLAGS = -all-static libxyz_la_DEPENDENCIES = abc.txt

SOURCES list of source and header files LIBADD other objects to add to library; if it contains e.g.

  • labc, any program linked with this library will also be

linked with the abc library,

LDFLAGS linker flags (not -l, -L)

  • all
  • static ,
  • static Only create a static library.
  • R libdir Add to runtime path of any program linked with

this library.

DEPENDENCIES extra dependencies for library

Introduction to Autotools and Cvs – p.51/77

slide-52
SLIDE 52

Other variables

AM CPPFLAGS or INCLUDES preprocessor flags. AM CFLAGS default C-compiler flags (hello_CFLAGS is also

possible)

LDADD Default libraries to link programs with. AM LDFLAGS Default linker flags to use.

Introduction to Autotools and Cvs – p.52/77

slide-53
SLIDE 53

Headers

Header files can simply be added to a _SOURCES attribute. Include header files that must be installed in e.g. pkginclude_HEADERS.

Introduction to Autotools and Cvs – p.53/77

slide-54
SLIDE 54

What goes into a distribution

Most source files are automatically included: program_SOURCES, source files corresponding to files mentioned in AC_CONFIG_FILES, etc. Any primary or ‘_SOURCES’ variable can be prefixed with ‘dist_’ to add the listed files to the distribution. Similarly, ‘nodist_’ can be used to omit the files from the distribution. dist_data_DATA = distribute-this bin_PROGRAMS = foo nodist_foo_SOURCES = do-not-distribute.c Use the EXTRA_DIST variable to include extra files.

Introduction to Autotools and Cvs – p.54/77

slide-55
SLIDE 55

Standard Make Targets

all Make all programs etc. in the current directory. install All, followed by installation. install

  • data Only install machined-independent files.

install

  • exec Only install machined-dependent files.

uninstall clean Remove stuff (including $(CLEANFILES)). dist

  • clean Restore to before-configuration state.

maintainer

  • clean Remove even Makefile etc.

check Run tests. dist Make tarball package

  • version.tar.gz.

distcheck Make distribution, then try to install it from

scratch.

Introduction to Autotools and Cvs – p.55/77

slide-56
SLIDE 56

The cvs-dist Target

Check in files and tag them with the version. cvs-dist: maintainer-check pkg=‘echo "@PACKAGE@" | tr a-z A-Z‘; \ ver=‘echo "@VERSION@" | sed ’s/\./_/g’‘; \ tag="$$pkg-$$ver"; \ echo tag=$$tag; \ if cvs -n log -h README| egrep -e $$tag \ >/dev/null; then \ echo "VERSION not new; not releasing" 1>&2; exit 1; \ else :; \ fi; \ cvs tag -c $$tag $(MAKE) dist

Introduction to Autotools and Cvs – p.56/77

slide-57
SLIDE 57

Cookbook

Introduction to Autotools and Cvs – p.57/77

slide-58
SLIDE 58

Autoizing a Package

  • 1. Create configure.in.
  • 2. Create Makefile.am in all directories where make

should run.

  • 3. Put under cvs: cvs import project vendor initial avoids

cluttering the repository

  • 4. In topdir:

(a) Run aclocal (b) Run autoconf and autoheader (c) Run libtoolize

  • copy
  • force

(d) Run automake

  • add
  • missing
  • force

(e) Run ./ configure (f) Run make

  • 5. From now on, you can use just make for most updates.

Introduction to Autotools and Cvs – p.58/77

slide-59
SLIDE 59

Autoizing With One Command

autoreconf to install or when configure.in changes or when autotools have been updated.

  • install missing files
  • force remake, even if targets not out of date
  • debug do not remove temporary files
  • help show options

Introduction to Autotools and Cvs – p.59/77

slide-60
SLIDE 60

Cvs

Introduction to Autotools and Cvs – p.60/77

slide-61
SLIDE 61

Cvs Concept

pack doc Makefile.am configure.in pack Makefile.am f.C CVS CVS check out check in Repository User copy Makefile.am f.C pack Makefile.am configure.in doc pack

Introduction to Autotools and Cvs – p.61/77

slide-62
SLIDE 62

Cvs Commands

co: check out, make local copy of latest repository version ci: check in (commit), apply local modifications to repository update: synchronize with latest version in repository (will merge your changes, if necessary). add/remove: (file or directory); remove keeps copy in repository’s “attic”. tag: give a “release label” to the current repository version; this tag can be used to later retrieve an exact copy of that version. watch: notify selected people on cvs operations on certain (groups of) files commands for creating branches, log info, . . .

Introduction to Autotools and Cvs – p.62/77

slide-63
SLIDE 63

Cvs Example

Two people, dirk@tinf2 and paolo@igwe3 want to collaborate on the “hello world” project. They decide to use tinf2 as the server machine. The repository will be in the directory tinf2 :/ home/dirk/cvsroot.

Introduction to Autotools and Cvs – p.63/77

slide-64
SLIDE 64

Creating the Repository

tinf2$ pwd # print current directory /export/home/tinf2/dirk tinf2$ mkdir cvsroot # create directory # for CVS repository tinf2$ cvs -d $HOME/cvsroot init # create CVS repository

Introduction to Autotools and Cvs – p.64/77

slide-65
SLIDE 65

Example: Update $CVSROOT

tinf2$ vi ˜/.bashrc # add this line to .bashrc # CVSROOT=$HOME/cvsroot; export CVSROOT tinf2$ source ˜/.bashrc # process .bashrc

Introduction to Autotools and Cvs – p.65/77

slide-66
SLIDE 66

Setting Up the Project

# create work directory for project "hello" tinf2$ mkdir hello tinf2$ cd hello # create subdirectories for source, documentation tinf2$ mkdir hello doc # Make autotool files tinf2$ touch Makefile.am configure.in tinf2$ touch doc/Makefile.am hello/Makefile.am tinf2$ touch NEWS README AUTHORS Changelog tinf2$ cvs import -m "initial import" hello cvs import: Importing /export/home/.. cvs import: Importing /export/home/.. No conflicts created by this import tinf2$ cd .. tinf2$ rm -fr hello

Introduction to Autotools and Cvs – p.66/77

slide-67
SLIDE 67

Checking Out the Project

tinf2$ cvs co hello # get a copy of the project cvs checkout: Updating hello cvs checkout: Updating hello/doc cvs checkout: Updating hello/hello tinf2$ ls -d CVS hello doc Makefile.am configure.in tinf2$ autoreconf --force --install tinf2$ ls AUTHORS INSTALL NEWS autom4te.cache configure install-sh xxx COPYING Makefile.am README autoscan.log configure.in missing ChangeLog Makefile.in aclocal.m4 config.h.in doc mkinstalldirs

Introduction to Autotools and Cvs – p.67/77

slide-68
SLIDE 68

Adding Files

tinf2$ cd ˜/hello/hello tinf2$ vi hello.C tinf2$ cvs add hello.C cvs add: scheduling file ’hello.C’ for addition cvs add: use ’cvs commit’ to add this file permanently tinf2$ cvs ci # commit changes .. # editor is called to add descriptive # log message RCS file: /home/dirk/cvsroot/hello/hello/hello.C done Checking in hello.C; ../cvsroot/hello/hello/hello.C,v <-- hello.C initial revision: 1.1 done

Introduction to Autotools and Cvs – p.68/77

slide-69
SLIDE 69

Committing Changes

# -m "comment" avoids calling editor tinf2$ cvs ci -m "working version" cvs commit: Examining . cvs commit: Committing . RCS file: /home/dirk/cvsroot/hello/src/Makefile, done Checking in Makefile; ../cvsroot/hello/src/Makefile,v <-- Makefile initial revision: 1.1 done Checking in hello.C; ../cvsroot/hello/src/hello.C,v <-- hello.C new revision: 1.2; previous revision: 1.1 done

Introduction to Autotools and Cvs – p.69/77

slide-70
SLIDE 70

Making a Release

tinf2$ cd .. # top project dir # no dots in name of release tinf2$ cvs tag release-1_0 cvs tag: Tagging . T Makefile.am T configure.in cvs tag: Tagging doc T doc/Makefile.am cvs tag: Tagging hello T hello/Makefile.am T hello/hello.C

Introduction to Autotools and Cvs – p.70/77

slide-71
SLIDE 71

Releasing User Copy

tinf2$ cd .. # 1 above project directory tinf2$ cvs release -d hello # remove working version of project ? hello/hello # not under cvs control You have [0] altered files in this repository. Are you sure you want to release (and delete)

Introduction to Autotools and Cvs – p.71/77

slide-72
SLIDE 72

Checking Out a Release

tinf2$ cvs co -r release-1_0 hello cvs checkout: Updating hello U hello/Makefile.am U hello/conifgure.in cvs checkout: Updating hello/doc cvs checkout: Updating hello/hello U hello/hello/Makefile.am U hello/hello/hello.C tinf2$ cd hello/hello; make

Introduction to Autotools and Cvs – p.72/77

slide-73
SLIDE 73

Remote Checkout

CVSROOT=:ext:dirk@tinf2:/home/dirk/cvsroot CVS_RSH=/usr/bin/ssh # by paolo, with group permissions on repository igwe3% cvs co hello # check out the project from dirk@tinf2 cvs server: Updating hello U hello/Makefile.am U hello/conifgure.in cvs server: Updating hello/doc cvs server: Updating hello/hello U hello/hello/Makefile.am U hello/hello/hello.C igwe3% vi hello/hello/hello.C # edit hello.C

Introduction to Autotools and Cvs – p.73/77

slide-74
SLIDE 74

Remote Users

tinf2$ cd hello/src tinf2$ vi hello.C # dirk also edits hello.C igwe3% cvs ci -m "small change" Checking in hello.C; ../cvsroot/hello/hello/hello.C,v <-- hello.C new revision: 1.4; previous revision: 1.3 done # dirk tries to commit his changes tinf2$ cvs ci -m "different change" cvs commit: Examining . cvs commit: Up-to-date check failed for ’hello.C’ cvs [commit aborted]: correct above errors first!

Introduction to Autotools and Cvs – p.74/77

slide-75
SLIDE 75

Conflict Resolution 1

tinf2$ cvs update # cvs will merge changes cvs update: Updating . RCS file: /export/home/tinf2/dirk/cvsroot/hello/ retrieving revision 1.3 retrieving revision 1.4 Merging differences between 1.3 and 1.4 into hello.C M hello.C tinf2$ cat hello.C # cvs marks differences ... <<<<<< hello.C cout << "Hello world!" << endl; ====== cout << "hi world" << endl; >>>>>> 1.4 ...

Introduction to Autotools and Cvs – p.75/77

slide-76
SLIDE 76

Conflict Resolution 2

tinf2$ vi hello.C # edit merged version tinf2$ cvs ci -m "merged paolo’s changes" Checking in hello.C; /export/home/tinf2/dirk/cvsroot/hello/src/hello. new revision: 1.5; previous revision: 1.4 done igwe3% cvs update # get an up-to-date version cvs server: Updating . P hello.C cvs update: could not patch hello.C; will refetch cvs client: refetching unpatchable files U hello.C

Introduction to Autotools and Cvs – p.76/77

slide-77
SLIDE 77

Auxiliary Cvs Tools

ViewCvs and other packages export cvs repository to the web. Define your own policy using hook scripts on commit, edit etc. GUI interfaces (useful?). . . . (see the web).

Introduction to Autotools and Cvs – p.77/77