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!
16 printf >&2 -- "${fmt}\\n" "${@}"
21 n
=${1} i=${2} opt=${3:-0}
22 # Evaluate, just in case user comes in with shell snippets (..well..)
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}"
29 if [ ${opt} -eq 0 ]; then
30 msg
'ERROR: no trace of utility %s' "${n}"
37 if [ ${#} -gt 0 ]; then
38 echo >&2 "ERROR: ${*}"
41 echo >&2 'Synopsis: SOURCEDIR/make-emerge.sh [from within target directory]'
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
/xpg
4/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}`
58 if [ "${srcdir}" = .
]; then
59 echo >&2 'This is not out of tree?!'
62 echo 'Initializing out-of-tree build.'
63 echo 'Source directory: '"${srcdir}"
64 echo 'Build directory : '"${blddir}"
67 ${awk} -v srcdir="${srcdir}" -v blddir="${blddir}" '
69 gsub(/^SRCDIR=\.\/$/, "SRCDIR
=" srcdir)
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
")'