Commit 71ac15c2 authored by Erick Gallesio's avatar Erick Gallesio

Fixed Makefile machinery for libffi integration

parent 62a9de08
......@@ -2,10 +2,10 @@
#
# Author: Erick Gallesio [eg@unice.fr]
# Creation date: 11-Apr-2000 10:30 (eg)
# Last file update: 19-Jun-2007 11:55 (eg)
# Last file update: 3-May-2008 19:58 (eg)
EXTRA_DIST =
SUBDIRS = @PCRE@ @GC@ @GMP@ @CINVOKE@ src utils lib @GTKLOS@ \
SUBDIRS = @PCRE@ @GC@ @GMP@ @LIBFFI@ src utils lib @GTKLOS@ \
@EXAMPLES@ pkgman extensions tests doc
SVN_URL = @SVN_URL@/STklos
VERSION_TAG = @PACKAGE@-@VERSION@
......
......@@ -18,7 +18,7 @@
#
# Author: Erick Gallesio [eg@unice.fr]
# Creation date: 11-Apr-2000 10:30 (eg)
# Last file update: 19-Jun-2007 11:55 (eg)
# Last file update: 3-May-2008 19:58 (eg)
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
......@@ -87,7 +87,6 @@ CALLCC_STK = @CALLCC_STK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CINVOKE = @CINVOKE@
COMPOBJ = @COMPOBJ@
COMPSRC = @COMPSRC@
CPP = @CPP@
......@@ -126,6 +125,7 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDAP_LIB = @LDAP_LIB@
LDFLAGS = @LDFLAGS@
LIBFFI = @LIBFFI@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
......@@ -146,7 +146,6 @@ PCRE = @PCRE@
PCREINC = @PCREINC@
PCRELIB = @PCRELIB@
PCRETARGET = @PCRETARGET@
PERLINT = @PERLINT@
PREFIX = @PREFIX@
RANLIB = @RANLIB@
SCMDIR = @SCMDIR@
......@@ -205,7 +204,7 @@ target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
EXTRA_DIST =
SUBDIRS = @PCRE@ @GC@ @GMP@ @CINVOKE@ src utils lib @GTKLOS@ \
SUBDIRS = @PCRE@ @GC@ @GMP@ @LIBFFI@ src utils lib @GTKLOS@ \
@EXAMPLES@ pkgman extensions tests doc
VERSION_TAG = @PACKAGE@-@VERSION@
......
......@@ -701,7 +701,6 @@ NO_THREAD_FALSE
GTK_CONFIG
GNOME_CONFIG
LIBOBJS
PERLINT
STKCFLAGS
HAVE_DLOPEN
HAVE_FFI
......@@ -742,7 +741,7 @@ SVN_URL
THREADS
LURCDIR
CALLCC_STK
CINVOKE
LIBFFI
LTLIBOBJS'
ac_subst_files=''
ac_precious_vars='build_alias
......@@ -6782,45 +6781,6 @@ fi
# Extract the first word of "perl", so it can be a program name with args.
set dummy perl; ac_word=$2
{ echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
if test "${ac_cv_prog_PERLINT+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test -n "$PERLINT"; then
ac_cv_prog_PERLINT="$PERLINT" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_PERLINT=""yes""
echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
test -z "$ac_cv_prog_PERLINT" && ac_cv_prog_PERLINT=""no""
fi
fi
PERLINT=$ac_cv_prog_PERLINT
if test -n "$PERLINT"; then
{ echo "$as_me:$LINENO: result: $PERLINT" >&5
echo "${ECHO_T}$PERLINT" >&6; }
else
{ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6; }
fi
# Check whether --enable-ffi was given.
if test "${enable_ffi+set}" = set; then
enableval=$enable_ffi; USER_FFI="no"
......@@ -6829,18 +6789,19 @@ else
fi
if test "$PERLINT" = "yes" -a "$USER_FFI" = "yes" ;then
# We have perl and user did't disable FFI. We can try to configure C/invoke
echo "Configuring C/Invoke"
(cd cinvoke; perl configure.pl --prefix=$prefix)
LIBS="$LIBS ../cinvoke/lib/libcinvoke.a"
CFLAGS="$CFLAGS -I../cinvoke/lib"
CINVOKE="cinvoke"
if test "$USER_FFI" = "yes" ;then
echo "Configuring libffi"
(cd ffi; CC=${CC} CFLAGS=${CFLAGS} ./configure \
--disable-structs --disable-raw-api --disable-shared \
--prefix=$prefix)
LIBS="$LIBS ../ffi/.libs/libffi.a"
CFLAGS="$CFLAGS -I../ffi/include"
LIBFFI="ffi"
HAVE_FFI="#define HAVE_FFI 1"
FFI="yes"
else
echo "Disabling FFI support"
CINVOKE=""
LIBFFI=""
HAVE_FFI=""
FFI="no"
fi
......@@ -7761,7 +7722,6 @@ NO_THREAD_FALSE!$NO_THREAD_FALSE$ac_delim
GTK_CONFIG!$GTK_CONFIG$ac_delim
GNOME_CONFIG!$GNOME_CONFIG$ac_delim
LIBOBJS!$LIBOBJS$ac_delim
PERLINT!$PERLINT$ac_delim
STKCFLAGS!$STKCFLAGS$ac_delim
HAVE_DLOPEN!$HAVE_DLOPEN$ac_delim
HAVE_FFI!$HAVE_FFI$ac_delim
......@@ -7770,6 +7730,7 @@ GC!$GC$ac_delim
GCLIB!$GCLIB$ac_delim
GCINC!$GCINC$ac_delim
GMP!$GMP$ac_delim
GMPLIB!$GMPLIB$ac_delim
_ACEOF
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
......@@ -7811,7 +7772,6 @@ _ACEOF
ac_delim='%!_!# '
for ac_last_try in false false false false false :; do
cat >conf$$subs.sed <<_ACEOF
GMPLIB!$GMPLIB$ac_delim
GMPINC!$GMPINC$ac_delim
PREFIX!$PREFIX$ac_delim
SCMDIR!$SCMDIR$ac_delim
......@@ -7843,11 +7803,11 @@ SVN_URL!$SVN_URL$ac_delim
THREADS!$THREADS$ac_delim
LURCDIR!$LURCDIR$ac_delim
CALLCC_STK!$CALLCC_STK$ac_delim
CINVOKE!$CINVOKE$ac_delim
LIBFFI!$LIBFFI$ac_delim
LTLIBOBJS!$LTLIBOBJS$ac_delim
_ACEOF
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 34; then
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 33; then
break
elif $ac_last_try; then
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
......
......@@ -2,7 +2,7 @@ dnl configure.in for STklos
dnl
dnl Author: Erick Gallesio [eg@unice.fr]
dnl Creation date: 28-Dec-1999 21:19 (eg)
dnl Last file update: 31-Jan-2008 16:04 (eg)
dnl Last file update: 3-May-2008 19:57 (eg)
AC_INIT(src/stklos.c)
......@@ -389,24 +389,23 @@ fi
dnl
dnl FFI support
dnl
AC_CHECK_PROG(PERLINT, [perl], "yes", "no")
AC_ARG_ENABLE(ffi,
[ --disable-ffi disable FFI support],
USER_FFI="no", USER_FFI="yes")
if test "$PERLINT" = "yes" -a "$USER_FFI" = "yes" ;then
# We have perl and user did't disable FFI. We can try to configure C/invoke
echo "Configuring C/Invoke"
(cd cinvoke; perl configure.pl --prefix=$prefix)
LIBS="$LIBS ../cinvoke/lib/libcinvoke.a"
CFLAGS="$CFLAGS -I../cinvoke/lib"
CINVOKE="cinvoke"
if test "$USER_FFI" = "yes" ;then
echo "Configuring libffi"
(cd ffi; CC=${CC} CFLAGS=${CFLAGS} ./configure \
--disable-structs --disable-raw-api --disable-shared \
--prefix=$prefix)
LIBS="$LIBS ../ffi/.libs/libffi.a"
CFLAGS="$CFLAGS -I../ffi/include"
LIBFFI="ffi"
HAVE_FFI="#define HAVE_FFI 1"
FFI="yes"
else
echo "Disabling FFI support"
CINVOKE=""
LIBFFI=""
HAVE_FFI=""
FFI="no"
fi
......@@ -557,7 +556,7 @@ AC_SUBST(SVN_URL)
AC_SUBST(THREADS)
AC_SUBST(LURCDIR)
AC_SUBST(CALLCC_STK)
AC_SUBST(CINVOKE)
AC_SUBST(LIBFFI)
AC_OUTPUT(Makefile src/Makefile src/extraconf.h doc/Makefile
lib/Makefile gtklos/Makefile gtklos/gtklosconf.h
......
......@@ -40,7 +40,7 @@ subdir = doc
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
$(srcdir)/stklos-compile.1.in $(srcdir)/stklos-config.1.in \
$(srcdir)/stklos-genlex.1.in $(srcdir)/stklos-install.1.in \
$(srcdir)/stklos-pkg.1.in $(srcdir)/stklos.1.in TODO
$(srcdir)/stklos-pkg.1.in $(srcdir)/stklos.1.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
......@@ -81,7 +81,6 @@ CALLCC_STK = @CALLCC_STK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CINVOKE = @CINVOKE@
COMPOBJ = @COMPOBJ@
COMPSRC = @COMPSRC@
CPP = @CPP@
......@@ -120,6 +119,7 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDAP_LIB = @LDAP_LIB@
LDFLAGS = @LDFLAGS@
LIBFFI = @LIBFFI@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
......@@ -140,7 +140,6 @@ PCRE = @PCRE@
PCREINC = @PCREINC@
PCRELIB = @PCRELIB@
PCRETARGET = @PCRETARGET@
PERLINT = @PERLINT@
PREFIX = @PREFIX@
RANLIB = @RANLIB@
SCMDIR = @SCMDIR@
......
......@@ -67,7 +67,6 @@ CALLCC_STK = @CALLCC_STK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CINVOKE = @CINVOKE@
COMPOBJ = @COMPOBJ@
COMPSRC = @COMPSRC@
CPP = @CPP@
......@@ -106,6 +105,7 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDAP_LIB = @LDAP_LIB@
LDFLAGS = @LDFLAGS@
LIBFFI = @LIBFFI@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
......@@ -126,7 +126,6 @@ PCRE = @PCRE@
PCREINC = @PCREINC@
PCRELIB = @PCRELIB@
PCRETARGET = @PCRETARGET@
PERLINT = @PERLINT@
PREFIX = @PREFIX@
RANLIB = @RANLIB@
SCMDIR = @SCMDIR@
......
......@@ -63,7 +63,6 @@ CALLCC_STK = @CALLCC_STK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CINVOKE = @CINVOKE@
COMPOBJ = @COMPOBJ@
COMPSRC = @COMPSRC@
CPP = @CPP@
......@@ -102,6 +101,7 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDAP_LIB = @LDAP_LIB@
LDFLAGS = @LDFLAGS@
LIBFFI = @LIBFFI@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
......@@ -122,7 +122,6 @@ PCRE = @PCRE@
PCREINC = @PCREINC@
PCRELIB = @PCRELIB@
PCRETARGET = @PCRETARGET@
PERLINT = @PERLINT@
PREFIX = @PREFIX@
RANLIB = @RANLIB@
SCMDIR = @SCMDIR@
......
......@@ -39,7 +39,7 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
subdir = extensions
DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
$(srcdir)/extconf.h.in TODO
$(srcdir)/extconf.h.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
......@@ -73,7 +73,6 @@ CALLCC_STK = @CALLCC_STK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@ @SH_COMP_FLAGS@ @GTK_CONFIG_CFLAGS@ @GCINC@ $(INCLUDES)
CINVOKE = @CINVOKE@
COMPOBJ = @COMPOBJ@
COMPSRC = @COMPSRC@
CPP = @CPP@
......@@ -112,6 +111,7 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDAP_LIB = @LDAP_LIB@
LDFLAGS = @LDFLAGS@
LIBFFI = @LIBFFI@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
......@@ -132,7 +132,6 @@ PCRE = @PCRE@
PCREINC = @PCREINC@
PCRELIB = @PCRELIB@
PCRETARGET = @PCRETARGET@
PERLINT = @PERLINT@
PREFIX = @PREFIX@
RANLIB = @RANLIB@
SCMDIR = @SCMDIR@
......
......@@ -2,7 +2,7 @@
AUTOMAKE_OPTIONS = foreign subdir-objects
SUBDIRS = include man
SUBDIRS = include testsuite man
EXTRA_DIST = LICENSE ChangeLog.v1 ChangeLog.libgcj configure.host \
src/alpha/ffi.c src/alpha/osf.S src/alpha/ffitarget.h \
......
......@@ -333,7 +333,7 @@ toolexeclibdir = @toolexeclibdir@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = foreign subdir-objects
SUBDIRS = include man
SUBDIRS = include testsuite man
EXTRA_DIST = LICENSE ChangeLog.v1 ChangeLog.libgcj configure.host \
src/alpha/ffi.c src/alpha/osf.S src/alpha/ffitarget.h \
src/arm/ffi.c src/arm/sysv.S src/arm/ffitarget.h \
......
## Process this file with automake to produce Makefile.in.
AUTOMAKE_OPTIONS = foreign dejagnu
# Setup the testing framework, if you have one
EXPECT = `if [ -f $(top_builddir)/../expect/expect ] ; then \
echo $(top_builddir)/../expect/expect ; \
else echo expect ; fi`
RUNTEST = `if [ -f $(top_srcdir)/../dejagnu/runtest ] ; then \
echo $(top_srcdir)/../dejagnu/runtest ; \
else echo runtest; fi`
AM_RUNTESTFLAGS =
CLEANFILES = *.exe core* *.log *.sum
EXTRA_DIST = config/default.exp lib/libffi-dg.exp \
lib/target-libpath.exp lib/wrapper.exp libffi.call/call.exp \
libffi.call/closure_fn0.c libffi.call/closure_fn1.c \
libffi.call/closure_fn2.c libffi.call/closure_fn3.c \
libffi.call/closure_fn4.c libffi.call/closure_fn5.c \
libffi.call/closure_fn6.c libffi.call/closure_stdcall.c \
libffi.call/cls_1_1byte.c libffi.call/cls_12byte.c \
libffi.call/cls_16byte.c libffi.call/cls_18byte.c \
libffi.call/cls_19byte.c libffi.call/cls_20byte1.c \
libffi.call/cls_20byte.c libffi.call/cls_24byte.c \
libffi.call/cls_2byte.c libffi.call/cls_3_1byte.c \
libffi.call/cls_3byte1.c libffi.call/cls_3byte2.c \
libffi.call/cls_4_1byte.c libffi.call/cls_4byte.c \
libffi.call/cls_5_1_byte.c libffi.call/cls_5byte.c \
libffi.call/cls_6_1_byte.c libffi.call/cls_64byte.c \
libffi.call/cls_6byte.c libffi.call/cls_7_1_byte.c \
libffi.call/cls_7byte.c libffi.call/cls_8byte.c \
libffi.call/cls_9byte1.c libffi.call/cls_9byte2.c \
libffi.call/cls_align_double.c libffi.call/cls_align_float.c \
libffi.call/cls_align_longdouble.c libffi.call/cls_align_pointer.c \
libffi.call/cls_align_sint16.c libffi.call/cls_align_sint32.c \
libffi.call/cls_align_sint64.c libffi.call/cls_align_uint16.c \
libffi.call/cls_align_uint32.c libffi.call/cls_align_uint64.c \
libffi.call/cls_double.c libffi.call/cls_float.c \
libffi.call/cls_multi_schar.c libffi.call/cls_multi_sshort.c \
libffi.call/cls_multi_sshortchar.c libffi.call/cls_multi_uchar.c \
libffi.call/cls_multi_ushort.c libffi.call/cls_multi_ushortchar.c \
libffi.call/cls_schar.c libffi.call/cls_sint.c \
libffi.call/cls_sshort.c libffi.call/cls_uchar.c \
libffi.call/cls_uint.c libffi.call/cls_ulonglong.c \
libffi.call/cls_ushort.c libffi.call/ffitest.h libffi.call/float1.c \
libffi.call/float2.c libffi.call/float3.c libffi.call/float4.c \
libffi.call/float.c libffi.call/many.c libffi.call/many_win32.c \
libffi.call/negint.c libffi.call/nested_struct10.c \
libffi.call/nested_struct1.c libffi.call/nested_struct2.c \
libffi.call/nested_struct3.c libffi.call/nested_struct4.c \
libffi.call/nested_struct5.c libffi.call/nested_struct6.c \
libffi.call/nested_struct7.c libffi.call/nested_struct8.c \
libffi.call/nested_struct9.c libffi.call/nested_struct.c \
libffi.call/problem1.c libffi.call/promotion.c \
libffi.call/pyobjc-tc.c libffi.call/return_dbl1.c \
libffi.call/return_dbl2.c libffi.call/return_dbl.c \
libffi.call/return_fl1.c libffi.call/return_fl2.c \
libffi.call/return_fl3.c libffi.call/return_fl.c \
libffi.call/return_ldl.c libffi.call/return_ll1.c \
libffi.call/return_ll.c libffi.call/return_sc.c \
libffi.call/return_sl.c libffi.call/return_uc.c \
libffi.call/return_ul.c libffi.call/strlen.c \
libffi.call/strlen_win32.c libffi.call/struct1.c \
libffi.call/struct2.c libffi.call/struct3.c libffi.call/struct4.c \
libffi.call/struct5.c libffi.call/struct6.c libffi.call/struct7.c \
libffi.call/struct8.c libffi.call/struct9.c \
libffi.special/ffitestcxx.h libffi.special/special.exp \
libffi.special/unwindtest.cc libffi.special/unwindtest_ffi_call.cc
This diff is collapsed.
load_lib "standard.exp"
# Copyright (C) 2003, 2005, 2008 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 of the License, 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, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
proc load_gcc_lib { filename } {
global srcdir
load_file $srcdir/lib/$filename
}
load_lib dg.exp
load_lib libgloss.exp
load_gcc_lib target-libpath.exp
load_gcc_lib wrapper.exp
# Define libffi callbacks for dg.exp.
proc libffi-dg-test-1 { target_compile prog do_what extra_tool_flags } {
# To get all \n in dg-output test strings to match printf output
# in a system that outputs it as \015\012 (i.e. not just \012), we
# need to change all \n into \r?\n. As there is no dejagnu flag
# or hook to do that, we simply change the text being tested.
# Unfortunately, we have to know that the variable is called
# dg-output-text and lives in the caller of libffi-dg-test, which
# is two calls up. Overriding proc dg-output would be longer and
# would necessarily have the same assumption.
upvar 2 dg-output-text output_match
if { [llength $output_match] > 1 } {
regsub -all "\n" [lindex $output_match 1] "\r?\n" x
set output_match [lreplace $output_match 1 1 $x]
}
# Set up the compiler flags, based on what we're going to do.
set options [list]
switch $do_what {
"compile" {
set compile_type "assembly"
set output_file "[file rootname [file tail $prog]].s"
}
"link" {
set compile_type "executable"
set output_file "[file rootname [file tail $prog]].exe"
# The following line is needed for targets like the i960 where
# the default output file is b.out. Sigh.
}
"run" {
set compile_type "executable"
# FIXME: "./" is to cope with "." not being in $PATH.
# Should this be handled elsewhere?
# YES.
set output_file "./[file rootname [file tail $prog]].exe"
# This is the only place where we care if an executable was
# created or not. If it was, dg.exp will try to run it.
remote_file build delete $output_file;
}
default {
perror "$do_what: not a valid dg-do keyword"
return ""
}
}
if { $extra_tool_flags != "" } {
lappend options "additional_flags=$extra_tool_flags"
}
set comp_output [libffi_target_compile "$prog" "$output_file" "$compile_type" $options];
return [list $comp_output $output_file]
}
proc libffi-dg-test { prog do_what extra_tool_flags } {
return [libffi-dg-test-1 target_compile $prog $do_what $extra_tool_flags]
}
proc libffi-init { args } {
global gluefile wrap_flags;
global srcdir
global blddirffi
global objdir
global TOOL_OPTIONS
global tool
global libffi_include
global libffi_link_flags
global tool_root_dir
global ld_library_path
set blddirffi [pwd]/..
verbose "libffi $blddirffi"
set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
if {$gccdir != ""} {
set gccdir [file dirname $gccdir]
}
verbose "gccdir $gccdir"
set ld_library_path "."
append ld_library_path ":${gccdir}"
set compiler "${gccdir}/xgcc"
if { [is_remote host] == 0 && [which $compiler] != 0 } {
foreach i "[exec $compiler --print-multi-lib]" {
set mldir ""
regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
set mldir [string trimright $mldir "\;@"]
if { "$mldir" == "." } {
continue
}
if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
append ld_library_path ":${gccdir}/${mldir}"
}
}
}
# add the library path for libffi.
append ld_library_path ":${blddirffi}/.libs"
verbose "ld_library_path: $ld_library_path"
# Point to the Libffi headers in libffi.
set libffi_include "${blddirffi}/include"
verbose "libffi_include $libffi_include"
set libffi_dir "${blddirffi}/.libs"
verbose "libffi_dir $libffi_dir"
if { $libffi_dir != "" } {
set libffi_dir [file dirname ${libffi_dir}]
set libffi_link_flags "-L${libffi_dir}/.libs"
}
set_ld_library_path_env_vars
libffi_maybe_build_wrapper "${objdir}/testglue.o"
}
proc libffi_exit { } {
global gluefile;
if [info exists gluefile] {
file_on_build delete $gluefile;
unset gluefile;
}
}
proc libffi_target_compile { source dest type options } {
global gluefile wrap_flags;
global srcdir
global blddirffi
global TOOL_OPTIONS
global libffi_link_flags
global libffi_include
global target_triplet
if { [target_info needs_status_wrapper]!="" && [info exists gluefile] } {
lappend options "libs=${gluefile}"
lappend options "ldflags=$wrap_flags"
}
# TOOL_OPTIONS must come first, so that it doesn't override testcase
# specific options.
if [info exists TOOL_OPTIONS] {
lappend options [concat "additional_flags=$TOOL_OPTIONS" $options];
}
# search for ffi_mips.h in srcdir, too
lappend options "additional_flags=-I${libffi_include} -I${srcdir}/../include -I${libffi_include}/.."
lappend options "additional_flags=${libffi_link_flags}"
# If you're building the compiler with --prefix set to a place
# where it's not yet installed, then the linker won't be able to
# find the libgcc used by libffi.dylib. We could pass the
# -dylib_file option, but that's complicated, and it's much easier
# to just make the linker find libgcc using -L options.
if { [string match "*-*-darwin*" $target_triplet] } {
lappend options "libs= -shared-libgcc"
}
lappend options "libs= -lffi"
verbose "options: $options"
return [target_compile $source $dest $type $options]
}
# Utility routines.
#
# search_for -- looks for a string match in a file
#
proc search_for { file pattern } {
set fd [open $file r]
while { [gets $fd cur_line]>=0 } {
if [string match "*$pattern*" $cur_line] then {
close $fd
return 1
}
}
close $fd
return 0
}
# Modified dg-runtest that can cycle through a list of optimization options
# as c-torture does.
proc libffi-dg-runtest { testcases default-extra-flags } {
global runtests
foreach test $testcases {
# If we're only testing specific files and this isn't one of
# them, skip it.
if ![runtest_file_p $runtests $test] {
continue
}
# Look for a loop within the source code - if we don't find one,
# don't pass -funroll[-all]-loops.
global torture_with_loops torture_without_loops
if [expr [search_for $test "for*("]+[search_for $test "while*("]] {
set option_list $torture_with_loops
} else {
set option_list $torture_without_loops
}
set nshort [file tail [file dirname $test]]/[file tail $test]
foreach flags $option_list {
verbose "Testing $nshort, $flags" 1
dg-test $test $flags ${default-extra-flags}
}
}
}
# Like check_conditional_xfail, but callable from a dg test.
proc dg-xfail-if { args } {
set args [lreplace $args 0 0]
set selector "target [join [lindex $args 1]]"
if { [dg-process-target $selector] == "S" } {
global compiler_conditional_xfail_data
set compiler_conditional_xfail_data $args
}
}
# We need to make sure that additional_files and additional_sources
# are both cleared out after every test. It is not enough to clear
# them out *before* the next test run because gcc-target-compile gets
# run directly from some .exp files (outside of any test). (Those
# uses should eventually be eliminated.)
# Because the DG framework doesn't provide a hook that is run at the
# end of a test, we must replace dg-test with a wrapper.
if { [info procs saved-dg-test] == [list] } {
rename dg-test saved-dg-test