1load_lib libgomp-dg.exp
2load_gcc_lib gcc-dg.exp
3load_gcc_lib gfortran-dg.exp
4
5global shlib_ext
6global ALWAYS_CFLAGS
7
8set shlib_ext [get_shlib_extension]
9set lang_library_path	"../libgfortran/.libs"
10set lang_link_flags	"-lgfortran -foffload=-lgfortran"
11if [info exists lang_include_flags] then {
12    unset lang_include_flags
13}
14set lang_test_file_found 0
15set quadmath_library_path "../libquadmath/.libs"
16
17
18# Initialize dg.
19dg-init
20
21# Turn on OpenMP.
22lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
23
24if { $blddir != "" } {
25    set lang_source_re {^.*\.[fF](|90|95|03|08)$}
26    set lang_include_flags "-fintrinsic-modules-path=${blddir}"
27    # Look for a static libgfortran first.
28    if [file exists "${blddir}/${lang_library_path}/libgfortran.a"] {
29        set lang_test_file "${lang_library_path}/libgfortran.a"
30        set lang_test_file_found 1
31	# We may have a shared only build, so look for a shared libgfortran.
32    } elseif [file exists "${blddir}/${lang_library_path}/libgfortran.${shlib_ext}"] {
33        set lang_test_file "${lang_library_path}/libgfortran.${shlib_ext}"
34        set lang_test_file_found 1
35    } else {
36        puts "No libgfortran library found, will not execute fortran tests"
37    }
38} elseif [info exists GFORTRAN_UNDER_TEST] {
39    set lang_test_file_found 1
40    # Needs to exist for libgomp.exp.
41    set lang_test_file ""
42} else {
43    puts "GFORTRAN_UNDER_TEST not defined, will not execute fortran tests"
44}
45
46if { $lang_test_file_found } {
47    # Gather a list of all tests.
48    set tests [lsort [find $srcdir/$subdir *.\[fF\]{,90,95,03,08}]]
49
50    if { $blddir != "" } {
51	if { [file exists "${blddir}/${quadmath_library_path}/libquadmath.a"]
52	     || [file exists "${blddir}/${quadmath_library_path}/libquadmath.${shlib_ext}"] } {
53	    lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/${quadmath_library_path}/"
54	    # Allow for spec subsitution.
55	    lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/${quadmath_library_path}/"
56	    set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}:${blddir}/${quadmath_library_path}"
57	    append lang_link_flags " -lquadmath"
58	} else {
59	    set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}"
60	}
61    } else {
62        set ld_library_path "$always_ld_library_path"
63        if { [check_no_compiler_messages has_libquadmath executable {
64                 int main() {return 0;}
65              } "-lgfortran -lquadmath"] } then {
66            append lang_link_flags " -lquadmath"
67        }
68    }
69    append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
70    set_ld_library_path_env_vars
71
72    # For Fortran we're doing torture testing, as Fortran has far more tests
73    # with arrays etc. that testing just -O0 or -O2 is insufficient, that is
74    # typically not the case for C/C++.
75    gfortran-dg-runtest $tests "" ""
76}
77
78# All done.
79dg-finish
80