# # $Id: frontend.in,v 1.44 2004/05/14 15:13:38 jmmv Exp $ # bt_logic's frontend. # # buildtool # Copyright (c) 2003, 2004 Julio M. Merino Vidal. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # 3. Neither the name of the author nor the names of contributors may # be used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # usage() { local exitstatus=${1} local detailed=${2} [ ${detailed} = yes ] && echo "@PACKAGE@ version @VERSION@" 1>&2 echo "usage: ${ProgName} [extra opts] {-s ,--stage=}name" \ "[target1 ... targetN]" 1>&2 if [ ${detailed} = yes ]; then cat 1>&2 </dev/null; then scrfile="./${2}" else scrfile="${2}" fi shift ;; --file=*) arg=$(echo ${1} | sed -e 's|--file=||') if echo ${arg} | grep / >/dev/null; then scrfile="./${arg}" else scrfile="${arg}" fi ;; --ignore-sw-config) load_sw_config=no ;; -h|--help) usage 0 yes ;; -l) LogFile="${2}"; shift ;; --logfile=*) LogFile=$(echo ${1} | sed -e 's|--logfile=||') ;; -s) Stage="${2}"; shift ;; --stage=*) Stage=$(echo ${1} | sed -e 's|--stage=||') ;; -w) BT_WORKDIR="${2}"; shift ;; --workdir=*) BT_WORKDIR=$(echo ${1} | sed -e 's|--workdir=||') ;; --) shift; break ;; *) btcmn_warn "unknown option \`${1}'" usage 1 no ;; esac shift done [ ${Stage} != install -a -n "${BT_DESTDIR}" ] && \ btcmn_err "-d (--destdir) can only be used during the \`install' stage" btcmn_req_project [ -n "${scrfile}" ] && LogicFile="${scrfile}" if [ -z "${BT_WORKDIR}" ]; then if [ -d "${BT_TOPDIR}/work.bt" -a \ -f "${BT_TOPDIR}/work.bt/bt_config.env" ] then BT_WORKDIR=${BT_TOPDIR}/work.bt else BT_WORKDIR=${BT_TOPDIR} fi fi # Load system configuration if [ ${load_sw_config} = yes -a -f "@DIR_CONF@/bt_logic.conf" ]; then echo "bt_logic: loading system-wide configuration" . "@DIR_CONF@/bt_logic.conf" fi if [ ! -f "${BT_WORKDIR}/bt_config.env" ]; then btcmn_err "the package is not configured (use \`buildtool config')" \ "(or maybe you forgot to specify the work directory?)" fi . ${BT_WORKDIR}/bt_config.env [ -f ${BT_WORKDIR}/bt_logic.env ] && . ${BT_WORKDIR}/bt_logic.env bt_enter_obj bt_init btcmn_req_docs btcmn_req_logic [ ${BT_FEATURE_DEVELOPER} = yes -a -z "${LogFile}" ] && \ LogFile=${BT_OBJDIR}/.bt_logic.log docs logic _BT_CMDTARGETS="$*" if [ $# -gt 0 ]; then BT_TARGETS= bt_target $* fi local res if ! isfunc stage_${Stage}; then btcmn_warn "unknown stage \`${Stage}'" res=1 else if [ -n "${LogFile}" ]; then [ -f "${LogFile}" ] && echo >> ${LogFile} echo "---------------------------------------------------------------------------" >> ${LogFile} # NOLINT echo "bt_logic session started at $(date)" >> ${LogFile} echo >> ${LogFile} fi eval stage_${Stage} ${BT_TARGETS} res=$? fi return ${res} } # Local Variables: *** # mode: shell-script *** # End: *** # vim: syntax=sh