; *******************************************************************
;
; $VER: Install 3.5 (18.6.97)
; 
; Install script for Xtruder copyright © 1995-1997 Martin Wulffeld
;
; *******************************************************************

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

(set default_lang 256)

(set #bad-kick
(cat "You must at least have Kickstart 2.04 to install Xtruder!"
))

(set #copying-bootblockbb	"\nCopying Bootblock.brainfile to L:...")
(set #copying-bootblock		"\nCopying Bootblock.library 3.1 to LIBS:...")
(set #copying-fileid		"\nCopying FileID.library 7.10 to LIBS:...")
(set #copying-filevirus		"\nCopying filevirus.library 2.11 to LIBS:...")
(set #copying-reqtools		"\nCopying reqtools.library 38.1436 to LIBS:...")
(set #copying-unpack		"\nCopying unpack.library 42.71 to LIBS:...")
(set #copying-xfdlib        "\nCopying xfdmaster.library 37.6 to LIBS:...")
(set #copying-xtruderlib	"\nCopying xtruder.library 37.2 to LIBS:...")
(set #copying-xtruderexe	"\nCopying Xtruder executable...")
(set #copying-documentation	"\nCopying Xtruder documentation...")
(set #copying-regfiles		"\nCopying registration files...")
(set #copying-catalogs		"\nCopying catalogs...")
(set #copying-rexxscripts	"\nCopying rexx scripts...")
(set #creating-xfd			"\nCreating directory\n\nLIBS:xfd\n\nfor external decrunchers...")
(set #copying-xfdfiles		"\nCopying external decrunchers\nfor xfdmaster.library...")
(set #select-dest			"Please select the path where you want to install Xtruder. A drawer named Xtruder will be created there.")
(set #select-destguide		"Please select the alternative path where you want to install the Xtruder documentation. It has already been installed along with the main program.")
(set #select-destrexx		"Please select the path where you want to install the Rexx scripts. A drawer named Xtruder will be created there.")
(set #select-language       "Which languages should be installed?")

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

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

;=============================================================================

;*** Required libraries

(copylib
	(prompt #copying-bootblockbb)
	(help @copylib-help)
	(source "L/Bootblock.brainfile")
	(dest "L:")
	(confirm)
)

(copylib
	(prompt #copying-bootblock)
	(help @copylib-help)
	(source "Libs/Bootblock.library")
	(dest "LIBS:")
	(confirm)
)

(copylib
	(prompt #copying-fileid)
	(help @copylib-help)
	(source "Libs/FileID.library")
	(dest "LIBS:")
	(confirm)
)

(copylib
	(prompt #copying-filevirus)
	(help @copylib-help)
	(source "Libs/filevirus.library")
	(dest "LIBS:")
	(confirm)
)

(copylib
	(prompt #copying-reqtools)
	(help @copylib-help)
	(source "Libs/reqtools.library")
	(dest "LIBS:")
	(confirm)
)

(copylib
	(prompt #copying-unpack)
	(help @copylib-help)
	(source "Libs/unpack.library")
	(dest "LIBS:")
	(confirm)
)

(copylib
	(prompt #copying-xfdlib)
	(help @copylib-help)
	(source "Libs/xfdmaster.library")
	(dest "LIBS:")
	(confirm)
)

(copylib
	(prompt #copying-xtruderlib)
	(help @copylib-help)
	(source "Libs/xtruder.library")
	(dest "LIBS:")
	(confirm)
)

(set xfdokay
	(makedir "LIBS:xfd"
		(prompt #creating-xfd)
		(help @makedir-help)
		(confirm)
	)
)

(if xfdokay
	(copyfiles
		(prompt #copying-xfdfiles)
		(help @copyfiles-help)
		(source "Libs/xfd")
		(pattern "#?")
		(dest "LIBS:xfd/")
		(confirm)
	)
)

;*** Xtruder executable

(set programdir
	(tackon
		(askdir
			(prompt #select-dest)
			(help @askdir-help)
			(default "SYS:")
			(newpath)
		)
		"Xtruder"
	)
)

(set @default-dest programdir)

(copyfiles
	(prompt #copying-xtruderexe)
	(source "Xtruder")
	(dest programdir)
	(infos)
)

;*** Backup rexx script to Xtruder dir for backup

(copyfiles
	(prompt #copying-rexxscript)
	(source "")
	(dest programdir)
	(pattern "Rexx#?")
)

;*** Copy Catalogs to Xtruder dir for backup

(copyfiles
	(prompt #copying-catalogs)
	(source "")
	(dest programdir)
	(pattern "Catalogs#?")
)

;*** Copy registration files

(copyfiles
	(prompt #copying-regfiles)
	(source "")
	(dest programdir)
	(pattern "Registration#?")
)

;*** Documentation files

; Backup

(copyfiles
	(prompt #copying-documentation)
	(source "")
	(dest programdir)
	(pattern "Documentation#?")
)

; Ask if documentation should be installed elsewhere

(set tempdocdir
	(tackon
		programdir
		"Documentation"
	)
)

(set docdir
	(askdir
		(prompt #select-destguide)
		(help @askdir-help)
		(default tempdocdir)
		(newpath)
	)
)

(copyfiles
	(prompt #copying-documentation)
	(source "Documentation/Xtruder.guide")
	(dest docdir)
	(infos)
)

;*** Rexx scripts

(set rexxdir
	(tackon
		(askdir
			(prompt #select-destrexx)
			(help @askdir-help)
			(default "REXX:")
			(newpath)
		)
		"Xtruder"
	)
)

(copyfiles
	(prompt #copying-rexxscripts)
	(source "Rexx")
	(pattern "#?")
	(dest rexxdir)
)

;*** Install catalog

(if (exists "SYS:Locale")
(
	(if (exists "LOCALE:")
	(
		(set lang (askoptions (prompt #select-language)
								(help #which-language-help)
								(choices
									"Dansk"
									"Deutsch"
									"Français"
									"Italiano"
									"Nederlands"
									"Norsk"
									"Suomi"
									"Svenska"
									"English")
								(default default_lang)
					)
		)
		
		(set n 0)
		(while
			(set language (select n
								"dansk"
								"deutsch"
								"français"
								"italiano"
								"nederlands"
								"norsk"
								"suomi"
								"svenska"
								"")
			)
		(
			(if (IN lang n)
			(
				(if (< n 9)
				(
					(makedir (cat "LOCALE:Catalogs/" language))
					
					(copyfiles (source (cat "Catalogs/" language))
						(dest (cat "LOCALE:Catalogs/" language))
						(all)
					)
				))
			))
			(set n (+ n 1))
		))
	))
))

(exit "Please reboot! Some older versions of the installed files might be present in memory."
)
