cc-test.sh:t_behave_S_freeze(): fix test number in skip message
[s-mailx.git] / make-emerge.sh
blob040d6ae9ffc2ad89d43548f68945d27a9c83231e
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 # 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}" "${@}"
16 [ -n "${SHELL}" ] || SHELL=/bin/sh
17 export SHELL
19 ( set -o noglob ) >/dev/null 2>&1 && noglob_shell=1 || unset noglob_shell
21 config_exit() {
22 exit ${1}
25 msg() {
26 fmt=${1}
27 shift
28 printf >&2 -- "${fmt}\\n" "${@}"
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}
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
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
61 if [ -z "${path}" ] || [ "${path}" = . ]; then
62 if [ -d "${PWD}" ]; then
63 path=${PWD}
64 else
65 path=.
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
74 done
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
86 [ ${dofail} -eq 0 ] && return 1
87 msg 'ERROR: no trace of utility '"${pname}"
88 exit 1
91 syno() {
92 if [ ${#} -gt 0 ]; then
93 echo >&2 "ERROR: ${*}"
94 echo >&2
96 echo >&2 'Synopsis: SOURCEDIR/make-emerge.sh [from within target directory]'
97 exit 1
100 [ ${#} -eq 0 ] || syno
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}
107 thecmd_testandset_fail awk awk
108 thecmd_testandset_fail cp cp
109 thecmd_testandset_fail dirname dirname
110 thecmd_testandset_fail pwd pwd
112 srcdir=`${dirname} ${0}`
113 blddir=`${pwd}`
114 if [ "${srcdir}" = . ]; then
115 msg 'This is not out of tree?!'
116 config_exit 1
118 echo 'Initializing out-of-tree build.'
119 echo 'Source directory: '"${srcdir}"
120 echo 'Build directory : '"${blddir}"
121 srcdir="${srcdir}"/
123 ${awk} -v srcdir="${srcdir}" -v blddir="${blddir}" '
125 gsub(/^CWDDIR=\.\/$/, "CWDDIR=" blddir)
126 gsub(/^SRCDIR=\.\/$/, "SRCDIR=" srcdir)
127 print
129 ' < "${srcdir}"makefile > ./makefile
131 ${cp} "${srcdir}"config.h ./
132 ${cp} "${srcdir}"gen-version.h ./
133 ${cp} "${srcdir}"make.rc ./
135 echo 'You should now be able to proceed as normal (e.g., "$ make all")'
137 # s-sh-mode