"Fossies" - the Fresh Open Source Software Archive

Member "s-nail-14.9.11/make-emerge.sh" (8 Aug 2018, 3873 Bytes) of package /linux/misc/s-nail-14.9.11.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "make-emerge.sh": 14.9.10_vs_14.9.11.

    1 #!/bin/sh -
    2 #@ Out-of-tree compilation support, à la
    3 #@    $ cd /tmp && mkdir build && cd build &&
    4 #@       ~/src/nail.git/make-emerge.sh && make tangerine DESTDIR=.ddir
    5 # Public Domain
    6 
    7 ## See make-config.sh, the source of all this!
    8 
    9 # For heaven's sake auto-redirect on SunOS/Solaris
   10 if [ "x${SHELL}" = x ] || [ "${SHELL}" = /bin/sh ] && \
   11       [ -f /usr/xpg4/bin/sh ] && [ -x /usr/xpg4/bin/sh ]; then
   12    SHELL=/usr/xpg4/bin/sh
   13    export SHELL
   14    exec /usr/xpg4/bin/sh "${0}" "${@}"
   15 fi
   16 [ -n "${SHELL}" ] || SHELL=/bin/sh
   17 export SHELL
   18 
   19 ( set -o noglob ) >/dev/null 2>&1 && noglob_shell=1 || unset noglob_shell
   20 
   21 config_exit() {
   22    exit ${1}
   23 }
   24 
   25 msg() {
   26    fmt=${1}
   27    shift
   28    printf >&2 -- "${fmt}\\n" "${@}"
   29 }
   30 
   31 # which(1) not standardized, command(1) -v may return non-executable: unroll!
   32 acmd_test() { __acmd "${1}" 1 0 0; }
   33 acmd_test_fail() { __acmd "${1}" 1 1 0; }
   34 acmd_set() { __acmd "${2}" 0 0 0 "${1}"; }
   35 acmd_set_fail() { __acmd "${2}" 0 1 0 "${1}"; }
   36 acmd_testandset() { __acmd "${2}" 1 0 0 "${1}"; }
   37 acmd_testandset_fail() { __acmd "${2}" 1 1 0 "${1}"; }
   38 thecmd_set() { __acmd "${2}" 0 0 1 "${1}"; }
   39 thecmd_set_fail() { __acmd "${2}" 0 1 1 "${1}"; }
   40 thecmd_testandset() { __acmd "${2}" 1 0 1 "${1}"; }
   41 thecmd_testandset_fail() { __acmd "${2}" 1 1 1 "${1}"; }
   42 __acmd() {
   43    pname=${1} dotest=${2} dofail=${3} verbok=${4} varname=${5}
   44 
   45    if [ "${dotest}" -ne 0 ]; then
   46       eval dotest=\$${varname}
   47       if [ -n "${dotest}" ]; then
   48          [ -n "${VERBOSE}" ] && [ ${verbok} -ne 0 ] &&
   49             msg ' . ${%s} ... %s' "${pname}" "${dotest}"
   50          return 0
   51       fi
   52    fi
   53 
   54    oifs=${IFS} IFS=:
   55    [ -n "${noglob_shell}" ] && set -o noglob
   56    set -- ${PATH}
   57    [ -n "${noglob_shell}" ] && set +o noglob
   58    IFS=${oifs}
   59    for path
   60    do
   61       if [ -z "${path}" ] || [ "${path}" = . ]; then
   62          if [ -d "${PWD}" ]; then
   63             path=${PWD}
   64          else
   65             path=.
   66          fi
   67       fi
   68       if [ -f "${path}/${pname}" ] && [ -x "${path}/${pname}" ]; then
   69          [ -n "${VERBOSE}" ] && [ ${verbok} -ne 0 ] &&
   70             msg ' . ${%s} ... %s' "${pname}" "${path}/${pname}"
   71          [ -n "${varname}" ] && eval ${varname}="${path}/${pname}"
   72          return 0
   73       fi
   74    done
   75 
   76    # We may have no builtin string functions, we yet have no programs we can
   77    # use, try to access once from the root, assuming it is an absolute path if
   78    # that finds the executable
   79    if ( cd && [ -f "${pname}" ] && [ -x "${pname}" ] ); then
   80      [ -n "${VERBOSE}" ] && [ ${verbok} -ne 0 ] &&
   81             msg ' . ${%s} ... %s' "${pname}" "${pname}"
   82       [ -n "${varname}" ] && eval ${varname}="${pname}"
   83       return 0
   84    fi
   85 
   86    [ ${dofail} -eq 0 ] && return 1
   87    msg 'ERROR: no trace of utility '"${pname}"
   88    exit 1
   89 }
   90 
   91 syno() {
   92    if [ ${#} -gt 0 ]; then
   93       echo >&2 "ERROR: ${*}"
   94       echo >&2
   95    fi
   96    echo >&2 'Synopsis: SOURCEDIR/make-emerge.sh [from within target directory]'
   97    exit 1
   98 }
   99 
  100 [ ${#} -eq 0 ] || syno
  101 
  102 # Rude simple, we should test for Solaris, but who runs this script?
  103 if [ -d /usr/xpg4 ]; then
  104    PATH=/usr/xpg4/bin:${PATH}
  105 fi
  106 
  107 thecmd_testandset_fail awk awk
  108 thecmd_testandset_fail cp cp
  109 thecmd_testandset_fail dirname dirname
  110 thecmd_testandset_fail pwd pwd
  111 
  112 srcdir=`${dirname} ${0}`
  113 if [ "${srcdir}" = . ]; then
  114    msg 'This is not out of tree?!'
  115    config_exit 1
  116 fi
  117 srcdir=`cd ${srcdir}; ${pwd}`/
  118 blddir=`${pwd}`/
  119 echo 'Initializing out-of-tree build.'
  120 echo 'Source directory: '"${srcdir}"
  121 echo 'Build directory : '"${blddir}"
  122 srcdir="${srcdir}"/
  123 
  124 ${awk} -v srcdir="${srcdir}" -v blddir="${blddir}" '
  125    {
  126       gsub(/^CWDDIR=.*$/, "CWDDIR=" blddir)
  127       gsub(/^SRCDIR=.*$/, "SRCDIR=" srcdir)
  128       print
  129    }
  130    ' < "${srcdir}"makefile > ./makefile
  131 
  132 ${cp} "${srcdir}"config.h ./
  133 ${cp} "${srcdir}"gen-version.h ./
  134 ${cp} "${srcdir}"make.rc ./
  135 
  136 echo 'You should now be able to proceed as normal (e.g., "$ make all")'
  137 
  138 # s-sh-mode