home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / sofa / install < prev    next >
Text File  |  1999-10-10  |  18KB  |  562 lines

  1. ; $VER: install 1.4 (10.10.99)
  2. ;
  3. ; An Amiga Installer script for Sofa.
  4. ;
  5. ; Written by Thomas Aglassinger <agi@sbox.tu-graz.ac.at>
  6. ; Placed  in the public domain.
  7. ;
  8. ; NOTE: Start Installer from CLI with "APPNAME debug" to skip the stuff
  9. ;       that copies the files and modifies the s:User-Startup.
  10.  
  11. ;----------------------------------------------------------------------------
  12. ; Specify minimum installer version
  13. ;----------------------------------------------------------------------------
  14. (debug "set version")
  15. (set #minimum-installer-version 43)
  16. (set #minimum-installer-revision 3)
  17. (set #minimum-installer-id
  18.    (+ #minimum-installer-revision
  19.        (* #minimum-installer-version 65536)
  20.    )
  21. )
  22. (debug "  minimum-installer-id = " #minimum-installer-id)
  23. (debug "  current-installer-id = " @installer-version)
  24.  
  25. ;----------------------------------------------------------------------------
  26. ; Setup messages, prompts and help text
  27. ;----------------------------------------------------------------------------
  28. (set #message-wrong-installer
  29. (cat "You have an old version of the program `Installer' on your Amiga.\n\n"
  30.      "The installation procedure needs at least Installer "
  31.      #minimum-installer-version "." #minimum-installer-revision ".\n\n"
  32.      "Obtain a newer version and try again.\n\n"
  33.      "(Check Aminet or the WWW site of the current owner of the rights for "
  34.      "Amiga - whoever that might be right now.)"
  35. ))
  36.  
  37. (set #message-welcome
  38. (cat "Welcome to the Amiga Installer for Sofa\n\n"
  39.      "This installs the Sofa distribution of the SmallEiffel compiler "
  40.      "on your Amiga."
  41.      ;"\n\n"
  42.      ;"It lets you choose you preferred C compiler to create native code, "
  43.      ;"copies all required files (if you choose a target directory different "
  44.      ;"from the current one), adds a few lines to your User-Startup and "
  45.      ;"setups the files in the Sofa/SmallEiffel/sys directory."
  46. ))
  47.  
  48. (set #message-welcome-change-compiler
  49. (cat "Welcome to the Amiga Installer for Sofa\n\n"
  50.      "This lets you choose a different C compiler when creating "
  51.      "native code."
  52. ))
  53.  
  54. (set #message-exit
  55. (cat "\nSofa has been installed.\n\n"
  56.      "Please reboot before using it."
  57. ))
  58.  
  59. (set #message-exit-change-compiler
  60. (cat "\nThe C compiler for Sofa has been changed. It will be used "
  61.      "the next time you invoke the \"compile\" command."
  62. ))
  63.  
  64. (set #prompt-ask-sofa-directory
  65. (cat "Select where to install Sofa.\n"
  66.      "A directory named \"sofa\" is created automatically"
  67. ))
  68.  
  69. (set #prompt-ask-c-compiler
  70. (cat "Select C compiler to be used by Sofa"
  71. ))
  72.  
  73. (set #help-ask-c-compiler
  74. (cat "Sofa does not compile to Amiga native code directly but rather "
  75.      "translates a Eiffel source into a C source. To actually create an "
  76.      "executable, you need a C compiler.\n\n"
  77.      "The following compilers are known to work with Sofa:\n\n"
  78.      "· SAS/c - commercial but meanwhile abandoned by SAS Institute; "
  79.        "if you don't own it by now, you probably won't get it anywhere.\n"
  80.      "· EGCS/GCC - the freely distributable GNU C/C++ compiler; "
  81.        "stable, efficient code but horribly slow.\n"
  82.      ;"· DICE - former commercial but meanwhile freely distributable; "
  83.      ;  "does not even support ANSI C, but is good enough for Sofa "
  84.      ;  "and very fast.\n"
  85.      "· Other - none of the above; you have to specify it manually as "
  86.        "described in the documentation.\n"
  87.      "\n"
  88.      "Naturally, the compiler selected has to be installed and within "
  89.      "the Workbench search path.\n\n"
  90. ))
  91.  
  92. (set #prompt-update-user-startup
  93. (cat "The following lines are added to the s:User-Startup:\n\n"
  94. ))
  95.  
  96. (set #help-update-user-startup
  97. (cat "These lines are necessary for Sofa to find its classes.\n\n"
  98.      "You can however skip this part and perform it manually later on "
  99.      "according to the documentation."
  100. ))
  101.  
  102. (set #prompt-copy-support-files "Copy additional documentation")
  103. (set #help-copy-support-files
  104. (cat "These files are not needed to run Sofa. Still they contain documentation "
  105.      "you might find useful."
  106. ))
  107.  
  108. (set #working-user-startup "Updating user-startup")
  109. (set #working-set-smalleiffel "Updating SmallEiffel settings")
  110. (set #working-extract-archive "Extracting \"%s\"\n(%s)\n\nThis may take a while.")
  111.  
  112. (set #message-manual-compiler-setup
  113. (cat "As you did not specify a certain compiler, you have to perform some "
  114.      "steps manually.\n\n"
  115.      "In particular, the files \"compiler.Amiga\" and \"linker.Amiga\" "
  116.      "have to be set. Refer to \"man/system.txt\" in the SmallEiffel "
  117.      "directory for more information."
  118. ))
  119.  
  120. (set #message-binaries-missing
  121. (cat "Note that the compiler binaries are available in a different "
  122.      "archive depending on your CPU. You can obtain them from Aminet, "
  123.      "look out for a file dev/lang/sofa*.lha with \"*\" "
  124.      "indicating your CPU.\n\n"
  125.      "Then simply copy the included binaries to \"%s\"."
  126. ))
  127.  
  128. (set #message-extract-failed
  129. (cat "Cannot extract \"%s\".\n\nPlease submit the file \"%s\" to Sofa support."
  130. ))
  131.  
  132.  
  133. ;----------------------------------------------------------------------------
  134. ; Some global constants and defaults
  135. ;----------------------------------------------------------------------------
  136. (set #env-appendix "sys/system.se")
  137.  
  138. (set #compiler-sas-name  "SAS/c")
  139. (set #compiler-sas-id     0)
  140. (set #compiler-gcc-name  "gcc/egcs")
  141. (set #compiler-gcc-id     1)
  142. ;(set #compiler-dice-name "vbcc") ; TODO: Support VBCC
  143. ;(set #compiler-dice-id    2)
  144. ;(set #compiler-dice-name "Dice") ; TODO: Support DICE
  145. ;(set #compiler-dice-id    3)
  146. (set #compiler-other-name "Other")
  147. (set #compiler-other-id   2) ; TODO: Change to 3/4 for VBCC/DICE
  148.  
  149. ;----------------------------------------------------------------------------
  150. ; Check requirements
  151. ;----------------------------------------------------------------------------
  152.  
  153. ; Check installer version to piss people off and make them
  154. ; download a new one or forget about the whole thing - He he he.
  155. ; (The script should work with older versions, but how am I
  156. ; supposed to test this?)
  157.  
  158. (procedure P-check-requirements
  159. (
  160.    (debug "check installer version")
  161.    (if (< @installer-version #minimum-installer-id)
  162.      (
  163.        (debug "installer too old")
  164.        (abort #message-wrong-installer)
  165.      )
  166.    )
  167. ))
  168.  
  169.  
  170. ;----------------------------------------------------------------------------
  171. ; Welcome user
  172. ;----------------------------------------------------------------------------
  173. (procedure P-welcome
  174. (
  175.    (debug "welcome")
  176.    (welcome #message-welcome)
  177. ))
  178.  
  179. (procedure P-welcome-change-compiler
  180. (
  181.    (debug "welcome")
  182.    (welcome #message-welcome-change-compiler)
  183. ))
  184.  
  185. ;----------------------------------------------------------------------------
  186. ; Ask for target directory where to install Sofa
  187. ;----------------------------------------------------------------------------
  188. (procedure P-ask-sofa-directory
  189. (
  190.    (debug "ask-sofa-directory")
  191.  
  192.    (if (exists "sofa:" (noreq))
  193.       (
  194.          ; Update existing installation. Use parent of "Sofa:" as default
  195.          (set #default-sofa-directory "sofa:/")
  196.       )
  197.       (
  198.          ; New installation. Use parent of current directory as default
  199.          (set #default-sofa-directory "/")
  200.       )
  201.    )
  202.  
  203.    (set #default-sofa-directory (expandpath #default-sofa-directory))
  204.  
  205.    (set #sofa-directory
  206.    (askdir
  207.       (prompt #prompt-ask-sofa-directory)
  208.       (default #default-sofa-directory)
  209.       (help @askdir-help)
  210.    ))
  211.  
  212.    ; Compute name of Sofa directory
  213.    (set #sofa-directory (tackon #sofa-directory "sofa"))
  214.    (debug "  #sofa-directory =" #sofa-directory)
  215.  
  216.    ; Compute name of library directory
  217.    (set #library-directory (tackon #sofa-directory "library"))
  218.    (debug "  #library-directory =" #library-directory)
  219.  
  220.    ; Compute name of SmallEiffel's "bin" and "sys" directory
  221.    (set #smalleiffel-directory (tackon #sofa-directory "SmallEiffel"))
  222.    (set #smalleiffel-directory-bin (tackon #smalleiffel-directory "bin"))
  223.    (set #smalleiffel-directory-sys (tackon #smalleiffel-directory "sys"))
  224.    (debug "  #smalleiffel-directory =" #smalleiffel-directory)
  225.  
  226.    ; Set target directory used in standard message during (exit)
  227.    (set @default-dest #sofa-directory)
  228.    (debug " @default-dest =" @default-dest)
  229.  
  230. ))
  231.  
  232. ;----------------------------------------------------------------------------
  233. ; Ask for C compiler to use
  234. ;----------------------------------------------------------------------------
  235. (procedure P-ask-c-compiler
  236. (
  237.    (debug "ask-c-compiler")
  238.  
  239.    ; Figure out default selection of compiler: If DCC: exists, use DICE,
  240.    ; if SC: exists use SAS/c, if ADE: or GG: exists, use EGCS/GCC
  241.    (set #compiler-choice #compiler-other-id)
  242.    (if (exists("sc:" (noreq)))
  243.       (set #compiler-choice #compiler-sas-id)
  244.       (if (exists("dcc:" (noreq)))
  245.          (set #compiler-choice #compiler-other-id) ; TODO: Support DICE
  246.          (if (OR (<> "" (exists("ade:" (noreq))) (<> "" (exists("gg:" (noreq))))))
  247.              (set #compiler-choice #compiler-gcc-id)
  248.          )
  249.       )
  250.    )
  251.  
  252.    (debug "  default compiler: " #compiler-choice)
  253.  
  254.    (set #compiler-dice-name "") ; TODO: Support DICE by removing this line
  255.  
  256.    (set #compiler-choice
  257.    (askchoice
  258.       (prompt #prompt-ask-c-compiler)
  259.       (help #help-ask-c-compiler)
  260.       (default #compiler-choice)
  261.       (choices
  262.          #compiler-sas-name
  263.          #compiler-gcc-name
  264.          #compiler-dice-name
  265.          #compiler-other-name
  266.       )
  267.    ))
  268.  
  269.    (debug "  choice = " #compiler-choice)
  270. ))
  271.  
  272. ;----------------------------------------------------------------------------
  273. ; Set a variable in SmallEiffel/sys
  274. ;----------------------------------------------------------------------------
  275. (procedure P-set-smalleiffel-variable #variable #value
  276. (
  277.    (debug "  set" #variable "to" #value)
  278.    (if (<> "debug" @app-name)
  279.       (
  280.          (textfile
  281.             (dest (tackon #smalleiffel-directory-sys #variable))
  282.             (append #value)
  283.          )
  284.       )
  285.       (debug "  debug-skip")
  286.    )
  287. ))
  288.  
  289. ;----------------------------------------------------------------------------
  290. ; Set stuff in sofa/SmallEiffel/sys
  291. ;----------------------------------------------------------------------------
  292. (procedure P-set-smalleiffel-sys
  293. (
  294.    (working #working-set-smalleiffel)
  295.  
  296.    (set #sys-gc       "m68k-amigaos.c")
  297.    (set #sys-system   "Amiga")
  298.  
  299.    (select (+ 0 #compiler-choice)
  300.       (
  301.          ; SAS/c
  302.          (set #sys-compiler "sc")
  303.       )
  304.       (
  305.          ; gcc/egcs
  306.          (set #sys-compiler "gcc")
  307.       )
  308.       (
  309.          ; DICE
  310.          (set #sys-compiler "") ; TODO: support DICE
  311.       )
  312.       (
  313.          ; Other
  314.          (set #sys-compiler "")
  315.       )
  316.    )
  317.  
  318.    ; Reset loadpath to current directory
  319.    (set #sys-loadpath "\n")
  320.  
  321.    ; Add additional libraries to loadpath
  322.    (set #sys-loadpath
  323.    (cat #sys-loadpath
  324.         "${GOBO}/library/loadpath.se" "\n"
  325.         "${EXML}/compiler_specific/se/loadpath.se" "\n"
  326.    ))
  327.  
  328.    ; Add SmallEiffel to loadpath
  329.    (set #sys-loadpath
  330.    (cat #sys-loadpath
  331.         "sofa:SmallEiffel/lib_std/"  "\n"
  332.         "sofa:SmallEiffel/lib_rand/" "\n"
  333.         "sofa:SmallEiffel/lib_show/" "\n"
  334.         "sofa:SmallEiffel/lib_se/"   "\n"
  335.    ))
  336.  
  337.    (P-set-smalleiffel-variable "system.se"      #sys-system )
  338.    (P-set-smalleiffel-variable "compiler.se"    #sys-compiler)
  339.    (P-set-smalleiffel-variable "gc"             #sys-gc)
  340.    (P-set-smalleiffel-variable "loadpath.Amiga" #sys-loadpath)
  341. ))
  342.  
  343. ;----------------------------------------------------------------------------
  344. ; Update User-Startup
  345. ;----------------------------------------------------------------------------
  346. (procedure P-update-user-startup
  347. (
  348.    ; Simply adds a SetEnv and Path command
  349.    (debug "update user-startup")
  350.  
  351.    (working #working-user-startup)
  352.  
  353.    (set #command-user-startup
  354.    (cat ("Assign sofa: \"%s\"\n" #sofa-directory)
  355.         ("SetEnv SmallEiffel \"%s\"\n" (tackon "sofa:SmallEiffel" #env-appendix ))
  356.         ("SetEnv GOBO \"%s\"\n" "sofa:library/gobo")
  357.         ("SetEnv EXML \"%s\"\n" "sofa:library/exml")
  358.         "Path Add \"sofa:SmallEiffel/bin\" \"${GOBO}/bin\"\n"
  359.    ))
  360.  
  361.    (debug "---")
  362.    (debug #command-user-startup)
  363.    (debug "---")
  364.  
  365.    (if (<> "debug" @app-name)
  366.       (startup "Sofa"
  367.          (confirm)
  368.          (prompt  (cat #prompt-update-user-startup #command-user-startup))
  369.          (help    #help-update-user-startup)
  370.          (command #command-user-startup)
  371.       )
  372.       (debug "  debug-skip")
  373.    )
  374. ))
  375.  
  376. ;----------------------------------------------------------------------------
  377. ; Create directories
  378. ;----------------------------------------------------------------------------
  379. (procedure P-create-directories
  380. (
  381.    ; Create Sofa directory and SmallEiffel/bin because they are needed in any case
  382.    (makedir #sofa-directory            (safe))
  383.    (copyfiles
  384.        (source "/sofa.info")
  385.        (dest (tackon #sofa-directory "/"))
  386.    )
  387.  
  388.    (makedir #library-directory         (safe))
  389.    (makedir #smalleiffel-directory     (safe))
  390.    (makedir #smalleiffel-directory-bin (safe))
  391.    (makedir #smalleiffel-directory-sys)
  392. ))
  393.  
  394. ;----------------------------------------------------------------------------
  395. ; Check if current directory is target directory
  396. ;----------------------------------------------------------------------------
  397. (procedure P-check-already-in-sofa
  398. (
  399.    (debug "P-check-already-in-sofa")
  400.  
  401.    ; Check, if target directory is current directory. If so, no files have
  402.    ; to be copied later on
  403.    (set #expanded-current (expandpath ""))
  404.    (set #expanded-sofa    (expandpath #sofa-directory))
  405.    (debug "  expanded-current = " #expanded-current)
  406.    (debug "  expanded-sofa    = " #expanded-sofa)
  407.  
  408.    (set #already-in-sofa (= #expanded-current #expanded-sofa))
  409.  
  410.    (debug "  already-in-sofa = " #already-in-sofa)
  411. ))
  412.  
  413. ;----------------------------------------------------------------------------
  414. ; Copy support files (Readme etc)
  415. ;----------------------------------------------------------------------------
  416. (procedure P-copy-support-files
  417. (
  418.    (debug "copy-support-files")
  419.  
  420.    ; Copy all files in the root directory
  421.    (if (<> "debug" @app-name)
  422.       (
  423.          (debug "  copy files")
  424.          (copyfiles
  425.             (prompt #prompt-copy-support-files)
  426.             (help #help-copy-support-files)
  427.             (source "")
  428.             (choices "Readme" "Welcome.html" "SmallEiffel" "library")
  429.             (dest #sofa-directory)
  430.             (infos)
  431.          )
  432.       )
  433.       (debug "  debug-skip")
  434.    )
  435. ))
  436.  
  437. ;----------------------------------------------------------------------------
  438. ; Copy generic files
  439. ;----------------------------------------------------------------------------
  440. (procedure P-copy-generic-files
  441. (
  442.    (debug "copy-generic-files")
  443.  
  444.    ; template to fill in for more stuff to copy
  445. ))
  446.  
  447. ;----------------------------------------------------------------------------
  448. ; Extract lha archive to relative target directory using c/lhex
  449. ;----------------------------------------------------------------------------
  450. (procedure P-extract-archive #archive-name #relative-target #description (
  451.    (working (#working-extract-archive #archive-name #description))
  452.  
  453.    (set #script-name "t:sofa-lhex.bat")
  454.  
  455.    (set #lhex (expandpath "c/lhex"))
  456.    (set #expanded-target (expandpath (tackon #sofa-directory #relative-target)))
  457.    (set #expanded-archive (expandpath (tackon "archive" #archive-name)))
  458.  
  459.    (set #command-extract-archive
  460.    (cat ("cd \"%s\"\n" #expanded-target)
  461.         ("\"%s\" >\"con:///100/Extract %s/AUTO\" -qaf x \"%s\"\n" #lhex #archive-name #expanded-archive)
  462.    ))
  463.  
  464.    (debug "---")
  465.    (debug #command-extract-archive)
  466.    (debug "---")
  467.  
  468.    (textfile
  469.       (dest #script-name)
  470.       (append #command-extract-archive)
  471.    )
  472.  
  473.    (set #execute-result (execute #script-name))
  474.    (if (= 0 #execute_result)
  475.       (
  476.          ; extracted successfully
  477.          (delete #script-name)
  478.       )
  479.       (
  480.          ; error during extraction
  481.          (abort (#message-extract-failed #archive-name #script-name))
  482.       )
  483.    )
  484. ))
  485. ;----------------------------------------------------------------------------
  486. ; Exit
  487. ;----------------------------------------------------------------------------
  488. (procedure P-exit
  489. (
  490.    (debug "exit")
  491.  
  492.  
  493.    ; If no specific compiler was specified, give the user a hint
  494.    (if (= #compiler-other-id #compiler-choice)
  495.       (message #message-manual-compiler-setup)
  496.    )
  497.  
  498.    ; If no binaries have been found, tell the user where he can get them from
  499.    ; (complete 95)
  500.    ; (if (= 0 (exists(tackon #target-directory-bin "compile")))
  501.    ;    (message (#message-binaries-missing #target-directory-bin) (all))
  502.    ; )
  503.  
  504.    ; Say "good bye"
  505.    (complete 100)
  506.    (message (#message-exit) (all))
  507.    (exit (quiet))
  508. ))
  509.  
  510. (procedure P-exit-change-compiler
  511. (
  512.    (debug "exit")
  513.  
  514.    ; Just say "good bye"
  515.    (message (#message-exit-change-compiler) (all))
  516.    (exit (quiet))
  517. ))
  518.  
  519. ;----------------------------------------------------------------------------
  520. ; Do it!
  521. ;----------------------------------------------------------------------------
  522.  
  523. (complete 0) (P-check-requirements)
  524.  
  525. (if (<> @app-name "Settings")
  526.    (
  527.       ; Install the package
  528.       (complete  0) (P-welcome)
  529.  
  530.       (complete 20) (P-ask-sofa-directory)
  531.       (complete 30) (P-ask-c-compiler)
  532.  
  533. ;      (complete 35) (P-check-already-in-sofa)
  534.  
  535.       (complete 35) (P-create-directories)
  536.       (complete 40) (P-copy-support-files)
  537.  
  538.       (complete 50) (P-extract-archive "SmallEiffel.lha" ""        "Compiler and base library")
  539.       (complete 60) (P-extract-archive "gobo.lha"        "library" "Portable kernal, data structures library and parser tools")
  540.       (complete 70) (P-extract-archive "exml.lha"        "library" "XML parsing library")
  541.       (complete 75) (P-extract-archive "other.lha"       ""        "Various other material")
  542.       (complete 77) (P-extract-archive "developer.lha"   ""        "Sofa Team developer material")
  543.  
  544.       (complete 80) (P-update-user-startup)
  545.       (complete 85) (P-set-smalleiffel-sys)
  546.  
  547.       (complete 90) (P-exit)
  548.    )
  549.    (
  550.       ; Only change the C compiler used by Sofa
  551.       (complete   0) (P-welcome-change-compiler)
  552.       (set #sofa-directory (expandpath ""))
  553.       (set #smalleiffel-directory (expandpath "SmallEiffel"))
  554.       (set #smalleiffel-directory-bin (tackon #smalleiffel-directory "bin"))
  555.       (set #smalleiffel-directory-sys (tackon #smalleiffel-directory "sys"))
  556.       (complete  30) (P-ask-c-compiler)
  557.       (complete  60) (P-set-smalleiffel-sys)
  558.       (complete 100) (P-exit-change-compiler)
  559.    )
  560. )
  561.  
  562.