-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfigure
executable file
·130 lines (110 loc) · 2.51 KB
/
configure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#! /bin/sh
# Copyright (c) 2023 Robbert Haarman
#
# SPDX-License-Identifier: MIT
#
# Creates config and Makefile.
#
# The script requires the following command line arguments:
#
# --shell-to-test <path>
#
# This specifies the path of the shell to be tested.
#
# If the configure script is run inside a directory other than
# the directory where it is located, the config file and Makefile
# are created in that directory.
#
# If the configure script is run inside the directory where it
# is located, a directory "out" is created if it does not already
# exist, and the configure script is re-run in there. Then, a
# Makefile is created in the currect directory which
# effectively cd's into the out directory and invokes the
# Makefile there.
set -e
goodsh=/bin/sh
# Parse command line arguments.
testsh=""
while [ $# -gt 0 ]
do
if [ "$1" = "--shell-to-test" ]
then
if [ $# -lt 2 ]
then
printf "missing value for --shell-to-test\n" >&2
exit 2
fi
shift
testsh="$1"
else
printf "unknown parameter: %s\n" "$1" >&2
exit 2
fi
shift
done
if [ -z "$testsh" ]
then
printf "missing required argument --shell-to-test\n" >&2
exit 2
fi
srcdir="$(dirname "$0")"
if [ "$srcdir" = "." -o "$srcdir" = "" ]
then
# configure is being run in the sourc directory.
# Create the out directory, re-run configure from there,
# and create a Makefile in the source directory so that
# running make from there works.
# If testsh is not absolute, make it absolute.
case "$testsh" in
/*) true ;;
*) testsh="$PWD/$testsh" ;;
esac
mkdir -p out
cd out
../configure --shell-to-test "$testsh"
cd ..
cat >Makefile <<'EOT'
all :
$(MAKE) -C out all
check :
$(MAKE) -C out check
clean :
$(MAKE) -C out clean
distclean :
$(MAKE) -C out distclean
rm -fr out
.PHONY : all check clean distclean
EOT
exit
fi
# Enumerate tests.
tests=""
for x in "$srcdir/src/"*.test
do
name="$(basename "$x" .test)"
tests="$tests $name"
test_targets="$(printf "%s %s\n\t%s" "$tests" \\ "$name")"
done
bindir="$srcdir/bin"
cat >config <<EOT
TESTSH="$testsh"
BINDIR="$bindir"
EOT
cat >Makefile <<EOT
all :
check : ${test_targets}
@$goodsh "${bindir}/check_results"
clean :
distclean : clean
.PHONY : all check clean distclean
EOT
for test in $tests
do
cat >>Makefile <<EOT
.PHONY : ${test}
${test} :
@printf "%s\n" "$test"
@printf 'UNFINISHED\n' > "$test.result"
@$goodsh ${srcdir}/src/${test}.test
EOT
done