; THIS IS THE INTUIDEX 2.0 INSTALLER SCRIPT.
; INTUIDEX IS COPYRIGHT 1995, JEFFERY C. MAY
;
; THIS VERSION CREATED: JAN 31, 1995
;
; ALTHOUGH THE COMMODORE INSTALLER USES SCRIPTS THAT VERY MUCH RESEMBLE
; LISP, I HAVE ENDEVORED TO MAKE THEM LOOK AS MUCH LIKE C AS POSSIBLE.
; MAYBE THAT WAY I'LL REMEMBER HOW IT WORKS...


; SETUP SOME ERROR AND OTHER MESSAGES SO THAT THE CODE WILL BE A LITTLE
; EASIER TO READ...
(
    (set target-dir             "DH1:")
    (set multiview              "sys:utilities/multiview")
    (set amigaguide             "sys:utilities/amgiaguide")

    (set OtherAnnounce   (cat   "You are about to be asked to provide a "
                                "path to where you want IntuiDex to be "
                                "installed to.  If you wish to create a "
                                "drawer to put IntuiDex in, you must create "
                                "it with the \"Make New Drawer\" gadget.  "
                                "All neccessary subdirectories that are "
                                "needed will be created automatically."))

    (set AnnounceHelp    (cat   "   I need to know where you want IntuiDex "
                                "to be installed to.  The next window will "
                                "have in it a file requester in which you "
                                "can specify the location that you want "
                                "IntuiDex.\n"
                                "   I recommend that you put IntuiDex into the "
                                "same area of your hard disk that you put "
                                "your other applications, and NOT in the "
                                "system area. Grouping software like "
                                "this will make it easier to find it "
                                "later."))

    (set intuitionNeeded (cat   "IntuiDex requires at least version 37 of "
                                "the Intuition Library.  If your system does "
                                "not have at least release 2.04 of the Amiga "
                                "operating system, IntuiDex will not operate."))

    (set gadtoolsNeeded (cat "  IntuiDex requires at least version 37 of "
                                "the GadTools Library.  If your system does "
                                "not have at least release 2.04 of the Amiga "
                                "operating system, IntuiDex will not operate."))

    (set aslNeeded       (cat   "IntuiDex requires at least version 37 of "
                                "the ASL Library.  If your system does "
                                "not have at least release 2.04 of the Amiga "
                                "operating system, IntuiDex will not operate."))

    (set graphicsNeeded (cat    "IntuiDex requires at least version 37 of "
                                "the Graphics Library.  If your system does "
                                "not have at least release 2.04 of the Amiga "
                                "operating system, IntuiDex will not operate."))

    (set utilityNeeded   (cat   "IntuiDex requires at least version 37 of "
                                "the Utility Library.  If your system does "
                                "not have at least release 2.04 of the Amiga "
                                "operating system, IntuiDex will not operate."))

    (set iconNeeded      (cat   "IntuiDex requires at least version 37 of "
                                "the Icon Library.  If your system does "
                                "not have at least release 2.04 of the Amiga "
                                "operating system, IntuiDex will not operate."))

    (set amigaguideNeeded (cat  "IntuiDex requires at least version 34 of "
                                "the AmigaGuide Library.  Your system does "
                                "not have the AmigaGuide Library, which was "
                                "included with release 3.0 and above of the Amiga "
                                "operating system.  "
                                "Note that the AmigaGuide system can be obtained "
                                "from Aminet, or any other source of PD and shareware "
                                "software."))
)


; MAKE SURE THAT THEY'RE USING THE PROPER OPERATING SYSTEM...
; INTUIDEX ONLY WORKS WITH SYSTEMS THAT HAVE AT LEAST RELEASE 2.04
; (VERSION 37) OF THE AMIGA OS.
(
    (
        (set IXEmulVer
            (/ (getversion "libs:ixemul.library") 65536))

        (set intuitionVer
            (/ (getversion "intuition.library" (resident)) 65536))

        (set gadtoolsVer
            (/ (getversion "gadtools.library" (resident)) 65536))

        (set aslVer
            (/ (getversion "asl.library" (resident)) 65536))

        (set graphicsVer
            (/ (getversion "graphics.library" (resident)) 65536))

        (set utilityVer
            (/ (getversion "libs:utility.library" (resident)) 65536))

        (set iconVer
            (/ (getversion "icon.library" (resident)) 65536))

        (set amigaguideVer
            (/ (getversion "libs:amigaguide.library") 65536))
    )
)


; NOW WE HAVE THE VERSION NUMBERS FOR ALL THE REQUIRED LIBRARIES.
; MAKE SURE THAT THEY'RE NEW ENOUGH TO WORK.
(
    (if (< intuitionVer 37)     ((message    intutionNeeded) (exit (quiet))))
    (if (< gadtoolsVer 37)      ((message    gadtoolsNeeded) (exit (quiet))))
    (if (< aslVer 37)           ((message    aslNeeded) (exit (quiet))))
    (if (< graphicsVer 37)      ((message    graphicsNeeded) (exit (quiet))))
    (if (< utilityVer 3)7       ((message    utilityNeeded) (exit (quiet))))
    (if (< iconVer 37)          ((message    iconNeeded) (exit (quiet))))
    (if (< amigaguideVer 34)    ((message    amigaguideNeeded) (exit (quiet))))
)



; GET THE LOCATION FROM THE USER WHERE TO PUT INTUIDEX
; NOTE THAT IF THE USER SELECTED "NOVICE" AS HIS USER LEVEL, THEN WE NEED
; TO SKIP THIS, AND JUST INSTALL INTUIDEX TO THE DH1: (WORK) PARTITION
(
    (if (> @user-level 0)
        (
            (message OtherAnnounce (help AnnounceHelp))
            (set @default-dest  target-dir)
            (set target-dir
            (askdir     (prompt     "Where should I put IntuiDex?")
                        (help       @askdir-help)
                        (default    @default-dest)
                        (newpath)
                        (disk))
            )
        )
    )
)


; NOW WE'LL COPY THE FILES...
; THE VARIABLE @default-dest NOW HOLDS THE DIRECTORY WHERE WE'RE GOING
; TO BE PLACING ALL THE FILES.  NOW WE CAN COPY STUFF...
(set  src (pathonly @icon))
(copyfiles  (source src)
            (dest   target-dir)
            (all)
)



; NOW, SET THE @default-dest VARIABLE TO POINT TO WHERE WE PUT THE STUFF
; SO THAT THE COMPLETION MESSAGE WILL BE RIGHT.
(if (> @user-level 0) (set    @default-dest   target-dir))


; AT THE END NOW- LET'S BE NICE AND AUTOMATICALLY START THE ON-LINE HELP
; AMIGAGUIDE FILE IF WE CAN.  WE NEED TO CHECK AND SEE IF MULTIVIEW IS
; PRESENT IN THE SYS:UTILITIES DRAWER FIRST.
(if (= (exists multiview (noreq)) 1)
    (
        (set AGCommand (cat multiview " \"" (tackon target-dir "help/IntuiDex.guide") "\""))
        (run AGCommand)
    )
)