; $VER: PowerCache_Install_IconX 37.104 (22.1.94)
;
; Installation script for PowerCache. Will install 68000-68040 executable,
; documentation and also locale files for users running v38.
;
; Distributed as a part of the PowerCache project.
; PowerCache is Copyright (C) 1993, 1994 by Michael Berg
; All righs reserved
;
FailAt 20

Echo "PowerCache installation script for use with IconX"
Echo "Copyright © 1993, 1994 by Michael Berg"
Echo "All Rights Reserved"
Echo ""

Echo "Installing Libraries:"

Echo "    reqtools.library"

SetEnv DoCopyLib YES

Version >NIL: reqtools.library 37
If NOT WARN
    Echo "        You already have: [1m" NOLINE
    Version reqtools.library
    Echo "[0m" NOLINE
    Ask "        Do you want to install version [1m38.1194[0m of reqtools.library?"
    If NOT WARN
        SetEnv DoCopyLib NO
    EndIf
EndIf

If $DoCopyLib EQ "YES"
    Echo "        Copying reqtools.library to your LIBS: ..."
    Copy /libs/reqtools.library LIBS: QUIET
Else
    Echo "        Skipped"
EndIf

Avail >NIL: FLUSH

Echo ""

If EXISTS Locale:Catalogs
    Echo "Do you wish to install the PowerCache catalog files?"
    Ask  "Kickstart 2.04 users should answer No, all others Yes: [y/n]:"
    If WARN
        Copy >NIL: Locale Locale: All
        Echo "Catalogs installed"
    EndIf
Else
    Echo "Catalog files not installed -- no Locale directory found"
EndIf

If EXISTS SYS:Tools/Commodities
    SetEnv TargetDir Sys:Tools/Commodities
Else
    SetEnv TargetDir Sys:
Endif

Lab SelectVersion

Echo "Which version do you wish to install?"
Echo "Enter '000' for the 68000 version"
Echo "Enter '020' for the 68020 version"
Echo "Enter '030' for the 68030 version"
Echo NOLINE "Enter '040' for the 68040 version: "
/GetLine >ENV:PCInstallVersion

If $PCInstallVersion EQ "000"
    SetEnv SourceFile /PowerCache
Else
    SetEnv SourceFile /PowerCache.$PCInstallVersion
EndIf

If NOT EXISTS $SourceFile
    Echo "Illegal selection. Please re-select*N"
    Skip BACK SelectVersion
EndIf

Echo "Installing the PowerCache files in $TargetDir/PowerCache/"

MakeDir $TargetDir/PowerCache
MakeDir $TargetDir/PowerCache/Documentation

If EXISTS Env:Sys/def_drawer.info
    Copy >NIL: Env:Sys/def_drawer.info $TargetDir/PowerCache.info
    Copy >NIL: Env:Sys/def_drawer.info $TargetDir/PowerCache/Documentation.info
Else
    Echo "-> Note: No default drawer icon found. You'll have to use the"
    Echo "   'show all' workbench menu item to locale the PowerCache drawer"
    Echo "   in $TargetDir."
EndIf

Copy >NIL: $SourceFile $TargetDir/PowerCache
Copy >NIL: $SourceFile.info $TargetDir/PowerCache
Copy >NIL: /Documentation/#?.guide#? $TargetDir/PowerCache/Documentation

Echo "Add PowerCache: ASSIGN statement to S:User-Startup?"
Ask  "(Not strictly required to run PowerCache, but recommended) [y/n]:"

If WARN
    Echo "Adding to S:User-Startup..."

    Echo ";BEGIN PowerCache" >>S:User-Startup
    Echo "Assign PowerCache: *"$TargetDir/PowerCache*" DEFER" >>S:User-Startup
    Echo ";END PowerCache" >>S:User-Startup

    Echo "*NNote: Make sure your S:Startup-sequence executes S:User-Startup!"
EndIf

Echo "*NInstallation complete. You may close the window now."
