| 1 | # Configuration script |
| 2 | # Copyright (C) 1994, 1995 Free Software Foundation, Inc. |
| 3 | |
| 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. |
| 8 | # |
| 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. |
| 13 | # |
| 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. |
| 17 | |
| 18 | ### WARNING |
| 19 | ### This script (and mpw-config.in fragments) must NOT use any 8-bit chars! |
| 20 | ### WARNING |
| 21 | |
| 22 | # This is an MPW Shell script that sets everything up for compilation, |
| 23 | # mainly creating directories, and editing copies of files. |
| 24 | |
| 25 | Set savedir "`Directory`" |
| 26 | |
| 27 | #Set Echo 1 |
| 28 | |
| 29 | Set ThisScript "{0}" |
| 30 | |
| 31 | Set srcroot "--------" |
| 32 | |
| 33 | Set srcdir ":" |
| 34 | |
| 35 | Set objdir ":" |
| 36 | |
| 37 | Set prefix "{MPW}":GNUTools: |
| 38 | |
| 39 | Set exec_prefix "" |
| 40 | |
| 41 | Set host_alias "m68k-apple-mpw" |
| 42 | |
| 43 | Set target_alias {host_alias} |
| 44 | |
| 45 | Set host_cc "mpwc" |
| 46 | |
| 47 | Set with_gnu_ld 0 |
| 48 | |
| 49 | Set verify 0 |
| 50 | Set verifystr "" |
| 51 | |
| 52 | # Parse arguments. |
| 53 | |
| 54 | Loop |
| 55 | Break If {#} == 0 |
| 56 | If "{1}" =~ /--cc/ |
| 57 | Set host_cc "{2}" |
| 58 | Shift 1 |
| 59 | Else If "{1}" =~ /--enable/ |
| 60 | Set "{2}" 1 |
| 61 | Shift 1 |
| 62 | Else If "{1}" =~ /--exec-prefix/ |
| 63 | Set exec_prefix "{2}" |
| 64 | Shift 1 |
| 65 | Else If "{1}" =~ /--host/ |
| 66 | Set host_alias "{2}" |
| 67 | Shift 1 |
| 68 | Else If "{1}" =~ /--prefix/ |
| 69 | Set prefix "{2}" |
| 70 | Shift 1 |
| 71 | Else If "{1}" =~ /--srcdir/ |
| 72 | Set srcdir "{2}" |
| 73 | Shift 1 |
| 74 | Else If "{1}" =~ /--srcroot/ |
| 75 | Set srcroot "{2}" |
| 76 | Shift 1 |
| 77 | Else If "{1}" =~ /--target/ |
| 78 | Set target_alias "{2}" |
| 79 | Shift 1 |
| 80 | Else If "{1}" =~ /-v/ |
| 81 | Set verify 1 |
| 82 | Set verifystr "-v" |
| 83 | Else If "{1}" =~ /--with-gnu-ld/ |
| 84 | Set with_gnu_ld 1 |
| 85 | Else |
| 86 | Echo "{1}" is not a valid argument |
| 87 | Exit 1 |
| 88 | End If |
| 89 | Shift 1 |
| 90 | End Loop |
| 91 | |
| 92 | Set Exit 0 |
| 93 | |
| 94 | # Default exec_prefix from prefix. |
| 95 | |
| 96 | If "{exec_prefix}" == "" |
| 97 | Set exec_prefix "{prefix}" |
| 98 | End If |
| 99 | |
| 100 | # Point to the correct set of tools to use with the chosen compiler. |
| 101 | |
| 102 | If "{host_cc}" =~ /mpwc/ |
| 103 | Set host_alias "m68k-apple-mpw" |
| 104 | Set cc_name '{CC_MPW_C}' |
| 105 | Set segment_flag '-s {Default}' |
| 106 | Set ar_name '{AR_LIB}' |
| 107 | Set ranlib_name '{RANLIB_NULL}' |
| 108 | Set cc_ld_name '{CC_LD_LINK}' |
| 109 | Set prog_ext_name '{PROG_EXT_68K}' |
| 110 | Set extralibs_name '{EXTRALIBS_C}' |
| 111 | Set makepef_name '{MAKEPEF_NULL}' |
| 112 | Set rez_name '{REZ_68K}' |
| 113 | Else If "{host_cc}" =~ /sc68k/ |
| 114 | Set host_alias "m68k-apple-mpw" |
| 115 | Set cc_name '{CC_SC}' |
| 116 | Set segment_flag '-s {Default}' |
| 117 | Set ar_name '{AR_LIB}' |
| 118 | Set ranlib_name '{RANLIB_NULL}' |
| 119 | Set cc_ld_name '{CC_LD_LINK}' |
| 120 | Set prog_ext_name '{PROG_EXT_68K}' |
| 121 | Set extralibs_name '{EXTRALIBS_C}' |
| 122 | Set makepef_name '{MAKEPEF_NULL}' |
| 123 | Set rez_name '{REZ_68K}' |
| 124 | Else If "{host_cc}" =~ /mwc68k/ |
| 125 | Set host_alias "m68k-apple-mpw" |
| 126 | Set cc_name '{CC_MWC68K}' |
| 127 | Set segment_flag '-s {Default}' |
| 128 | Set ar_name '{AR_MWLINK68K}' |
| 129 | Set ranlib_name '{RANLIB_NULL}' |
| 130 | Set cc_ld_name '{CC_LD_MWLINK68K}' |
| 131 | Set prog_ext_name '{PROG_EXT_68K}' |
| 132 | Set extralibs_name '{EXTRALIBS_C}' |
| 133 | Set makepef_name '{MAKEPEF_NULL}' |
| 134 | Set rez_name '{REZ_PPC}' |
| 135 | Else If "{host_cc}" =~ /gcc68k/ |
| 136 | Set host_alias "m68k-apple-mpw" |
| 137 | Set cc_name '{CC_68K_GCC}' |
| 138 | Set segment_flag '-s {Default}' |
| 139 | Set ar_name '{AR_68K_AR}' |
| 140 | Set ranlib_name '{RANLIB_RANLIB}' |
| 141 | Set cc_ld_name '{CC_68K_GCC}' |
| 142 | Set prog_ext_name '{PROG_EXT_68K}' |
| 143 | Set extralibs_name '{EXTRALIBS_C}' |
| 144 | Set makepef_name '{MAKEPEF_NULL}' |
| 145 | Set rez_name '{REZ_68K}' |
| 146 | Else If "{host_cc}" =~ /ppcc/ |
| 147 | Set host_alias "powerpc-apple-mpw" |
| 148 | Set cc_name '{CC_PPCC}' |
| 149 | Set segment_flag '' |
| 150 | Set ar_name '{AR_PPCLINK}' |
| 151 | Set ranlib_name '{RANLIB_NULL}' |
| 152 | Set cc_ld_name '{CC_LD_PPCLINK}' |
| 153 | Set prog_ext_name '{PROG_EXT_XCOFF}' |
| 154 | Set extralibs_name '{EXTRALIBS_PPC}' |
| 155 | Set makepef_name '{MAKEPEF_PPC}' |
| 156 | Set rez_name '{REZ_PPC}' |
| 157 | Else If "{host_cc}" =~ /mrc/ |
| 158 | Set host_alias "powerpc-apple-mpw" |
| 159 | Set cc_name '{CC_MRC}' |
| 160 | Set segment_flag '' |
| 161 | Set ar_name '{AR_PPCLINK}' |
| 162 | Set ranlib_name '{RANLIB_NULL}' |
| 163 | Set cc_ld_name '{CC_LD_PPCLINK}' |
| 164 | Set prog_ext_name '{PROG_EXT_XCOFF}' |
| 165 | Set extralibs_name '{EXTRALIBS_PPC}' |
| 166 | Set makepef_name '{MAKEPEF_PPC}' |
| 167 | Set rez_name '{REZ_PPC}' |
| 168 | Else If "{host_cc}" =~ /scppc/ |
| 169 | Set host_alias "powerpc-apple-mpw" |
| 170 | Set cc_name '{CC_SC}' |
| 171 | Set segment_flag '' |
| 172 | Set ar_name '{AR_PPCLINK}' |
| 173 | Set ranlib_name '{RANLIB_NULL}' |
| 174 | Set cc_ld_name '{CC_LD_PPCLINK}' |
| 175 | Set prog_ext_name '{PROG_EXT_XCOFF}' |
| 176 | Set extralibs_name '{EXTRALIBS_PPC}' |
| 177 | Set makepef_name '{MAKEPEF_PPC}' |
| 178 | Set rez_name '{REZ_PPC}' |
| 179 | Else If "{host_cc}" =~ /mwcppc/ |
| 180 | Set host_alias "powerpc-apple-mpw" |
| 181 | Set cc_name '{CC_MWCPPC}' |
| 182 | Set segment_flag '' |
| 183 | Set ar_name '{AR_MWLINKPPC}' |
| 184 | Set ranlib_name '{RANLIB_NULL}' |
| 185 | Set cc_ld_name '{CC_LD_MWLINKPPC}' |
| 186 | # Misleading, but we don't need a PEF step. |
| 187 | Set prog_ext_name '{PROG_EXT_68K}' |
| 188 | Set extralibs_name '{EXTRALIBS_MWCPPC}' |
| 189 | Set makepef_name '{MAKEPEF_NULL}' |
| 190 | Set rez_name '{REZ_PPC}' |
| 191 | Else If "{host_cc}" =~ /gccppc/ |
| 192 | Set host_alias "powerpc-apple-mpw" |
| 193 | Set cc_name '{CC_PPC_GCC}' |
| 194 | Set segment_flag '' |
| 195 | Set ar_name '{AR_PPCLINK}' |
| 196 | Set ranlib_name '{RANLIB_RANLIB}' |
| 197 | If {with_gnu_ld} == 1 |
| 198 | Set cc_ld_name '{CC_LD_GLD}' |
| 199 | Else |
| 200 | Set cc_ld_name '{CC_LD_PPCLINK}' |
| 201 | End If |
| 202 | Set prog_ext_name '{PROG_EXT_XCOFF}' |
| 203 | Set extralibs_name '{EXTRALIBS_PPC}' |
| 204 | Set makepef_name '{MAKEPEF_PPC}' |
| 205 | Set rez_name '{REZ_PPC}' |
| 206 | Else |
| 207 | Echo "{host_cc}" is not a known MPW compiler type |
| 208 | End If |
| 209 | |
| 210 | # (should interpret aliases if not in canonical form) |
| 211 | |
| 212 | Set host_canonical "{host_alias}" |
| 213 | |
| 214 | Set target_canonical "{target_alias}" |
| 215 | |
| 216 | Set configdirs "" |
| 217 | |
| 218 | If "{srcroot}" =~ /--------/ |
| 219 | Set srcroot "{srcdir}" |
| 220 | End If |
| 221 | If "`Exists "{srcdir}"`" == "" |
| 222 | Echo Source directory {srcdir} does not exist! |
| 223 | Exit 1 |
| 224 | End If |
| 225 | If "`Exists "{srcroot}"`" == "" |
| 226 | Echo Top-level source directory {srcroot} does not exist! |
| 227 | Exit 1 |
| 228 | End If |
| 229 | |
| 230 | Set target_cpu "`echo {target_canonical} | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`" |
| 231 | Set target_vendor "`echo {target_canonical} | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`" |
| 232 | Set target_os "`echo {target_canonical} | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`" |
| 233 | |
| 234 | # Create a file that is guaranteed to be older than any other here. |
| 235 | |
| 236 | If "`Exists "{objdir}"_oldest`" == "" |
| 237 | mpw-touch _oldest |
| 238 | End If |
| 239 | |
| 240 | # Record this before creating any files, makefiles sometimes mention |
| 241 | # dependencies on config.status. |
| 242 | |
| 243 | Echo "# This directory was configured as follows:" >config.new |
| 244 | Echo "{ThisScript} --host {host_alias} --target {target_alias} --srcdir {srcdir} --srcroot {srcroot} --prefix {prefix} --cc {host_cc}" >>config.new |
| 245 | MoveIfChange config.new config.status |
| 246 | |
| 247 | If "`Exists "{srcdir}"mpw-config.in`" != "" |
| 248 | tr-7to8 "{srcdir}"mpw-config.in >"{objdir}"mpw-config.in |
| 249 | Execute "{objdir}"mpw-config.in |
| 250 | End If |
| 251 | |
| 252 | # Start Makefile construction by defining all the variables chosen by |
| 253 | # configuration. |
| 254 | |
| 255 | Echo "# This Makefile produced by mpw-configure. Changes may get lost!" > "{objdir}"Makefile.tem |
| 256 | Echo "srcroot = " {srcroot} >> "{objdir}"Makefile.tem |
| 257 | Echo "topsrcdir = " {srcroot} >> "{objdir}"Makefile.tem |
| 258 | Echo "srcdir = " {srcdir} >> "{objdir}"Makefile.tem |
| 259 | Echo "mpw_prefix = " {prefix} >> "{objdir}"Makefile.tem |
| 260 | Echo "mpw_exec_prefix = " {exec_prefix} >> "{objdir}"Makefile.tem |
| 261 | Echo "host_alias = " {host_alias} >> "{objdir}"Makefile.tem |
| 262 | Echo "target_alias = " {target_alias} >> "{objdir}"Makefile.tem |
| 263 | Echo "target_cpu = " {target_cpu} >> "{objdir}"Makefile.tem |
| 264 | Echo "target_vendor = " {target_vendor} >> "{objdir}"Makefile.tem |
| 265 | Echo "target_os = " {target_os} >> "{objdir}"Makefile.tem |
| 266 | Echo "target_canonical = " {target_canonical} >> "{objdir}"Makefile.tem |
| 267 | Echo "host_makefile_frag = " >> "{objdir}"Makefile.tem |
| 268 | Echo "target_makefile_frag = " >> "{objdir}"Makefile.tem |
| 269 | Echo "CC = " {cc_name} >> "{objdir}"Makefile.tem |
| 270 | Echo "AR = " {ar_name} >> "{objdir}"Makefile.tem |
| 271 | Echo "RANLIB = " {ranlib_name} >> "{objdir}"Makefile.tem |
| 272 | Echo "CC_LD = " {cc_ld_name} >> "{objdir}"Makefile.tem |
| 273 | Echo "PROG_EXT = " {prog_ext_name} >> "{objdir}"Makefile.tem |
| 274 | Echo "EXTRALIBS = " {extralibs_name} >> "{objdir}"Makefile.tem |
| 275 | Echo "MAKEPEF = " {makepef_name} >> "{objdir}"Makefile.tem |
| 276 | Echo "REZ = " {rez_name} >> "{objdir}"Makefile.tem |
| 277 | |
| 278 | # Append the master set of definitions for the various compilers. |
| 279 | |
| 280 | If "`Exists "{srcdir}"config:mpw-mh-mpw`" != "" |
| 281 | tr-7to8 "{srcdir}"config:mpw-mh-mpw >>"{objdir}"Makefile.tem |
| 282 | Else If "`Exists "{srcroot}"config:mpw-mh-mpw`" != "" |
| 283 | tr-7to8 "{srcroot}"config:mpw-mh-mpw >>"{objdir}"Makefile.tem |
| 284 | Else |
| 285 | Echo "can't find a host config file!" |
| 286 | Exit 0 |
| 287 | End If |
| 288 | |
| 289 | # Append anything produced by the directory's mpw-config.in. |
| 290 | |
| 291 | If "`Exists "{objdir}"mk.tmp`" != "" |
| 292 | Catenate "{objdir}"mk.tmp >>"{objdir}"Makefile.tem |
| 293 | # An mpw-config.in might change so as not to create this |
| 294 | # anymore, so get rid of it now to be safe. |
| 295 | Delete -i -y "{objdir}"mk.tmp |
| 296 | End If |
| 297 | |
| 298 | # If there are sed scripts to edit the Unix Makefile.in, use them; otherwise |
| 299 | # use an mpw-make.in if present. |
| 300 | |
| 301 | If "`Exists "{srcdir}"mpw-make.sed`" != "" |
| 302 | If "`Exists "{objdir}"hacked_Makefile.in`" != "" |
| 303 | Set MakefileIn "{objdir}"hacked_Makefile.in |
| 304 | Else |
| 305 | Set MakefileIn "{srcdir}"Makefile.in |
| 306 | End If |
| 307 | If "`Exists "{srcroot}"utils:mpw:g-mpw-make.sed`" != "" |
| 308 | sed -f "{srcroot}"utils:mpw:g-mpw-make.sed "{MakefileIn}" >"{objdir}"Makefile.tem1 |
| 309 | Else |
| 310 | Catenate "{MakefileIn}" >"{objdir}"Makefile.tem1 |
| 311 | End If |
| 312 | sed -f "{srcdir}"mpw-make.sed "{objdir}"Makefile.tem1 >"{objdir}"Makefile.tem2 |
| 313 | sed -e 's/^prefix = .*$/prefix = {mpw_prefix}/g' -e 's/^exec_prefix = .*$/exec_prefix = {mpw_exec_prefix}/g' "{objdir}"Makefile.tem2 >"{objdir}"Makefile.tem3 |
| 314 | sed -e "s/@SEGMENT_FLAG@/{segment_flag}/" "{objdir}"Makefile.tem3 >"{objdir}"mpw-make.in |
| 315 | tr-7to8 "{objdir}"mpw-make.in >>"{objdir}"Makefile.tem |
| 316 | MoveIfChange "{objdir}"Makefile.tem "{objdir}"Makefile |
| 317 | Delete -i -y "{objdir}"Makefile.tem[12] |
| 318 | If {verify} == 1 |
| 319 | Echo Created Makefile in "`Directory`" |
| 320 | End If |
| 321 | Else If "`Exists "{srcdir}"mpw-make.in`" != "" |
| 322 | sed -e 's/^prefix = .*$/prefix = {mpw_prefix}/g' "{srcdir}"mpw-make.in >"{objdir}"Makefile.tem1 |
| 323 | sed -e "s/@SEGMENT_FLAG@/{segment_flag}/" "{objdir}"Makefile.tem1 >"{objdir}"Makefile.tem2 |
| 324 | tr-7to8 "{objdir}"Makefile.tem2 >>"{objdir}"Makefile.tem |
| 325 | MoveIfChange "{objdir}"Makefile.tem "{objdir}"Makefile |
| 326 | Delete -i -y "{objdir}"Makefile.tem[12] |
| 327 | If {verify} == 1 |
| 328 | Echo Created Makefile in "`Directory`" |
| 329 | End If |
| 330 | End If |
| 331 | |
| 332 | # Produce a build script if the source is defined. |
| 333 | |
| 334 | If "`Exists "{srcdir}"mpw-build.in`" != "" |
| 335 | Echo "Set srcroot " {srcroot} > "{objdir}"mpw-build.tem |
| 336 | Echo "Set srcdir " {srcdir} >> "{objdir}"mpw-build.tem |
| 337 | Echo "Set target_canonical " {target_canonical} >> "{objdir}"mpw-build.tem |
| 338 | Echo "Set prefix " {prefix} >> "{objdir}"mpw-build.tem |
| 339 | tr-7to8 "{srcdir}"mpw-build.in >>"{objdir}"mpw-build.tem |
| 340 | MoveIfChange "{objdir}"mpw-build.tem "{objdir}"mpw-build |
| 341 | If {verify} == 1 |
| 342 | Echo Created mpw-build in "`Directory`" |
| 343 | End If |
| 344 | End If |
| 345 | |
| 346 | For subdir In {configdirs} |
| 347 | Set savedir "`Directory`" |
| 348 | If "`Exists "{srcdir}{subdir}:"`" == "" |
| 349 | Echo Strange, no {subdir} in {srcdir} |
| 350 | Continue |
| 351 | End If |
| 352 | If {verify} == 1 |
| 353 | Echo Configuring {subdir}... |
| 354 | End If |
| 355 | If "`Exists "{objdir}{subdir}:"`" == "" |
| 356 | NewFolder "{objdir}{subdir}" |
| 357 | End If |
| 358 | SetDirectory "{objdir}{subdir}:" |
| 359 | "{ThisScript}" --target "{target_canonical}" --srcdir "{srcdir}{subdir}:" --srcroot "{srcroot}" --prefix "{prefix}" --cc "{host_cc}" {verifystr} |
| 360 | SetDirectory "{savedir}" |
| 361 | End For |
| 362 | |
| 363 | SetDirectory "{savedir}" |