Æ„—„GNU autotools by ccf65261

VIEWS: 9 PAGES: 40

									    GNU autotools
      thep@linux.thai.net


Thai Linux Working Group




                            GNU autotools -- p. /
  GNU autotools
        :                GNU
   GNU autotools: make
GNU autoconf
GNU automake

GNU libtool



                               GNU autotools -- p. /
     :                          GNU
   tarball
$ gzip -cd foo-0.1.1.tar.gz | tar -xf -
                config source
$ ./configure


$ make


$ make check




                                  GNU autotools -- p. /
     :             GNU

$ make install


$ make clean


$ make uninstall




                   GNU autotools -- p. /
     :                    GNU

$ make distclean


$ make maintainer-clean
    source tarball
$ make dist
    source tarball
$ make distcheck




                          GNU autotools -- p. /
       :                          GNU
              VPATH
source tree
$   gzip -cd foo-0.1.1.tar.gz | tar -xf -
$   cd foo-0.1.1
$   mkdir build
$   cd build
$   ../configure
$   make




                                    GNU autotools -- p. /
     :                              GNU

$ ../configure --prefix=/usr
         binary tarball   DESTDIR
$ mkdir /tmp/dist
$ make install DESTDIR=/tmp/dist
$ tar -C /tmp/dist -cf - /tmp/dist |
gzip -9 > foo-0.1.1.tar.gz




                                    GNU autotools -- p. /
GNU autotools: make
make:
   auto incremental build
       option
                            install,
   clean



                            GNU autotools -- p. /
GNU autotools: make
Makefile:
            :
   target: dependencies
    TAB command
    TAB ...
   (          )
   target              build
   command               dependencies
                 target

                                        GNU autotools -- p. /
       GNU autotools: make
         Makefile
greet: hello.o bye.o
 TAB cc -o greet hello.o bye.o

hello.o: hello.c bye.h
 TAB cc -c hello.c

bye.o: bye.c bye.h
 TAB cc -c bye.c

install:
 TAB mkdir -p /usr/local/bin
TAB   cp -f greet /usr/local/bin




                                   GNU autotools -- p. /
GNU autotools: make
    Makefile

       :   var=val
     : $(var)




                      GNU autotools -- p. /
GNU autotools: make
  abstract
                    file .s2   file .s1 :-
   .s1.s2:
   TAB command
   TAB ...
                   command
      $@     target
      $<     dependency
      $ˆ     dependency
                                  GNU autotools -- p. /
GNU autotools: make
  abstract
   suffix            abstract   list :
   .SUFFIXES: s1 s2 ...   sn




                                GNU autotools -- p. /
       GNU autotools: make
         Makefile
CC = gcc
CFLAGS = -Wall -g
PREFIX = /usr/local
.SUFFIXES: .c .o
.c.o:
 TAB $(CC) $(CFLAGS) -c $<
.o:
 TAB $(CC) $ˆ -o $@
greet: hello.o bye.o
hello.o: hello.c bye.h
bye.o: bye.c bye.h
install:
 TAB mkdir -p $(PREFIX)/bin
TAB   cp -f greet $(PREFIX)/bin


                                  GNU autotools -- p. /
GNU autotools: make
                     Makefile
             dependency   target
(gcc   -MM                cc                        )
                        Makefile

                     target          clean,
install, uninstall

Makefile                 recursive
                                        GNU autotools -- p. /
GNU autoconf
                               (BSD, AT&T
    System V, SunOS, Ultrix, HP-UX, AIX, SCO
    Unix, GNU/Linux, etc.)

      solution 4           config
    2535
        metaconfig Larry Wall et. al.
        configure   Cygnus      GCC
        GNU autoconf David MacKenzie
        Imake     X Window
                                         GNU autotools -- p. /
GNU autoconf
                                      config
    Makefile       make
    metaconfig      autoconf
                 shell script
    configure     Cygnus       GCC      shell script
                            config file
    platform
    imake                               config
                       platform
                                               GNU autotools -- p. /
GNU autoconf
    script        metaconfig   interactive

        2537 David MacKenzie      feature
    configure    Cygnus    GCC
    autoconf    Cygnus     GCC
    autoconf
    metaconfig                 Perl
    imake                              X
    Window                        imake
                                             GNU autotools -- p. /
GNU automake
   autoconf
      imake :       dependency
        imake
   target Imakefile      imake
   Makefile    dependency
   David MacKenzie        automake
   2537     Tom Tromey                   2538


                                     GNU autotools -- p. /
GNU automake
        automake
          target Makefile.am            automake
         Makefile.in         dependency
   target               GNU        check, install,
   uninstall, clean, dist, distclean
                     test suite



                                                GNU autotools -- p. /
                                    GNU
   autoscan



configure.scan
              [user macro file]
              [acinclude.m4]        aclocal      aclocal.m4
              configure.in




                                    autoheader         config.h.in


                                    autoconf                   configure


                                                              configure     Makefile
                         automake        Makefile.in
 Makefile.am




                                                                           GNU autotools -- p. /
                         GNU

        autoconf          configure   shell script
                    configure.in a
        m4
        aclocal.m4
        automake          Makefile.in
        Makefile.am
        configure.in

   a   autoconf   2.50          configure.ac
configure.in
                                                 GNU autotools -- p. /
            GNU

configure                Makefile
         Makefile.in   config.h
config.h.in
make                   Makefile




                             GNU autotools -- p. /
configure.in:
AC   INIT(hello.c)
AM   INIT AUTOMAKE(hello,1.0)
AC   PROG CC
AC   PROG INSTALL
AC   OUTPUT(Makefile)

Makefile.am:
bin PROGRAMS = greet
greet SOURCES = greet.c hello.c bye.c hello.h bye.h




                                                      GNU autotools -- p. /
      ..
$   aclocal
$   autoconf
$   touch NEWS README AUTHORS ChangeLog
$   automake --add-missing
$   mkdir build
$   cd build
$   ../configure
$   make




                                    GNU autotools -- p. /
         autoconf
    configure.in              m4
definition         autoconf
aclocal.m4
configure

    aclocal.m4                aclocal
      definition        m4
   configure.in
acinclude.m4
aclocal.m4



                                        GNU autotools -- p. /
        autoconf
               aclocal   autoconf
automake                        autoconf
( AM INIT AUTOMAKE
    automake) autoconf




                                   GNU autotools -- p. /
    autoconf
  configure
     config                option

       out.in        out
   AC OUTPUT(out),               @var@


AC SUBST(var)
configure                  out



                                    GNU autotools -- p. /
       automake
           Makefile.am
                AC OUTPUT()    configure.in
                         Makefile.am


automake                   automake
Makefile.am
Makefile.in




                                       GNU autotools -- p. /
           automake
Primary:         object automake
primary         automake
    DATA:     install
    HEADERS:      DATA        header file
    SCRIPTS:      DATA            executable
    MANS:        manual page      section
    TEXINFOS:         info page


                                      GNU autotools -- p. /
          automake
primary          automake ( )
    PROGRAMS:
    executable
    LIBRARIES:
    library
    LTLIBRARIES:   library      libtool



                                    GNU autotools -- p. /
       automake
                 /         object
     primary         prefix      :
bin PROGRAMS = greet
        target
     bindir
greet SOURCES = hello.c bye.c
  source    greet
pixmapsdir = @datadir@/pixmaps
pixmaps DATA = hello.png bye.png
                            pixmapsdir

                                         GNU autotools -- p. /
    automake

DEPENDENCIES:      dependency
target (                     )
 LDADD:    shared object

LDFLAGS:
LIBADD:      LDADD         static library


                                  GNU autotools -- p. /
     automake

SUBDIRS:                        build
EXTRA DIST:
SOURCES                         source
tarball           ‘‘make dist''
DISTCLEANFILES:
   ‘‘make distclean''
MAINTAINERCLEANFILES:
        ‘‘make maintainer-clean''
                                    GNU autotools -- p. /
static library            indexed archive
object file:
$ ar cru libgreet.a hello.o bye.o
$ ranlib libgreet.a

                  static library
        executable file
shared library                run-time
resolve symbol             dynamic
                                              bug

                                            GNU autotools -- p. /
GNU libtool
    shared library              AT&T Unix System
    V Relese 3                   implement
                ...           (     )


         2539 Gordon Matzigkeit          libtool
    shell script                shared library


                                             GNU autotools -- p. /
 GNU libtool             automake
automake primary LTLIBRARIES
    /           libtool:
lib LTLIBRARIES = libgreet.la
libgreet la SOURCES = hello.c bye.c
bye.h

                automake    normalize
                       underscore



                                  GNU autotools -- p. /
                   shared library
configure.in:
AC   INIT(hello.c)
AM   INIT AUTOMAKE(libgreet,0.1.1)
AC   PROG CC
AC   PROG INSTALL
AC   PROG LN S
AC   PROG LIBTOOL
AC   OUTPUT(Makefile)

Makefile.am:
lib LTLIBRARIES = libgreet.la
libgreet la SOURCES = hello.c bye.c
include HEADERS = greet.h hello.h bye.h




                                          GNU autotools -- p. /
             shared library
      ..
$   libtoolize
$   aclocal
$   autoconf
$   touch NEWS README AUTHORS ChangeLog
$   automake --add-missing
$   mkdir build
$   cd build
$   ../configure
$   make



                                    GNU autotools -- p. /
Happy Hacking!!



                  GNU autotools -- p. /

								
To top