;
; InfraRexx 1.6c Installer Script
; $VER: InfraRexx_Install 1.1 (7.4.95)
;
(message
  "\nWelcome to the\nInfraRexx Installer Utility\n\n"
  "This program will install\n"
  "InfraRexx release 1.6c.\n"
  "\n"
  "The 'Help...' button will provide\n"
  "help during the installation.\n"
  "\n"
  "InfraRexx and InfraJoy are\n"
  "© 1994-1995 by Leon Woestenberg\n"
  "(Digital Disturbance) and\n"
  "Jeroen Steenblik.\n"
)
(welcome)

;
; check AmigaOS version
;
(transcript "Checking AmigaOS version...")
(if
  (<
    (/
      (getversion)
      65536
    )
    37
  )
  (
    (transcript "Aborting because AmigaOS Release 2.04 (or higher) is not available.")
    (abort "\nInfraRexx requires at least AmigaOS Release 2.04 to run.\n\n"
       "Press the Proceed button to abort the installation procedure.")

  )
  (transcript "AmigaOS version 2.04 (or higher) found. Proceeding.")
)
(complete 0)

;
; Ask for the version of the used hardware
;
(set hardware-choice
  (askchoice
    (prompt "What hardware is used?\n(Use 'Help' for more information)")
    (help "About the hardware:\n"
      "    InfraRexx requires a small hardware extension in order to "
      "operate. Due to the availability of several hardware versions "
      "the software has to be configured to use the correct version.\n"
      "\n"
      "Determining the hardware version:\n"
      "    If you have ordered the hardware directly from the authors, you "
      "can read the version number from the print circuit board. If there's "
      "no version indication, you have an InfraJoy v1 design.\n"
      "\n"
      "    If you built (or later patched) the hardware yourself, check the "
      "building (or patch) documentation to determine the version number.\n"
      "\n"
      "    If you have no hardware yet, you can either order it from the authors "
      "or build it yourself. See the documentation for more information on this. "
      "If you choose to install the software now, please select the latest version number.\n"
      "\n"
      @askchoice-help
    )
    (choices
      "InfraJoy v1"
      "InfraJoy v2"
      "InfraJoy v3"
      "InfraJoy v4"
    )
    (default 3)
  )
)

;
; Ask where to install the InfraRexx drawer
;
(set infrarexx-dest
  (tackon
    (askdir
      (prompt "Where should the InfraRexx drawer be installed?")
      (help
    "InfraRexx Destination:\n"
    "    Please choose a place on your (hard)disk where you would like "
    "the InfraRexx software, and documentation to be installed. A new "
    "drawer called 'InfraRexx' will be created there, and most of the "
    "files will be copied there.\n"
    "\n"
      @askdir-help)
      (default @default-dest)
    )
    "InfraRexx"
  )
)
(set @default-dest infrarexx-dest)
(complete 10)

;
; Ask whether to install MagicWB icons
;
(set magicwb-bool
  (askbool
    (prompt
      "Install MagicWB icons?\n\n"
      "Slick looking icons for the MagicWB look.\n\n"
      "NewIcons wanted for the next release. Anyone? :_)\n"
    )
    (help
       "MagicWB Icons\n"
       "    Magic Workbench (MWB) is a new Workbench appearance "
       "containing styleful and colourful icons and some display "
       "programs, improving the overall look of your Workbench.\n"
       "    If you have MagicWB installed, you're advised to use "
       "these icons. MagicWB is copyrighted by Martin Huttenloher.\n"
    )
  )
)
;
; Set the source direcoty for icons
;
(set icons-source
  (if
    (<>
      magicwb-bool
      0
    )
    (
      "MagicWB"
    )
    (
      ""
    )
  )
)

(copyfiles
  (source "InfraRexxEditor")
  (dest infrarexx-dest)
  (infos)
)
(copyfiles
  (source
    (tackon
      icons-source
      "InfraRexxEditor.info"
    )
  )
  (dest infrarexx-dest)
)
(complete 20)

(copyfiles
  (source "InfraRexxDaemon")
  (dest infrarexx-dest)
  (infos)
)
(copyfiles
  (source
    (tackon
      icons-source
      "InfraRexxDaemon.info"
    )
  )
  (dest infrarexx-dest)
)

(complete 30)

;
; Set the hardware version tooltypes
;
(tooltype
  (dest
    (tackon
      infrarexx-dest
      "InfraRexxEditor"
    )
  )
  (settooltype
    "HARDWARE"
    (select
      hardware-choice
      "1"
      "2"
      "3"
      "4"
    )
  )
)
(tooltype
  (dest
    (tackon
      infrarexx-dest
      "InfraRexxDaemon"
    )
  )
  (settooltype
    "HARDWARE"
    (select
      hardware-choice
      "1"
      "2"
      "3"
      "4"
    )
  )
)
(complete 35)
;
; Check for locale.library
;
(if
  (>=
    (/
      (getversion "LIBS:locale.library")
      65536
    )
    38
  )
  (
    ;
    ; Guess catalogs to be installed
    ;
    (set catalog-options
      (+
    (if (exists "LOCALE:Catalogs/dansk") 1)
    (if (exists "LOCALE:Catalogs/deutsch") 2)
    (if (exists "LOCALE:Catalogs/italiano") 4)
    (if (exists "LOCALE:Catalogs/nederlands") 8)
    (if (exists "LOCALE:Catalogs/norsk") 16)
    (if (exists "LOCALE:Catalogs/svenska") 32)
       0 ; needed because none, or just one directory may exist,
       0 ; in which case the + has too few arguments.
      )
    )
    ;
    ; Ask for catalogs to be installed
    ;
    (set catalog-options
      (askoptions
        (prompt "Which language catalogs do you want to install?\n"
        (choices
          "Dansk"
          "Deutsch"
          "Italiano"
          "Nederlands"
          "Norsk"
          "Svenska"
        )
        (default catalog-options)
        (help
          "Language catalogs:\n"
          "    Starting with Workbench 2.1, Amiga programs can present "
          "themselves in different languages, as long as program specific "
          "catalogs for that language are present. Here you can select "
          "which language catalogs you would like to install.\n"
          "    Use the Workbench `Locale' Preferences program to select "
          "your preferred language. InfraRexx will appear in that language, "
          "when the language's catalog is available and installed.\n"
          "\n"
          @askoptions-help)
        )
      )
    )
    ;
    ; Install the selected catalogs
    ;
    (set current 0)
    (while
      (< current 6) ;latest number indicates #languages
      (
    (if
      (IN catalog-options current)
      (
        (copyfiles
          (prompt "Copying the selected catalogs...\n")
          (source
        (tackon
          "Catalogs"
          (select current
            "dansk"
            "deutsch"
            "italiano"
            "nederlands"
            "norsk"
            "svenska"
          )
        )
          )
          (pattern
        "#?.catalog"
          )
          (dest
        (tackon
          "LOCALE:Catalogs"
          (select current
            "dansk"
            "deutsch"
            "italiano"
            "nederlands"
            "norsk"
            "svenska"
          )
        )
          )
          (help @copyfiles-help)
        )
      )
    )
    (set current (+ current 1))
      )
    )
  )
)
(complete 40)
;
; Rename previous codeset directory if present
;
(if
  (=
    (exists
      (tackon
     infrarexx-dest
     "Codesets"
      )
      (noreq)
    )
    2
  )
  (
    (transcript "Codesets directory found.")
    (rename
      (tackon
    infrarexx-dest
    "Codesets"
      )
      (tackon
    infrarexx-dest
    "Your_Pre_1.6_Codesets"
      )
      (prompt
    "Renaming your old codesets directory to prevent "
    "overwriting your edited codeset files.\n")
      (help
    "Renaming Codesets directory:\n"
    "    The Install Utility tried to install the codeset "
    "directory, but such a directory was already present. "
    "You are now asked to rename the existing directory, so "
    "that the contained files will not be overwritten. "
    "Select either 'Proceed' to rename the existing directory to "
    "'Your_Pre_1.6_Codesets' or 'Skip' to resume without renaming."
      )
      (confirm)
    )
  )
)
(complete 45)
;
; Ask for codeset to be used
;
(set usedcodeset-options
  (select
    (set usedcodeset-choice
      (askchoice
    (prompt "Please select the command codeset that you want to use initially:\n")
    (choices
     ;"Akai"
      "Canon"
     ;"Goldstar"
     ;"Hitachi"
      "JVC"
     ;"Kenwood"
     ;"NEC"
     ;"Onkyo"
      "Panasonic"
      "Philips"
      "Pioneer"
     ;"Sharp"
      "Sony"
     ;"Teac"
      "Technics"
     ;"Yamaha"
    )
    (default 0)
    (help "Initial codeset selection:\n"
          "    You are asked for a command codeset that will be used if "
          "you start the InfraRexx Daemon immediately after installation. "
          "Please select an electronics brand you possess which you want "
          "InfraRexx to communicate with. Of course you can later change this.\n"
          "\n"
          @askchoice-help
    )
      )
    )
   ;(shiftleft 1 0)  ;Akai
    (shiftleft 1 1)  ;Canon
   ;(shiftleft 1 2)  ;Goldstar
   ;(shiftleft 1 3)  ;Hitachi
    (shiftleft 1 4)  ;JVC
   ;(shiftleft 1 5)  ;Kenwood
   ;(shiftleft 1 6)  ;NEC
   ;(shiftleft 1 7)  ;Onkyo
    (shiftleft 1 8)  ;Panasonic
    (shiftleft 1 9)  ;Philips
    (shiftleft 1 10) ;Pioneer
   ;(shiftleft 1 11) ;Sharp
    (shiftleft 1 12) ;Sony
   ;(shiftleft 1 13) ;Teac
    (shiftleft 1 14) ;Technics
   ;(shiftleft 1 15) ;Yamaha
  )
)
;
; Set FROM tooltype to used codeset
;
(tooltype
  (dest
    (tackon
      infrarexx-dest
      "InfraRexxDaemon"
    )
  )
  (settooltype
    "FROM"
    (tackon
      infrarexx-dest
      (tackon
    "Codesets"
    (select
      usedcodeset-choice
     ;"Akai"
      "Canon"
     ;"Goldstar"
     ;"Hitachi"
      "JVC"
     ;"Kenwood"
     ;"NEC"
     ;"Onkyo"
      "Panasonic"
      "Philips"
      "Pioneer"
     ;"Sharp"
      "Sony"
     ;"Teac"
      "Technics"
     ;"Yamaha"
    )
      )
    )
  )
)
(complete 50)
;
; Ask for additional codesets to be installed
;
(set additionalcodeset-options
  (askoptions
    (prompt "Please select additional command codesets that you want to install: (Empty codesets are marked with ¹)\n"
    (choices
       "Akai¹"
       "Canon"
       "Goldstar¹"
       "Hitachi¹"
       "JVC"
       "Kenwood¹"
       "NEC¹"
       "Onkyo¹"
       "Panasonic"
       "Philips"
       "Pioneer"
       "Sharp¹"
       "Sony"
       "Teac¹"
       "Technics"
       "Yamaha¹"
    )
    (default usedcodeset-options)
    (help
      "Additional codesets selection:\n"
      "    Here you may choose codesets that will be installed into the "
      "codesets directory; either empty codesets that you use as a base "
      "project for learning new codes, or supplemental codesets for "
      "other electronic brands than that of the initial codeset.\n"
      "\n"
      @askoptions-help)
    )
  )
)
;
; Merge the used and additional codesets together
;
(set codesets-options
  (BITOR
    usedcodeset-options
    additionalcodeset-options
  )
)
;
; Install the selected codesets
;
(set current 0)
(while
  (< current 16) ;latest number indicates #codesets
  (
    (if
      (IN codesets-options current)
      (
    (copyfiles
      (prompt "Copying the selected codesets...\n")
      (source
        (tackon
          "Codesets"
          (select
        current
        "Akai"
        "Canon"
        "Goldstar"
        "Hitachi"
        "JVC"
        "Kenwood"
        "NEC"
        "Onkyo"
        "Panasonic"
        "Philips"
        "Pioneer"
        "Sharp"
        "Sony"
        "Teac"
        "Technics"
        "Yamaha"
          )
        )
      )
      (dest
        (tackon infrarexx-dest "Codesets")
      )
      (help @copyfiles-help)
    )
      )
    )
    (set current (+ current 1))
  )
)
(complete 55)
;
; Guess documentation to be installed
;
(set documentation-options
  (if
    (=
      hardware-choice
      2
    )
    3
    31)
)
;
; Ask for documentation to be installed
;
(set documentation-options
  (askoptions
    (prompt "What documentation do you want to install?\n"
    (choices "InfraRexx User Guide"
         "Hardware Info/Build/Patch Guide"
         "Hardware Schematic (IFF format)"
         "Hardware PCB Layout (IFF format)"
         "Hardware PCB Layout (Postscript format)"
    )
    (default documentation-options)
    (help "Documentation description:\n"
      "    The InfraRexx User Guide describes every aspect of this package, "
      "except the hardware construction. It is therefore advisable to "
      "install and read this guide.\n"
      "\n"
      "    The hardware can be ordered from the authors (read the "
      "InfraRexx User Guide), but you can also build it yourself. "
      "For this purpose, there is a Hardware Guide to guide you "
      "through the building process in a comfortable way. For users "
      "who already have the hardware, there are patch instructions "
      "to upgrade it.\n"
      "\n"
      "    Choose the Hardware Schematic and/or Print Circuit Board "
      "Layouts as a source for your hardware. Both are available in "
      "IFF bitmap format, common to the Amiga, while the layout is "
      "available in PostScript as well, used by professional "
      "(laser)printers.\n"
      "\n"
      @askoptions-help)
    )
  )
)
(complete 60)
;
; Determine if MultiView exists on this system
;
(set multiview-exists
  (exists
    "SYS:Utilities/MultiView"
    (noreq)
  )
)
;
; Install InfraRexx User Guide if selected
;
(if
  (IN documentation-options 0)
  (
     (copyfiles
      (prompt "Installing the InfraRexx User Guide...")
      (source "InfraRexx.guide")
      (dest
    (set userguide-dest
      (askdir
        (prompt "Select a place for the InfraRexx User Guide.")
        (default infrarexx-dest)
        (help @askdir-help)
      )
    )
      )
      (infos)
      (help @copyfiles-help)
    )
    (copyfiles
      (source
    (tackon
      icons-source
      "InfraRexx.guide.info"
    )
      )
      (dest userguide-dest)
    )
    (copyfiles
      (prompt "Installing the InfraRexx Order Form...")
      (source "OrderForm")
      (dest userguide-dest)
      (help @copyfiles-help)
      (infos)
    )
    (copyfiles
      (source
    (tackon
      icons-source
      "OrderForm.info"
    )
      )
      (dest userguide-dest)
    )
    (if
      multiview-exists
      (tooltype
    (dest
      (tackon userguide-dest "InfraRexx.guide")
    )
    (setdefaulttool "MultiView")
      )
    )
  )
)
(complete 70)
;
; Install InfraRexx Hardware Guide if selected
;
(if
  (IN documentation-options 1)
  (
    (copyfiles
      (prompt "Installing the Hardware Building Guide...")
      (source "Hardware/Hardware.guide")
      (dest
    (tackon
      infrarexx-dest
      "Hardware"
    )
      )
      (infos)
      (help @copyfiles-help)
    )
    (copyfiles
      (source
    (tackon
      icons-source
      "Hardware/Hardware.guide.info"
    )
      )
      (dest
    (tackon
      infrarexx-dest
      "Hardware"
    )
      )
    )
    (if
      multiview-exists
      (tooltype
    (dest
      (tackon infrarexx-dest "Hardware/Hardware.guide")
    )
    (setdefaulttool "MultiView")
      )
    )
  )
)
(complete 75)
;
; Install InfraRexx Hardware Schematic if selected
;
(if
  (IN documentation-options 2)
  (
    (copyfiles
      (prompt "Installing the Hardware Schematic...")
      (source "Hardware/Schematic.iff")
      (dest
    (tackon
      infrarexx-dest
      "Hardware"
    )
      )
      (infos)
      (help @copyfiles-help)
    )
    (copyfiles
      (source
    (tackon
      icons-source
      "Hardware/Schematic.iff.info"
    )
      )
      (dest
    (tackon
      infrarexx-dest
      "Hardware"
    )
      )
    )
    (if
      multiview-exists
      (tooltype
    (dest
      (tackon infrarexx-dest "Hardware/Schematic.iff")
    )
    (setdefaulttool "MultiView")
      )
    )
  )
)
(complete 80)
;
; Install InfraRexx Hardware Layouts (IFF) if selected
;
(if
  (IN documentation-options 3)
  (
    (copyfiles
      (prompt "Installing the Hardware Layouts (IFF)...")
      (source "Hardware")
      (dest
    (tackon
      infrarexx-dest
      "Hardware"
    )
      )
      (choices
    "SilkScreen.iff"
    "ComponentSide.iff"
    "SolderSide.iff"
      )
      (infos)
      (help @copyfiles-help)
    )
    (copyfiles
      (source
    (tackon
      icons-source
      "Hardware"
    )
      )
      (dest
    (tackon
      infrarexx-dest
      "Hardware"
    )
      )
      (choices
    "SilkScreen.iff.info"
    "ComponentSide.iff.info"
    "SolderSide.iff.info"
      )
    )
    (if
      multiview-exists
      (
    (tooltype
      (dest
        (tackon infrarexx-dest "Hardware/SilkScreen.iff")
      )
      (setdefaulttool "MultiView")
    )
    (tooltype
      (dest
        (tackon infrarexx-dest "Hardware/ComponentSide.iff")
      )
      (setdefaulttool "MultiView")
    )
    (tooltype
      (dest
        (tackon infrarexx-dest "Hardware/SolderSide.iff")
      )
      (setdefaulttool "MultiView")
    )
      )
    )
  )
)
(complete 85)
;
; Install InfraRexx Hardware Layouts (PostScript) if selected
;
(if
  (IN documentation-options 4)
  (
    (copyfiles
      (prompt "Installing the Hardware Layouts (PostScript)...")
      (source "Hardware")
      (dest
    (tackon
      infrarexx-dest
      "Hardware"
    )
      )
      (choices
    "ComponentSide.ps"
    "SolderSide.ps"
      )
      (infos)
      (help @copyfiles-help)
    )
  )
)
(complete 90)
;
; Ask for examples to be installed
;
(set examples-options
  (askoptions
    (prompt "Please select any examples you want to install:"
    (choices "Scala Example"
         "Toolmanager Example"
    )
    (default 3)
    (help
       "Examples:\n"
       "    These examples show you some ways of using InfraRexx. "
       "Use your imagination and available software to achieve "
       "other ways of using this product, that even the authors "
       "didn't think of.\n"
       "    And ehh..., feel free to let us know what that might be...:-)\n"
       "\n"
       @askoptions-help)
    )
  )
)
;
; Install the selected examples
;
(set current 0)
(while
  (< current 2) ;latest number indicates #examples
  (
    (if
      (IN examples-options current)
      (
    (copyfiles
      (prompt "Copying the selected examples...\n")
      (source
        "Examples"
      )
      (pattern
        (select
           current
           "Scala"
           "ToolManager"
        )
      )
      (dest
        (tackon infrarexx-dest "Examples")
      )
      (infos)
      (help @copyfiles-help)
    )
    (copyfiles
      (source
        (tackon
          icons-source
          "Examples"
        )
      )
      (pattern
        (select
           current
           "Scala"
           "ToolManager"
        )
      )
      (dest
        (tackon infrarexx-dest "Examples")
      )
      (infos)
      (help @copyfiles-help)
    )
      )
    )
    (set current (+ current 1))
  )
)
(complete 95)
;
; Ask for RexxEvent to be installed
;
(set rexxevent-bool
  (askbool
    (prompt
      "Install the handy 'RexxEvent' software?\n\n"
      "Besides remote-controlling programs via ARexx, "
      "you can steer them via keypresses and other inputevents, "
      "if you have RexxEvent running.\n"
    )
    (help
       "RexxEvent\n"
       "    This small program enables you to force events to happen "
       "using ARexx. An event can be the touch of a key, or the click "
       "of a mousebutton, etc. In combination with the InfraRexxDaemon, "
       "this enables you to control certain software via your remote "
       "controller, that would otherwise not be controllable via ARexx.\n"
    )
  )
)
;
; Install RexxEvent
;
(if
  (=
    rexxevent-bool
    1
  )
  (
    (copyfiles
      (prompt "Copying RexxEvent...\n")
      (source
    "RexxEvent"
      )
      (all)
      (dest
    (tackon infrarexx-dest "RexxEvent")
      )
      (infos)
      (help @copyfiles-help)
    )
    (copyfiles
      (source
    (tackon
      icons-source
      "RexxEvent"
    )
      )
      (dest
    (tackon
      infrarexx-dest
      "RexxEvent"
    )
      )
      (choices
    "RexxEvent.info"
    "RexxEvent.doc.info"
      )
    )
  )
)
(complete 100)

(exit "You have just installed release 1.6c of InfraRexx.\n"
      "\n"
      "Good for you!\n"
      "\n"
      "InfraRexx and InfraJoy are\n"
      "© 1994-1995 by Leon Woestenberg\n"
      "(Digital Disturbance) and\n"
      "Jeroen Steenblik.\n"
)
