; Install script for Bump
; 1999 Robin Cloutman

(set @default-dest "C:")

;---------------------------------------------------------------------------
;(if (= @language "english)
;(
(set #setup-text "Checking system and application...")

(set #dest-prompt "Where do you want to install Bump?\n(A new drawer will NOT be created)")
(set #dest-help "This should be in your path somewhere.")

(set #cpu-prompt "Which version of Bump do you wish to install?")
(set #cpu-help "Unless you have some reason to choose\na different version, best leave\nthis to the default version.\n(The 68000 version is safe for all cpu's)")

(set #install-prompt "Installing Bump...")
(set #install-help "Blah...")
;)
;---------------------------------------------------------------------------

(if (= (exists "Bump") 0)(abort "ERROR - Cannot find Bump!!!"))

(welcome)

(complete 0)

(working #setup-text)
(set #cpu (substr (database "cpu") 3 1))
(set #patch 0)
(set #max 0)
(foreach "" "Bump.0?0(|.pch)" (
	(set #chr (substr @each-name (- (strlen @each-name) 2) 1))
	(if (= #chr "c")((set #patch 1)(set #chr (substr @each-name (- (strlen @each-name) 6) 1))))
	(if (> #chr #max)(set #max #chr))
))
(if (> #cpu #max)(set #cpu #max))

(complete 25)

(if (>= @user-level 2)
	(set @default-dest
		(askdir
			(prompt #dest-prompt)
			(help #dest-help)
			(default @default-dest)
)))

(complete 50)

(if (>= @user-level 1)(
	(if (= #cpu 6)(set #cpu 5))
	(if (> #cpu 0)(set #cpu (- #cpu 1)))
	(set #cpu
		(askchoice
			(if (> #max 5)	(choices "68000" "68020" "68030" "68040" "68060")
			(if (> #max 4)	(choices "68000" "68020" "68030" "68040")
			(if (> #max 3)	(choices "68000" "68020" "68030")
			(if (> #max 1)	(choices "68000" "68020")
								(choices "68000")))))
			(default #cpu)
			(prompt #cpu-prompt)
			(help #cpu-help)
	))
	(if (> #cpu 0)(set #cpu (+ #cpu 1)))
	(if (= #cpu 5)(set #cpu 6))
))
(set #file (cat "Bump.0" #cpu "0"))
(if (= #patch 1)(if (= (exists (cat #file ".pch")) 1)(set #file (cat #file ".pch"))(set #patch 0)))

(complete 75)

(if (= #patch 0)
	(copylib
		(prompt #install-prompt)
		(help #install-help)
		(source #file)
		(dest @default-dest)
		(newname "Bump")
	)
	(run (cat "spatch -o" (tackon @default-dest "Bump") " -p" #file " Bump")
		(prompt #install-prompt)
		(help #install-help)
		(confirm)
	)
)

(run "Copy Bump-#? S: QUIET")

(complete 100)

(exit)
