]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh
MFC r277912,r278738,r279418,r280835,r288416:
[FreeBSD/stable/10.git] / cddl / usr.sbin / dtrace / tests / tools / genmakefiles.sh
1 # $FreeBSD$
2
3 usage()
4 {
5     cat <<__EOF__ >&2
6 usage: $(basename $0)
7
8 This script regenerates the DTrace test suite makefiles. It should be run
9 whenever \$srcdir/cddl/contrib/opensolaris/cmd/dtrace/test/tst is modified.
10 __EOF__
11     exit 1
12 }
13
14 # Format a file list for use in a make(1) variable assignment: take the
15 # basename of each input file and append " \" to it.
16 fmtflist()
17 {
18     awk 'function bn(f) {
19         sub(".*/", "", f)
20         return f
21     }
22     {print "    ", bn($1), " \\"}'
23 }
24
25 genmakefile()
26 {
27     local basedir=$1
28
29     local tdir=${CONTRIB_TESTDIR}/${basedir}
30     local tfiles=$(find $tdir -type f -a \
31         \( -name \*.d -o -name \*.ksh -o -name \*.out \) | sort | fmtflist)
32     local tcfiles=$(find $tdir -type f -a -name \*.c | sort | fmtflist)
33     local texes=$(find $tdir -type f -a -name \*.exe | sort | fmtflist)
34
35     # One-off variable definitions.
36     local special
37     if [ "$basedir" = proc ]; then
38         special="
39 LDADD.tst.sigwait.exe+= -lrt
40 DPADD.tst.sigwait.exe+= \${LIBRT}
41 "
42     elif [ "$basedir" = uctf ]; then
43         special="
44 WITH_CTF=YES
45 "
46     fi
47
48     local makefile=$(mktemp)
49     cat <<__EOF__ > $makefile
50 # \$FreeBSD$
51
52 #
53 # This Makefile was generated by \$srcdir${ORIGINDIR#${TOPDIR}}/genmakefiles.sh.
54 #
55
56 TESTFILES= \\
57 $tfiles
58
59 TESTEXES= \\
60 $texes
61
62 CFILES= \\
63 $tcfiles
64
65 $special
66 .include "../../Makefile.inc1"
67 __EOF__
68
69     mv -f $makefile ${ORIGINDIR}/../common/${basedir}/Makefile
70 }
71
72 set -e
73
74 if [ $# -ne 0 ]; then
75     usage
76 fi
77
78 readonly ORIGINDIR=$(realpath $(dirname $0))
79 readonly TOPDIR=$(realpath ${ORIGINDIR}/../../../../..)
80 readonly CONTRIB_TESTDIR=${TOPDIR}/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common
81
82 # Generate a Makefile for each test group under common/.
83 for dir in $(find ${CONTRIB_TESTDIR} -mindepth 1 -maxdepth 1 -type d); do
84     genmakefile $(basename $dir)
85 done