1# $FreeBSD$ 2 3usage() 4{ 5 cat <<__EOF__ >&2 6usage: $(basename $0) 7 8This script regenerates the DTrace test suite makefiles. It should be run 9whenever \$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. 16fmtflist() 17{ 18 awk 'function bn(f) { 19 sub(".*/", "", f) 20 return f 21 } 22 {print " ", bn($1), " \\"}' 23} 24 25genmakefile() 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=" 39LIBADD.tst.sigwait.exe+= rt 40" 41 elif [ "$basedir" = uctf ]; then 42 special=" 43WITH_CTF=YES 44" 45 fi 46 47 local makefile=$(mktemp) 48 cat <<__EOF__ > $makefile 49# \$FreeBSD$ 50 51# 52# This Makefile was generated by \$srcdir${ORIGINDIR#${TOPDIR}}/genmakefiles.sh. 53# 54 55TESTFILES= \\ 56$tfiles 57 58TESTEXES= \\ 59$texes 60 61CFILES= \\ 62$tcfiles 63 64$special 65.include "../../dtrace.test.mk" 66__EOF__ 67 68 mv -f $makefile ${ORIGINDIR}/../common/${basedir}/Makefile 69} 70 71set -e 72 73if [ $# -ne 0 ]; then 74 usage 75fi 76 77readonly ORIGINDIR=$(realpath $(dirname $0)) 78readonly TOPDIR=$(realpath ${ORIGINDIR}/../../../../..) 79readonly CONTRIB_TESTDIR=${TOPDIR}/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common 80 81# Generate a Makefile for each test group under common/. 82for dir in $(find ${CONTRIB_TESTDIR} -mindepth 1 -maxdepth 1 -type d); do 83 genmakefile $(basename $dir) 84done 85