; Oberon Installations Skript für Version 3.11
;
; © 1994 by Thomas Wagner [tom]
;
; $VER: Install_Oberon_3_11 1.0 (17.1.94)
; Permission granted to include to the Amiga Oberon Distribution.
;
; KEINE HAFTUNG
;
; Die Tabulatorlänge sollte auf 4 gesetzt werden, um diesen Text zu lesen/editieren


(set verstring "3.20")

(set #start
        (cat "© 1994 by Thomas Wagner [tom]\n"
                 "*********************************\n\n"
                 "This Script installs\n\nAmiga Oberon Compiler " verstring "\n\n"
                 "or updates an older installation.\n"
        )
)

(set #copy-arp-lib "\nInstalling arp.library")
(set #copy-gc-lib  "\nInstalling garbagecollector.library")
(set #copy-os-lib  "\nInstalling oberonsupport.library")

(set #destination "In which drawer should Oberon be installed?\n")

;(set #lower-version "Warning: A newer version seams to be already installed!")
;(set #same-version "Warning: This version seams to be alreayd installed!")

(set #insert-disk "\n\nPlease insert \"%s\" in any drive.")

(set #disk-1 ("Oberon%s_Disk1" verstring))
(set #disk-2 ("Oberon%s_Disk2" verstring))
(set #disk-3 ("Oberon%s_Disk3" verstring))
(set #disk-4 ("Oberon%s_Disk4" verstring))

(set #select-files 
        (cat "Please select which of the following files and drawers"
             "should be copied to which destination."
        )
)

(set #select-dir "Where do you want the contents of the drawer \"%s\" to be copied to?")

(set #select-overwrite
    (cat "Please select those of the following files and drawers that "
         "should be copied. Existing files will be overwritten!"
    )
)

(set #select-texts
    (cat "Please chose which textfiles you want to have installed and "
         "to which drawer they should be copied"
    )
)
(set #german-menu "\n\nDo you want German menus for OEd?")

(set #install-interfaces
    (cat "\n\nDo you want to install the source of the Oberon Interface modules?\n\n"
    )
)

(set #install-locale
    (cat "\n\nDo you want to install the catalog file\n to your LOCALE: drawer?\n\n"
    )
)

(set #want-demos "\n\nDo you want to install the Oberon-Demos?")
(set #want-demos2 "\n\nDo you want to install the Oberon-Examples?")
(set #want-support 
    (cat "\n\nTo control Oberon with different editors (AmokEd, CED, TurboText), there exist "
         "special scripts. Do you want them to be installed?"
    )
)

(set #startup "I will extend the User-Startup by the following lines:\n\n")

(set #ust-mod "Which lines should be added to the User-Startup?")

(set #good-bye
    (cat "Have fun programming in Oberon!\nThe commands added to the User-Startup "
         "have already been executed. You can just start to use Oberon..."
    )
)

(set #good-bye-without-obj
    (cat "Have fun programming in Oberon!\nThe commands added to the User-Startup "
         "have already been executed. \n\nHowever, no Interface modules have been "
         "installed and no object- and symbolfiles have been created (as you "
         "wanted). Please do this now..."
    )
)

(set #really-good-bye?
    (cat "\n\nI want to inform you that you have not created symbol- and "
         "objektfiles. If nothing works now, ..."
    )
)

(set #select-comp
    (cat "Now the symbol- and objectfiles have to be created. "
         "Please chose, which objectfiles you want me to create."
    )
)

(set #ask-info "Should I reinstall your old .info-Files?")

(set #compilation 
    (cat "I'm compiling now with the parameters selected by you.\n\n"
         "Please be patient. This part can take a while...\n\n"
         "I'm currently creating *.obj%s-files."
    )
)
(set #compilation-liblink
    (cat "I'm compiling the modules used by LibLink now.\n\n"
         "Please be a little patient..."
    )
)

(set #where-are-interfaces "Where are the interface modules?")
(set #where-are-modules "Where are the modules?")
(set #where-are-syms
    (cat "Which drawer has both the \"sym\" and the \"obj\" sub-drawers or"
         "in which drawer should these drawers be created, respectively?"
    )
)

(set #where-ist-list "Where is the list with the compilation order?")

(set #german 1)
;-----------------------------------------------------------

(user 2)

(message #start)

(user 0)

(if (exists "Oberon:" (noreq))
    (
        (set @default-dest "OBERON:")
        (set oberonassign 1)
    )
    (
        (set @default-dest (tackon @default-dest "Oberon"))
        (set oberonassign 0)
    )
)

(welcome)

(set interfaces-dir "")
(set modules-dir "")
(set locale-dir "LOCALE:")

;++++++++++++
;   Disk 1
;++++++++++++

(set default-dest
    (askdir
        (prompt #destination)
        (help @askdir-help)
        (default @default-dest)
        (newpath)
    )
)

(set @default-dest default-dest)

(if (exists (tackon @default-dest "oberon.info"))
    (copyfiles
        (prompt "")
        (source @default-dest)
        (dest "T:icons")
        (pattern "#?.info")
    )
)

(askdisk
    (prompt (#insert-disk #disk-1))
    (help @askdisk-help)
    (dest #disk-1)
    (newname "d1")
)

(copylib 
    (prompt #copy-arp-lib)
    (help @copylib-help)
    (source "d1:libs/arp.library")
    (dest "LIBS:")
    (confirm)
    (optional nofail)
)

(copylib 
    (prompt #copy-os-lib)
    (help @copylib-help)
    (source "d1:libs/oberonsupport.library")
    (dest "LIBS:")
    (confirm)
)

(copylib 
    (prompt #copy-gc-lib)
    (help @copylib-help)
    (source "d1:libs/garbagecollector.library")
    (dest "LIBS:")
    (confirm)
)

;----------------------------------------
; get dir to copy to


(copyfiles
    (prompt "")
    (help @copyfiles-help)
    (source "d1:")
    (infos)
    (dest @default-dest)
    (pattern "(Oberon|OLink|OErr|Path.info|Fehler-Meldungen|Compile_All)")
)

(copyfiles
    (prompt #select-texts)
    (help @copyfiles-help)
    (source "d1:")
    (infos)
    (dest (tackon @default-dest "Texte"))
    (pattern "(LiesMich_Deutsch|ReadMe_English|ModulaToOberon|Oberon-Bericht_Deutsch|Oberon-Report_English|Oberon2.txt)")
    (confirm)
)

(copyfiles
    (prompt #select-overwrite)
    (help @copyfiles-help)
    (source "d1:")
    (infos)
    (dest @default-dest)
    (pattern "(Icons)")
    (confirm)
)

(if (NOT (exists (tackon @default-dest "Path")))
    (textfile
        (prompt "")
        (help @textfile-help)
        (dest (tackon @default-dest "Path"))
        (append "OBERON:\nOBERON:LibLink\n")
    )
)


(set want-locale
    (askbool
        (prompt #install-locale)
        (help @askbool-help)
        (default 1)
    )
)

(if want-locale
    (copyfiles
        (prompt "")
        (source "d1:locale")
        (infos)
        (all)
        (dest locale-dir)
    )
)

(makeassign "d1" (safe))

;--------------------------------------------------------
; common parts

;++++++++++++
;   Disk 2
;++++++++++++

(askdisk
    (prompt (#insert-disk #disk-2))
    (help @askdisk-help)
    (dest #disk-2)
    (newname "d2")
)

(copyfiles
    (prompt #select-files)
    (help @copyfiles-help)
    (source "d2:")
    (infos)
    (confirm)
    (dest @default-dest)
    (pattern "(OMake|ResidentManager|ResidentModules.info|ModToDef|GCStat)")
)

(copyfiles
    (prompt #select-files)
    (help @copyfiles-help)
    (source "d2:")
    (choices "GarbagePrefs")
    (infos)
    (confirm)
    (dest "sys:Prefs")
)

(if (NOT (exists (tackon @default-dest "ResidentModules")))
    (textfile
        (prompt "")
        (help @textfile-help)
        (dest (tackon @default-dest "ResidentModules"))
        (append "all\n")
    )
)

(copyfiles
    (prompt "")
    (help @copyfiles-help)
    (source "d2:")
    (choices "LibLink")
    (infos)
    (dest @default-dest)
)

(set modules-dir
    (askdir
        (prompt (#select-dir "Module"))
        (help @askdir-help)
        (default (tackon @default-dest "Module"))
        (newpath)
    )
)
(copyfiles
    (prompt "")
    (help @copyfiles-help)
    (source "d2:Module")
    (all)
    (infos)
    (dest modules-dir)
)

(if (askbool
        (prompt #want-demos)
        (help @askbool-help)
        (default 1)
    )
    (copyfiles
        (prompt "")
        (source "d2:Demos")
        (all)
        (infos)
        (dest
            (askdir
                (prompt (#select-dir "Demos"))
                (help @askdir-help)
                (default (tackon @default-dest "Demos"))
                (newpath)
            )
        )
    )
)

(if (askbool
        (prompt #want-support)
        (help @askbool-help)
        (default 1)
    )
    (copyfiles
        (prompt "")
        (source "d2:ObSup_Scripts")
        (all)
        (infos)
        (dest
            (askdir
                (prompt (#select-dir "ObSup_Scripts"))
                (help @askdir-help)
                (default (tackon @default-dest "ObSup_Scripts"))
                (newpath)
            )
        )
    )
)

(makeassign "d2" (safe))

;++++++++++++
;   Disk 3
;++++++++++++

(set want-interfaces
    (askbool
        (prompt #install-interfaces)
        (help @askbool-help)
        (default 1)
    )
)

(if want-interfaces
    (set interfaces-dir
        (askdir
            (prompt (#select-dir "Interfaces"))
            (help @askdir-help)
            (default (tackon @default-dest "Interfaces"))
            (newpath)
        )
    )
)

(if want-interfaces
    (
        (askdisk
            (prompt (#insert-disk #disk-3))
            (help @askdisk-help)
            (dest #disk-3)
            (newname "d3")
        )
        (copyfiles
            (prompt "")
            (source "d3:Interfaces")
            (infos)
            (all)
            (dest interfaces-dir)
        )
    )
)


(makeassign "d3" (safe))


;++++++++++++
;   Disk 4
;++++++++++++


(askdisk
    (prompt (#insert-disk #disk-4))
    (help @askdisk-help)
    (dest #disk-4)
    (newname "d4")
)

(copyfiles
    (prompt #select-texts)
    (help @copyfiles-help)
    (source "d4:")
    (infos)
    (dest @default-dest)
    (pattern "(OEd|Rexx|OEd#?.txt)")
    (confirm)
)

(if want-interfaces
    (copyfiles
        (prompt "")
        (source "d4:Interfaces")
        (all)
        (dest interfaces-dir)
    )
)

(if (askbool
        (prompt #german-menu)
        (help @askbool-help)
        (default #german)
    )
    (copyfiles
        (prompt "")
        (source "d4:OEd_Menu.txt.d")
        (newname "OEd_Menu.txt")
        (infos)
        (dest @default-dest)
    )
)

(if (askbool
        (prompt #want-demos2)
        (help @askbool-help)
        (default 1)
    )
    (copyfiles
        (prompt "")
        (source "d4:Beispiele")
        (all)
        (infos)
        (dest
            (askdir
                (prompt (#select-dir "Beispiele"))
                (help @askdir-help)
                (default (tackon @default-dest "Beispiele"))
                (newpath)
            )
        )
    )
)

(makeassign "d4" (safe))

;-----------------------------------

(if (exists "T:icons/oberon.info")
    (if (askbool
            (prompt #ask-info)
            (help @askbool-help)
        )
        (copyfiles
            (prompt "")
            (source "t:icons")
            (dest @default-dest)
            (all)
        )
    )
)

(run "delete t:icons all" (safe))

(set ust
    (askoptions
        (prompt #ust-mod)
        (help @askoptions-help)
        (choices ("assign OBERON: %s" (expandpath @default-dest))
                 "resident OBERON:Oberon"
                 "resident OBERON:OLink"
                 "resident OBERON:OEd"
                 "resident OBERON:OEd_NOGC"
                 "path OBERON: add"
                 "OBERON:residentmanager"
        )
        (default 33)
    )
)

(set ust-string "")

(debug @default-dest)

(if (IN ust 0)
    (
        (set ust-string (cat ust-string ("assign OBERON: %s\n" (expandpath @default-dest))))
        (makeassign "OBERON" @default-dest)
    )
)

(if (IN ust 1)
    (
        (set ust-string (cat ust-string "resident OBERON:Oberon\n"))
        (run "resident OBERON:Oberon")
    )
)

(if (IN ust 2)
    (
        (set ust-string (cat ust-string "resident OBERON:OLink\n"))
        (run "resident OBERON:OLink")
    )
)

(if (IN ust 3)
    (
        (set ust-string (cat ust-string "resident OBERON:OEd\n"))
        (run "resident OBERON:OEd")
    )
)

(if (IN ust 4)
    (
        (set ust-string (cat ust-string "path OBERON: add\n"))
        (run "path OBERON: add")
    )
)

(if (IN ust 5)
    (
        (set ust-string (cat ust-string "OBERON:residentmanager\n"))
        (run "OBERON:residentmanager")
    )
)

(if (> ust 0)
    (startup "Amiga Oberon"
        (prompt (cat #startup ust-string))
        (help @startup-help)
        (command ust-string)
    )
)

;--------------------------------------------------------
; compile modules and interfaces

(debug modules-dir)

(makeassign "om" modules-dir (safe))

(set obfull (tackon @default-dest "Oberon"))

(working #compilation-liblink)
(textfile
    (prompt "")
    (help @textfile-help)
    (dest "T:OBINST")
    (append (cat "cd " (tackon @default-dest "LibLink/Obj") "\n"))
    (append (cat obfull " -m SET LibLink   OM:OberonLib\n"))
    (append (cat obfull " -dm SET LibLink  OM:OberonLib\n"))
    (append (cat obfull " -ma SET LibLink  OM:OberonLib\n"))
    (append (cat obfull " -dma SET LibLink OM:OberonLib\n"))
    (append "DELETE LibOberonLib.obj*\n")
    (append "RENAME OberonLib.obj LibOberonLib.obj\n")
    (append "RENAME OberonLib.objs LibOberonLib.objs\n")
    (append "RENAME OberonLib.obja LibOberonLib.obja\n")
    (append "RENAME OberonLib.objsa LibOberonLib.objsa\n")
)
(execute "T:OBINST")
(run "delete T:OBINST" (safe))

(if (NOT want-interfaces)
    (
        (makeassign "om" (safe))
        (exit #good-bye-without-obj)
    )
)

(set comp
    (askoptions
        (prompt #select-comp)
        (help @askoptions-help)
        (choices " <    > (*.obj)"
                 " <-md > (*.objs)"
                 " <-a  > (*.obja)"
                 " <-mda> (*.objsa)"
        )
        (default 15)
    )
)

(if (= comp 0)
    (exit (cat #good-bye #really-good-bye?))
)

(if (= interfaces-dir "")
    (set interfaces-dir
        (askdir
            (prompt #where-are-interfaces)
            (help @askdir-help)
            (default (tackon @default-dest "Interfaces"))
        )
    )
)

(set sym-dir
    (askdir
        (prompt #where-are-syms)
        (help @askdir-help)
        (default @default-dest)
    )
)

(set list
    (askfile
        (prompt #where-is-list)
        (help @askdir-help)
        (default (tackon @default-dest "Compile_All"))
    )
)

(if (NOT (exists (tackon sym-dir "sym")))
    (makedir (tackon sym-dir "sym") (infos))
)

(if (NOT (exists (tackon sym-dir "obj")))
    (makedir (tackon sym-dir "obj") (infos))
)

(makeassign "oa" interfaces-dir (safe))

(set intro (cat "cd " sym-dir "\nstack 30000\n"))

(if (IN comp 0)
    (
        (working (#compilation ""))
        (textfile
            (prompt "")
            (help @textfile-help)
            (dest "T:OBINST")
            (append intro)
            (append (cat obfull " >CON: <" list "\n"))
        )
        (execute "T:OBINST")
        (run "delete T:OBINST")
    )
)

(if (IN comp 1)
    (
        (working (#compilation "s"))
        (textfile
            (prompt "")
            (help @textfile-help)
            (dest "T:OBINST")
            (append intro)
            (append (cat obfull " -md >CON: <" list "\n"))
        )
        (execute "T:OBINST")
        (run "delete T:OBINST")
    )
)

(if (IN comp 2)
    (
        (working (#compilation "a"))
        (textfile
            (prompt "")
            (help @textfile-help)
            (dest "T:OBINST")
            (append intro)
            (append (cat obfull " -a >CON: <" list "\n"))
        )
        (execute "T:OBINST")
        (run "delete T:OBINST")
    )
)

(if (IN comp 3)
    (
        (working (#compilation "sa"))
        (textfile
            (prompt "")
            (help @textfile-help)
            (dest "T:OBINST")
            (append intro)
            (append (cat obfull " -mda >CON: <" list "\n"))
        )
        (execute "T:OBINST")
        (run "delete T:OBINST")
    )
)

(makeassign "om" (safe))
(makeassign "oa" (safe))

(exit #good-bye)

