Presentation is loading. Please wait.

Presentation is loading. Please wait.

Developing Portable Applications ● Introduction GNU autotools – GNU toolchain ● Goals - cross-platform ● Supported platforms (POSIX compliant) ● GNU autotools.

Similar presentations


Presentation on theme: "Developing Portable Applications ● Introduction GNU autotools – GNU toolchain ● Goals - cross-platform ● Supported platforms (POSIX compliant) ● GNU autotools."— Presentation transcript:

1 Developing Portable Applications ● Introduction GNU autotools – GNU toolchain ● Goals - cross-platform ● Supported platforms (POSIX compliant) ● GNU autotools – autoconf – automake – libtool ● Prerequisites – Tools

2 Developing Portable Applications ● GNU toolchain – GNU make – GCC – GNU binutils (linker, assembler, library tools) – GNU debugger – GNU autotools

3 Developing Portable Applications ● What GNU autotools are for ? ● What GNU autotools are not for ? ● When to use GNU autotools ? ● When not to use GNU autotools ?

4 Developing Portable Applications ● Source distribution *.tar.gz ● Build from sources ● Steps in building programs: – configuration step – building step – Makefiles generated on the target machine.

5 Developing Portable Applications ● Tools (developer) – (GNU autotools) – autoconf package – automake package – libtool package ● Tools (installer) – Standard shell + common utilities (grep, sed,...) – C/C++ compiler – Perl (required by automake) – make utility

6 Developing Portable Applications ● Supported operating systems – GNU/Linux – Variants of Unices. – MAC/OS – Windows (with Cygwin support) – Other Posix compliant OSs' (OpenVMS)

7 Developing Portable Applications ● Supported languages – C/C++ – Fortran77/90 – Objective C – Ada – Erlang – Python – Java (limited)

8 Developing Portable Applications ● Installing GNU autotools – Download ● autoconf ● automake ● libtool from www.gnu.orgwww.gnu.org – tar.gz files – Unpack –./configure && make && make install

9 Developing Portable Applications ● Versions – GNU autoconf 2.61 – GNU automake 1.10 – GNU libtool 1.5.22 – GNU m4 1.4.8

10 Developing Portable Applications ● Installation example –./configure (with optional arguments) – make – make all – make check – make install – make dist – make distcheck – make clean

11 Developing Portable Applications ● Commonly used configure options: –./configure –help –./configure --prefix=/home/space ● Configure destination directories – /usr/local/bin – /usr/local/lib – /usr/local/include – /usr/local/man ● --prefix -> /usr/local

12 Developing Portable Applications ● Enabling or disabling package features. – --with-package – --without-package – –enable-feature – --disable-feature ● Passing environment variables – Example, export CFLAGS=-g (bash) ●./configure –disable- ●./configure --enable-debug=full

13 Developing Portable Applications ● Source directory structure – Shallow structure – Deep structure ● Organising project in sub-directories. ● src ● lib ● include ● doc

14 Developing Portable Applications ● Minimal files – in top level directory. – README – INSTALL – AUTHORS – NEWS – ChangeLog

15 Developing Portable Applications ● Version numbers – Major number – Minor number – A third number for unofficial releases. ● Example: – tar-1.16 – glpi-0.70.2

16 Developing Portable Applications ● Basic input files: – configure.ac (or configure.in) – Makefile.am

17 Developing Portable Applications ● Contents of distribution (in addition to the source files) – config.h.in – Makefile.in – aclocal.m4

18 Developing Portable Applications ● Example: – shmem_s.c – shmem_c.c

19 Developing Portable Applications ● Configuration steps – aclocal – autoheader – autoconf – libtoolize – automake

20 Developing Portable Applications ● Process flow

21 Developing Portable Applications ● aclocal

22 Developing Portable Applications ● autoheader

23 Developing Portable Applications ● Files generated by configure script. – config.cache – config.status – config.log – config.h – Makefile

24 Developing Portable Applications ● Note: – Only one configure.in at top level directory. – One Makefile.am for each subdirectory. – autoreconf program OR the following script. ● #/bin/sh ● rm -f config.cache ● aclocal ● autoconf ● autoheader ● libtoolize -c –force ● automake -a

25 Developing Portable Applications ● Order of invoking macros in configure.ac – AC_INIT – AC_CONFIG_HEADERS – Check for programs – Check for libraries – Check for header files – Check for types/structures – Check for compiler characteristics – Check for library functions – Check for system services – AC_CONFIG_FILES – AC_OUTPUT

26 Developing Portable Applications ● Automake variables – prefix_primary – Common prefixes (w.r.t /usr/local - default) ● bin_ ● sbin_ ● lib_ ● noinst_ ● EXTRA_ ● check_

27 Developing Portable Applications ● Common primaries – _PROGRAMS – _LIBRARIES – _SCRIPTS – _HEADERS – _OBJECTS – _DATA – _LDADD

28 Developing Portable Applications ● Portability considerations – Shell scripts ● It is easier to write portable shell than writing a portable shell script. – Larry Wall – Compiler characteristics – Library functions – System calls

29 Developing Portable Applications ● Top level directory – configure.ac – Makefile.am ● Sub-directories – Makefile.am

30 Developing Portable Applications ● Defining user macros in configure.ac ● AC_DEFUN[MACRO_NAME, MACRO_BODY] – dnl Make an uppercase version of a given name – AC_DEFUN([NC_UPPERCASE], – [changequote(,)dnl – $2=`echo $1 |tr '[a-z]' '[A-Z]'` – changequote([,])dnl – ])dnl

31 Developing Portable Applications ● Makefile basics – Specifies the dependencies on how the target is to be built. – Dependencies may be nested. – Format: ● target:.... ● commands – Timestamps.

32 Developing Portable Applications ● VPATH build. – Building for more than one architecture.

33 Developing Portable Applications ● Shared library basics – Static vs shared library – Advantages – Object/executable formats – Library names and version numbering. – Symbolic links – Special gcc flags $(CCFLAGS) – $(LDFLAGS) – -$(LIBS)

34 Developing Portable Applications ● Static linking,runtime linking,dynamic linking ● ld ● LD_LIBRARY_PATH ● ld.so.conf, ld.so.cache ● ld.linux.so ● dlopen() ● dlsym() ● dlclose()

35 Developing Portable Applications ● Some useful library related commands: – nm – objdump – readelf – ar – ranlib – ldd

36 Developing Portable Applications ● GNU autotools and cross compilation. ● Linux Standard Base – binary compatibility


Download ppt "Developing Portable Applications ● Introduction GNU autotools – GNU toolchain ● Goals - cross-platform ● Supported platforms (POSIX compliant) ● GNU autotools."

Similar presentations


Ads by Google