functions

Name

functions  --  shell function definitions for configure scripts

Description

functions contains all shell functions that can be used by shell scripts to generate makefiles for building products using GNU make. The shell must probably be POSIX compliant.

To use these functions in a script, first source functions, like this:

    . path/to/functions
    

or, like this:

    source path/to/functions
    

The behaviour of the shell functions can be controlled by giving command line options to the configure(1) script (which are parsed and handled by functions).

Functions

The following functions are documented and available for use:

aconfig_targets(3)

add the product configuration targets

buildtype(3)

set default buildtype target

compiler(3)

check that a compiler exists and its version

conditional_reexec(3)

fetch a file or package and reexecute conditionally

console_linux_2_4(3)

create the console link

core(3)

create the makefile core

directory(3)

install a directory

envfile(3)

specify the name of an environment variables init file

error(3)

print an error message to stderr and exit

fetch(3)

download a file or package

file(3)

install a regular file

flashimage(3)

create the flashimage target and the HWID variable

fragment(3)

include a makefile fragment

functest(3)

fetch a package and add it to the FUNCTESTS variable

help_target(3)

create a help target

ignore(3)

ignore any future references to a file or package

include(3)

fetch a file and source it

inform(3)

print an informational message to stdout

inform_done(3)

conclude an informational message positively

inform_failed(3)

conclude an informational message negatively

inform_progress(3)

draw a spinner to stdout

install_target(3)

create the install target

jimage(3)

create the factorydefault image target

kernel(3)

create the kernel target

kernel_dir(3)

set the path to the kernel source directory

make_rules(3)

include the rules file

output(3)

specify the file name of the output file

override(3)

override fetch-options for files or packages

partition(3)

add an entry to the partition table and/or a line to fstab

path(3)

add directories to the PATH variable

prepare_build(3)

prepares the build

protect(3)

protect files and packages from being fetched

release(3)

add software release information

repository_root(3)

set the global repository root URL

sub(3)

fetch a package and add it to the SUBDIRS variable

symlink(3)

create a symbolic link

tool(3)

fetch a tool and add it to the tools target

top_dir(3)

set the path to the top directory

unittest_target(3)

create the include for the unit test targets

unpack(3)

extract a (compressed) tarball in current working directory

var_tar(3)

create a tarfile of the var directory

warning(3)

print a warning message to stderr

Example

A configure script that uses functions to generate Makefile that builds a very small (and rather useless) product software:

    #! /bin/sh
    #
    # Configuration script for Axis Product
    #
    
    SOURCE="configure-files/source"
    SOURCE_REV="R1_2_0"
    
    [ -z "$CVSROOT" ] && CVSROOT=":ext:mycvshost:/path/to/cvsroot"
    
    if [ ! -f "$SOURCE/functions" ]; then
            cvs -d "$CVSROOT" co -r "$SOURCE_REV" "$SOURCE" || exit 1
    fi
    
    . "$SOURCE/functions" || exit 1
    
    repository_root "$CVSROOT"
    conditional_reexec "$SOURCE" rev="$SOURCE_REV"
    
    compiler gcc-cris rev=R56
    buildtype cris-axis-linux-gnuuclibc librev=IR0_9_21-6--memfix
    
    # Environment initialization file
    envfile init_env
    
    # This is usually included from a common include-file
    core
    make_rules
    tool tools/build rev=R2_5_2
    path tools/build/bin
    
    # Software version
    release "1.0" build=1
    
    # Kernel version
    kernel os/linux rev=R2_4_25_040223
    
    # Partition table and fstab
    partition ptable name=rescue size=0x010000 csum=yes type=rescue \
                     bin=rfl.bin
    partition ptable name=flash1 size=0x350000 csum=yes type=kernel
    partition fstab name=rootfs dev=/dev/flash3 mpoint=/ type=cramfs \
                    mopts=noauto dump=0 pass=1
    partition ptable name=flash2 size=0x0a0000 csum=no type=jffs2 \
              fstab dev=/dev/flash2 mpoint=/mnt/flash mopts=noauto \
                    dump=0 pass=2
    partition fstab dev=proc mpoint=/proc type=proc dump=0 pass=0
    partition fstab dev=tmpfs mpoint=/var type=tmpfs dump=0 pass=0
    partition fstab dev=devpts mpoint=/dev/pts type=devpts dump=0 pass=0
    
    # Flash image with hardware ID
    flashimage 1
    
    # Factorydefault image with JIMAGEID
    jimage
    
    # Files needed by a very small Linux system
    sub packages/filesystem rev=R1_2_0
    sub packages/base-files rev=R1_1_0
    sub packages/devices/standard rev=R1_2_0
    sub packages/devices/axis-2.4 rev=R1_0_7
    sub apps/init rev=R1_3_4
    sub packages/initscripts/common rev=R2_9_1
    sub apps/shells/dash rev=IR0_4_17-4
    symlink dash /bin/sh
    sub apps/busybox rev=R1_3_1
    sub packages/romfs_meta/common rev=R1_0_0
    
    # Generate Makefile
    output Makefile
    

Coding Style

A few rules that need to be followed when submitting changes:

Caveats

functions should only use POSIX, but extensive testing has not been made yet. functions has only been verified to work with bash, but ought to work with any POSIX compliant shell, and maybe even some non-POSIX Bourne shells.

Bugs

You are welcome to send bug reports and feedback to the author or to the dev-etrax mailing list .

See Also

configure(1)

Copyright

Copyright (C) 2003-2007 Axis Communications AB

Author

Jonas Holmberg