1 # Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved.
3 # Permission to use, copy, modify, and distribute this software
4 # is freely granted, provided that this notice is preserved.
7 proc newlib_version { } {
10 verbose "In newlib version...\n"
15 set newlib_initialized 0
17 proc newlib_init { args } {
18 global gluefile wrap_flags
19 global newlib_initialized
21 global CFLAGS_FOR_TARGET
22 # These values are initialized in the local site.exp file
24 global build_triplet host_triplet
25 # newlib_cflags comes from acinclude.m4, through the site.exp file
27 global old_ld_library_path
29 verbose "In newlib_init...\n"
31 if { $newlib_initialized == 1 } { return; }
33 set CFLAGS_FOR_TARGET $newlib_cflags
35 set_currtarget_info "wrap_compile_flags" "$newlib_cflags"
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];
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"
58 proc newlib_target_compile { source dest type options } {
59 global gluefile wrap_flags
64 verbose "In newlib_target_compile...\n"
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 \
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"
85 return [target_compile $source $dest $type $options]
88 proc newlib_finish { } {
89 global old_ld_library_path
90 global build_triplet host_triplet
92 verbose "In newlib_finish...\n"
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"
101 proc newlib_exit { } {
104 verbose "In newlib_exit...\n"
106 if [info exists gluefile] {
107 file_on_build delete $gluefile;