; MPImage - Amiga Image program
; Copyright (C)  1993-95 Mark John Paddock

; mark@topic.demon.co.uk
; mpaddock@cix.compulink.co.uk

; This is the script to install MPImage
; $VER: Install-MPImage 4.0 (5.7.95)

(complete 0)

; Determine machine config
(Set Use040
	(= 
		(database "cpu")
		68040
	)
)

(Set Has881
	(+
		(AND
			(NOT (run "cpu check 68881"))
			(>=
				(database "cpu")
				68020
			)
		)
		Use040
	)
)

(Set InstallDir (expandpath ""))

(Set DestLib
	(tackon InstallDir "MPImage.library")
)

; Check choice of program to install
(set Use881
	(askchoice
		(prompt "Install which version?")
		(help "There are three versions of the MPImage.library. "
				"One which requires a 68020. "
				"One requires both a 68020 or 68030 CPU with a 68881 or 68882 FPU. "
				"The other requires a 68040.")
		(choices
			"68020"
			"68020/030/68881/2"
			"68040"
		)
		(default Has881)
	)
)

(if (> Use881 1)
	(
	 	(set SrcLib
			(tackon InstallDir "MPImage.library.040")
	 	)
		(copyfiles
			(source SrcLib)
			(dest InstallDir)
			(newname DestLib)
		)
	)
)

(if (= Use881 1)
	(
	 	(set SrcLib
			(tackon InstallDir "MPImage.library.881")
	 	)
		(copyfiles
			(source SrcLib)
			(dest InstallDir)
			(newname DestLib)
		)
	)
)

(if (= Use881 0)
	(
	 	(set SrcLib
			(tackon InstallDir "MPImage.library.020")
	 	)
		(copyfiles
			(source SrcLib)
			(dest InstallDir)
			(newname DestLib)
		)
	)
)

(complete 50)

(if
	(askbool
		(prompt "Do you have djpeg and cjpeg?")
		(help "Select 'Yes' if you have cjpeg and djpeg and you wish to "
				"use them to load and save jpeg files.")
	  	(default 0)
	)
	(
		(makedir
			"ENV:MPImage"
		)
		(makedir
			"ENVARC:MPImage"
		)
		(set cjpeg
			(askstring
				(prompt "Enter your command to run cjpeg")
				(help '"%s" should be used to in place of the input and '
						"output files")
				(default 'cjpeg "%s" "%s"')
			)
		)
		(textfile
			(dest "ENV:MPImage/cjpeg")
			(append cjpeg)
		)
		(textfile
			(dest "ENVARC:MPImage/cjpeg")
			(append cjpeg)
		)
		(set djpeg
			(askstring
				(prompt "Enter your command to run djpeg")
				(help '"%s" should be used to in place of the input and '
						"output files")
				(default 'djpeg "%s" "%s"')
			)
		)
		(textfile
			(dest "ENV:MPImage/djpeg")
			(append djpeg)
		)
		(textfile
			(dest "ENVARC:MPImage/djpeg")
			(append djpeg)
		)
	)
)

(complete 100)
