;
;   $VER: MailWatch_Install 4.1e (11.5.97)
;

(complete 0)

(if (= (askchoice (prompt  "Which installation method should I use?")
                  (help    (cat "This installation script supports two types of installation.\n\n"
                                "You can install into a single, newly created directory, "
                                "or you can start MailWatch every time your Amiga is booted."))
                  (choices "Own directory" "Onto SYS:")
                  (default 0)
        ) 0)

    (

        (set #DEST_MAIN
          (askdir (prompt  "Choose the path where the new drawer 'MailWatch' should be created.")
                  (help    "In the chosen path, a new drawer named 'MailWatch' will be created, in which MailWatch and its files will be copied.")
                  (default @default-dest)
          )
        )

        (set #DEST_MAIN (tackon #DEST_MAIN "MailWatch"))
        (set #DEST_PREFS #DEST_MAIN)
        (set #DEST_DOCS (tackon #DEST_MAIN "docs"))
        (set #DEST_ICONS (tackon #DEST_MAIN "icons"))
        (set #DEST_MODS (tackon #DEST_MAIN "modules"))

        (set @default-dest #DEST_MAIN)

        (makedir #DEST_MAIN
          (help @makedir-help)
          (infos)
        )

     )

     (

        ;
        ; This installs MailWatch etc. across the system disk
        ;

        (set #DEST_MAIN  "SYS:WbStartup")
        (set #DEST_PREFS "SYS:Prefs")
        (set #DEST_MODS  "LIBS:mwModules")
        (set #DEST_DOCS  "HELP:English/MailWatch")
        (set #DEST_ICONS "ENVARC:MailWatch/Icons")

        (set @default-dest #DEST_MAIN)

     )
)

(complete 10)

(copyfiles (prompt "Install the main program, MailWatch?")
           (source "")
           (choices "MailWatch")
           (dest #DEST_MAIN)
           (infos)
           (confirm)
           (help "I guess you want to install this, otherwise you wouldn't be running the install script :)")
)

(complete 15)

(copyfiles (prompt "Install the preferences program, MailWatchPrefs?")
           (source "")
           (choices "MailWatchPrefs")
           (dest #DEST_PREFS)
           (infos)
           (confirm)
           (help "The preferences program is the only supported way of configuring MailWatch's behaviour. I recommend that you install it.")
)

(complete 20)

(set #CHECKCA_HELP (cat "ClassAct programs will not work properly with the CBM "
                        "'button.gadget', but programs expecting to find the "
                        "CBM 'button.gadget' will work properly with the ClassAct "
                        "version."))

(message (cat "MailWatchPrefs requires that 'button.gadget' be installed."
              "\n\nIf you have ClassAct installed on your system, DO NOT "
              "install the 'button.gadget' included with this release."
              "\n\nThis script will check for the presence of an installed "
              "ClassAct setup, and will not install the included 'button.gadget'"
              "(which is ©CBM) over the top of it.")
         (help #CHECKCA_HELP)
         (all)
)

(set #os_ver (getversion))
(set #os_version (/ #os_ver 65536))

(if (< #os_version 39)
    (set #DEST_BUTTONGAD
        (askdir (prompt  "AmigaOS 2.x system - where are '#?.gadget' files normally installed?")
                (help    @askdir-help)
                (default "LIBS:Gadgets")
        )
    )
    (set #DEST_BUTTONGAD "SYS:Classes/Gadgets/")
)

(set #BG_NAME (tackon #DEST_BUTTONGAD "button.gadget"))

(set #bg_ver (getversion #BG_NAME))
(set #bg_version (/ #bg_ver 65536))

(if (<> #bg_version 41)
    (
        (set #INSTALL_BG
            (askchoice (prompt  "You don't seem to have ClassAct installed on your system. Therefore, you should install the included 'button.gadget'.")
                       (help    #CHECKCA_HELP)
                       (choices "Install CBM 'button.gadget'" "Do not install")
                       (default 0)
            )
        )
    )
    (
        (set #INSTALL_BG 1)
        (message "You seem to have ClassAct installed on your system. Therefore, I will not overwrite the ClassAct 'button.gadget'." (all))
    )
)

(if (= #INSTALL_BG 0)
    (copylib (prompt "Installing 'button.gadget'....")
             (help   @copylib-help)
             (source "classes/gadgets/button.gadget")
             (dest   #DEST_BUTTONGAD)
             (confirm)
    )
)

(complete 30)

(copyfiles (prompt "Install the external modules for MailWatch?")
           (source "")
           (choices "modules/")
           (dest #DEST_MODS)
           (confirm)
           (help "You also need to install the external modules that MailWatch uses.")
)

(complete 36)

(set #MAKEPREFDIRS
    (askbool (prompt "MailWatch stores its preferences, by default, in ENVARC:MailWatch/ and ENV:MailWatch/. Create these directories now?")
             (default 1)
             (help   "The preferences program will create these directories if they are needed.")
    )
)

(if (= #MAKEPREFDIRS 1)
    (
        (makedir "ENVARC:MailWatch")
        (makedir "ENV:MailWatch")
    )
)

(complete 40)

(copyfiles (prompt "Install the documentation?")
           (source "")
           (choices "docs/")
           (dest #DEST_DOCS)
           (confirm)
           (help "The documentation is in HTML form; you will need a HTML browser to read it.")
)

(complete 80)

(set #MSG_DOICONS "Install the icons?")

(set #ICONS
    (askchoice (prompt  "Which icons do you want to install to be used by MailWatch?")
               (help    "There are MagicWB and NewIcons icons provided.\n\nThese are suggestions only; any icons can be used in the program.\n")
               (choices "MagicWB" "NewIcons" "None")
               (default 2)
    )
)

(if (= #ICONS 0)
    (copyfiles (prompt  #MSG_DOICONS)
               (source  "Icons/MagicWB/")
               (dest #DEST_ICONS)
               (pattern "#?")
    )
)

(if (= #ICONS 1)
    (copyfiles (prompt  #MSG_DOICONS)
               (source  "Icons/NewIcons/")
               (dest #DEST_ICONS)
               (pattern "#?")
    )
)

(message (cat "\n\n\nYou will need to run MailWatchPrefs, to save a "
              "valid preferences file,\nbefore starting MailWatch. "
              "Look at the documentation for more details.\n\n"
              "Enjoy using MailWatch, and don't forget:\n\n\n"
              "MailWatch is MAILWARE!\n\n")
         (all)
)

(complete 100)
(exit)

