2 # Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 ### This script must NOT use any 8-bit chars!
22 # This is an MPW Shell script that sets everything up for compilation,
23 # mainly creating directories, and editing copies of files.
25 Set savedir "`Directory`"
31 Set srcroot "--------"
37 Set prefix "{MPW}":GNUTools:
43 Set host_alias "m68k-apple-mpw"
45 Set target_alias {host_alias}
59 Set disable_options ""
68 Else If "{1}" =~ /--bindir/
71 Else If "{1}" =~ /--disable-?+/
72 Set `Echo {1} | sed -e 's/--disable-/enable_/'` no
73 Set disable_options "{disable_options} '{1}'"
74 Else If "{1}" =~ /--enable-?+/
75 Set `Echo {1} | sed -e 's/--enable-/enable_/'` yes
76 Set enable_options "{enable_options} '{1}'"
77 Else If "{1}" =~ /--exec-prefix/
80 Else If "{1}" =~ /--help/
82 Else If "{1}" =~ /--host/
85 Else If "{1}" =~ /--norecursion/
87 Else If "{1}" =~ /--prefix/
90 Else If "{1}" =~ /--srcdir/
93 Else If "{1}" =~ /--srcroot/
96 Else If "{1}" =~ /--target/
97 Set target_alias "{2}"
102 Else If "{1}" =~ /--with-gnu-ld/
105 Echo -n 'mpw-configure: Unrecognized option: "'
107 Echo '"; use --help for usage.'
114 Echo "Usage: mpw-configure [OPTIONS]"
116 Echo "Options: [defaults in brackets]"
117 Echo "--bindir DIR directory for binaries []"
118 Echo "--cc CC use C compiler CC [mpwc]"
119 Echo "--disable-FOO do not include feature FOO"
120 Echo "--enable-FOO include feature FOO"
121 Echo "--exec-prefix DIR install host-dependent files into DIR []"
122 Echo "--help print this message"
123 Echo "--host HOST configure for HOST [m68k-apple-mpw]"
124 Echo "--norecursion configure this directory only [recurse]"
125 Echo "--prefix DIR install into DIR [{MPW}:GNUTools:]"
126 Echo "--srcdir DIR find the sources in DIR [:]"
127 Echo "--srcroot DIR find the toplevel sources in DIR [:]"
128 Echo "--target TARGET configure for TARGET [TARGET=HOST]"
130 Echo "--with-gnu-ld link using GNU ld [no]"
136 # Default exec_prefix from prefix.
138 If "{exec_prefix}" == ""
139 Set exec_prefix "{prefix}"
143 Set bindir "{prefix}"bin:
146 # Point to the correct set of tools to use with the chosen compiler.
148 If "{host_cc}" =~ /mpwc/
149 Set host_alias "m68k-apple-mpw"
150 Set cc_name '{CC_MPW_C}'
151 Set segment_flag '-s '
152 Set ar_name '{AR_LIB}'
153 Set ranlib_name '{RANLIB_NULL}'
154 Set cc_ld_name '{CC_LD_LINK}'
155 Set prog_ext_name '{PROG_EXT_68K}'
156 Set extralibs_name '{EXTRALIBS_C}'
157 Set makepef_name '{MAKEPEF_NULL}'
158 Set rez_name '{REZ_68K}'
159 Else If "{host_cc}" =~ /sc68k/
160 Set host_alias "m68k-apple-mpw"
161 Set cc_name '{CC_SC}'
162 Set segment_flag '-s '
163 Set ar_name '{AR_LIB}'
164 Set ranlib_name '{RANLIB_NULL}'
165 Set cc_ld_name '{CC_LD_LINK}'
166 Set prog_ext_name '{PROG_EXT_68K}'
167 Set extralibs_name '{EXTRALIBS_C}'
168 Set makepef_name '{MAKEPEF_NULL}'
169 Set rez_name '{REZ_68K}'
170 Else If "{host_cc}" =~ /mwc68k/
171 Set host_alias "m68k-apple-mpw"
172 Set cc_name '{CC_MWC68K}'
173 Set segment_flag '-s '
174 Set ar_name '{AR_MWLINK68K}'
175 Set ranlib_name '{RANLIB_NULL}'
176 Set cc_ld_name '{CC_LD_MWLINK68K}'
177 Set prog_ext_name '{PROG_EXT_68K}'
178 Set extralibs_name '{EXTRALIBS_MWC68K}'
179 Set makepef_name '{MAKEPEF_NULL}'
180 Set rez_name '{REZ_68K}'
181 Else If "{host_cc}" =~ /gcc68k/
182 Set host_alias "m68k-apple-mpw"
183 Set cc_name '{CC_68K_GCC}'
184 Set segment_flag '-s '
185 Set ar_name '{AR_68K_AR}'
186 Set ranlib_name '{RANLIB_RANLIB}'
187 Set cc_ld_name '{CC_68K_GCC}'
188 Set prog_ext_name '{PROG_EXT_68K}'
189 Set extralibs_name '{EXTRALIBS_C}'
190 Set makepef_name '{MAKEPEF_NULL}'
191 Set rez_name '{REZ_68K}'
192 Else If "{host_cc}" =~ /ppcc/
193 Set host_alias "powerpc-apple-mpw"
194 Set cc_name '{CC_PPCC}'
195 Set segment_flag '-d ___s_e_g___='
196 Set ar_name '{AR_PPCLINK}'
197 Set ranlib_name '{RANLIB_NULL}'
198 Set cc_ld_name '{CC_LD_PPCLINK}'
199 Set prog_ext_name '{PROG_EXT_XCOFF}'
200 Set extralibs_name '{EXTRALIBS_PPC}'
201 Set makepef_name '{MAKEPEF_PPC}'
202 Set rez_name '{REZ_PPC}'
203 Else If "{host_cc}" =~ /mrc/
204 Set host_alias "powerpc-apple-mpw"
205 Set cc_name '{CC_MRC}'
206 Set segment_flag '-d ___s_e_g___='
207 Set ar_name '{AR_PPCLINK}'
208 Set ranlib_name '{RANLIB_NULL}'
209 Set cc_ld_name '{CC_LD_PPCLINK}'
210 Set prog_ext_name '{PROG_EXT_XCOFF}'
211 Set extralibs_name '{EXTRALIBS_PPC}'
212 Set makepef_name '{MAKEPEF_PPC}'
213 Set rez_name '{REZ_PPC}'
214 Else If "{host_cc}" =~ /scppc/
215 Set host_alias "powerpc-apple-mpw"
216 Set cc_name '{CC_SC}'
217 Set segment_flag '-d ___s_e_g___='
218 Set ar_name '{AR_PPCLINK}'
219 Set ranlib_name '{RANLIB_NULL}'
220 Set cc_ld_name '{CC_LD_PPCLINK}'
221 Set prog_ext_name '{PROG_EXT_XCOFF}'
222 Set extralibs_name '{EXTRALIBS_PPC}'
223 Set makepef_name '{MAKEPEF_PPC}'
224 Set rez_name '{REZ_PPC}'
225 Else If "{host_cc}" =~ /mwcppc/
226 Set host_alias "powerpc-apple-mpw"
227 Set cc_name '{CC_MWCPPC}'
228 Set segment_flag '-d ___s_e_g___='
229 Set ar_name '{AR_MWLINKPPC}'
230 Set ranlib_name '{RANLIB_NULL}'
231 Set cc_ld_name '{CC_LD_MWLINKPPC}'
232 # Misleading, but we don't need a PEF step.
233 Set prog_ext_name '{PROG_EXT_68K}'
234 Set extralibs_name '{EXTRALIBS_MWCPPC}'
235 Set makepef_name '{MAKEPEF_NULL}'
236 Set rez_name '{REZ_PPC}'
237 Else If "{host_cc}" =~ /gccppc/
238 Set host_alias "powerpc-apple-mpw"
239 Set cc_name '{CC_PPC_GCC}'
240 Set segment_flag '-d ___s_e_g___='
241 Set ar_name '{AR_PPCLINK}'
242 If {with_gnu_ld} == 1
243 Set ranlib_name '{RANLIB_RANLIB}'
244 Set cc_ld_name '{CC_LD_GLD}'
246 Set ranlib_name '{RANLIB_NULL}'
247 Set cc_ld_name '{CC_LD_PPCLINK}'
249 Set prog_ext_name '{PROG_EXT_XCOFF}'
250 Set extralibs_name '{EXTRALIBS_PPC}'
251 Set makepef_name '{MAKEPEF_PPC}'
252 Set rez_name '{REZ_PPC}'
254 Echo "{host_cc}" is not a known MPW compiler type
258 If "{host_cc}" =~ /gcc68k/
260 Else If "{host_cc}" =~ /gccppc/
264 # (should interpret aliases if not in canonical form)
266 Set host_canonical "{host_alias}"
268 Set target_canonical "{target_alias}"
272 If "{srcroot}" =~ /--------/
273 Set srcroot "{srcdir}"
275 If "`Exists "{srcdir}"`" == ""
276 Echo Source directory {srcdir} does not exist!
279 If "`Exists "{srcroot}"`" == ""
280 Echo Top-level source directory {srcroot} does not exist!
284 Set target_cpu "`echo {target_canonical} | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`"
285 Set target_vendor "`echo {target_canonical} | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`"
286 Set target_os "`echo {target_canonical} | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`"
288 # Create a file that is guaranteed to be older than any other here.
290 If "`Exists "{objdir}"_oldest`" == ""
294 # Record this before creating any files, makefiles sometimes mention
295 # dependencies on config.status.
297 Echo "# This directory was configured as follows:" >config.new
298 Echo "{ThisScript} --host {host_alias} --target {target_alias} --srcdir {srcdir} --srcroot {srcroot} --prefix {prefix} --cc {host_cc} {verifystr} {enable_options} {disable_options} --norecursion" >>config.new
299 MoveIfChange config.new config.status
301 If "`Exists "{srcdir}"mpw-config.in`" != ""
302 tr-7to8 "{srcdir}"mpw-config.in >"{objdir}"mpw-config.in
303 Execute "{objdir}"mpw-config.in
306 # Start Makefile construction by defining all the variables chosen by
309 Echo "# This Makefile produced by mpw-configure. Changes may get lost!" > "{objdir}"Makefile.tem
310 Echo "srcroot = " {srcroot} >> "{objdir}"Makefile.tem
311 Echo "topsrcdir = " {srcroot} >> "{objdir}"Makefile.tem
312 Echo "srcdir = " {srcdir} >> "{objdir}"Makefile.tem
313 Echo "mpw_prefix = " {prefix} >> "{objdir}"Makefile.tem
314 Echo "mpw_exec_prefix = " {exec_prefix} >> "{objdir}"Makefile.tem
315 Echo "mpw_bindir = " {bindir} >> "{objdir}"Makefile.tem
316 Echo "host_alias = " {host_alias} >> "{objdir}"Makefile.tem
317 Echo "target_alias = " {target_alias} >> "{objdir}"Makefile.tem
318 Echo "target_cpu = " {target_cpu} >> "{objdir}"Makefile.tem
319 Echo "target_vendor = " {target_vendor} >> "{objdir}"Makefile.tem
320 Echo "target_os = " {target_os} >> "{objdir}"Makefile.tem
321 Echo "target_canonical = " {target_canonical} >> "{objdir}"Makefile.tem
322 Echo "host_makefile_frag = " >> "{objdir}"Makefile.tem
323 Echo "target_makefile_frag = " >> "{objdir}"Makefile.tem
324 Echo "CC = " {cc_name} >> "{objdir}"Makefile.tem
325 Echo "AR = " {ar_name} >> "{objdir}"Makefile.tem
326 Echo "RANLIB = " {ranlib_name} >> "{objdir}"Makefile.tem
327 Echo "CC_LD = " {cc_ld_name} >> "{objdir}"Makefile.tem
328 Echo "PROG_EXT = " {prog_ext_name} >> "{objdir}"Makefile.tem
329 Echo "EXTRALIBS = " {extralibs_name} >> "{objdir}"Makefile.tem
330 Echo "MAKEPEF = " {makepef_name} >> "{objdir}"Makefile.tem
331 Echo "REZ = " {rez_name} >> "{objdir}"Makefile.tem
333 If {host_cc} =~ /gccppc/
334 Echo -n "dq =\Option-d\Option-d\Option-d" > "{objdir}"Makefile.tem0
335 Echo '"' >> "{objdir}"Makefile.tem0
336 tr-7to8 "{objdir}"Makefile.tem0 >>"{objdir}"Makefile.tem
338 Echo -n "dq ='" >> "{objdir}"Makefile.tem
339 Echo -n '"' >> "{objdir}"Makefile.tem
340 Echo "'" >> "{objdir}"Makefile.tem
343 # Append the master set of definitions for the various compilers.
345 If "`Exists "{srcdir}"config:mpw-mh-mpw`" != ""
346 tr-7to8 "{srcdir}"config:mpw-mh-mpw >>"{objdir}"Makefile.tem
347 Else If "`Exists "{srcroot}"config:mpw-mh-mpw`" != ""
348 tr-7to8 "{srcroot}"config:mpw-mh-mpw >>"{objdir}"Makefile.tem
350 Echo "can't find a host config file!"
354 # Append anything produced by the directory's mpw-config.in.
356 If "`Exists "{objdir}"mk.tmp`" != ""
357 Catenate "{objdir}"mk.tmp >>"{objdir}"Makefile.tem
358 # An mpw-config.in might change so as not to create this
359 # anymore, so get rid of it now to be safe.
360 Delete -i -y "{objdir}"mk.tmp
363 # If there are sed scripts to edit the Unix Makefile.in, use them; otherwise
364 # use an mpw-make.in if present.
366 If "`Exists "{srcdir}"mpw-make.sed`" != ""
367 If "`Exists "{objdir}"hacked_Makefile.in`" != ""
368 Set MakefileIn "{objdir}"hacked_Makefile.in
370 Set MakefileIn "{srcdir}"Makefile.in
372 # Find the generic makefile editing script.
373 If "`Exists "{srcroot}"config:mpw:g-mpw-make.sed`" != ""
374 sed -f "{srcroot}"config:mpw:g-mpw-make.sed "{MakefileIn}" >"{objdir}"Makefile.tem1
375 Else If "`Exists "{srcroot}"utils:mpw:g-mpw-make.sed`" != ""
376 sed -f "{srcroot}"utils:mpw:g-mpw-make.sed "{MakefileIn}" >"{objdir}"Makefile.tem1
377 Else If "`Exists "{srcdir}"g-mpw-make.sed`" != ""
378 sed -f "{srcdir}"g-mpw-make.sed "{MakefileIn}" >"{objdir}"Makefile.tem1
380 Echo Warning: g-mpw-make.sed not found, copying "{MakefileIn}" verbatim...
381 Catenate "{MakefileIn}" >"{objdir}"Makefile.tem1
383 sed -f "{srcdir}"mpw-make.sed "{objdir}"Makefile.tem1 >"{objdir}"Makefile.tem2
384 sed -e 's/^prefix = .*$/prefix = {mpw_prefix}/g' -e 's/^exec_prefix = .*$/exec_prefix = {mpw_exec_prefix}/g' -e 's/^bindir = @bindir@/bindir = {mpw_bindir}/g' "{objdir}"Makefile.tem2 >"{objdir}"Makefile.tem3
385 sed -e "s/@DASH_C_FLAG@/{dash_c_flag}/" -e "s/@SEGMENT_FLAG(\([^)]*\))@/{segment_flag}\1/" "{objdir}"Makefile.tem3 >"{objdir}"mpw-make.in
386 tr-7to8 "{objdir}"mpw-make.in >>"{objdir}"Makefile.tem
387 If "`Exists "{objdir}"mk.sed`" != ""
388 sed -f "{objdir}"mk.sed "{objdir}"Makefile.tem >"{objdir}"Makefile.tem2
389 Rename -y "{objdir}"Makefile.tem2 "{objdir}"Makefile.tem
391 MoveIfChange "{objdir}"Makefile.tem "{objdir}"Makefile
392 Delete -i -y "{objdir}"Makefile.tem[12]
394 Echo Created Makefile in "`Directory`"
396 Else If "`Exists "{srcdir}"mpw-make.in`" != ""
397 sed -e 's/^prefix = .*$/prefix = {mpw_prefix}/g' "{srcdir}"mpw-make.in >"{objdir}"Makefile.tem1
398 sed -e "s/@DASH_C_FLAG@/{dash_c_flag}/" -e "s/@SEGMENT_FLAG(\([^)]*\))@/{segment_flag}}\1/" "{objdir}"Makefile.tem1 >"{objdir}"Makefile.tem2
399 tr-7to8 "{objdir}"Makefile.tem2 >>"{objdir}"Makefile.tem
400 If "`Exists "{objdir}"mk.sed`" != ""
401 sed -f "{objdir}"mk.sed "{objdir}"Makefile.tem >"{objdir}"Makefile.tem2
402 Rename -y "{objdir}"Makefile.tem2 "{objdir}"Makefile.tem
404 MoveIfChange "{objdir}"Makefile.tem "{objdir}"Makefile
405 Delete -i -y "{objdir}"Makefile.tem[12]
407 Echo Created Makefile in "`Directory`"
411 # Produce a build script if the source is defined.
413 If "`Exists "{srcdir}"mpw-build.in`" != ""
414 Echo "Set srcroot " {srcroot} > "{objdir}"mpw-build.tem
415 Echo "Set srcdir " {srcdir} >> "{objdir}"mpw-build.tem
416 Echo "Set target_canonical " {target_canonical} >> "{objdir}"mpw-build.tem
417 Echo "Set prefix " {prefix} >> "{objdir}"mpw-build.tem
418 tr-7to8 "{srcdir}"mpw-build.in >>"{objdir}"mpw-build.tem
419 MoveIfChange "{objdir}"mpw-build.tem "{objdir}"mpw-build
421 Echo Created mpw-build in "`Directory`"
425 # Apply ourselves recursively to the list of subdirectories to configure.
428 For subdir In {configdirs}
429 Set savedir "`Directory`"
430 If "`Exists "{srcdir}{subdir}:"`" == ""
432 Echo No "{srcdir}{subdir}:" found, skipping
437 Echo Configuring {subdir}...
439 If "`Exists "{objdir}{subdir}:"`" == ""
440 NewFolder "{objdir}{subdir}"
442 SetDirectory "{objdir}{subdir}:"
443 "{ThisScript}" --target "{target_canonical}" --srcdir "{srcdir}{subdir}:" --srcroot "{srcroot}" --prefix "{prefix}" --cc "{host_cc}" {verifystr} {enable_options} {disable_options}
444 SetDirectory "{savedir}"
448 SetDirectory "{savedir}"