OSDN Git Service

* Makefile.am (check-DEJAGNU): New target.
[pf3gnuchains/pf3gnuchains3x.git] / newlib / testsuite / lib / newlib.exp
1 # Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved.
2 #
3 # Permission to use, copy, modify, and distribute this software
4 # is freely granted, provided that this notice is preserved.
5 #
6
7 proc newlib_version { } {
8     global tool_version
9
10     verbose "In newlib version...\n"
11
12     return $tool_version
13 }
14
15 set newlib_initialized 0
16
17 proc newlib_init { args } {
18     global gluefile wrap_flags
19     global newlib_initialized
20     global target_info
21     global CFLAGS_FOR_TARGET
22     # These values are initialized in the local site.exp file
23     global srcdir objdir
24     global build_triplet host_triplet
25     # newlib_cflags comes from acinclude.m4, through the site.exp file
26     global newlib_cflags
27     global old_ld_library_path
28
29     verbose "In newlib_init...\n"
30
31     if { $newlib_initialized == 1 } { return; }
32
33     set CFLAGS_FOR_TARGET $newlib_cflags
34
35     set_currtarget_info "wrap_compile_flags" "$newlib_cflags"
36
37     if {[target_info needs_status_wrapper] != "" && \
38             [target_info needs_status_wrapper] != "0" && \
39             ![info exists gluefile]} {
40         set gluefile ${objdir}/testglue.o;
41         set result [build_wrapper $gluefile];
42         if { $result != "" } {
43             set gluefile [lindex $result 0];
44             set wrap_flags [lindex $result 1];
45         } else {
46             unset gluefile
47         }
48     }
49
50     if [string match $build_triplet $host_triplet] then {
51         if [string match "i686-pc-linux-gnu" $build_triplet] then {
52             set old_ld_library_path [getenv LD_LIBRARY_PATH]
53             setenv LD_LIBRARY_PATH "$objdir/.libs"
54         }
55     }
56 }
57
58 proc newlib_target_compile { source dest type options } {
59     global gluefile wrap_flags
60     global srcdir objdir
61     global build_triplet
62     global host_triplet
63
64     verbose "In newlib_target_compile...\n"
65         
66     if {[target_info needs_status_wrapper] != "" && \
67             [target_info needs_status_wrapper] != "0" && \
68             [info exists gluefile] } {
69         lappend options "libs=$gluefile"
70         # This method of finding libgloss_target_dir may not work for some targets
71         set libgloss_target_dir [lindex [split $host_triplet "-"] 0]
72         lappend options "ldflags=$wrap_flags -B$objdir/../libgloss/$libgloss_target_dir \
73                                              -L$objdir/../libgloss/$libgloss_target_dir \
74                                              -L$srcdir/../../libgloss/$libgloss_target_dir \
75                                              -L$objdir"
76     }
77
78     if [string match $build_triplet $host_triplet] then {
79         if [string match "i686-pc-linux-gnu" $build_triplet] then {
80             lappend options "libs=$objdir/crt0.o -lc"
81             lappend options "ldflags=-nostdlib -L$objdir/.libs -lgcc"
82         }
83     }
84
85     return [target_compile $source $dest $type $options]
86 }
87
88 proc newlib_finish { } {
89     global old_ld_library_path
90     global build_triplet host_triplet
91
92     verbose "In newlib_finish...\n"
93
94     if [string match $build_triplet $host_triplet] then {
95         if [string match "i686-pc-linux-gnu" $build_triplet] then {
96             setenv LD_LIBRARY_PATH "$old_ld_library_path"
97         }
98     }
99 }
100
101 proc newlib_exit { } {
102     global gluefile;
103     
104     verbose "In newlib_exit...\n"
105
106     if [info exists gluefile] {
107         file_on_build delete $gluefile;
108         unset gluefile;
109     }
110 }