; Installiert die neuen Interfaces und compiliert alles neu
; Installs the new interfaces and recompiles everything
;
; © 1994 by Thomas Wagner [tom]
; Permission granted to include to Interfaces edited by hartmut Goebel
; and the Amiga Oberon Distribution.
;
; $VER: Compile_All_2 1.0 (17.1.94)
;
; KEINE HAFTUNG
;
; Die Tabulatorlänge sollte auf 4 gesetzt werden, um diesen Text zu lesen/editieren
; set tabsize to 4 to read/edit this text

(set #archivename "Interfaces3_4.lha")

(if (= @language "deutsch")
(
(set #start
        (cat "\n© 1994 by Thomas Wagner [tom]\n"
                 "*********************************\n\n"
                 "Mit diesem Skript kann man den alle System- und Objekt-Files von "
                 "Amiga Oberon neu erzeugen.\n\n"
                 "Da das Archiv entpackt wird, benötigt es LHA im Suchpfad.\n\n"
                 "Wenn der Diskettenname ein '#' enthält, muß die Schublade erst "
                 "z.B. ins RAM: kopiert werden, da LHA das nicht verkraftet."
        )
)

(set #select-comp
        (cat "Jetzt müssen noch die Symbol- und Objekt-Files erstellt werden. "
                 "Bitte wählen Sie, welche Objekt-Files ich erstellen soll."
        )
)

(set #compilation
        (cat "Ich compiliere jetzt mit den von Ihnen gewünschten Parametern.\n\n"
                 "Bitte haben Sie etwas Geduld. Dieser Teil dauert etwas länger...\n\n"
                 "Ich erzeuge gerade die *.obj%s-Files."
        )
)

(set #where-are-interfaces "In welches Verzeichnis soll ich die Interfaces entpacken?")
(set #where-are-modules "Wo sind die Module?")
(set #where-are-syms
        (cat "In welchem gemeinsamen (Ober-)Verzeichnis befindet sich sowohl "
                 "das Verzeichnis \"sym\" also auch \"obj\", bzw. wo sollen diese "
                 "angelegt werden?"
        )
)

(set #where-is-list "Welche Compilerversion verwenden sie?")

(set #comp-old "niedriger als 3.10")
(set #comp-new "3.10 oder höher")

(set #where-is-oberon "In welchem Verzeichnis ist der Oberon Compiler?")

(set #extracting "Entpacke Daten ...")

(set interfaces-dir "")
(set modules-dir "")
))

(if (= @language "english")
(
(set #start
        (cat "\n© 1994 by Thomas Wagner [tom]\n"
                 "*********************************\n\n"
                 "With this script you can recreate all system and objekt files of "
                 "Amiga Oberon.\n\n"
                 "This the archive will be unpacked, it needs LHA in the search path.\n\n"
                 "If the volume name contains '#' the drawer must be copied to e.g. "
                 "RAM: first, because LHA can't handle this."
        )
)

(set #select-comp
        (cat "Now the symbol and object files have to be created. "
                 "Please select which sort of object files should be created."
        )
)

(set #compilation
        (cat "I compile with you selected parameters.\n\n"
                 "Please be patient. This part will take some time...\n\n"
                 "I now create the *.obj%s files."
        )
)

(set #where-are-interfaces "Into which dir I should extract the interfaces?")
(set #where-are-modules "Where are the modules?")
(set #where-are-syms
        (cat "In which common (main-)directory are your \"sym\" AND \"obj\" "
         "drawer, or in which directory should they be created?"
        )
)

(set #where-is-list "Which compiler version do you use?")

(set #comp-old "lower than 3.10")
(set #comp-new "3.10 or higher")

(set #where-is-oberon "In which directory os your compiler?")

(set #extracting "Extracting from archive ...")

(set interfaces-dir "")
(set modules-dir "")
))

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

(message #start)

(welcome)

(set @default-dest "OBERON:")

(set obfull
        (askdir
                (prompt #where-is-oberon)
                (help @askfile-help)
                (default @default-dest)
;               (newpath)
        )
)

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

(set obfull (tackon obfull "Oberon"))

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

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

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

(set list (pathonly @icon))

(if
        (askbool
                (prompt #where-is-list)
                (help @askbool-help)
                (choices (#comp-old) (#comp-new))
        )
    (set list (tackon list "recomp.lst"))
    (set list (tackon list "recomp3_1.lst"))
)

(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 "om" modules-dir)
(makeassign "oa" interfaces-dir)
(makeassign "symdir" (tackon sym-dir "obj") )

(working #extracting)

(run (cat "lha -x0 e " (tackon (pathonly @icon) #archivename) " symdir: *.o"))
(run (cat "lha -x0 e " (tackon (pathonly @icon) #archivename) " oa: *.mod"))

(makeassign "symdir")

(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 "oa")
(makeassign "om")
