a_nag_group_lookup(): FIX used case-i?sensitive hash function!
[s-mailx.git] / make-emerge.sh
blob2b6fa8bbc21c36453786e28ae42d782e5fd2a344
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
7 # See make-config.sh, the source of all this!
9 config_exit() {
10 exit ${1}
13 msg() {
14 fmt=${1}
15 shift
16 printf >&2 -- "${fmt}\\n" "${@}"
19 unset -f command
20 check_tool() {
21 n=${1} i=${2} opt=${3:-0}
22 # Evaluate, just in case user comes in with shell snippets (..well..)
23 eval i="${i}"
24 if type "${i}" >/dev/null 2>&1; then # XXX why have i type not command -v?
25 [ -n "${VERBOSE}" ] && msg ' . ${%s} ... %s' "${n}" "${i}"
26 eval ${n}=${i}
27 return 0
29 if [ ${opt} -eq 0 ]; then
30 msg 'ERROR: no trace of utility %s' "${n}"
31 config_exit 1
33 return 1
36 syno() {
37 if [ ${#} -gt 0 ]; then
38 echo >&2 "ERROR: ${*}"
39 echo >&2
41 echo >&2 'Synopsis: SOURCEDIR/make-emerge.sh [from within target directory]'
42 exit 1
45 [ ${#} -eq 0 ] || syno
47 # Rude simple, we should test for Solaris, but who runs this script?
48 if [ -d /usr/xpg4 ]; then
49 PATH=/usr/xpg4/bin:${PATH}
52 check_tool awk "${awk:-`command -v awk`}"
53 check_tool dirname "${dirname:-`command -v dirname`}"
54 check_tool pwd "${pwd:-`command -v pwd`}"
56 srcdir=`${dirname} ${0}`
57 blddir=`${pwd}`
58 if [ "${srcdir}" = . ]; then
59 echo >&2 'This is not out of tree?!'
60 exit 1
62 echo 'Initializing out-of-tree build.'
63 echo 'Source directory: '"${srcdir}"
64 echo 'Build directory : '"${blddir}"
65 srcdir="${srcdir}"/
67 ${awk} -v srcdir="${srcdir}" -v blddir="${blddir}" '
69 gsub(/^SRCDIR=\.\/$/, "SRCDIR=" srcdir)
70 print
72 ' < "${srcdir}"makefile > ./makefile
74 cp "${srcdir}"config.h ./
75 cp "${srcdir}"gen-version.h ./
76 cp "${srcdir}"make.rc ./
78 echo 'You should now be able to proceed as normal (e.g., "$ make all")'
80 # s-sh-mode