Statistics
| Branch: | Tag: | Revision:

root / autotools / docbook-wrapper @ 8ab8e969

History | View | Annotate | Download (720 Bytes)

1
#!/bin/sh
2

    
3
set -e
4

    
5
input="${1}"
6
output="${2}"
7

    
8
# docbook2man inserts a date formatted using the current locale into its
9
# output. Using the "C" locale makes sure it's always in the default format.
10
export LC_ALL=C
11

    
12
case "${output}" in
13
  *.pdf) cmd=docbook2pdf ;;
14
  *.html) cmd='docbook2html --nochunks' ;;
15
  *.7|*.8) cmd=docbook2man ;;
16
  *)
17
    echo "Unknown filetype: ${output}" >&2
18
    exit 1
19
  ;;
20
esac
21

    
22
tmpdir=`mktemp -d`
23
trap "rm -rf ${tmpdir}" EXIT
24

    
25
if ! ( cd `dirname ${input}` &&
26
       ${cmd} -o ${tmpdir} `basename "${input}"` >/dev/null; )
27
then
28
  echo "Building ${output} failed." >&2
29
  exit 1
30
fi;
31

    
32
mv "${tmpdir}/`basename "${output}"`" "${output}"
33

    
34
# Needed for make to recognize output file
35
touch "${output}"