; 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 InstallIXEmulNew (cat  "IntuiDex requires at least version 40 of "
                                "the IXEmul.library.  You do not currently "
                                "have any version in your LIBS: "
                                "drawer.  I will now copy verison 40.4 into "
                                "your LIBS: drawer."))

    (set InstallIXEmulUp1 (cat  "IntuiDex requires at least version 40 of "
                                "the IXEmul.library.  Currently, you are "
                                "using version "))

    (set InstallIXEmulUp2 (cat  "I will now install version 40.4 of the "
                                "IXEmul.library into your LIBS: drawer"))

    (set IXEmulHelp (cat        "The IXEmul.library is a part of the GNU C "
                                "programming environment.  It was developed "
                                "by Markus Wild to permit his port of the "
                                "GNU C compiler to the Amiga.\n\n"
                                "The IXEmul.library is copyrighted under "
                                "the GNU General Public License.  This "
                                "means that I must make available the source "
                                "code to it.  Said source code is already "
                                "available on Aminet, in the dev/GCC "
                                "directory.  If you do not have 'net access, "
                                "please contact me if you are interested in "
                                "obtaining a copy of hte IXEmul.library "
                                "source code.\n\n"
                                "Please note that IntuiDex IS NOT copy"
                                "righted under the GNU GPL, and I WILL NOT "
                                "release the source code to it.  (Why would "
                                "you want to see it anyway? :)"))


    (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)
            (infos)
            (pattern "IntuiDex")
)
(copyfiles  (source src)
            (dest   target-dir)
            (infos)
            (pattern "data")
)
(copyfiles  (source src)
            (dest   target-dir)
            (infos)
            (pattern "help")
)
(copyfiles  (source src)
            (dest   target-dir)
            (infos)
            (pattern "#?config")
)
(copyfiles  (source src)
            (dest   target-dir)
            (infos)
            (pattern "mailmerge")
)

; NOW WE'LL MAKE SURE THAT A NEW ENOUGH VERSION OF THE IXEMUL.LIBRARY IS
; AVAILABLE.  IF NOT, WE'LL COPY OUR NEW VERSION INTO THE USER'S LIBS:
; DRAWER.
; THIS IS FOR A NEW INSTALLATION
(if (= IXEmulVER 0)
    (
        (set libsrc  (cat src "\libs"))
        (message InstallIXEmulNew (help IXEmulHelp))
        (copyfiles  (source libsrc)
                    (dest   "LIBS:")
                    (all)
        )
        (set IXEmulVer
            (/ (getversion "libs:ixemul.library") 65536))
    )
)
; THIS IS TO UPDATE AN EXISTING INSTALLATION.
(if (< IXEmulVER 40)
    (
        (set IXEmsg (cat InstallIXEmulUp1 IXEmulVER "\n\n" InstallIXEmulUp2))
        (set libsrc  (cat src "\libs"))
        (message IXEmsg (help IXEmulHelp))
        (copyfiles  (source libsrc)
                    (dest   "LIBS:")
                    (all)
        )
        (set IXEmulVer
            (/ (getversion "libs:ixemul.library") 65536))
    )
)


; 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)
    )
)