77b726fb13ff3a612b29eb635f0788b3327dde75
[external/binutils.git] / ld / emultempl / m88kbcs.em
1 # This shell script emits a C file. -*- C -*-
2 # It does some substitutions.
3 cat >em_${EMULATION_NAME}.c <<EOF
4 /* This file is is generated by a shell script.  DO NOT EDIT! */
5
6 /* emulate the original gld for the given ${EMULATION_NAME}
7    Copyright (C) 1991 Free Software Foundation, Inc.
8    Written by Steve Chamberlain steve@cygnus.com
9
10 This file is part of GLD, the Gnu Linker.
11
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
16
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
25
26 #define TARGET_IS_${EMULATION_NAME}
27
28 #include "bfd.h"
29 #include "sysdep.h"
30 #include "ld.h"
31 #include "config.h"
32 #include "ldemul.h"
33 #include "ldfile.h"
34 #include "ldmisc.h"
35
36 extern boolean lang_float_flag;
37
38 extern enum bfd_architecture ldfile_output_architecture;
39 extern unsigned long ldfile_output_machine;
40 extern char *ldfile_output_machine_name;
41
42 static void
43 gld${EMULATION_NAME}_before_parse()
44 {
45   extern char *lprefix;
46   lprefix = "@";
47   lprefix_len = 1;
48
49   ldfile_output_architecture = bfd_arch_${ARCH};
50 }
51
52 static char *
53 gld${EMULATION_NAME}_get_script(isfile)
54      int *isfile;
55 EOF
56
57 if test -n "$COMPILE_IN"
58 then
59 # Scripts compiled in.
60
61 # sed commands to quote an ld script as a C string.
62 sc='s/["\\]/\\&/g
63 s/$/\\n\\/
64 1s/^/"{/
65 $s/$/n}"/
66 '
67
68 cat >>em_${EMULATION_NAME}.c <<EOF
69 {                            
70   extern ld_config_type config;
71
72   *isfile = 0;
73
74   if (config.relocateable_output == true && config.build_constructors == true)
75     return `sed "$sc" ldscripts/${EMULATION_NAME}.xu`;
76   else if (config.relocateable_output == true)
77     return `sed "$sc" ldscripts/${EMULATION_NAME}.xr`;
78   else if (!config.text_read_only)
79     return `sed "$sc" ldscripts/${EMULATION_NAME}.xbn`;
80   else if (!config.magic_demand_paged)
81     return `sed "$sc" ldscripts/${EMULATION_NAME}.xn`;
82   else
83     return `sed "$sc" ldscripts/${EMULATION_NAME}.x`;
84 }
85 EOF
86
87 else
88 # Scripts read from the filesystem.
89
90 cat >>em_${EMULATION_NAME}.c <<EOF
91 {                            
92   extern ld_config_type config;
93
94   *isfile = 1;
95
96   if (config.relocateable_output == true && config.build_constructors == true)
97     return "ldscripts/${EMULATION_NAME}.xu";
98   else if (config.relocateable_output == true)
99     return "ldscripts/${EMULATION_NAME}.xr";
100   else if (!config.text_read_only)
101     return "ldscripts/${EMULATION_NAME}.xbn";
102   else if (!config.magic_demand_paged)
103     return "ldscripts/${EMULATION_NAME}.xn";
104   else
105     return "ldscripts/${EMULATION_NAME}.x";
106 }
107 EOF
108
109 fi
110
111 cat >>em_${EMULATION_NAME}.c <<EOF
112
113 struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = 
114 {
115   gld${EMULATION_NAME}_before_parse,
116   syslib_default,
117   hll_default,
118   after_parse_default,
119   after_allocation_default,
120   set_output_arch_default,
121   ldemul_default_target,
122   before_allocation_default,
123   gld${EMULATION_NAME}_get_script,
124   "${EMULATION_NAME}",
125   "${OUTPUT_FORMAT}"
126 };
127 EOF