; Installationsskript für LControl 1.53
; $VER: LControl Install 1.53 (09.06.95)
; (c) 1995 Michael Watzl

(set version 1)
(set revision 53)

; *********** Zuerst Strings sprachenabhängig initialisieren **
(if (= @language "deutsch")
; //+   detusch
    (
        (set @abort-button "Installation abrrechen!")
        (set @error-msg    "Fataler Fehler!")

        (set #welcome (cat
            "Wilkommen zur Installation von " @app-name "\n\n"
            "© 1993-1995 Jürgen Frank und Michael Watzl\n"
            "All rights reserved."))
        (set #versionerror (cat
            "Tut mir leid!\n\n"
            @app-name
            " benötigt mindestens Amiga-OS 2.04!\n"))
        (set #uncompress
            "Entpacke ")
        (set #cantuncompress
            "Fehler beim Entpacken von ")
        (set #install
            "Installiere ")
        (set #hardware
            "Baupläne")
        (set #whichdrawer (cat
            "Wo soll " @app-name " installiert werden?"))
        (set #whichdrawer_help (cat
            "Ein Verzeichnis namens '" @app-name "' wird erzeugt."))
        (set #asklibs
            "Welche Libraries sollen installiert werden?")
        (set #asklibs_help (cat
            "LANC.library\n"
            "Zum Steuern von LANC-Kameras über die Parallelporthardware (LControl).\n\n"
            "SLANC.library\n"
            "Zum Steuern von LANC-Kameras über die Serialporthardware (SControl).\n\n"
            "EDIT.library\n"
            "Zum Steuern von 5-Pin-Edit über die Parallelporthardware (PControl)."
            "(Die Hardware von LControl und PControl sind nicht kompatibel!\n\n"
            "DEBUG.library\n"
            "Täuscht eine Kamera nur vor." ))
        (set #main
            "Hauptprogramm")
        (set #main_help (cat
            "Das Hauptprogramm heißt zwar LControl, doch mit der "
            "entsprechenden library wird es zu PControl, SControl..."))
        (set #icon
            "Piktogramm" )
        (set #project_help (cat
            "Die Piktogramme versorgen das Hauptprogramm (LControl) mit den passenden Parametern."))
        (set #docs
            "Anleitung")
        (set #docs_help
            "Amiga-guide-Datei, DVI-File und LIZENZ-Informationen")
        (set #docs_pattern
            "(LControlD.guide|LControlD.DVI|LIZENZ)")
        (set #guide
            "LControlD.guide")
        (set #dvi
            "LControlD.dvi")
        (set #bye (cat
            "Viel Spaß mit " @app-name
            " wünschen\n"
            "Jürgen Frank und Michael Watzl"))




    )
; //-
; //+   englisch
    (
        (set #welcome (cat
            "Welcome to the Installation of " @app-name "\n\n"
            "© 1993-1995 Jürgen Frank and Michael Watzl\n"
            "All rights reserved."))
        (set #versionerror (cat
            "Sorry!! " @app-name " requires Amiga-OS 2.04 of better!\n"))
        (set #uncompress
            "Uncompress ")
        (set #cantuncompress
            "Error while uncompressing ")
        (set #install
            "Installing ")
        (set #hardware
            "schematics")
        (set #whichdrawer (cat
            "Where should " @app-name " be installed?"))
        (set #whichdrawer_help (cat
            "A new drawer named '" @app-name "' will be created."))
        (set #asklibs
            "Which libraries should be installed?")
        (set #asklibs_help (cat
            "LANC.library\n"
            "controls LANC-players via the parallelport harware (LControl).\n\n"
            "SLANC.library\n"
            "controls LANC-players via the serialport hardware (SControl).\n\n"
            "EDIT.library\n"
            "controls 5-Pin-Edit-players via the parallelport hardware (PControl)."
            "(The PControl-hardware and the LControl-hardware are not compatible!)\n\n"
            "DEBUG.library\n"
            "Fakes a camera" ))
        (set #main
            "main program")
        (set #main_help (cat
            "The main programm is named LControl. However together with "
            "the correct library it becomes PControl, SControl..."))
        (set #icon
            "icon" )
        (set #project_help (cat
            "The icons start the main programm (LControl) with the correct parameters"))
        (set #docs
            "Documentation")
        (set #docs_help
            "Amigaguide file, DVI-file and some licence information.")
        (set #docs_pattern
            "(LControlE.guide|LControlE.DVI|LICENCE)")
        (set #guide
            "LControlE.guide")
        (set #dvi
            "LControlE.dvi")
        (set #bye (cat
            "Jürgen Frank and Michael Watzl\n"
            "wish you a lot of fun with\n"
            @app-name))
    )
; //-
)

(message #welcome)
(complete 0)

; ***********************************************
; Amiga-OS Versionscheck
; ***********************************************
(if (< (/ (getversion) 65536) 37)
    (abort #version_error)
)

; ***********************************************
; Zielverzeichnis erzeugen
; ***********************************************
(set ziel
    (askdir
        (prompt #whichdrawer )
        (default "Work:")
        (help   #whichdrawer_help )
    )
)
(set @default-dest ziel )
(set ziel (tackon ziel @app-name ))
(makedir ziel (infos))


; ***********************************************
; Libs & Hardware entpacken (wenn vorhanden)
; => was wird eigentlich installiert?
; ***********************************************
; nach dem entpacken der hw wird eine vorauswahl
; initialisiert (bitweise):
;   1. LANC
;   2. SLANC
;   3. EDIT
;   4. DEBUG

(set options %1000) ; default: DEBUG

; libs entpacken
(working (cat "\n\n" #uncompress "libraries"))
(set rc (run "libs.run t:"))
(if (<> rc 0)
    (abort (cat #cantuncompress "libraries"))
)

(set L  0)
(set S  0)
(set E  0)
(set D  0)

(if (exists "hardware.run")
    (
        ; hardware entpacken
        (working (cat "\n\n" #uncompress #hardware))
        (set rc (run "hardware.run t:"))
        (if (<> rc 0)
            (abort (cat #cantuncompress #hardware))
        )
        (if (exists "T:hardware/LANC.iff")
            (set options (bitor options %0001)) ; options |= LANC
        )
        (if (exists "T:hardware/SLANC.iff")
            (set options (bitor options %0010)) ; options |= SLANC
        )
        (if (exists "T:hardware/EDIT.iff")
            (set options (bitor options %0100)) ; options |= EDIT
        )
    )
)

(set x (askoptions
    (prompt #asklibs)
    (help   #asklibs_help)
    (choices    "LANC.library" "SLANC.library" "EDIT.library" "DEBUG.library")
    (default options)
))
(if (<> 0 (bitand x %1000))   ; DEBUG
    ( (set D 1)
    (copylib
        (source "t:libs/DEBUG.library")
        (dest   "libs:")
    ))

)
(if (<> 0 (bitand x %0100))   ; EDIT
    ((set E 1)
    (copylib
        (source "T:libs/EDIT.library")
        (dest   "libs:")
    ))
)
(if (<> 0 (bitand x %0010))   ; SLANC
    ((set S 1)
    (copylib
        (source "T:libs/SLANC.library")
        (dest   "libs:")
    ))
)
(if (<> 0 (bitand x %0001))   ; LANC
    ((set L 1)
    (copylib
        (source "T:libs/LANC.library")
        (dest   "libs:")
    ))
)

;cleanup libs
(run "delete t:libs#? all quiet")

; *****************************************************
; Hauptprogramm und Projects entpacken und installieren
; *****************************************************

; libs entpacken
(working (cat "\n\n" #uncompress #main ))
(set rc (run "LControl.run t:"))
(if (<> rc 0)
    (abort (cat #cantuncompress #main))
)

(copyfiles
    (prompt #main)
    (help #main_help)
    (source "T:")
    (choices "LControl")
    (dest ziel)
    (confirm "expert")
)

(complete 10)

(if( (= L 1))
    ((copyfiles
        (prompt (cat "LControl-" #icon))
        (help #project_help)
        (source "T:")
        (choices "LANC.info")
        (dest ziel)
        (confirm "expert")
        (nogauge)
    )
    (tooltype
        (dest (tackon ziel "LANC"))
        (noposition)
    ))
)
(if( (= S 1))
    ((copyfiles
        (prompt (cat "SControl-" #icon))
        (help #project_help)
        (source "T:")
        (choices "SLANC.info")
        (dest ziel)
        (confirm "expert")
        (nogauge)
    )
    (tooltype
        (dest (tackon ziel "SLANC"))
        (noposition)
    ))
)
(if( (= E 1))
    ((copyfiles
        (prompt (cat "PControl-" #icon))
        (help #project_help)
        (source "T:")
        (choices "EDIT.info")
        (dest ziel)
        (confirm "expert")
        (nogauge)
    )
    (tooltype
        (dest (tackon ziel "EDIT"))
        (noposition)
    ))
)
(if( (= D 1))
    ((copyfiles
        (prompt (cat "DControl-" #icon))
        (help #project_help)
        (source "T:")
        (choices "DEBUG.info")
        (dest ziel)
        (confirm "expert")
        (nogauge)
    )
    (tooltype
        (dest (tackon ziel "DEBUG"))
        (noposition)
    ))
)
;cleanup
(run "delete t:LControl")                        ; the main prg
(run "delete t:(LANC|SLANC|EDIT|DEBUG).info")    ; the projects

(complete 20)

; catalogs kopieren (wenn deutsch)
(if (= @language "deutsch")(
    (working (cat "\n\n" #uncompress "catalogs"))
    (set rc (run "catalogs.run T:"))
    (if (<> rc 0)
        (abort (cat #cantuncompress "libraries"))
        (; else
            (makedir (tackon ziel "catalogs"))
            (copyfiles
                (source "t:catalogs")
                (dest (tackon ziel "catalogs"))
                (all)
                (nogauge)
            )
        )
    )
    ; cleanup
    (run "delete T:catalogs#? all quiet")
))
(complete 30)

(if (exists "hardware.run")(
    (makedir (tackon ziel "Hardware"))
    (copyfiles
        (source "T:Hardware.info")
        (dest ziel)
        (nogauge)
    )

    (copyfiles
        (source "T:hardware")
        (dest (tackon ziel "Hardware"))
        (all)
        (nogauge)
    )

    ; cleanup hardware
    (run "delete T:hardware#? all quiet")
))
(complete 40)


; ***********************************************
; Install documentation
; ***********************************************
(working "\n\n" #uncompress #docs)
(set rc (run "docs.run T:"))
(if (<> rc 0)
    (abort (cat #cantuncompress #docs))
)
(makedir (tackon ziel #docs))
(copyfiles
    (source "T:docs.info")
    (dest ziel)
    (newname (cat #docs ".info"))
    (nogauge)
)
(copyfiles
    (source "T:docs")
    (dest (tackon ziel #docs))
    (pattern #docs_pattern)
    (infos)
)
;cleanup docs
(run "delete t:docs#? all quiet")
(complete 70)

; tooltypes anpassen
(set tt "sys:utilities/more")
(if (exists( "sys:utilities/amigaguide" (noreq)))
    (set tt "sys:utilities/amigaguide")
)
(if (exists( "sys:utilities/multiview" (noreq)))
    (set tt "sys:utilities/multiview")
)

(set docpath (tackon ziel #docs ))

(tooltype
    (dest (tackon docpath #guide ))
    (setdefaulttool tt)
    (noposition)
)
(tooltype
    (dest (tackon docpath #dvi ))
    (noposition)
)
(complete 80)

; *********************************************
; install ARex-Examples
; *********************************************
(working "\n\n" #uncompress "ARexx")
(set rc (run "arexx.run T:"))
(if (<> rc 0)
    (abort (cat #cantuncompress "ARexx"))
)
(makedir (tackon ziel "ARexx" ))
(copyfiles
    (source "T:ARexx.info")
    (dest ziel)
    (nogauge)
)
(copyfiles
    (source "T:ARexx")
    (dest (tackon ziel "ARexx"))
    (all)
)
;cleanup arexx
(run "delete t:arexx#? all quiet")
(complete 100)

(message #bye)
(exit)


