;Install script for mebPlug version 1.0 © 1998 Esteve Boix
;This install script is © Bo Liljegren (bosse@algonet.se)
;Updated 04/98 Esteve Boix (again :)
;

(complete 0)

;========================================================
; variable setup

(set #installver (/ @installer-version 65536))
(set #installrev (- @installer-version (* #installver 65536)))
(set #tempversion (getversion))
(set #osversion (/ #tempversion 65536))
(set #osrevision (- #tempversion (* #osversion 65536)))
(set #adddocs 0)
(set #frominstdir (pathonly @icon))
(set #frominstdir (substr #frominstdir 0 (- (strlen #frominstdir) (strlen "/install"))))

;========================================================
; check installer version

(if (< #installver 43)
    (
     (abort (#mess-oldinstaller1 #installver #installrev)
             #mess-oldinstaller2)
))

;========================================================
; check kickstart version

(if (< #osversion 39)
    (
     (abort "Sorry, but mapPlug requires AmigaOS v3.0+")
))

;========================================================
; Display picture

;(if (> (exists ("c:multiview")) 0) (set #mv "c:") )
;(if (> (exists ("sys:utilities/multiview")) 0) (set #mv "sys:Utilities") )
;(if (> (exists ("sys:tools/multiview")) 0) (set #mv "sys:Tools") )
;
;(if (<> #mv 0)
;    ((run (cat "run " (tackon #mv "multiview ") "/docs/pics/webPlugS.gif"))))
;
; Hehe... Still to do :)

;========================================================
; check mui (MUI 3.8 = muimaster.library V19.35)

(if (= (exists "LIBS:muimaster.library" (noreq)) 1)
    (
     (set #tempver (getversion "LIBS:muimaster.library"))
     (set #muiver (/ #tempver 65536))
     (set #muirev (- #tempver (* #muiver 65536)))
     (if (< #muiver 19)
    (
     (abort ("You need a newer version of MUI. Please install it before installing mapPlug"))
     )))
  ((abort "mapPlug requires MUI v3.8+ !"))
)

;=============================================================================
; where should mapPlug be installed

(if (= (exists "Work:" (noreq)) 2)
    (set #def-dest "Work:")
    (set #def-dest "SYS:")
    )

(set #directory
   (askdir
       (prompt "Where do you want mapPlug to be installed ?\nA new dir WILL be created")
       (help @askdir-help)
       (default #def-dest)
    )
)
(complete 10)

;=============================================================================
; should documentation be installed?

(if (OR (= #adddocs 0) (= @user-level 2))
(
    (set #adddocs
   (askbool
       (prompt "Install the provided AmigaGuide documentation ?")
       (help @askbool-help)
       (default 1)
    ))
))
(complete 20)

;=============================================================================
; if new installation create the main directory

(if (= 0 #b-upgrade)
(
   (set @default-dest (tackon #directory "mapPlug"))
   (makedir
    (@default-dest)
    (prompt "Creating mapPlug's dir")
    (help @makedir-help)
    (infos)
   )
   (complete 30)

;-----------------------------------------------
; and copying icon file for main program/directory

   (copyfiles
    (source (cat #frominstdir ".info"))
    (dest (tackon @default-dest '/'))
    (newname 'mapPlug.info' )
    (infos)
    (help @copyfiles-help)
   )
)
;-----------------------------------------------
; else just set @default-dest

    (set @default-dest #directory)
)
(complete 50)

;=============================================================================
; copy the "toolicons" directory

(copyfiles
   (source "/bin/toolicons")
   (dest (tackon @default-dest "toolicons"))
   (prompt "Copying mapPlug icons")
   (all)
   (help @copyfiles-help)
)
(complete 60)

;=============================================================================
; copy the (AmigaGuide) documentation
(set #docs-dest @default-dest)

(if (= 1 #adddocs)
   (copyfiles
      (source "/bin/mapPlug.guide")
      (dest #docs-dest)
      (prompt "Copying the AmigaGuide documentation")
      (help @copyfiles-help)
      (infos)
   )
)
(complete 70)

;=============================================================================
; install the BetterString.mcc MUI:Libs/mui/

(copylib
    (source "/bin/mui/betterstring.mcc")
    (dest "mui:libs/mui")
    (prompt #prompt-betterstring)
)

(complete 80)

;=============================================================================
; install executable files for mapPlug

(copyfiles
   (source "/bin/mapPlug")
   (dest @default-dest)
   (prompt #prompt-executable)
   (help @copyfiles-help)
   (infos)
)
(complete 90)

;=============================================================================
;Close the mlutiview window

;(rexx "quit_multiview.rexx")
;
(complete 100)

;=============================================================================
; That's it!


(exit ("mapPlug is now installed ! Congratulations !\nPlease remember that this software is shareware. If you use it, register it. Read the docs for further details.\nThank you") )
