]>
Commit | Line | Data |
---|---|---|
342b8b6e | 1 | # Checking the output filenames. -*- Autotest -*- |
cf48f675 EB |
2 | # Copyright (C) 2000, 2001, 2002, 2005, 2006, 2007, 2008, 2009 Free |
3 | # Software Foundation, Inc. | |
342b8b6e | 4 | |
f16b0819 | 5 | # This program is free software: you can redistribute it and/or modify |
342b8b6e | 6 | # it under the terms of the GNU General Public License as published by |
f16b0819 PE |
7 | # the Free Software Foundation, either version 3 of the License, or |
8 | # (at your option) any later version. | |
9 | # | |
342b8b6e AD |
10 | # This program is distributed in the hope that it will be useful, |
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | # GNU General Public License for more details. | |
f16b0819 | 14 | # |
342b8b6e | 15 | # You should have received a copy of the GNU General Public License |
f16b0819 | 16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
342b8b6e AD |
17 | |
18 | AT_BANNER([[Output file names.]]) | |
19 | ||
20 | ||
7625ec2c AD |
21 | # AT_CHECK_OUTPUT(INPUT-FILE, [DIRECTIVES], [FLAGS], EXPECTED-FILES, [SHELLIO], |
22 | # [ADDITIONAL-TESTS]) | |
f1bbfcce | 23 | # ----------------------------------------------------------------------------- |
342b8b6e | 24 | m4_define([AT_CHECK_OUTPUT], |
bbf9ca37 | 25 | [AT_SETUP([[Output files: ]$2 $3 $5]) |
cae5057f JD |
26 | for file in $1 $4; do |
27 | case "$file" in | |
28 | */*) mkdir -p `echo "$file" | sed 's,/.*,,'`;; | |
29 | esac | |
30 | done | |
342b8b6e | 31 | AT_DATA([$1], |
bbf9ca37 | 32 | [$2[ |
342b8b6e | 33 | %% |
bfcf1f3a | 34 | foo: {}; |
342b8b6e AD |
35 | ]]) |
36 | ||
da730230 | 37 | AT_BISON_CHECK([$3 $1 $5], 0) |
342b8b6e | 38 | AT_CHECK([ls $4], [], [ignore]) |
7625ec2c | 39 | $6 |
d803322e | 40 | AT_CLEANUP |
342b8b6e AD |
41 | ]) |
42 | ||
43 | AT_CHECK_OUTPUT([foo.y], [], [-dv], | |
02650b7f | 44 | [foo.output foo.tab.c foo.tab.h]) |
f1bbfcce | 45 | AT_CHECK_OUTPUT([foo.y], [], [-dv], |
02650b7f PE |
46 | [foo.output foo.tab.c foo.tab.h], |
47 | [>&-]) | |
342b8b6e | 48 | AT_CHECK_OUTPUT([foo.y], [], [-dv -o foo.c], |
02650b7f | 49 | [foo.c foo.h foo.output]) |
342b8b6e | 50 | AT_CHECK_OUTPUT([foo.y], [], [-dv -o foo.tab.c], |
02650b7f | 51 | [foo.output foo.tab.c foo.tab.h]) |
342b8b6e | 52 | AT_CHECK_OUTPUT([foo.y], [], [-dv -y], |
02650b7f | 53 | [y.output y.tab.c y.tab.h]) |
342b8b6e | 54 | AT_CHECK_OUTPUT([foo.y], [], [-dv -b bar], |
02650b7f | 55 | [bar.output bar.tab.c bar.tab.h]) |
342b8b6e | 56 | AT_CHECK_OUTPUT([foo.y], [], [-dv -g -o foo.c], |
35fe0834 | 57 | [foo.c foo.dot foo.h foo.output]) |
342b8b6e AD |
58 | |
59 | ||
60 | AT_CHECK_OUTPUT([foo.y], [%defines %verbose], [], | |
02650b7f | 61 | [foo.output foo.tab.c foo.tab.h]) |
342b8b6e | 62 | AT_CHECK_OUTPUT([foo.y], [%defines %verbose %yacc],[], |
02650b7f | 63 | [y.output y.tab.c y.tab.h]) |
342b8b6e | 64 | |
5e5d5415 | 65 | AT_CHECK_OUTPUT([foo.yy], [%defines %verbose %yacc],[], |
02650b7f | 66 | [y.output y.tab.c y.tab.h]) |
5e5d5415 | 67 | |
02975b9a JD |
68 | # Exercise %output and %file-prefix including deprecated `=' |
69 | AT_CHECK_OUTPUT([foo.y], [%file-prefix "bar" %defines %verbose], [], | |
02650b7f | 70 | [bar.output bar.tab.c bar.tab.h]) |
951366c1 | 71 | AT_CHECK_OUTPUT([foo.y], [%output="bar.c" %defines %verbose %yacc],[], |
02650b7f | 72 | [bar.output bar.c bar.h]) |
951366c1 | 73 | AT_CHECK_OUTPUT([foo.y], |
02975b9a | 74 | [%file-prefix="baz" %output "bar.c" %defines %verbose %yacc], |
02650b7f PE |
75 | [], |
76 | [bar.output bar.c bar.h]) | |
951366c1 | 77 | |
342b8b6e AD |
78 | |
79 | # Check priorities of extension control. | |
80 | AT_CHECK_OUTPUT([foo.yy], [%defines %verbose], [], | |
02650b7f | 81 | [foo.output foo.tab.cc foo.tab.hh]) |
342b8b6e AD |
82 | |
83 | AT_CHECK_OUTPUT([foo.yy], [%defines %verbose ], [-o foo.c], | |
02650b7f | 84 | [foo.c foo.h foo.output]) |
342b8b6e AD |
85 | |
86 | AT_CHECK_OUTPUT([foo.yy], [], | |
02650b7f PE |
87 | [--defines=foo.hpp -o foo.c++], |
88 | [foo.c++ foo.hpp]) | |
342b8b6e | 89 | |
02975b9a JD |
90 | AT_CHECK_OUTPUT([foo.yy], [%defines "foo.hpp"], |
91 | [-o foo.c++], | |
92 | [foo.c++ foo.hpp]) | |
93 | ||
342b8b6e | 94 | AT_CHECK_OUTPUT([foo.yy], [], |
02650b7f PE |
95 | [-o foo.c++ --graph=foo.gph], |
96 | [foo.c++ foo.gph]) | |
7625ec2c AD |
97 | |
98 | ||
99 | ## ------------ ## | |
100 | ## C++ output. ## | |
101 | ## ------------ ## | |
102 | ||
103 | m4_define([AT_CHECK_NO_SUBDIR_PART], | |
104 | [# Also make sure that the includes do not refer to the subdirectory. | |
105 | AT_CHECK([grep 'include .subdir/' $1.cc], 1, []) | |
106 | AT_CHECK([grep 'include .subdir/' $1.hh], 1, []) | |
107 | ]) | |
108 | ||
109 | AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %defines %verbose], [], | |
2ea7730c AD |
110 | [foo.tab.cc foo.tab.hh foo.output stack.hh]) |
111 | ||
112 | AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %defines %verbose %locations], [], | |
02650b7f | 113 | [foo.tab.cc foo.tab.hh foo.output location.hh stack.hh position.hh]) |
7625ec2c AD |
114 | |
115 | AT_CHECK_OUTPUT([subdir/foo.yy], [%skeleton "lalr1.cc" %defines %verbose], [], | |
2ea7730c | 116 | [foo.tab.cc foo.tab.hh foo.output stack.hh], |
02650b7f | 117 | [], [AT_CHECK_NO_SUBDIR_PART([foo.tab])]) |
7625ec2c | 118 | |
2ea7730c | 119 | AT_CHECK_OUTPUT([subdir/foo.yy], [%skeleton "lalr1.cc" %defines %verbose %locations], |
7625ec2c | 120 | [-o subdir/foo.cc], |
02650b7f | 121 | [subdir/foo.cc subdir/foo.hh subdir/foo.output subdir/location.hh subdir/stack.hh subdir/position.hh], |
7625ec2c | 122 | [], [AT_CHECK_NO_SUBDIR_PART([subdir/foo])]) |
3f7ca628 | 123 | |
cae5057f JD |
124 | AT_CHECK_OUTPUT([gram_dir/foo.yy], |
125 | [%skeleton "lalr1.cc" %defines %verbose %file-prefix "output_dir/foo"], | |
126 | [], | |
2ea7730c AD |
127 | [output_dir/foo.tab.cc output_dir/foo.tab.hh output_dir/foo.output output_dir/stack.hh]) |
128 | ||
129 | AT_CHECK_OUTPUT([gram_dir/foo.yy], | |
130 | [%skeleton "lalr1.cc" %defines %locations %verbose %file-prefix "output_dir/foo"], | |
131 | [], | |
cae5057f JD |
132 | [output_dir/foo.tab.cc output_dir/foo.tab.hh output_dir/foo.output output_dir/location.hh output_dir/stack.hh output_dir/position.hh]) |
133 | ||
3f7ca628 | 134 | |
c0ee9e21 DJ |
135 | # AT_CHECK_CONFLICTING_OUTPUT(INPUT-FILE, DIRECTIVES, FLAGS, STDERR, |
136 | # [EXIT-STATUS]) | |
137 | # ------------------------------------------------------------------ | |
3f7ca628 JD |
138 | m4_define([AT_CHECK_CONFLICTING_OUTPUT], |
139 | [AT_SETUP([Conflicting output files: $2 $3]) | |
140 | case "$1" in | |
141 | */*) mkdir `echo "$1" | sed 's,/.*,,'`;; | |
142 | esac | |
143 | AT_DATA([$1], | |
144 | [[$2 | |
145 | %% | |
146 | foo: {}; | |
147 | ]]) | |
148 | ||
c0ee9e21 | 149 | AT_BISON_CHECK([$3 $1], $5, [], [$4]) |
3f7ca628 JD |
150 | AT_CLEANUP |
151 | ]) | |
152 | ||
153 | AT_CHECK_CONFLICTING_OUTPUT([foo.y], | |
154 | [], [--graph="foo.tab.c"], | |
155 | [foo.y: warning: conflicting outputs to file `foo.tab.c' | |
156 | ]) | |
157 | ||
158 | AT_CHECK_CONFLICTING_OUTPUT([foo.y], | |
159 | [%defines "foo.output"], [-v], | |
160 | [foo.y: warning: conflicting outputs to file `foo.output' | |
161 | ]) | |
162 | ||
163 | AT_CHECK_CONFLICTING_OUTPUT([foo.y], | |
2ea7730c | 164 | [%skeleton "lalr1.cc" %defines %locations], [--graph="location.hh"], |
3f7ca628 JD |
165 | [foo.y: warning: conflicting outputs to file `location.hh' |
166 | ]) | |
bd9d212b | 167 | |
c0ee9e21 DJ |
168 | AT_CHECK_CONFLICTING_OUTPUT([foo.y], [], [-o foo.y], |
169 | [foo.y: fatal error: refusing to overwrite the input file `foo.y' | |
170 | ], 1) | |
171 | ||
bd9d212b JD |
172 | |
173 | # AT_CHECK_OUTPUT_FILE_NAME(FILE-NAME-PREFIX, [ADDITIONAL-TESTS]) | |
2ea7730c | 174 | # --------------------------------------------------------------- |
bd9d212b JD |
175 | m4_define([AT_CHECK_OUTPUT_FILE_NAME], |
176 | [AT_SETUP([Output file name: $1]) | |
177 | ||
7439c5c0 JD |
178 | # Skip if platform doesn't support file name. For example, Cygwin |
179 | # doesn't support file names containing ":" or "\". | |
180 | AT_CHECK([[touch "]AS_ESCAPE([$1[.tmp]])[" || exit 77]]) | |
181 | ||
ce3448d5 | 182 | AT_DATA_GRAMMAR([glr.y], |
bd9d212b JD |
183 | [[%glr-parser |
184 | %code { | |
185 | int yylex (void); | |
186 | void yyerror (const char *); | |
187 | } | |
188 | %% | |
189 | start: {}; | |
190 | ]]) | |
da730230 | 191 | AT_BISON_CHECK([-o "AS_ESCAPE([$1.c])" --defines="AS_ESCAPE([$1.h])" glr.y]) |
bd9d212b JD |
192 | AT_CHECK([ls "AS_ESCAPE([$1.c])" "AS_ESCAPE([$1.h])"], [], [ignore]) |
193 | AT_COMPILE([glr.o], [-c "AS_ESCAPE([$1.c])"]) | |
194 | $2 | |
195 | ||
ce3448d5 | 196 | AT_DATA_GRAMMAR([cxx.y], |
bd9d212b JD |
197 | [[%skeleton "lalr1.cc" |
198 | %code { int yylex (yy::parser::semantic_type*); } | |
199 | %% | |
200 | start: {}; | |
201 | ]]) | |
da730230 | 202 | AT_BISON_CHECK([-o "AS_ESCAPE([$1.c])" --defines="AS_ESCAPE([$1.h])" cxx.y]) |
bd9d212b JD |
203 | AT_CHECK([ls "AS_ESCAPE([$1.c])" "AS_ESCAPE([$1.h])"], [], [ignore]) |
204 | AT_COMPILE_CXX([cxx.o], [-c "AS_ESCAPE([$1.c])"]) | |
205 | $2 | |
206 | ||
207 | AT_CLEANUP | |
208 | ]) | |
209 | ||
210 | # Notice that the header file name here cannot contain | |
211 | # `"' since FILENAME in `#include "FILENAME"' cannot. | |
212 | AT_CHECK_OUTPUT_FILE_NAME([[`~!@#$%^&*()-=_+{}[]|\:;<>, .']]) | |
f55efa38 JD |
213 | dnl Work around a bug in m4_expand that broke AT_SETUP in autoconf 2.62, |
214 | dnl by using the definition from 2.63. | |
215b40ac EB |
215 | m4_version_prereq([2.63], [], |
216 | [m4_define([m4_expand], [_$0(-=<{($1)}>=-)]) | |
f55efa38 | 217 | m4_define([_m4_expand], |
215b40ac | 218 | [m4_changequote([-=<{(], [)}>=-])$1m4_changequote([, ])])]) |
f55efa38 JD |
219 | AT_CHECK_OUTPUT_FILE_NAME([[(]]) |
220 | AT_CHECK_OUTPUT_FILE_NAME([[)]]) | |
cf48f675 | 221 | AT_CHECK_OUTPUT_FILE_NAME([[@%:@]]) |
bd9d212b JD |
222 | AT_CHECK_OUTPUT_FILE_NAME([[@@]]) |
223 | AT_CHECK_OUTPUT_FILE_NAME([[@{]]) | |
224 | AT_CHECK_OUTPUT_FILE_NAME([[@}]]) | |
bd9d212b JD |
225 | AT_CHECK_OUTPUT_FILE_NAME([[@<:@]]) |
226 | AT_CHECK_OUTPUT_FILE_NAME([[@:>@]]) |