#! /bin/sh
# Copyright (C) 1997, 2001, 2002, 2006  Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Test to make sure bison + bison's C++ skeleton + C++ works.

required="bison gcc"

. ./defs || Exit 1

set -e

cat > configure.in << 'END'
AC_INIT([yaccpp2], [1.0])
AC_CONFIG_AUX_DIR([.])
AM_INIT_AUTOMAKE
AC_CONFIG_FILES([Makefile])
AC_PROG_CXX
AC_PROG_YACC
AC_OUTPUT
END

cat > Makefile.am << 'END'
bin_PROGRAMS = zardoz
zardoz_SOURCES = zardoz.yy foo.cc
AM_YFLAGS = -d --skeleton lalr1.cc
END

# Parser.
cat > zardoz.yy << 'END'
%{
int yylex () {return 0;}
void yyerror (char *s) {}
%}
%%
foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
END

cat > foo.cc << 'END'
int main(int argc, char** argv) { return 0; }
END

$ACLOCAL
$AUTOCONF
$AUTOMAKE -a

mkdir sub
cd sub

../configure
$MAKE
