; $VER: Install-Script for Skimmer 1.30

(set SkimmerVer 1)
(set SkimmerRev 30)
(set dest-dir @default-dest)

(welcome
   (cat "This is the installer for the fabulous evaluation version of Skimmer "
        SkimmerVer"."SkimmerRev". Follow the instructions and nothing can "
        "go wrong. :-)"
   )
)

; Check installer version

(set ver @installer-version)
(set ver (/ ver 65536))

(if
   (< ver 43)
   (
      (abort
         (cat "This installer script requires V43 of the Amiga Installer. "
              "You can find this version on AmiNet if you do not already "
              "have it."
         )
      )
   )
)

; check for workbench 2.1

(set ver (getversion))
(set ver (/ ver 65536))

(if (NOT (exists "libs:locale.library"))
   (Abort
     "Skimmer requires KickStart 2.1 (v38) or later."
   )
)

; select destination directory

(set dest-dir
   (askdir
      (prompt "Please specify where you would like Skimmer to be installed. "
              "A new directory called SKIMMER will be created there."
      )

      (Help "The new directory created will be Skimmer's \"home\" where "
            "it, its help files, and most support files will be kept."
      )

      (default dest-dir)
      (NewPath)
      (Disk)
   )
)

(set dest-dir
   (tackon dest-dir "Skimmer")
)

; Should we install ReqTools?

(set ver (getversion "reqtools.library" (resident)))
(set ver (/ ver 65536))

(if
   (= ver 0)
   (
      (set ver (getversion "libs:reqtools.library"))
      (set ver (/ ver 65536))
   )
)

(if
   (= ver 0)
   (set InstallReqTools 1)
   (set InstallReqTools 0)
)

(if
   (< ver 38)
   (set InstallReqTools 1)
   (set InstallReqTools 0)
)

(if
   (= InstallReqTools 1)
   (set OK2Install
      (AskBool
         (prompt
            (cat  "You are either using an obsolete version of ReqTools "
                  "or you do not have it installed. Skimmer requires the "
                  "use of ReqTools.library to operate. Would you like to "
                  "install reqtools.library?"
            )
         )
         (help
            (cat  "If you choose \"YES\", the installer will copy "
                  "reqtools.library to your LIBS: directory. If you "
                  "choose \"NO\", the installer will abort."
            )
         )
         (default 0)
      )
   )
)

(if
   (= InstallReqTools 1)
   (if
      (= OK2Install 1)
      (set InstallReqTools 1)
      (abort "Cannot use Skimmer without ReqTools!")
   )
)

; copy contents of the directory over to the destination

(copyfiles
   (prompt
      (cat  "The installer will now copy all relevant files to the destination "
            "directory that you chose earlier. A directory called SKIMMER will "
            "be created for you."
      )
   )
   (help
      (cat  "You earlier chose a destination for Skimmer to be installed to. "
            "A directory called SKIMMER will be created there. The program, "
            "help files, and so on will be copied there for you."
      )
   )
   (source "InstallMe")
   (dest dest-dir)
   (all)
   (files)
   (infos)
   (noposition)
)

; copy reqtools.library if it does not already exist in the current version

(if
   (= InstallReqTools 1)
   (copylib
      (prompt
         (cat  "The installer will now copy reqtools.library to your LIBS: "
               "directory."
         )
      )
      (help
         (cat  "You earlier indicated that you wished the most recent version "
               "of reqtools.library to be installed for you. Skimmer requires "
               "this library in order to function properly."
         )
      )
      (source "InstallLibs/reqtools.library")
      (dest "Libs:")
   )
)


(exit "Instllation is complete!")
