xref: /netbsd-src/external/bsd/flex/dist/tests/tableopts.sh (revision bdc22b2e01993381dcefeff2bc9b56ca75a4235c)
1#!/bin/bash
2set -euo pipefail
3IFS=$'\n\t'
4
5# This script is present to generate the automake _SOURCES variables
6# for the tableopts_* tests. It also generates the linking rules for
7# each test since automake isn't able to handle the pattern rules that
8# would be natural to use. Output is written to standard output for
9# inclusion in a Makefile.am, typically by redirecting the output and then an automake include directive.
10
11TABLEOPTS_TESTS=""
12tableopts_tables=""
13
14for kind in opt ser ver ; do
15    for threading in nr r ; do
16        for opt in -Ca -Ce -Cf -CF -Cm -Cem -Cae -Caef -CaeF -Cam -Caem ; do
17            testname=tableopts_${kind}_${threading}${opt}.${kind}
18            if [ "${TABLEOPTS_TESTS}" = "" ] ;then
19                TABLEOPTS_TESTS=${testname}
20                if [ "$kind" = "ser" -o "$kind" = "ver" ] ; then
21                    tableopts_tables=${testname}.tables
22                fi
23            else
24                TABLEOPTS_TESTS="${TABLEOPTS_TESTS} ${testname}"
25                if [ "$kind" = "ser" -o "$kind" = "ver" ] ; then
26                    tableopts_tables="${tableopts_tables} ${testname}.tables"
27                fi
28            fi
29
30            bare_opt=${opt#-}
31            cat << EOF
32tableopts_${kind}_${threading}_${bare_opt}_${kind}_SOURCES = tableopts.l4
33
34${testname}\$(EXEEXT): tableopts_${kind}_${threading}${opt}.\$(OBJEXT)
35	\$(LINK) -o \$@ \$<
36
37EOF
38        done
39    done
40done
41
42echo TABLEOPTS_TESTS = ${TABLEOPTS_TESTS}
43echo
44echo tableopts_tables = ${tableopts_tables}
45