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"
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	} else {
58	    set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}"
59	}
60    } else {
61        set ld_library_path "$always_ld_library_path"
62    }
63    append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
64    set_ld_library_path_env_vars
65
66    # For Fortran we're doing torture testing, as Fortran has far more tests
67    # with arrays etc. that testing just -O0 or -O2 is insufficient, that is
68    # typically not the case for C/C++.
69    gfortran-dg-runtest $tests "" ""
70}
71
72# All done.
73dg-finish
74