GNU Autotools Are What Your Users Need

GNU Autotools Are What Your Users Need

GNU Autotools Are What Your Users Need Ludovic Courtes` GNU Autotools Do What Your Users Need Ludovic Courtes` agenda 1. intro 2. goals & design 3. on portability 4. action 5. wrap up L. Courtes` – GNU Autotools Do What Your Users Need 2 1 intro L. Courtes` – GNU Autotools Do What Your Users Need 3 is your software installable? --with-color --disable-shared CC=gcc-4.9 --prefix=$HOME/soft what do users want? • ./configure • make • make check • make install L. Courtes` – GNU Autotools Do What Your Users Need 7 --with-color --disable-shared CC=gcc-4.9 what do users want? • ./configure --prefix=$HOME/soft • make • make check • make install L. Courtes` – GNU Autotools Do What Your Users Need 7 --disable-shared CC=gcc-4.9 what do users want? • ./configure --prefix=$HOME/soft --with-color • make • make check • make install L. Courtes` – GNU Autotools Do What Your Users Need 7 CC=gcc-4.9 what do users want? • ./configure --prefix=$HOME/soft --with-color --disable-shared • make • make check • make install L. Courtes` – GNU Autotools Do What Your Users Need 7 what do users want? • ./configure --prefix=$HOME/soft --with-color --disable-shared CC=gcc-4.9 • make • make check • make install L. Courtes` – GNU Autotools Do What Your Users Need 7 2 goals & design L. Courtes` – GNU Autotools Do What Your Users Need 8 - mostly among Unix variants - easy way to install the software - standardized (GNU Coding Standards) - only requires POSIX sh and make! autotools goals • portability aid • friendly user interface • no additional dependencies for the user L. Courtes` – GNU Autotools Do What Your Users Need 9 - easy way to install the software - standardized (GNU Coding Standards) - only requires POSIX sh and make! autotools goals • portability aid - mostly among Unix variants • friendly user interface • no additional dependencies for the user L. Courtes` – GNU Autotools Do What Your Users Need 9 - only requires POSIX sh and make! autotools goals • portability aid - mostly among Unix variants • friendly user interface - easy way to install the software - standardized (GNU Coding Standards) • no additional dependencies for the user L. Courtes` – GNU Autotools Do What Your Users Need 9 autotools goals • portability aid - mostly among Unix variants • friendly user interface - easy way to install the software - standardized (GNU Coding Standards) • no additional dependencies for the user - only requires POSIX sh and make! L. Courtes` – GNU Autotools Do What Your Users Need 9 “The primary goal of Autoconf is making the user’s life easier; making the maintainer’s life easier is only a secondary goal.” — Autoconf manual L. Courtes` – GNU Autotools Do What Your Users Need 10 “autotools”? • Autoconf • Automake • Libtool • Gnulib L. Courtes` – GNU Autotools Do What Your Users Need 11 3 on portability L. Courtes` – GNU Autotools Do What Your Users Need 12 being “portable” to different... • shells • make implementations • C library features • C library quirks (non-conformance, bugs, etc.) • compilers • linkers • loaders • ... L. Courtes` – GNU Autotools Do What Your Users Need 13 systemology rm, mv, cp, ... grep, sed shell compiler stdlib.h libc.so math.h libc libm.so pthread.h libpthread.so dlfcn.h ld.so kernel L. Courtes` – GNU Autotools Do What Your Users Need 14 systemology rm, mv, cp, ... GNU grep, sed GNU shell Bash compiler GCC stdlib.h libc.so math.h libc libm.so pthread.h GNUlibpthread.so dlfcn.h ld.so kernel Linux L. Courtes` – GNU Autotools Do What Your Users Need 14 systemology rm, mv, cp, ... GNU grep, sed GNU shell zsh compiler Clang stdlib.h libc.so math.h libc libm.so pthread.h GNUlibpthread.so dlfcn.h ld.so kernel Linux L. Courtes` – GNU Autotools Do What Your Users Need 14 systemology rm, mv, cp, ... Busybox grep, sed Busybox shell zsh compiler Clang stdlib.h libc.so math.h libc libm.so pthread.h GNUlibpthread.so dlfcn.h ld.so kernel Linux L. Courtes` – GNU Autotools Do What Your Users Need 14 systemology rm, mv, cp, ... Busybox grep, sed Busybox shell zsh compiler Clang stdlib.h libc.so math.h libc libm.so pthread.h GNUlibpthread.so dlfcn.h ld.so kernel kFreeBSD L. Courtes` – GNU Autotools Do What Your Users Need 14 systemology rm, mv, cp, ... Busybox grep, sed Busybox shell zsh compiler Clang stdlib.h libc.so math.h libc libm.so pthread.h Bioniclibpthread.so(Android) dlfcn.h ld.so kernel Linux L. Courtes` – GNU Autotools Do What Your Users Need 14 systemology rm, mv, cp, ... Busybox grep, sed Busybox shell zsh compiler Clang stdlib.h how do I checklibc.so math.h for featurelibc X?libm.so pthread.h Bioniclibpthread.so(Android) dlfcn.h ld.so kernel Linux L. Courtes` – GNU Autotools Do What Your Users Need 14 if [ `uname` = Linux ] then CC=gcc ; SHELL=/bin/bash ... fi gcc -DOS LINUX=1 ... identity test #ifdef __linux__ # include <langinfo.h> #endif L. Courtes` – GNU Autotools Do What Your Users Need 15 gcc -DOS LINUX=1 ... identity test #ifdef __linux__ # include <langinfo.h> #endif if [ `uname` = Linux ] then CC=gcc ; SHELL=/bin/bash ... fi L. Courtes` – GNU Autotools Do What Your Users Need 15 identity test #ifdef __linux__ # include <langinfo.h> #endif if [ `uname` = Linux ] then CC=gcc ; SHELL=/bin/bash ... fi gcc -DOS LINUX=1 ... L. Courtes` – GNU Autotools Do What Your Users Need 15 identity test #ifdef __linux__ # include <langinfo.h> #endif wrong if [ `uname` = Linux ] then CC=gcc ; SHELL=/bin/bash ... fi gcc -DOS LINUX=1 ... L. Courtes` – GNU Autotools Do What Your Users Need 15 solution: feature tests • AC PATH PROG • AC CHECK LIB • AC CHECKcheckHEADER for specific features • AC COMPILE IFELSE • AC LINK IFELSE • ... L. Courtes` – GNU Autotools Do What Your Users Need 16 solution: feature tests • AC PATH PROG • AC CHECK LIB • AC CHECK HEADER • AC COMPILE IFELSE • AC LINK IFELSE • ... L. Courtes` – GNU Autotools Do What Your Users Need 16 going further... Gnulib: a portability library http://www.gnu.org/software/gnulib/ L. Courtes` – GNU Autotools Do What Your Users Need 17 4 action L. Courtes` – GNU Autotools Do What Your Users Need 18 running example git://scm.gforge.inria.fr/autotools-demo/ autotools-demo.git • C program • requirements: GNU Scientific Library, GNU Plotutils • computes an FFT, plots it L. Courtes` – GNU Autotools Do What Your Users Need 19 road map 0. hand-written makefile 1. Autoconf + simple makefile template 2. Autoconf + Automake 3. + optional libplot support 4. + tests 5. + turn plotting into a Libtool library each step has a corresponding branch in git://scm.gforge.inria.fr/.../autotools-demo.git L. Courtes` – GNU Autotools Do What Your Users Need 20 road map 0. hand-written makefile 1. Autoconf + simple makefile template 2. Autoconf + Automakeall that in 25mn! 3. + optional libplot support 4. + tests 5. + turn plotting into a Libtool library each step has a corresponding branch in git://scm.gforge.inria.fr/.../autotools-demo.git L. Courtes` – GNU Autotools Do What Your Users Need 20 road map 0. hand-written makefile 1. Autoconf + simple makefile template 2. Autoconf + Automakeall that in 25mn! 3. + optional libplot support 4. + tests 5. + turn plotting into a Libtool library each step has a corresponding branch in git://scm.gforge.inria.fr/.../autotools-demo.git L. Courtes` – GNU Autotools Do What Your Users Need 20 step 0: hand-written makefile branch 0-hand-written-makefile L. Courtes` – GNU Autotools Do What Your Users Need 21 step 0: hand-written makefile branch 0-hand-written-makefile Yay it builds on my machine! L. Courtes` – GNU Autotools Do What Your Users Need 21 • gains - user interface to specify installation directories - tools to check for programming environment features - template instantiation: foo.in ! foo - config.h, config.log step 1: our first configure.ac branch 1-autoconf+simple-makefile-template • tools - commands: autoscan, autoconf - macros: AC CHECK LIB, AC CHECK HEADERS L. Courtes` – GNU Autotools Do What Your Users Need 22 step 1: our first configure.ac branch 1-autoconf+simple-makefile-template • tools - commands: autoscan, autoconf - macros: AC CHECK LIB, AC CHECK HEADERS • gains - user interface to specify installation directories - tools to check for programming environment features - template instantiation: foo.in ! foo - config.h, config.log L. Courtes` – GNU Autotools Do What Your Users Need 22 • gains - honor installation directories: bindir, etc. - honor user variables: CFLAGS, DESTDIR, etc. - rules: all, install, uninstall • bonuses! - distribution: dist & distcheck - --enable-silent-rules - dependency tracking among .c and .h - rules to rebuild configure & co. - out-of-source builds - cross-compilation support - ... step 2: using Automake branch 2-autoconf+automake • tools - commands: automake, autoreconf - naming of Makefile.am variables, installation directories L. Courtes` – GNU Autotools Do What Your Users Need 23 • bonuses! - distribution: dist & distcheck - --enable-silent-rules - dependency tracking among .c and .h - rules to rebuild configure & co. - out-of-source builds - cross-compilation support - ... step 2: using Automake branch 2-autoconf+automake • tools - commands: automake, autoreconf - naming of Makefile.am variables, installation directories • gains - honor installation directories: bindir, etc. - honor user variables: CFLAGS, DESTDIR, etc. - rules: all, install, uninstall L. Courtes` – GNU Autotools Do What Your Users Need 23 step 2: using Automake branch 2-autoconf+automake • tools - commands: automake, autoreconf - naming of Makefile.am variables, installation directories • gains - honor installation directories: bindir, etc. - honor user variables: CFLAGS, DESTDIR, etc. - rules: all, install, uninstall • bonuses! - distribution: dist & distcheck - --enable-silent-rules - dependency tracking among .c and .h - rules to rebuild configure & co. - out-of-source builds - cross-compilation support - ... L. Courtes` – GNU Autotools Do What Your Users Need 23 • gains - optional part of the build - user can choose step 3: making a dependency optional branch 3-autoconf+automake+conditional-libplot • tools - in configure.ac: AM CONDITIONAL, AC ARG ENABLE - in Makefile.am: if, += L.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    64 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us