remove unnecessary blank line
[deliverable/binutils-gdb.git] / ld / emultempl / gld960.em
1 # This shell script emits a C file. -*- C -*-
2 # It does some substitutions.
3 cat >em_${EMULATION_NAME}.c <<EOF
4 /* Copyright (C) 1991 Free Software Foundation, Inc.
5
6 This file is part of GLD, the Gnu Linker.
7
8 GLD is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 1, or (at your option)
11 any later version.
12
13 GLD is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GLD; see the file COPYING. If not, write to
20 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
21
22 /*
23 * emulate the Intels port of gld
24 */
25
26
27 #include "bfd.h"
28 #include "sysdep.h"
29
30
31 #include "ld.h"
32 #include "config.h"
33 #include "ldemul.h"
34 #include "ldfile.h"
35 #include "ldmisc.h"
36
37
38 /* IMPORTS */
39 extern char *output_filename;
40 extern boolean lang_float_flag;
41
42
43 extern enum bfd_architecture ldfile_output_architecture;
44 extern unsigned long ldfile_output_machine;
45 extern char *ldfile_output_machine_name;
46
47 extern bfd *output_bfd;
48
49
50
51 #ifdef GNU960
52
53 static void
54 gld960_before_parse()
55 {
56 static char *env_variables[] = { "G960LIB", "G960BASE", 0 };
57 char **p;
58 char *env ;
59
60 for ( p = env_variables; *p; p++ ){
61 env = (char *) getenv(*p);
62 if (env) {
63 ldfile_add_library_path(concat(env,"/lib/libbout",""));
64 }
65 }
66 ldfile_output_architecture = bfd_arch_i960;
67 }
68
69 #else /* not GNU960 */
70
71 static void gld960_before_parse()
72 {
73 char *env ;
74 env = getenv("G960LIB");
75 if (env) {
76 ldfile_add_library_path(env);
77 }
78 env = getenv("G960BASE");
79 if (env) {
80 ldfile_add_library_path(concat(env,"/lib",""));
81 }
82 ldfile_output_architecture = bfd_arch_i960;
83 }
84
85 #endif /* GNU960 */
86
87
88 static void
89 gld960_set_output_arch()
90 {
91 bfd_set_arch_mach(output_bfd, ldfile_output_architecture, bfd_mach_i960_core);
92 }
93
94 static char *
95 gld960_choose_target()
96 {
97 #ifdef GNU960
98
99 output_filename = "b.out";
100 return bfd_make_targ_name(BFD_BOUT_FORMAT, 0);
101
102 #else
103
104 char *from_outside = getenv(TARGET_ENVIRON);
105 output_filename = "b.out";
106
107 if (from_outside != (char *)NULL)
108 return from_outside;
109
110 return "b.out.little";
111
112 #endif
113 }
114
115 static char *
116 gld960_get_script(isfile)
117 int *isfile;
118 EOF
119
120 if test "$DEFAULT_EMULATION" = "$EMULATION_NAME"
121 then
122 # Scripts compiled in.
123
124 # sed commands to quote an ld script as a C string.
125 sc='s/["\\]/\\&/g
126 s/$/\\n\\/
127 1s/^/"{/
128 $s/$/n}"/
129 '
130
131 cat >>em_${EMULATION_NAME}.c <<EOF
132 {
133 extern ld_config_type config;
134
135 *isfile = 0;
136
137 if (config.relocateable_output == true && config.build_constructors == true)
138 return `sed "$sc" ldscripts/${EMULATION_NAME}.xu`;
139 else if (config.relocateable_output == true)
140 return `sed "$sc" ldscripts/${EMULATION_NAME}.xr`;
141 else if (!config.text_read_only)
142 return `sed "$sc" ldscripts/${EMULATION_NAME}.xbn`;
143 else if (!config.magic_demand_paged)
144 return `sed "$sc" ldscripts/${EMULATION_NAME}.xn`;
145 else
146 return `sed "$sc" ldscripts/${EMULATION_NAME}.x`;
147 }
148 EOF
149
150 else
151 # Scripts read from the filesystem.
152
153 cat >>em_${EMULATION_NAME}.c <<EOF
154 {
155 extern ld_config_type config;
156
157 *isfile = 1;
158
159 if (config.relocateable_output == true && config.build_constructors == true)
160 return "ldscripts/${EMULATION_NAME}.xu";
161 else if (config.relocateable_output == true)
162 return "ldscripts/${EMULATION_NAME}.xr";
163 else if (!config.text_read_only)
164 return "ldscripts/${EMULATION_NAME}.xbn";
165 else if (!config.magic_demand_paged)
166 return "ldscripts/${EMULATION_NAME}.xn";
167 else
168 return "ldscripts/${EMULATION_NAME}.x";
169 }
170 EOF
171
172 fi
173
174 cat >>em_${EMULATION_NAME}.c <<EOF
175
176 struct ld_emulation_xfer_struct ld_gld960_emulation =
177 {
178 gld960_before_parse,
179 syslib_default,
180 hll_default,
181 after_parse_default,
182 after_allocation_default,
183 gld960_set_output_arch,
184 gld960_choose_target,
185 before_allocation_default,
186 gld960_get_script,
187 "960",
188 ""
189 };
190 EOF
This page took 0.033276 seconds and 4 git commands to generate.