caam
changeset 28:a2eab6cbd1a0
Logfile extension can be controled by $CAAM_LOGSUFFIX
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Tue, 27 Feb 2018 08:35:07 +0900 |
parents | 00b093d6567b |
children | a74630a971bf |
files | bin/caam |
diffstat | 1 files changed, 57 insertions(+), 4 deletions(-) [+] |
line diff
1.1 --- a/bin/caam Sat Feb 24 07:42:35 2018 +0900 1.2 +++ b/bin/caam Tue Feb 27 08:35:07 2018 +0900 1.3 @@ -33,7 +33,6 @@ 1.4 */caam*) top=`dirname $dir` ;; 1.5 *) top="$dir" ;; 1.6 esac 1.7 -echo d=$dir, top=$top 1.8 1.9 chasemytop () ( 1.10 me=$0; cd $mydir 1.11 @@ -55,11 +54,63 @@ 1.12 [ "$CAAM_DEBUG" ] && echo wrapdir=$WRAPDIR 1.13 SUSPEND=: 1.14 CAAM_LOG=true 1.15 +logsuffix=${CAAM_LOGSUFFIX:-$myname} 1.16 +if [ -w .. ]; then 1.17 + logfile=../`basename $PWD`.$logsuffix 1.18 +else 1.19 + logdir=/tmp/caamLogBy-`logname` # No need to care race condition 1.20 + [ -d $logdir ] || mkdir $logdir 1.21 + logfile=$logdir/`basename $PWD`.$logsuffix 1.22 +fi 1.23 1.24 +usage() { 1.25 + cat<<-EOF 1.26 + $myname: Configure And And Make helper 1.27 + Usage: $myname [caam-options] [configure-options] 1.28 + Available caam-options: 1.29 + -m Do make only, not calling configure 1.30 + -c Do configure only, not calling make 1.31 + -g Call "gmake" instead of default "make" 1.32 + -mai, -gmai "make all install", "gmake all install" 1.33 + -maic, -gmaic "make all install clean", ditto for gmake 1.34 + -t TGT Set TGT as "make" target instead of "all" 1.35 + -k MKOPT Call make with option MKOPT 1.36 + -jN, -j N Make job concurrency set to N 1.37 + -s SEC Sleep SEC seconds between configure and make 1.38 + -S Suspend execution of $myname before calling make 1.39 + -h HOOK Call HOOK script between configure and make 1.40 + -l Replace ./libtool to that of the system 1.41 + -o LOG Output log to LOG (default: $logfile) 1.42 + -d Debug information 1.43 + 1.44 + Available environment variables: 1.45 + CAAM_PREFIXES Reset default prefix 1.46 + CAAM_ADD Colon delimited additional prefixes 1.47 + CAAM_LOGSUFFIX Logfile's suffix w/o dot (default: $myname) 1.48 + CC, CFLAGS, CXX, LDFLAGS, CPPFLAGS and ac_cv_* for many compiler 1.49 + systems are also passed to them 1.50 + Examples: 1.51 + $myname -j5 1.52 + --> ./configure && make -j5 1.53 + 1.54 + $myname -gmai --prefix=/usr/local/foo 1.55 + --> ./configure --prefix=/usr/local/foo && gmake all install 1.56 + 1.57 + CAAM_ADD=gtk2:/usr/X11R7 $myname -maic --prefix=/usr/local/bar 1.58 + --> Add -I$top/gtk2/include and -I/usr/X11R7/include 1.59 + to CFLAGS, add 1.60 + -L$top/gtk2/lib -R$top/gtk2/lib 1.61 + -L/usr/X11R7/lib -R/usr/X11R7/lib 1.62 + to LDFLAGS, then call 1.63 + ./configure --preifx=/usr/local/bar && make all install clean 1.64 + EOF 1.65 + exit 0 1.66 +} 1.67 # Parse my own arguments 1.68 while [ x"" != x"$1" ]; do 1.69 case "$1" in 1.70 --) break;; 1.71 + -help|--help) usage ;; 1.72 -gmaic) TGT2="install clean"; CAAM_MAKE=gmake;; 1.73 -maic) TGT2="install clean";; 1.74 -gmai) TGT2="install"; CAAM_MAKE=gmake;; 1.75 @@ -100,7 +151,7 @@ 1.76 # extract pkg-config path's 1.77 pcp=$PKG_CONFIG_PATH 1.78 1.79 -[ $debug ] && echo ca=$ca 1.80 +[ $debug ] && { echo d=$dir, top=$top, ca=$ca; } 1.81 for e in $ca '' $dpx; do 1.82 case "$e" in 1.83 /*) pfx=$e ;; 1.84 @@ -192,10 +243,10 @@ 1.85 1.86 successlog() ( 1.87 status=$? 1.88 - if $CAAM_LOG; then 1.89 + $CAAM_LOG || return 1.90 + if touch $logfile 2>/dev/null; then 1.91 PWD=`pwd` # for compatibility 1.92 uname=`uname -sm 2>/dev/null` 1.93 - logfile=../`basename $PWD`.caam 1.94 [ -s $logfile ] || echo "### $logfile started at `date`" > $logfile 1.95 (echo 1i 1.96 echo "# ** $uname ** - $myname succeeded at `date`" 1.97 @@ -222,6 +273,8 @@ 1.98 echo "Saved caam log in $logfile." 1.99 echo "To build again with same parameters: sh $logfile" 1.100 echo "To see successfull caam arguments: sh $logfile -n" 1.101 + else 1.102 + echo "Cannot output log to [$logfile]" >&2 1.103 fi 1.104 exit $status 1.105 )