diff --git a/bin/caam b/bin/caam index 73875ec..5dceb93 100755 --- a/bin/caam +++ b/bin/caam @@ -33,7 +33,6 @@ */caam*) top=`dirname $dir` ;; *) top="$dir" ;; esac -echo d=$dir, top=$top chasemytop () ( me=$0; cd $mydir @@ -55,11 +54,63 @@ [ "$CAAM_DEBUG" ] && echo wrapdir=$WRAPDIR SUSPEND=: CAAM_LOG=true +logsuffix=${CAAM_LOGSUFFIX:-$myname} +if [ -w .. ]; then + logfile=../`basename $PWD`.$logsuffix +else + logdir=/tmp/caamLogBy-`logname` # No need to care race condition + [ -d $logdir ] || mkdir $logdir + logfile=$logdir/`basename $PWD`.$logsuffix +fi +usage() { + cat<<-EOF + $myname: Configure And And Make helper + Usage: $myname [caam-options] [configure-options] + Available caam-options: + -m Do make only, not calling configure + -c Do configure only, not calling make + -g Call "gmake" instead of default "make" + -mai, -gmai "make all install", "gmake all install" + -maic, -gmaic "make all install clean", ditto for gmake + -t TGT Set TGT as "make" target instead of "all" + -k MKOPT Call make with option MKOPT + -jN, -j N Make job concurrency set to N + -s SEC Sleep SEC seconds between configure and make + -S Suspend execution of $myname before calling make + -h HOOK Call HOOK script between configure and make + -l Replace ./libtool to that of the system + -o LOG Output log to LOG (default: $logfile) + -d Debug information + + Available environment variables: + CAAM_PREFIXES Reset default prefix + CAAM_ADD Colon delimited additional prefixes + CAAM_LOGSUFFIX Logfile's suffix w/o dot (default: $myname) + CC, CFLAGS, CXX, LDFLAGS, CPPFLAGS and ac_cv_* for many compiler + systems are also passed to them + Examples: + $myname -j5 + --> ./configure && make -j5 + + $myname -gmai --prefix=/usr/local/foo + --> ./configure --prefix=/usr/local/foo && gmake all install + + CAAM_ADD=gtk2:/usr/X11R7 $myname -maic --prefix=/usr/local/bar + --> Add -I$top/gtk2/include and -I/usr/X11R7/include + to CFLAGS, add + -L$top/gtk2/lib -R$top/gtk2/lib + -L/usr/X11R7/lib -R/usr/X11R7/lib + to LDFLAGS, then call + ./configure --preifx=/usr/local/bar && make all install clean + EOF + exit 0 +} # Parse my own arguments while [ x"" != x"$1" ]; do case "$1" in --) break;; + -help|--help) usage ;; -gmaic) TGT2="install clean"; CAAM_MAKE=gmake;; -maic) TGT2="install clean";; -gmai) TGT2="install"; CAAM_MAKE=gmake;; @@ -100,7 +151,7 @@ # extract pkg-config path's pcp=$PKG_CONFIG_PATH -[ $debug ] && echo ca=$ca +[ $debug ] && { echo d=$dir, top=$top, ca=$ca; } for e in $ca '' $dpx; do case "$e" in /*) pfx=$e ;; @@ -192,10 +243,10 @@ successlog() ( status=$? - if $CAAM_LOG; then + $CAAM_LOG || return + if touch $logfile 2>/dev/null; then PWD=`pwd` # for compatibility uname=`uname -sm 2>/dev/null` - logfile=../`basename $PWD`.caam [ -s $logfile ] || echo "### $logfile started at `date`" > $logfile (echo 1i echo "# ** $uname ** - $myname succeeded at `date`" @@ -222,6 +273,8 @@ echo "Saved caam log in $logfile." echo "To build again with same parameters: sh $logfile" echo "To see successfull caam arguments: sh $logfile -n" + else + echo "Cannot output log to [$logfile]" >&2 fi exit $status )