1 # Checking the output filenames. -*- Autotest -*-
2 # Copyright (C) 2000, 2001, 2002, 2005, 2006, 2007, 2008, 2009 Free
3 # Software Foundation, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
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.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 AT_BANNER([[Output file names.]])
21 # AT_CHECK_OUTPUT(INPUT-FILE, [DIRECTIVES], [FLAGS], EXPECTED-FILES, [SHELLIO],
23 # -----------------------------------------------------------------------------
24 m4_define([AT_CHECK_OUTPUT],
25 [AT_SETUP([[Output files: ]$2 $3 $5])
28 */*) mkdir -p `echo "$file" | sed 's,/.*,,'`;;
37 AT_BISON_CHECK([$3 $1 $5], 0)
38 AT_CHECK([ls $4], [], [ignore])
43 AT_CHECK_OUTPUT([foo.y], [], [-dv],
44 [foo.output foo.tab.c foo.tab.h])
45 AT_CHECK_OUTPUT([foo.y], [], [-dv],
46 [foo.output foo.tab.c foo.tab.h],
48 AT_CHECK_OUTPUT([foo.y], [], [-dv -o foo.c],
49 [foo.c foo.h foo.output])
50 AT_CHECK_OUTPUT([foo.y], [], [-dv -o foo.tab.c],
51 [foo.output foo.tab.c foo.tab.h])
52 AT_CHECK_OUTPUT([foo.y], [], [-dv -y],
53 [y.output y.tab.c y.tab.h])
54 AT_CHECK_OUTPUT([foo.y], [], [-dv -b bar],
55 [bar.output bar.tab.c bar.tab.h])
56 AT_CHECK_OUTPUT([foo.y], [], [-dv -g -o foo.c],
57 [foo.c foo.dot foo.h foo.output])
60 AT_CHECK_OUTPUT([foo.y], [%defines %verbose], [],
61 [foo.output foo.tab.c foo.tab.h])
62 AT_CHECK_OUTPUT([foo.y], [%defines %verbose %yacc],[],
63 [y.output y.tab.c y.tab.h])
65 AT_CHECK_OUTPUT([foo.yy], [%defines %verbose %yacc],[],
66 [y.output y.tab.c y.tab.h])
68 # Exercise %output and %file-prefix including deprecated `='
69 AT_CHECK_OUTPUT([foo.y], [%file-prefix "bar" %defines %verbose], [],
70 [bar.output bar.tab.c bar.tab.h])
71 AT_CHECK_OUTPUT([foo.y], [%output="bar.c" %defines %verbose %yacc],[],
72 [bar.output bar.c bar.h])
73 AT_CHECK_OUTPUT([foo.y],
74 [%file-prefix="baz" %output "bar.c" %defines %verbose %yacc],
76 [bar.output bar.c bar.h])
79 # Check priorities of extension control.
80 AT_CHECK_OUTPUT([foo.yy], [%defines %verbose], [],
81 [foo.output foo.tab.cc foo.tab.hh])
83 AT_CHECK_OUTPUT([foo.yy], [%defines %verbose ], [-o foo.c],
84 [foo.c foo.h foo.output])
86 AT_CHECK_OUTPUT([foo.yy], [],
87 [--defines=foo.hpp -o foo.c++],
90 AT_CHECK_OUTPUT([foo.yy], [%defines "foo.hpp"],
94 AT_CHECK_OUTPUT([foo.yy], [],
95 [-o foo.c++ --graph=foo.gph],
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, [])
109 AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %defines %verbose], [],
110 [foo.tab.cc foo.tab.hh foo.output stack.hh])
112 AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %defines %verbose %locations], [],
113 [foo.tab.cc foo.tab.hh foo.output location.hh stack.hh position.hh])
115 AT_CHECK_OUTPUT([subdir/foo.yy], [%skeleton "lalr1.cc" %defines %verbose], [],
116 [foo.tab.cc foo.tab.hh foo.output stack.hh],
117 [], [AT_CHECK_NO_SUBDIR_PART([foo.tab])])
119 AT_CHECK_OUTPUT([subdir/foo.yy], [%skeleton "lalr1.cc" %defines %verbose %locations],
121 [subdir/foo.cc subdir/foo.hh subdir/foo.output subdir/location.hh subdir/stack.hh subdir/position.hh],
122 [], [AT_CHECK_NO_SUBDIR_PART([subdir/foo])])
124 AT_CHECK_OUTPUT([gram_dir/foo.yy],
125 [%skeleton "lalr1.cc" %defines %verbose %file-prefix "output_dir/foo"],
127 [output_dir/foo.tab.cc output_dir/foo.tab.hh output_dir/foo.output output_dir/stack.hh])
129 AT_CHECK_OUTPUT([gram_dir/foo.yy],
130 [%skeleton "lalr1.cc" %defines %locations %verbose %file-prefix "output_dir/foo"],
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])
135 # AT_CHECK_CONFLICTING_OUTPUT(INPUT-FILE, DIRECTIVES, FLAGS, STDERR,
137 # ------------------------------------------------------------------
138 m4_define([AT_CHECK_CONFLICTING_OUTPUT],
139 [AT_SETUP([Conflicting output files: $2 $3])
141 */*) mkdir `echo "$1" | sed 's,/.*,,'`;;
149 AT_BISON_CHECK([$3 $1], $5, [], [$4])
153 AT_CHECK_CONFLICTING_OUTPUT([foo.y],
154 [], [--graph="foo.tab.c"],
155 [foo.y: warning: conflicting outputs to file `foo.tab.c'
158 AT_CHECK_CONFLICTING_OUTPUT([foo.y],
159 [%defines "foo.output"], [-v],
160 [foo.y: warning: conflicting outputs to file `foo.output'
163 AT_CHECK_CONFLICTING_OUTPUT([foo.y],
164 [%skeleton "lalr1.cc" %defines %locations], [--graph="location.hh"],
165 [foo.y: warning: conflicting outputs to file `location.hh'
168 AT_CHECK_CONFLICTING_OUTPUT([foo.y], [], [-o foo.y],
169 [foo.y: fatal error: refusing to overwrite the input file `foo.y'
173 # AT_CHECK_OUTPUT_FILE_NAME(FILE-NAME-PREFIX, [ADDITIONAL-TESTS])
174 # ---------------------------------------------------------------
175 m4_define([AT_CHECK_OUTPUT_FILE_NAME],
176 [AT_SETUP([Output file name: $1])
178 AT_DATA_GRAMMAR([glr.y],
182 void yyerror (const char *);
187 AT_BISON_CHECK([-o "AS_ESCAPE([$1.c])" --defines="AS_ESCAPE([$1.h])" glr.y])
188 AT_CHECK([ls "AS_ESCAPE([$1.c])" "AS_ESCAPE([$1.h])"], [], [ignore])
189 AT_COMPILE([glr.o], [-c "AS_ESCAPE([$1.c])"])
192 AT_DATA_GRAMMAR([cxx.y],
193 [[%skeleton "lalr1.cc"
194 %code { int yylex (yy::parser::semantic_type*); }
198 AT_BISON_CHECK([-o "AS_ESCAPE([$1.c])" --defines="AS_ESCAPE([$1.h])" cxx.y])
199 AT_CHECK([ls "AS_ESCAPE([$1.c])" "AS_ESCAPE([$1.h])"], [], [ignore])
200 AT_COMPILE_CXX([cxx.o], [-c "AS_ESCAPE([$1.c])"])
206 # Notice that the header file name here cannot contain
207 # `"' since FILENAME in `#include "FILENAME"' cannot.
208 AT_CHECK_OUTPUT_FILE_NAME([[`~!@#$%^&*()-=_+{}[]|\:;<>, .']])
209 dnl Work around a bug in m4_expand that broke AT_SETUP in autoconf 2.62,
210 dnl by using the definition from 2.63.
211 m4_version_prereq([2.63], [],
212 [m4_define([m4_expand], [_$0(-=<{($1)}>=-)])
213 m4_define([_m4_expand],
214 [m4_changequote([-=<{(], [)}>=-])$1m4_changequote([, ])])])
215 AT_CHECK_OUTPUT_FILE_NAME([[(]])
216 AT_CHECK_OUTPUT_FILE_NAME([[)]])
217 AT_CHECK_OUTPUT_FILE_NAME([[@%:@]])
218 AT_CHECK_OUTPUT_FILE_NAME([[@@]])
219 AT_CHECK_OUTPUT_FILE_NAME([[@{]])
220 AT_CHECK_OUTPUT_FILE_NAME([[@}]])
221 AT_CHECK_OUTPUT_FILE_NAME([[@<:@]])
222 AT_CHECK_OUTPUT_FILE_NAME([[@:>@]])