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
7 # See make-config.sh, the source of all this!
9 ( set -o noglob
) >/dev
/null
2>&1 && noglob_shell
=1 ||
unset noglob_shell
18 printf >&2 -- "${fmt}\\n" "${@}"
21 # which(1) not standardized, command(1) -v may return non-executable: unroll!
22 acmd_test
() { __acmd
"${1}" 1 0 0; }
23 acmd_test_fail
() { __acmd
"${1}" 1 1 0; }
24 acmd_set
() { __acmd
"${2}" 0 0 0 "${1}"; }
25 acmd_set_fail() { __acmd "${2}" 0 1 0 "${1}"; }
26 acmd_testandset
() { __acmd
"${2}" 1 0 0 "${1}"; }
27 acmd_testandset_fail() { __acmd "${2}" 1 1 0 "${1}"; }
28 thecmd_set
() { __acmd
"${2}" 0 0 1 "${1}"; }
29 thecmd_set_fail() { __acmd "${2}" 0 1 1 "${1}"; }
30 thecmd_testandset
() { __acmd
"${2}" 1 0 1 "${1}"; }
31 thecmd_testandset_fail() { __acmd "${2}" 1 1 1 "${1}"; }
33 pname
=${1} dotest=${2} dofail=${3} verbok=${4} varname=${5}
35 if [ "${dotest}" -ne 0 ]; then
36 eval dotest
=\$
${varname}
37 if [ -n "${dotest}" ]; then
38 [ -n "${VERBOSE}" ] && [ ${verbok} -ne 0 ] &&
39 msg
' . ${%s} ... %s' "${pname}" "${dotest}"
45 [ -n "${noglob_shell}" ] && set -o noglob
47 [ -n "${noglob_shell}" ] && set +o noglob
51 if [ -z "${path}" ] || [ "${path}" = . ]; then
52 if [ -d "${PWD}" ]; then
58 if [ -f "${path}/${pname}" ] && [ -x "${path}/${pname}" ]; then
59 [ -n "${VERBOSE}" ] && [ ${verbok} -ne 0 ] &&
60 msg ' .
${%s} ... %s' "${pname}" "${path}/${pname}"
61 [ -n "${varname}" ] && eval ${varname}="${path}/${pname}"
66 # We may have no builtin string functions, we yet have no programs we can
67 # use, try to access once from the root, assuming it is an absolute path if
68 # that finds the executable
69 if ( cd && [ -f "${pname}" ] && [ -x "${pname}" ] ); then
70 [ -n "${VERBOSE}" ] && [ ${verbok} -ne 0 ] &&
71 msg ' . ${%s} ... %s' "${pname}" "${pname}"
72 [ -n "${varname}" ] && eval ${varname}="${pname}"
76 [ ${dofail} -eq 0 ] && return 1
77 msg
'ERROR: no trace of utility '"${pname}"
82 if [ ${#} -gt 0 ]; then
83 echo >&2 "ERROR: ${*}"
86 echo >&2 'Synopsis: SOURCEDIR/make-emerge.sh [from within target directory]'
90 [ ${#} -eq 0 ] || syno
92 # Rude simple, we should test for Solaris, but who runs this script?
93 if [ -d /usr
/xpg4
]; then
94 PATH
=/usr
/xpg
4/bin
:${PATH}
97 thecmd_testandset_fail
awk awk
98 thecmd_testandset_fail
cp cp
99 thecmd_testandset_fail
dirname dirname
100 thecmd_testandset_fail
pwd pwd
102 srcdir
=`${dirname} ${0}`
104 if [ "${srcdir}" = .
]; then
105 msg
'This is not out of tree?!'
108 echo 'Initializing out-of-tree build.'
109 echo 'Source directory: '"${srcdir}"
110 echo 'Build directory : '"${blddir}"
113 ${awk} -v srcdir="${srcdir}" -v blddir="${blddir}" '
115 gsub(/^SRCDIR=\.\/$/, "SRCDIR
=" srcdir)
118 ' < "${srcdir}"makefile > ./makefile
120 ${cp} "${srcdir}"config.h ./
121 ${cp} "${srcdir}"gen-version.h ./
122 ${cp} "${srcdir}"make.rc ./
124 echo 'You should now be able to proceed as normal (e.g., "$
make all
")'