; $VER: SuperPlay-Interfaces 1.2 (03.02.97)
; Base on the installer script from Thomas Wagner for Interfaces3_6.lha

; Author    Date       Remark
; -------------------------------------------------------
; Indy      07-Jul-96  Version 1.0
; Indy      06-Aug-96  Version 1.1
; Indy      03-Feb-97  - add #where-is-oberon
;                      - asks now all questions before start working
;                      - compile example tools

; Feel free to use it for own installer-scripts.


(SET #selectLang (ASKCHOICE
                   (PROMPT "")
                   (HELP @askchoice-help)
                   (CHOICES "English Installation"
                            "Deutsche Installation" )
                   (DEFAULT 0)
                 )
)

(IF (= #selectLang 0) (SET @language "english")  )
(IF (= #selectLang 1) (SET @language "deutsch")  )

(IF (= @language "deutsch")
  (

  (SET #msg "Mit diesen Installer-Script werden die Interface-Dateien ins \
gewnschte Verzeichnis kopiert und dann anschlieend zur Erzeugung \
der .sym- und .obj-Dateien compiliert. Dabei kann gewhlt werden welche \
Objektdateien (.obj, .objs etc.) erzeugt werden sollen und in welchen \
Verzeichnis sich das sym- und obj-Verzeichnis befindet. Auerdem knnen die \
Quellcodes der Example_Tools kopiert und compiliert werden.")

  (SET #whereIsOberon "In welchem Verzeichnis befindet sich der Oberon Compiler?")
  (SET #whereInt-Dir  "In welches Verzeichnis sollen die SuperPlay-Interfaces kopiert werden?" )
  (SET #whereSym-Dir (CAT "In welchem gemeinsamen (Ober-)Verzeichnis befindet sich sowohl "
                         "das Verzeichnis \"sym\" also auch \"obj\", bzw. wo sollen diese "
                         "angelegt werden? " ))
  (SET #whereExamples "In welches Verzeichnis sollen die Example_Tools Beispielsourcen kopiert werden?")
  (SET #whichObjFiles "Welche Objekt-Files sollen angelegt werden? (GC = garbage collector) ")
  (SET #doCopy        "Kopiere")
  (SET #doCopyInfo    "Kopiere .info Dateien")
  (SET #bigDataGC     "Groes Datenmodell mit GC")
  (SET #bigData       "Groes Datenmodell ohne GC")
  (SET #smallDataGC   "Kleines Datenmodell mit GC")
  (SET #smallData     "Kleines Datenmodell ohne GC")
  (SET #compileExamples "Sollen die Example_Tools compiliert werden? Wenn ja mit welcher Option? (GC = garbage collector)")
  (SET #noCompile     "Nicht compilieren")

  )
)

(IF (= @language "english")
  (

  (SET #msg "With this installer-script you can copy and compile the interface-files and \
the Example_Tools sourcecodes. ")
  (SET #whereIsOberon "In which directory is your oberon compiler?")

  (SET #whereInt-Dir  "Into which directory I should copy the SuperPlay-interfaces?" )
  (SET #whereSym-Dir (CAT "In which common (main-)directory are your \"sym\" AND \"obj\" "
                          "drawer, or in which directory should they be created? "))
  (SET #whereExamples "Into which directory I should copy the Example_Tools sourcecodes?")
  (SET #whichObjFiles "Which sort of object-files should be created (gc = garbage collector)? ")
  (SET #doCopy        "Copy")
  (SET #doCopyInfo    "Copy .info files")
  (SET #bigDataGC     "Big data with gc")
  (SET #bigData       "Big data without gc")
  (SET #smallDataGC   "Small data with gc")
  (SET #smallData     "Small data without gc")
  (SET #compileExamples "Should I compile the Example_Tools? IF yes, please select the options (gc = garbage collector).")
  (SET #noCompile     "Do not compile")
  )
)

; *** Procedures ***

(PROCEDURE DoIt(
  (TEXTFILE
  (DEST "T:CompileSP")
  (APPEND "STACK 30000\n"
          #parameter)
  )

  (WORKING ("Compile SuperPlay-Interfaces:\n- %s..." #modell))
  (EXECUTE "T:CompileSP")
  (DELETE  "T:CompileSP")
))

; *** Falls nicht vorhanden sym- und obj-Verzeichnis erstellen ***
(PROCEDURE MakeSymObj(
  (IF (NOT (EXISTS (TACKON #parameter "sym")))
          (MAKEDIR (TACKON #parameter "sym") )
  )
  
  (IF (NOT (EXISTS (TACKON #parameter "obj")))
          (MAKEDIR (TACKON #parameter "obj") )
  )
))

(MESSAGE #msg)


; *** Where is oberon compiler? ***
(SET @default-dest "Oberon:")
(SET #oberon-dir (ASKDIR (PROMPT #whereIsOberon)
                  (HELP @askfile-help)
                  (DEFAULT @default-dest)
             )
)


; *** Zielverzeichnis fr Interfaces ermitteln ***

(SET @default-dest (TACKON #oberon-dir "Interfaces/"))
(SET #int-dir (ASKDIR (PROMPT #whereInt-Dir)
                  (HELP @askfile-help)
                  (DEFAULT @default-dest)
             )
)


; *** Verzeichnis fr sym-, obj-Verzeichnis ermitteln ***

(SET @default-dest #oberon-dir)
(SET #sym-dir (ASKDIR (PROMPT #whereSym-Dir)
                     (HELP @askfile-help)
                     (DEFAULT @default-dest)
             )
)


; *** Which object files ***

(SET obj
  (ASKOPTIONS
    (PROMPT #whichObjFiles)
    (HELP @askchoice-help)
    (CHOICES (CAT "obj   - " #bigDataGC)
             (CAT "obja  - " #bigData)
             (CAT "objs  - " #smallDataGC)
             (CAT "objsa - " #smallData)
    )
    (DEFAULT 15)
  )
)


; *** Where Examples? ***

(SET @default-dest "Example_Tools/")
(SET #example-dir (ASKDIR (PROMPT #whereExamples)
                     (HELP @askfile-help)
                     (DEFAULT @default-dest)
             )
)


; *** Compile example tools? ***

(SET #exaObj
  (ASKCHOICE
    (PROMPT #compileExamples)
    (HELP @askchoice-help)
    (CHOICES (CAT "obj   - " #bigDataGC)
             (CAT "obja  - " #bigData)
             (CAT "objs  - " #smallDataGC)
             (CAT "objsa - " #smallData)
             (CAT #noCompile )
    )
    (DEFAULT 3)
  )
)

; Results:
; --------
; #oberon-dir : directory of oberon compiler
; #int-dir    : destination directory for interfaces
; #sym-dir    : destination directory for .sym- and .obj files
; #example-dir: destination directory for Example_Tools sourcecodes
; #obj        : compile interfaces options
; #exaObj     : compile Example_Tools options


;*** Interfaces kopieren ***

(SET #parameter #sym-dir)  ; If not exists make sym/obj dir
(MakeSymObj)

(FOREACH "Interfaces/" "#?"
  (COPYLIB
   (PROMPT (CAT (#doCopy) (" '%s'..." @each-name)))
   (HELP @copylib-help)
   (SOURCE (TACKON "Interfaces/" @each-name))
   (DEST #int-dir)
   (CONFIRM)
  )
)
(COMPLETE 10)

;*** Copy Example_Tools ***

(WORKING #example-dir)
(SET #parameter #example-dir)  ; If not exists make sym/obj dir
(MakeSymObj)

(IF (<> #example-dir "Example_Tools/")
  (
    (FOREACH "Example_Tools/" "#?.mod"
      (COPYLIB
       (PROMPT (CAT (#doCopy) (" '%s'..." @each-name)))
       (HELP @copylib-help)
       (SOURCE (TACKON "Example_Tools/" @each-name))
       (DEST #example-dir)
       (CONFIRM)
      )
    )

    (COPYLIB
     (PROMPT (CAT #doCopy " 'CompileExample_Tools'"))
     (HELP @copylib-help)
     (SOURCE "Example_Tools/CompileExample_Tools")
     (DEST #example-dir)
     (CONFIRM)
    )

    (FOREACH "Example_Tools/" "#?.info"
      (COPYFILES
       (PROMPT (CAT (#doCopyInfo) (" '%s'..." @each-name)))
       (HELP @copyfiles-help)
       (SOURCE (TACKON "Example_Tools/" @each-name))
       (DEST #example-dir)
      )
    )
  )
)
(COMPLETE 20)


; Oberon Batch-Datei erstellen

(TEXTFILE (DEST "T:BatchSP")
          (APPEND (TACKON #int-dir ("spObjects.mod"))
                  ("\n")
                  (TACKON #int-dir ("SuperPlay.mod"))
                  ("\n")
          )
)

(SET @execute-dir #sym-dir)
(SET @default-dest #int-dir)

(SET #m   (TACKON #oberon-dir "Oberon <T:BatchSP >CON:////SuperPlay-Library -m  "))
(SET #ma  (TACKON #oberon-dir "Oberon <T:BatchSP >CON:////SuperPlay-Library -ma "))
(SET #md  (TACKON #oberon-dir "Oberon <T:BatchSP >CON:////SuperPlay-Library -md "))
(SET #mda (TACKON #oberon-dir "Oberon <T:BatchSP >CON:////SuperPlay-Library -mda"))

(RUN "Resident " (TACKON #oberon-dir "Oberon"))
(RUN "Resident " (TACKON #oberon-dir "OLink"))
(RUN (TACKON #oberon-dir "ResidentManager"))

(IF (IN obj 0)   ; Groes Datenmodell mit Garbage Collector
  (
  (SET #modell #bigDataGC)
  (SET #parameter #m)
  (DoIt)
  )
)

(IF (IN obj 1)   ; Groes Datenmodell ohne Garbage Collector
  (
  (SET #modell #bigData)
  (SET #parameter #ma)
  (DoIt)
  )
)

(IF (IN obj 2)   ; Kleines Datenmodell mit Garbage Collector
  (
  (SET #modell #smallDataGC)
  (SET #parameter #md)
  (DoIt)
  )
)

(IF (IN obj 3)   ; Kleines Datenmodell ohne Garbage Collector
  (
  (SET #modell #smallData)
  (SET #parameter #mda)
  (DoIt)
  )
)
(COMPLETE 50)


; *** Compile Example_Tools ***

(SET @execute-dir #example-dir)
(WORKING "Compile Example_Tools")

(IF (= #exaObj 0)   ; Groes Datenmodell mit Garbage Collector
  (
    (EXECUTE "CompileExample_Tools -m")
  )
)

(IF (= #exaObj 1)   ; Groes Datenmodell ohne Garbage Collector
  (
    (EXECUTE "CompileExample_Tools -ma")
  )
)

(IF (= #exaObj 2)   ; Kleines Datenmodell mit Garbage Collector
  (
    (EXECUTE "CompileExample_Tools -md")
  )
)

(IF (= #exaObj 3)   ; Kleines Datenmodell ohne Garbage Collector
  (
    (EXECUTE "CompileExample_Tools -mda")
  )
)

(COMPLETE 100)

(DELETE "T:CompileSP")
(DELETE "T:BatchSP")

(EXIT "tschuess\n         [|8:)")
