; $VER: Install_PowerCache 37.37 (13.06.1993)
;
; Install script for PowerCache (Workbench 2.1 or higher)
; Copyright (C) 1993 by Michael Berg
; All Rights Reserved
;

(set @default-dest "")
(set old_level @user-level)

; File- and directory names of what we're going to install
;
(set reqtoolslib	"//libs/reqtools.library")
(set PowerCache		"//PowerCache")
(set PowerCache020	"//PowerCache.020")
(set DocDir		"//Documentation")
(set CreateDir		"PowerCache")
(set catalogdir		"/Locale/Catalogs/")

;***************************************************************************
; English strings
;
; Translation: Native
;***************************************************************************

(set default_lang 1)

(set #targetstr		   "In which directory should PowerCache be installed?")
(set #targetsel		   (cat "\nPlease select the directory or partition in which you would like "
				"PowerCache installed (a directory named 'PowerCache' will be created "
				"in the directory you select)\n\nClick PROCEED to start the installation process.\n\n"
				@askdir-help))

(set #bad-kick		   "You must be using Kickstart 2.04+ to install PowerCache using this script!")
(set #fixing-ss		   "Correcting User-Startup file...")
(set #makingdir		   "Creating PowerCache directory...")
(set #copying-reqtools     "Copying reqtools.library to LIBS:")
(set #copying-PowerCache   "Copying PowerCache...")
(set #copying-docs	   "Copying PowerCache documentation...")
(set #copying-docs-help	   (cat "PowerCache has extensive online help. This part "
				"of the installation will copy the help files to "
				"a directory called 'Documentation' in the target "
				"directory.\n\n"
				@makedir-help
				@copyfiles-help))

(set #which-language	   ("\nWhich languages should be installed?"))
(set #what-versions	   ("\nWhich version(s) would you like to install?"))
(set #what-versions-help   (cat "\nTwo versions of PowerCache are provided. One version, "
				"the 68000 version, will work on all machines, whilst the "
				"other requires a 68020 (or better) "
				"equipped machine. If you have an Amiga 1200, Amiga 2500, "
				"Amiga 3000 or Amiga 4000, or an accellerator board in your machine, "
				"then select to install the 68020 version. This version uses "
				"some special instructions of the 68020 to boost performance.\n\n"
				"You may install both versions of PowerCache if you wish.\n\n"
				@askoptions-help))

(set #pc_68000			"PowerCache 68000")
(set #pc_68020			"PowerCache 68020+")

(set #which-language-help  (cat "\nThe Amiga can be operated in many different "
				"languages. If you want PowerCache to "
				"use the same language as the Amiga Workbench "
				"then a catalog file must be copied to your "
				"system disk for each language supported.\n\n"
				"To reduce the amount of space consumed by the "
				"language files, you can select to have only the "
				"files of specific languages copied.\n\n"
				"Simply check the boxes of the languages you wish "
				"to have available on your system.\n\n"
				@askoptions-help))

(set #startup-help	   (cat "\nAlthough not strictly required, it is recommended that "
				"PowerCache: is assigned to PowerCache's home directory when "
				"using the program. This can be done by hand, using the "
				"AmigaDOS 'Assign' command, or automatically, using this "
				"installation script.\n\n"
				"Two things will happen:\n\n"
				"The Installer will check if your startup-sequence\n"
				"  executes the file S:User-Startup, and will modify\n"
				"  it to do so, if necessary.\n\n"
				"The Installer will look through the S:User-Startup\n"
				"  file and insert the correct Assign statements where\n"
				"  appropriate.\n\n"
				@startup-help))


;***************************************************************************
; Danish strings
;
; Translation: Michael Berg
;***************************************************************************

(if (= @language "dansk")
(
	(set default_lang 2)

	(set #targetstr    ("I hvilket katalog skal PowerCache installeres?"))
	(set #targetsel	   (cat "\nVlg det katalog eller den partition som PowerCache nskes "
				"installeret i (et katalog ved navn 'PowerCache' vil blive "
				"oprettet i kataloget De vlger)\n\nTryk p PROCEED for at starte "
				"installeringen.\n\n"
				@askdir-help))

	(set #bad-kick	   (cat	"De har brug for Kickstart 2.04+ for at kunne installere "
				"PowerCache med dette installationsprogram"))

	(set #fixing-ss		"Retter User-Startup fil...")
	(set #makingdir		"Opretter PowerCache katalog...")

	(set #copying-reqtools	"Kopierer reqtools.library til LIBS:")
	(set #copying-PowerCache "Kopierer PowerCache...")
	(set #copying-docs	"Kopierer PowerCache dokumentation...")

	(set #copying-docs-help
			   (cat "PowerCache har omfattende online hjlp. Denne del "
				"af installationen vil kopiere hjlpefilerne til "
				"et katalog kaldet 'Documentation' i destinations "
				"kataloget\n\n"
				@makedir-help
				@copyfiles-help))

	(set #which-language	"\nHvilke(t) sprog nsker De at installere?")

	(set #what-versions	"\nHvilke(n) version(er) nsker De at installere?")
	(set #what-versions-help
			   (cat	"\nPowerCache leveres i to versioner. Den ene, 68000 versionen, "
				"vil virke p alle maskiner, mens den anden "
				"krver en 68020 (eller bedre) maskine. Hvis De har en Amiga 1200, "
				"Amiga 2500, Amiga 3000 eller Amiga 4000, eller hvis De har et "
				"accelleratorkort i Deres maskine, s br De installere 68020 "
				"versionen. Denne version benytter specielle, udvalgte 68020 "
				"instruktioner der forbedrer programmets ydeevne.\n\nDe kan "
				"installere begge versioner af PowerCache hvis De nsker.\n\n"
				@askoptions-help))

	(set #pc_68000		"PowerCache 68000")
	(set #pc_68020		"PowerCache 68020+")

	(set #which-language-help
			   (cat	"\nAmigaen kan benyttes i mange forskellige sprog.\n"
				"Hvis De nsker at PowerCache skal benytte samme sprog "
				"som Amiga Workbench, s skal der kopieres en katalogfil "
				"til Deres systemdisk for hvert sprog.\n\n"
				"For at reducere sprogfilernes pladsforbrug kan De vlge "
				"kun at installere det eller de sprog installeret som "
				"De har brug for.\n\n"
				"Klik i kasserne ud for de sprog De nsker at have tilgngelige "
				"p Deres system.\n\n"
				@askoptions-help))

	(set #startup-help
			   (cat	"\nSelvom det ikke er strengt ndvendigt, anbefales "
				"det at PowerCache: knyttes til PowerCache's hjemme katalog "
				"nr programmet anvendes. Dette kan gres med hndkraft, v.hj.a. "
				"AmigaDOS kommandoen 'Assign', eller automatisk, v.hj.a. dette "
				"installations program.\n\n"
				"To ting vil ske:\n\n"
				" The Installer vil checke om Deres startup-sequence\n"
				"  udfrer filen S:User-Startup, og om ndvendigt\n"
				"  ndre den s dette sker.\n\n"
				"The Installer vil kigge S:User-Startup filen igennem\n"
				"  og indstte de korrekte Assign kommandoer hvor\n"
				"  det er ndvendigt.\n\n"
				@startup-help))
))

;***************************************************************************
; Make sure we are running under a 2.04 ROM
;***************************************************************************

(if (< (/ (getversion) 65536) 37)
(
	(abort #bad-kick)
))


;***************************************************************************
; Ask user where he wants the PowerCache files
;***************************************************************************

(set @target-dir
	(askdir
		(prompt #targetstr)
		(help #targetsel @askdir-help)
		(default "SYS:Tools/Commodities")
	)
)

;***************************************************************************
; What hardware does the user have?
;***************************************************************************

(if (patmatch "680[234]0" (database "cpu"))
	(set cpuvers 2)
	(set cpuvers 1)
)

;***************************************************************************
; Ask user which versions of PowerCache to install
; Suggest the appropriate version, using the CPU calculation
; above
;***************************************************************************

(user 2)
(set whatvers
	(askoptions
		(prompt #what-versions)
		(help #what-versions-help)
		(choices
			#pc_68000
			#pc_68020
		)
		(default cpuvers)
	)
)
(user old_level)

;***************************************************************************
; Copy reqtools.library to LIBS:
;***************************************************************************

(copylib
	(prompt "\n" #copying-reqtools)
	(help @copylib-help)
	(source reqtoolslib)
	(dest "LIBS:")
	(confirm)
)

;***************************************************************************
; Make the PowerCache directory
;***************************************************************************

(set @target-dir (tackon @target-dir CreateDir))

(makedir
	@target-dir
	(infos)
	(confirm)
	(help @makedir-help)
	(prompt #makingdir)
)

;***************************************************************************
; Copy the PowerCache executable(s) (and its/their icon(s))  :-)
;***************************************************************************

(set n 0)

(while
	(set copyver
		(select n
			PowerCache
			PowerCache020
			""
		)
	)
(
	(if (IN whatvers n)
	(
		(copyfiles
			(prompt @copying-PowerCache)
			(source copyver)
			(dest @target-dir)
			(infos)
		)
	))

	(set n (+ n 1))
))

;***************************************************************************
; Copy documentation files
;***************************************************************************

(makedir
	(tackon @target-dir "Documentation")
	(infos)
	(confirm)
	(prompt #copying-docs)
	(help #copying-docs-help)
)

(copyfiles
	(prompt @copying-docs)
	(source DocDir)
	(dest (tackon @target-dir "Documentation"))
	(pattern "#?.guide")
	(infos)
	(files)
)

;***************************************************************************
; Copy catalog files (only relevant on v38+ machines)
;***************************************************************************

(if (exists "LOCALE:")
(
	(user 2)
	(set lang
		(askoptions
			(prompt #which-language)
			(help #which-language-help)
			(choices
				"English"
				"Dansk"
			)
			(default default_lang)
		)
	)
	(user old_level)

	(set n 0)

	(while
		(set language
			(select n
				"English"
				"Dansk"
				""
			)
		)
	(
		(if (IN lang n)
		(
			(if (<> 0 n)
			(
				(makedir (cat "LOCALE:Catalogs/" language))

				(copyfiles
					(source (cat catalogdir language))
					(dest (cat "LOCALE:Catalogs/" language))
					(all)
				)
			))
		))

		(set n (+ n 1))
	))
))

;***************************************************************************
; Modify S:User-Startup if necessary
;***************************************************************************

(startup
	(
		"PowerCache"
		(prompt #fixing-ss)
		(help #startup-help)
		(command (cat "Assign PowerCache: \"" @target-dir "\" DEFER"))
	)
)
