aboutsummaryrefslogtreecommitdiff
path: root/misc/do_m4.bash
blob: a63fb59364b0c724276b8d6da13788c43cf3f075 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env bash
# vim: set sw=4 sts=4 et tw=80 :

if test "xyes" = x"${BASH_VERSION}" ; then
    echo "This is not bash!"
    exit 127
fi

trap 'echo "exiting." ; exit 250' 15
KILL_PID=$$

get_m4() {
    type "gm4" &>/dev/null && echo gm4 && return
    type "m4"  &>/dev/null && echo m4  && return
    echo "Could not find m4" 1>&2
    kill $KILL_PID
}

get_abs_top_srcdir() {
    echo "$(dirname $(dirname "${0}"))"
}

echo ">>> $(get_m4) -I $(get_abs_top_srcdir) -E ${1} > ${2}"
if ! $(get_m4) -I $(get_abs_top_srcdir) -E "${1}" > "${2}" ; then
    echo "oops!" 1>&2
    exit 127
fi