home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / libg++-2.7.1-base.tgz / libg++-2.7.1-src.tar / fsf / libg++ / mpw-configure < prev    next >
Text File  |  1995-10-27  |  11KB  |  343 lines

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