#!/bin/sh # # /**********************************************************************/ # /* */ # /* TOP LEVEL BUILDING SCRIPT ALZAM */ # /* */ # /* loïc berthelot, cryonetworks, mars 2002 */ # /* created from shazam (Vincent Carron, CryoNetworks, april 2000 */ # /* */ # /**********************************************************************/ # # # /**********************************************************************/ # /* */ # /* !!! See alzamconf/alzam.conf if you want to add a module */ # /* to compile !!! */ # /* */ # /**********************************************************************/ # # # /**********************************************************************/ # /* */ # /* CONTENTS */ # /* ________ */ # /* */ # /* alzam_readConf */ # /* alzam_usage */ # /* alzam_checkCommandLine */ # /* alzam_execModule */ # /* alzam_checkModuleEnv */ # /* alzam_execMode */ # /* alzam_make */ # /* alzam_copy */ # /* M A I N */ # /* */ # /**********************************************************************/ # # # /********************************************************************/ # /* */ # /* alzam_readConf */ # /* */ # /* include alzam.conf - check environnement variables */ # /* */ # /********************************************************************/ # function alzam_readConf () { ALZAM_CONF="alzamconf/alzam.conf" # // check the file if [ ! -f $ALZAM_CONF ]; then echo; echo "alzam error : $ALZAM_CONF not found !!"; echo; exit fi # // execute the file . $ALZAM_CONF # // check the ALZAM_MODULES env. var. if [ ! "$ALZAM_MODULES" ]; then echo; echo "alzam error : there is no module to compile. Please check the ALZAM_MODULES var. in $ALZAM_CONF !!"; echo; exit fi # // check the ALZAM_MODES env. var. if [ ! "$ALZAM_MODES" ]; then echo; echo "alzam error : there is no compiling mode. Please check the ALZAM_MODES var. in $ALZAM_CONF !!"; echo; exit fi } # # /********************************************************************/ # /* */ # /* alzam_usage */ # /* */ # /* print a message to indicate the usage of alzam */ # /* */ # /********************************************************************/ # function alzam_usage () { # // check the modules to compile modules="" for module in $ALZAM_MODULES; do if [ "$modules" = "" ] ; then modules=" $module"; else modules="$modules | $module"; fi; done # // check the modes of compiling modes="" for mode in $ALZAM_MODES; do if [ "$modes" = "" ]; then modes=" $mode"; else modes="$modes | $mode"; fi; done # // print the usage message echo echo echo "Usage : $0 < $modules > < $modes >" echo echo } # # /********************************************************************/ # /* */ # /* alzam_checkCommandLine */ # /* */ # /* check the args. of alzam command line */ # /* */ # /********************************************************************/ # function alzam_checkCommandLine () { # // check the number of args. if [ $ALZAM_NBARGS -lt 2 ] ; then alzam_usage; exit; fi # // check the first arg. found=0 for module in $ALZAM_MODULES; do if [ "$module" = "$ALZAM_MODULE" ]; then found=1; fi; done; if [ $found -eq 0 ]; then alzam_usage; exit; fi; # // check the second arg. found=0 for mode in $ALZAM_MODES; do if [ "$mode" = "$ALZAM_MODE" ]; then found=1; fi; done; if [ $found -eq 0 ]; then alzam_usage; exit; fi; } # # /********************************************************************/ # /* */ # /* alzam_execModule */ # /* */ # /* call the execution of the module procedure given as parameter */ # /* */ # /********************************************************************/ # function alzam_execModule () { $ALZAM_MODULE } # # /********************************************************************/ # /* */ # /* alzam_checkModuleEnv */ # /* */ # /* did the executed module set the env. vars. ? */ # /* */ # /********************************************************************/ # function alzam_checkModuleEnv () { if [ ! "$CFLAGS" ]; then echo "alzam error : alzam.conf : $ALZAM_MODULE module : CFLAGS not found !"; exit; fi if [ ! "$LFLAGS" ]; then echo "alzam error : alzam.conf : $ALZAM_MODULE module : LFLAGS not found !"; exit; fi if [ ! "$SRC_PATH" ]; then echo "alzam error : alzam.conf : $ALZAM_MODULE module : SRC_PATH not found !"; exit; fi if [ ! "$TARGET_PATH" ]; then echo "alzam error : alzam.conf : $ALZAM_MODULE module : TARGET_PATH not found !"; exit; fi if [ ! "$TARGET_SCOL_PATH" ]; then echo "alzam error : alzam.conf : $ALZAM_MODULE module : TARGET_SCOL_PATH not found !"; exit; fi if [ ! "$TARGET_MAKE" ]; then echo "alzam error : alzam.conf : $ALZAM_MODULE module : TARGET_MAKE not found !"; exit; fi if [ ! "$TARGET" ]; then echo "alzam error : alzam.conf : $ALZAM_MODULE module : TARGET not found !"; exit; fi } # # /*************************************************************************/ # /* */ # /* alzam_execMode */ # /* */ # /* call the execution of the compiling mode procedure given as parameter */ # /* */ # /*************************************************************************/ # function alzam_execMode () { $ALZAM_MODE } # # /*************************************************************************/ # /* */ # /* alzam_make */ # /* */ # /* final stage : call the choosen Makefile */ # /* */ # /*************************************************************************/ # function alzam_checkEnv() { echo echo echo echo echo "**********************************************************************" echo "* " echo "* " echo "* module $ALZAM_MODULE " echo "* " echo "* mode $ALZAM_MODE " echo "* " echo "* " echo "* Platform : $(uname) on a $(uname -m) " echo "* " echo "* TARGET_PATH : $TARGET_PATH " echo "* " echo "* TARGET : $TARGET " echo "* " echo "* TARGET_SCOL : $TARGET_SCOL " echo "* " echo "* CFLAGS : $CFLAGS " echo "* " echo "* LFLAGS : $LFLAGS " echo "* " echo "* " echo "**********************************************************************" echo echo echo echo } # # /*************************************************************************/ # /* */ # /* alzam_make */ # /* */ # /* final stage : call the choosen Makefile */ # /* */ # /*************************************************************************/ # function alzam_make () { export SRC_PATH TARGET_PATH TARGET_MAKE TARGET CFLAGS LFLAGS rm -f $TARGET cd $SRC_PATH make all # No target ? There has been a build error ... if [ ! -e $TARGET ] ; then exit; fi # In release mode, strip symbols if [ $RELEASE = yes ]; then strip $TARGET; fi # And display some infos echo; ls -l $TARGET; echo } # # /*************************************************************************/ # /* */ # /* alzam_copy */ # /* */ # /* post final stage : copy the compiled module to its scol dest. */ # /* */ # /*************************************************************************/ # function alzam_copy () { cp -f $TARGET $TARGET_SCOL } # # /********************************************************************/ # /* */ # /* */ # /* M A I N */ # /* */ # /* */ # /********************************************************************/ # # // init global var env ALZAM_NBARGS="$#" ALZAM_MODULE="$1" ALZAM_MODE="$2" # // launch alzam process alzam_readConf alzam_checkCommandLine; alzam_execModule; alzam_checkModuleEnv; alzam_execMode; alzam_checkEnv; alzam_make; alzam_copy;