19990502 sourceware import
[deliverable/binutils-gdb.git] / config / mpw / g-mpw-make.sed
1 # Sed commands to translate Unix makefiles into MPW makefiles.
2 # These are nominally generic, but work best on the makefiles used
3 # for GNU programs.
4
5 # Whack out any commented-out lines that are probably commands;
6 # they can only cause trouble later on.
7 /^# /d
8
9 # Change dependency char.
10 /:$/s/:/ \\Option-f/g
11 /^[^ :#][^:]*:/s/\([ ]*\):\([ ]*\)/ \\Option-f /g
12
13 # Change syntax of Makefile vars.
14 /\$/s/\${\([a-zA-Z0-9_-]*\)}/{\1}/g
15 /\$/s/\$(\([a-zA-Z0-9_-]*\))/{\1}/g
16 / $@/s/ $@/ {Targ}/
17
18 # Double-$ are literals to Unix but not to MPW make.
19 /\$\$/s/\$\$/$/g
20
21 # Change pathname syntax.
22 /\//s,\.\./\/\.\./,:::,g
23 /\//s,\.\./,::,g
24 /\.\//s,\./,:,g
25 /\//s,/,:,g
26 # Undo excess changes.
27 /and/s,and:or$,and/or,
28 /and/s,and:or ,and/or ,
29 /want/s,want:need,want/need,
30 # Fixing up sed commands.
31 /-e/s_":\([^:]*\):d"_"/\1/d"_g
32 /-e/s_":\([^:]*\):,:\([^:]*\):d"_"/\1/,/\2/d"_g
33
34 /=/s/ = \.$/ = :/
35
36 # Make these go away so that later edits not confused.
37 /HLDENV/s/{HLDENV}//
38
39 # Comment out any explicit srcdir setting.
40 /srcdir/s/^srcdir/# srcdir/
41
42 /BASEDIR/s/^BASEDIR =.*$/BASEDIR = "{srcroot}"/
43 /{BASEDIR}:/s/{BASEDIR}:/{BASEDIR}/g
44 /{srcdir}:/s/{srcdir}:/"{srcdir}"/g
45 /"{srcdir}":/s/"{srcdir}":/"{srcdir}"/g
46
47 # Tweak some conventions that are backwards for the Mac.
48 /bindir/s/{exec_prefix}:bin/{exec_prefix}bin:/
49 /libdir/s/{exec_prefix}:lib/{exec_prefix}lib:/
50
51 # Comment out settings of anything set by mpw host config.
52 /CC/s/^CC *=/#CC =/
53 /CFLAGS/s/^CFLAGS *=/#CFLAGS =/
54 /AR/s/^AR *=/#AR =/
55 /AR_FLAGS/s/^AR_FLAGS *=/#AR_FLAGS =/
56 /RANLIB/s/^RANLIB *=/#RANLIB =/
57 /CC_LD/s/^CC_LD *=/#CC_LD =/
58 /LDFLAGS/s/^LDFLAGS *=/#LDFLAGS =/
59
60 # Change -I usages.
61 /-I/s/-I\./-i :/g
62 /-I/s/-I::bfd/-i ::bfd:/g
63 /-I/s/-I::include/-i ::include:/g
64 /-I/s/-I/-i /g
65
66 # Change -D usage.
67 /-D/s/\([ =]\)-D\([^ ]*\)/\1-d \2/g
68
69 # Change continuation char.
70 /\\$/s/\\$/\\Option-d/
71
72 # Change wildcard char.
73 /\*/s/\*/\\Option-x/g
74
75 # Change path of various types of source files. This rule does not allow
76 # for file names with multiple dots in the name.
77 /\.[chly]/s/\([ ><=]\)\([-a-zA-Z0-9_${}:"]*\)\.\([chly]\)/\1"{s}"\2.\3/g
78 /\.[chly]/s/^\([-a-zA-Z0-9_${}:"]*\)\.\([chly]\)/"{s}"\1.\2/
79 # Allow files named *.tab.[ch] as a special case.
80 /\.tab\.[ch]/s/\([ ><=]\)\([-a-zA-Z0-9_${}:"]*\.tab\)\.\([ch]\)/\1"{s}"\2.\3/g
81 /\.tab\.[ch]/s/^\([-a-zA-Z0-9_${}:"]*\.tab\)\.\([ch]\)/"{s}"\1.\2/
82 # Fix some overenthusiasms.
83 /{s}/s/"{s}""{srcdir}"/"{srcdir}"/g
84 /{s}/s/"{s}"{\([a-zA-Z0-9_]*\)dir}/"{\1dir}"/g
85 /{s}/s/"{s}"{\([a-zA-Z0-9_]*\)DIR}/"{\1DIR}"/g
86 /{s}/s/"{s}""{\([a-zA-Z0-9_]*\)dir}"/"{\1dir}"/g
87 /{s}/s/"{s}""{\([a-zA-Z0-9_]*\)DIR}"/"{\1DIR}"/g
88 /{s}/s/"{s}":/:/g
89 /{s}/s/^"{s}"//g
90 /{s}/s/"{s}""{s}"/"{s}"/g
91 /{s}/s/"{s}""{srcdir}"/"{s}"/g
92 /{s}/s/"{srcdir}""{s}"/"{s}"/g
93
94 # The .def files are also typically source files.
95 /\.def/s/\([ ><]\)\([-a-zA-Z0-9_${}:"]*\)\.def/\1"{s}"\2.def/g
96 /\.def/s/^\([-a-zA-Z0-9_${}:"]*\)\.def/"{s}"\1.def/g
97
98 # Change extension and path of objects.
99 /\.o/s/\([ =]\)\([-a-zA-Z0-9_${}:"]*\)\.o/\1"{o}"\2.c.o/g
100 /\.o/s/^\([-a-zA-Z0-9_${}:"]*\)\.o/"{o}"\1.c.o/
101 # Allow *.tab.o files as a special case of a 2-dot-name file.
102 /\.o/s/\([ =]\)\([-a-zA-Z0-9_${}:"]*\)\.tab\.o/\1"{o}"\2.tab.c.o/g
103 /\.o/s/^\([-a-zA-Z0-9_${}:"]*\)\.tab\.o/"{o}"\1.tab.c.o/
104 # Clean up.
105 /"{o}"/s/"{o}""{o}"/"{o}"/g
106 /"{o}"/s/^"{o}"\([a-zA-Z0-9_]*\)=/\1=/
107
108 # Change extension of libs.
109 /\.a/s/lib\([a-z]*\)\.a/lib\1.o/g
110
111 # Remove non-fail option.
112 /-/s/^\([ ]*\)-/\1/
113 # Fix overeagernesses - assumes no one-letter commands.
114 /^[ ]*[a-z] /s/^\([ ]*\)\([a-z]\) /\1-\2 /
115
116 # Remove non-echo option. (watch out for autoconf things)
117 /@/s/^\([ ]*\)@/\1/
118
119 # Change cp to Duplicate.
120 # Catenate is perhaps more accurate, but the pattern would have to
121 # identify the output file and add a '>' redirection into it.
122 /cp/s/^\([ ]*\)cp /\1Duplicate -d -y /
123 # Change mv to Rename.
124 /mv/s/^\([ ]*\)mv /\1Rename -y /
125 /Rename/s/^\([ ]*\)Rename -y -f/\1Rename -y/
126 # Change rm to Delete.
127 /rm -rf/s/^\([ ]*\)rm -rf /\1Delete -i -y /
128 /rm -f/s/^\([ ]*\)rm -f /\1Delete -i -y /
129 /rm/s/^\([ ]*\)rm /\1Delete -i -y /
130 # Note that we don't mess with ln - directory-specific scripts
131 # must decide what to do with symlinks.
132 # Change cat to Catenate.
133 /cat/s/^\([ ]*\)cat /\1Catenate /
134 # Change touch to mpw-touch.
135 /touch/s/^\([ ]*\)touch /\1mpw-touch /
136 # Change mkdir to NewFolder.
137 /mkdir/s/^\([ ]*\)mkdir /\1NewFolder /
138 # Change var setting to Set.
139 /=/s/^\([ ]*\)\([-a-zA-Z0-9_]*\)=\([^;]*\); \\Option-d/\1Set \2 \3/
140
141 # Change tests.
142 /if /s/if \[ *-f \([^ ]*\) ] *; *\\Option-d/If "`Exists "\1"`" != ""/
143 /if /s/if \[ *-f \([^ ]*\) ] *; *then *\\Option-d/If "`Exists "\1"`" != ""/
144 /if /s/if \[ ! *-f \([^ ]*\) ] *; *\\Option-d/If "`Exists "\1"`" == ""/
145 /if /s/if \[ ! *-f \([^ ]*\) ] *; *then \\Option-d/If "`Exists "\1"`" == ""/
146
147 /if /s/if \[ *-d \([^ ]*\) ] *; *\\Option-d/If "`Exists "\1"`" != ""/
148 /if /s/if \[ *-d \([^ ]*\) ] *; *then *\\Option-d/If "`Exists "\1"`" != ""/
149 /if /s/if \[ ! *-d \([^ ]*\) ] *; *\\Option-d/If "`Exists "\1"`" == ""/
150 /if /s/if \[ ! *-d \([^ ]*\) ] *; *then *\\Option-d/If "`Exists "\1"`" == ""/
151
152 /if /s/if \[ -d \([^ ]*\) ] *; then true *; else mkdir \([^ ;]*\) *; fi/If "`Exists "\1"`" != "" NewFolder \2 End If/
153
154 /if /s/if \[ \([^ ]*\) = \([^ ]*\) ] *; *\\Option-d/If "\1" == "\2"/
155 /if /s/if \[ \([^ ]*\) = \([^ ]*\) ] *; *then *\\Option-d/If "\1" == "\2"/
156
157 /if /s/if \[ \([^ ]*\) != \([^ ]*\) ] *; *\\Option-d/If "\1" != "\2"/
158 /if /s/if \[ \([^ ]*\) != \([^ ]*\) ] *; *then *\\Option-d/If "\1" != "\2"/
159
160 /if /s/if \[ \([^ ]*\) -eq \([^ ]*\) ] *; *\\Option-d/If "\1" != "\2"/
161 /if /s/if \[ \([^ ]*\) -eq \([^ ]*\) ] *; *then *\\Option-d/If "\1" != "\2"/
162
163 /^[ ]*else true$/c\
164 Else\
165 mpw-true\
166
167
168 /else/s/^\([ ]*\)else[ ]*$/\1Else/
169 /else/s/^\([ ]*\)else[; ]*\\Option-d$/\1Else/
170
171 /^[ ]*else[ ]*true[ ]*$/c\
172 Else\
173 mpw-true
174
175 /^[ ]*else[ ]*true[; ]*fi$/c\
176 Else\
177 mpw-true\
178 End If
179
180 /fi/s/^\([ ]*\)fi *$/\1End/
181 /fi/s/^\([ ]*\)fi *; *\\Option-d/\1End/
182
183 # Change looping.
184 /for/s/^\([ ]*\)for \([-a-zA-Z0-9_]*\) in \([^;]*\); *do *\\Option-d/\1For \2 In \3/
185 /^\([ ]*\)do *\\Option-d/d
186 /done/s/^\([ ]*\)done *; *\\Option-d/\1End/
187 /done/s/^\([ ]*\)done$/\1End/
188
189 # Trailing semicolons and continued lines are unneeded sh syntax.
190 /; \\Option-d/s/; \\Option-d//
191
192 # Change move-if-change to MoveIfChange.
193 /move-if-change/s/\([^ ]*\)move-if-change/MoveIfChange/g
194
195 # Change $(SHELL) to the script name by itself.
196 /SHELL/s/^\([ ]*\){SHELL} /\1/
197
198 # Change syntax of default rule dependency.
199 /^\.c\.o/s/^\.c\.o \\Option-f$/.c.o \\Option-f .c/
200
201 # Change default rule's action.
202 /{CC} -c/s/{CC} -c \(.*\) \$<$/{CC} @DASH_C_FLAG@ {DepDir}{Default}.c \1 @SEGMENT_FLAG({Default})@ -o {TargDir}{Default}.c.o/
203
204 # This is pretty disgusting, but I can't seem to detect empty rules.
205 /Option-f$/s/Option-f$/Option-f _oldest/g
206
207 # Remove -c from explicit compiler calls. (but should not if GCC)
208 # Handle the case of a source file that is "{xxx}"file.c.
209 / -c /s/{\([A-Z_]*\)CC}\(.*\) -c \(.*\)"\([^"]*\)"\([-a-z_]*\)\.c/{\1CC}\2 @DASH_C_FLAG@ \3"\4"\5.c -o "{o}"\5.c.o/
210 # Handle the case of a source file that is "{xxx}"dir:file.c.
211 / -c /s/{\([A-Z_]*\)CC}\(.*\) -c \(.*\)"\([^"]*\)"\([-a-z_]*\):\([-a-z_]*\)\.c/{\1CC}\2 @DASH_C_FLAG@ \3"\4"\5:\6.c -o "{o}"\6.c.o/
212
213 # Change linking cc to linking sequence.
214 /-o/s/^\([ ]*\){CC} \(.*\){\([A-Z_]*\)CFLAGS} \(.*\){LDFLAGS} \(.*\)-o \([^ ]*\) \(.*\)$/\1{CC_LD} \2 {\3CFLAGS} \4 {LDFLAGS} \5 -o \6{PROG_EXT} \7\
215 \1{MAKEPEF} \6{PROG_EXT} -o \6 {MAKEPEF_TOOL_FLAGS} {MAKEPEF_FLAGS}\
216 \1{REZ} "{s}"\6.r -o \6 -append -d PROG_NAME='"'\6'"' -d VERSION_STRING='"'{version}'"'/
217 /-o/s/^\([ ]*\){CC} \(.*\){\([A-Z_]*\)CFLAGS} \(.*\)-o \([^ ]*\) \(.*\){LDFLAGS} \(.*\)$/\1{CC_LD} \2 {\3CFLAGS} \4 {LDFLAGS} \6 -o \5{PROG_EXT} \7\
218 \1{MAKEPEF} \5{PROG_EXT} -o \5 {MAKEPEF_TOOL_FLAGS} {MAKEPEF_FLAGS}\
219 \1{REZ} "{s}"\5.r -o \5 -append -d PROG_NAME='"'\5'"' -d VERSION_STRING='"'{version}'"'/
220 /-o/s/^\([ ]*\){HOST_CC} \(.*\)-o \([^ ]*\) \(.*\)$/\1{HOST_CC_LD} \2 -o \3{PROG_EXT} \4\
221 \1{MAKEPEF} \3{PROG_EXT} -o \3 {MAKEPEF_TOOL_FLAGS} {MAKEPEF_FLAGS}\
222 \1{REZ} "{s}"\3.r -o \3 -append -d PROG_NAME='"'\3'"' -d VERSION_STRING='"'{version}'"'/
223
224 # Comment out .NOEXPORT rules.
225 /\.NOEXPORT/s/^\.NOEXPORT/#\.NOEXPORT/
226 # Comment out .PHONY rules.
227 /\.PHONY/s/^\.PHONY/#\.PHONY/
228 # Comment out .PRECIOUS rules.
229 /\.PRECIOUS/s/^\.PRECIOUS/#\.PRECIOUS/
230 # Comment out .SUFFIXES rules.
231 /\.SUFFIXES/s/^\.SUFFIXES/#\.SUFFIXES/
232
233 # Set the install program appropriately.
234 /INSTALL/s/^INSTALL *= *`.*`:install.sh -c/INSTALL = Duplicate -y/
235
236 # Don't try to decide whether to use the tree's own tools.
237 /bison/s/`.*bison:bison.*`/bison -y/
238 /byacc/s/`.*byacc:byacc.*`/byacc/
239 /flex/s/`.*flex:flex.*`/flex/
240
241 # Turn transformed C comments in echo commands back into comments.
242 /echo/s,echo '\(.*\):\\Option-x\(.*\)\\Option-x:\(.*\)',echo '\1/*\2*/\3',
243
244 # Whack out various clever expressions that search for tools, since
245 # the clever code is too /bin/sh specific.
246
247 /^AR_FOR_TARGET = `/,/`$/c\
248 AR_FOR_TARGET = ::binutils:ar\
249
250
251 /^RANLIB_FOR_TARGET = `/,/`$/c\
252 RANLIB_FOR_TARGET = ::binutils:ranlib\
253
254
255 /^RANLIB_TEST_FOR_TARGET = /,/ranlib ] )$/c\
256 RANLIB_TEST_FOR_TARGET = \
257
258
259 /^EXPECT = `/,/`$/c\
260 EXPECT = \
261
262
263 /^RUNTEST = `/,/`$/c\
264 RUNTEST = \
265
266
267 /^CC_FOR_TARGET = `/,/`$/c\
268 CC_FOR_TARGET = \
269
270
271 /^CXX_FOR_TARGET = `/,/`$/c\
272 CXX_FOR_TARGET = \
273
274
275 /^CHILL_FOR_TARGET = `/,/`$/c\
276 CHILL_FOR_TARGET = \
277
278
279 /^CHILL_LIB = `/,/`$/c\
280 CHILL_LIB = \
281
282 /sanit/s/{start-sanit...-[a-z0-9]*}//
283 /sanit/s/{end-sanit...-[a-z0-9]*}//
284
285 # Add standard defines and default rules.
286 /^# srcdir/a\
287 \
288 s = "{srcdir}"\
289 \
290 o = :\
291 \
292 "{o}" \\Option-f : "{s}"
293
This page took 0.035876 seconds and 4 git commands to generate.