tests: generalize the compilation macros.

* tests/local.at (AT_COMPILE, AT_COMPILE_CXX): If OUTPUT ends with ".o",
then append the "natural" extension for the input file (.c or .cc).
If there is no source, pass -c.
* tests/headers.at, tests/input.at, tests/regression.at: Adjust.
This commit is contained in:
Akim Demaille
2012-06-25 16:37:18 +02:00
parent 837b769659
commit 91ce0b3a66
4 changed files with 39 additions and 18 deletions

View File

@@ -111,8 +111,8 @@ main (void)
# Link and execute, just to make sure everything is fine (and in
# particular, that MY_LLOC is indeed defined somewhere).
AT_COMPILE([caller.o], [-c caller.c])
AT_COMPILE([input.o], [-c input.c])
AT_COMPILE([caller.o])
AT_COMPILE([input.o])
AT_COMPILE([caller], [caller.o input.o])
AT_PARSER_CHECK([./caller])

View File

@@ -533,8 +533,8 @@ main (void)
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([-d -v -o input.c input.y])
AT_COMPILE([input.o], [-c input.c])
AT_COMPILE([main.o], [-c main.c])
AT_COMPILE([input.o])
AT_COMPILE([main.o])
AT_COMPILE([input], [input.o main.o])
AT_PARSER_CHECK([./input], 0,
[[[@<:@],
@@ -654,7 +654,7 @@ input.y:18.8-16: warning: POSIX Yacc forbids dashes in symbol names: with-dash
AT_BISON_CHECK([-o input.c input.y])
# Make sure we don't export silly token identifiers with periods or dashes.
AT_COMPILE([input.o], [-c input.c])
AT_COMPILE([input.o])
# Periods are genuine letters, they can start identifiers.

View File

@@ -537,21 +537,37 @@ m4_define([AT_QUELL_VALGRIND],
# AT_COMPILE(OUTPUT, [SOURCES = OUTPUT.c])
# ----------------------------------------
# Compile SOURCES into OUTPUT. If OUTPUT does not contain '.',
# assume that we are linking too; this is a hack.
# Compile SOURCES into OUTPUT.
#
# If OUTPUT does not contain '.', assume that we are linking too,
# otherwise pass "-c"; this is a hack. The default SOURCES is OUTPUT
# with trailing .o removed, and ".c" appended.
m4_define([AT_COMPILE],
[AT_CHECK([$CC $CFLAGS $CPPFLAGS m4_bmatch([$1], [[.]], [], [$LDFLAGS ])-o $1 m4_default([$2], [$1.c])[]m4_bmatch([$1], [[.]], [], [ $LIBS])],
[AT_CHECK(m4_join([ ],
[$CC $CFLAGS $CPPFLAGS],
[m4_bmatch([$1], [[.]], [-c], [$LDFLAGS])],
[-o $1],
[m4_default([$2], [m4_bpatsubst([$1], [\.o$]).c])],
[m4_bmatch([$1], [[.]], [], [$LIBS])]),
0, [ignore], [ignore])])
# AT_COMPILE_CXX(OUTPUT, [SOURCES = OUTPUT.cc])
# --------------------------------------------
# Compile SOURCES into OUTPUT. If OUTPUT does not contain '.',
# assume that we are linking too; this is a hack.
# If the C++ compiler does not work, ignore the test.
# ---------------------------------------------
# Compile SOURCES into OUTPUT. If the C++ compiler does not work,
# ignore the test.
#
# If OUTPUT does not contain '.', assume that we are linking too,
# otherwise pass "-c"; this is a hack. The default SOURCES is OUTPUT
# with trailing .o removed, and ".cc" appended.
m4_define([AT_COMPILE_CXX],
[AT_KEYWORDS(c++)
AT_CHECK([$BISON_CXX_WORKS], 0, ignore, ignore)
AT_CHECK([$CXX $CXXFLAGS $CPPFLAGS m4_bmatch([$1], [[.]], [], [$LDFLAGS ])-o $1 m4_default([$2], [$1.cc])[]m4_bmatch([$1], [[.]], [], [ $LIBS])],
AT_CHECK(m4_join([ ],
[$CXX $CXXFLAGS $CPPFLAGS],
[m4_bmatch([$1], [[.]], [-c], [$LDFLAGS])],
[-o $1],
[m4_default([$2], [m4_bpatsubst([$1], [\.o$]).cc])],
[m4_bmatch([$1], [[.]], [], [$LIBS])]),
0, [ignore], [ignore])])
# AT_JAVA_COMPILE(SOURCES)
@@ -566,6 +582,11 @@ AT_CHECK([[$SHELL ../../../javacomp.sh ]$1],
# AT_LANG_COMPILE(OUTPUT, [SOURCES = OUTPUT.c]
# --------------------------------------------
# Compile SOURCES into OUTPUT. Skip if compiler does not work.
#
# If OUTPUT does not contain '.', assume that we are linking too,
# otherwise pass "-c"; this is a hack. The default SOURCES is OUTPUT
# with trailing .o removed, and ".c"/".cc" appended.
m4_define([AT_LANG_COMPILE],
[m4_case(AT_LANG,
[c], [AT_COMPILE([$1], [$2])],

View File

@@ -41,7 +41,7 @@ program: 'x';
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([-o input.c input.y])
AT_COMPILE([input.o], [-c input.c])
AT_COMPILE([input.o])
AT_COMPILE([input.o], [-DYYDEBUG -c input.c])
AT_CLEANUP
@@ -71,7 +71,7 @@ program: { $$ = ""; };
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([-o input.c input.y])
AT_COMPILE([input.o], [-c input.c])
AT_COMPILE([input.o])
AT_CLEANUP
@@ -111,7 +111,7 @@ exp: MY_TOKEN;
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([-y -o input.c input.y])
AT_COMPILE([input.o], [-c input.c])
AT_COMPILE([input.o])
AT_CLEANUP
@@ -156,7 +156,7 @@ exp: MY_TOKEN;
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([-o input.c input.y])
AT_COMPILE([input.o], [-c input.c])
AT_COMPILE([input.o])
AT_CLEANUP
@@ -527,7 +527,7 @@ exp:
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([-o input.c input.y])
AT_COMPILE([input.o], [-c input.c])
AT_COMPILE([input.o])
AT_CLEANUP