-
Notifications
You must be signed in to change notification settings - Fork 51
/
missingflex
executable file
·86 lines (68 loc) · 1.93 KB
/
missingflex
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
#! /bin/sh
if test "$#" -lt "1"; then
echo ""
echo "Error: $0 can only be called with at least one command line argument"
echo ""
echo "Usage: $0 [OPTIONS] FILE"
echo ""
echo "Where FILE is a flex source file"
echo ""
echo "all options except -o are ignored. Use -oOUTFILE to specify the output"
echo "file"
echo ""
exit 1
fi
OUTPUT=""
for PARM in $*; do
CHECK_FOR_OUTPUT_PARM=`echo "$PARM" | sed s/[^-o].*$//`;
if test "$CHECK_FOR_OUTPUT_PARM" = "-o"; then
OUTPUT=`echo "$PARM" | sed s/^-o//`
fi
LAST=$PARM
done
if ! test -e $LAST; then
echo ""
echo "ERROR: Could not find $1"
echo ""
exit 1
fi
EXT=`echo "$LAST" | sed s/^[^.]*//`
BASE=`echo "$LAST" | sed s/$EXT//`
if test "$EXT" != ".l" -a "$EXT" != ".ll"; then
echo ""
echo "ERROR: $LAST should end in \`.l' or \`.ll'"
echo ""
exit 1
fi
if test "$EXT" = ".l"; then
NEW_EXT=".c"
else
NEW_EXT=".cc"
fi
if test "$OUTPUT" = ""; then
OUTPUT="$BASE$NEW_EXT"
fi
POSSIBLE="$BASE$NEW_EXT"
if test -e "$OUTPUT"; then
touch "$OUTPUT"
echo ""
echo "WARNING: \`flex' is missing on your system. You should only need it if"
echo " you modified a \`.l' or \`.ll' file. You may need the \`Flex'"
echo " package in order for those modifications to take effect. You "
echo " can get \`Flex' from any GNU archive site."
echo ""
elif test -e "$POSSIBLE"; then
cp "$POSSIBLE" "$OUTPUT"
echo ""
echo "WARNING: \`flex' is missing on your system. You should only need it if"
echo " you modified a \`.l' or \`.ll' file. You may need the \`Flex'"
echo " package in order for those modifications to take effect. You "
echo " can get \`Flex' from any GNU archive site."
echo ""
else
echo ""
echo "ERROR: \`flex' is missing on your system and the flex generated"
echo " source could not be found. You can get \`Flex' from any "
echo " GNU archive site."
echo ""
fi