Sync usage with man page.
[netbsd-mini2440.git] / external / bsd / atf / dist / tools / atf-host-compile.sh
blob21598f904dc5b734c99825f51679e50e5c76f8d3
1 #! __ATF_SHELL__
3 # Automated Testing Framework (atf)
5 # Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
6 # All rights reserved.
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions
10 # are met:
11 # 1. Redistributions of source code must retain the above copyright
12 # notice, this list of conditions and the following disclaimer.
13 # 2. Redistributions in binary form must reproduce the above copyright
14 # notice, this list of conditions and the following disclaimer in the
15 # documentation and/or other materials provided with the distribution.
17 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
18 # CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
19 # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20 # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 # IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
22 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
24 # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
26 # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
28 # IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 Prog_Name=${0##*/}
32 Atf_Pkgdatadir="__ATF_PKGDATADIR__"
33 Atf_Shell="__ATF_SHELL__"
35 set -e
37 err()
39 echo "${Prog_Name}: ${@}" 1>&2
40 exit 1
43 usage()
45 echo "${Prog_Name}: ${@}" 1>&2
46 echo "Usage: ${Prog_Name} -o outfile srcfile" 1>&2
47 exit 1
50 main()
52 [ -f "${Atf_Pkgdatadir}/atf.init.subr" ] || \
53 err "Could not find ${Atf_Pkgdatadir}/atf.init.subr"
55 [ ${#} -ge 1 ] || usage "No -o option specified"
56 [ ${1} = '-o' ] || usage "No -o option specified"
57 [ ${#} -ge 2 ] || usage "No target file specified"
58 [ ${#} -ge 3 ] || usage "No source file specified"
60 shift # Strip -o
61 tfile=${1}; shift
62 sfiles="${@}"
64 for sfile in ${sfiles}; do
65 [ "${tfile}" != "${sfile}" ] || \
66 err "Source file and target file must not be the same"
68 [ -f "${sfile}" ] || err "Source file ${sfile} does not exist"
69 done
71 echo "#! ${Atf_Shell}" >${tfile}
72 cat ${Atf_Pkgdatadir}/atf.init.subr >>${tfile}
73 echo >>${tfile}
74 echo '. ${Atf_Pkgdatadir}/atf.header.subr' >>${tfile}
75 echo >>${tfile}
76 cat ${sfiles} >>${tfile}
77 echo '. ${Atf_Pkgdatadir}/atf.footer.subr' >>${tfile}
78 echo >>${tfile}
79 echo "main \"\${@}\"" >>${tfile}
81 chmod +x ${tfile}
83 exit 0
86 main "${@}"
88 # vim: syntax=sh:expandtab:shiftwidth=4:softtabstop=4