; MPImage - Amiga Image Conversion
; Copyright (C)  1996 Mark John Paddock
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; any later version.

; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
; GNU General Public License for more details.

; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

; mark@topic.demon.co.uk
; mpaddock@cix.compulink.co.uk
; MPImage - Amiga Image program
; Copyright (C)  1993-96 Mark John Paddock

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

; This is the script to install MPImage
; $VER: Install-MPImage 7.2 (16.2.97)

(complete 10)

;Check where to install libraries
(Set #LibChoice
	(askchoice
		(prompt "Where do you want to install the libraries?\n\n"
			"You can choose to install the libraries required by MPImage "
			"in the current directory, "
			"your LIBS: directory, or some other directory.")
		(help @askchoice-help)
		(choices "In Place" "LIBS:" "Elsewhere")
		(default 1)
	)
)

(complete 20)

(if (= #LibChoice 2)
	(Set #LibDir
		(askdir
			(prompt "Select directory in which to install the MPImage libraries")
			(help @askdir-help)
			(default "LIBS:")
		)
	)
)

(complete 30)

; Set up directory names
(Set #DestDir (expandpath ""))

(if (= #libchoice 0)
	(Set #LibDir #DestDir)
)

(if (= #libchoice 1)
	(Set #LibDir "LIBS:")
)

(set @default-dest 
	#DestDir
)

; Determine machine config
(Set #Has020
	(=
		(database "cpu")
		68020
	)
)
(Set #Has030
	(=
		(database "cpu")
		68030
	)
)
(Set #Has040
	(= 
		(database "cpu")
		68040
	)
)
(Set #Has060
	(= 
		(database "cpu")
		68060
	)
)
(Set #HasFPU
	(<>
		(database "fpu")
		"NOFPU"
	)
)

(Set #CPU 0)
(if #Has020
	(Set #CPU 1)
)
(if #Has030
	(Set #CPU 1)
)
(if (AND #Has020 #HasFPU)
	(Set #CPU 2)
)
(if (AND #Has030 #HasFPU)
	(Set #CPU 2)
)
(if (AND #Has040 #HasFPU)
	(Set #CPU 3)
)
(if #Has060
	(Set #CPU 4)
)

(Set #DestLib "MPImage.library")

(Set #DestGui "MPGui.library")

(Set #SrcGui "libs/MPGui.library")

(complete 40)

; Check choice of program to install
(set #CPU
	(askchoice
		(prompt "Install which version?")
		(help "There are five versions of the MPImage.library. "
				"The first requires just a 68000. "
				"The second requires a 68020. "
				"The third requires both a 68020 or 68030 CPU with a 68881 or 68882 FPU. "
				"The forth requires a 68040. "
				"The last requires a 68060.")
		(choices
			"68000"
			"68020"
			"68020/030/68881/2"
			"68040"
			"68060"
		)
		(default #CPU)
	)
)

(complete 50)

(if (= #CPU 4)
 	(set #SrcLib "libs/MPImage.library.060")
)
(if (= #CPU 3)
 	(set #SrcLib "libs/MPImage.library.040")
)
(if (= #CPU 2)
 	(set #SrcLib "libs/MPImage.library.881")
)
(if (= #CPU 1)
 	(set #SrcLib "libs/MPImage.library.020")
)
(if (= #CPU 0)
 	(set #SrcLib "libs/MPImage.library.000")
)

(complete 60)

; Copy libraries
(
	(copylib
		(source #SrcGui)
		(dest #LibDir)
		(newname #DestGui)
	)
)

(complete 70)

(
	(copylib
		(source #SrcLib)
		(dest #LibDir)
		(newname #DestLib)
	)
)

(complete 80)

(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. Depending on how cjpeg was compiled "
						"you may/may not need to supply < before the input file "
						"and/or > before the output file.")
				(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. Depending on how djpeg was compiled "
						"you may/may not need to supply < before the input file "
						"and/or > before the output file.")
				(default 'djpeg "%s" "%s"')
			)
		)
		(textfile
			(dest "ENV:MPImage/djpeg")
			(append #djpeg)
		)
		(textfile
			(dest "ENVARC:MPImage/djpeg")
			(append #djpeg)
		)
	)
)

(complete 90)

(if
	(askbool
		(prompt "Do you have pngtopnm and pnmtopng?")
		(help "Select 'Yes' if you have pngtopnm and pnmtopng and you wish to "
				"use them to load and save PNG files.")
	  	(default 0)
	)
	(
		(makedir
			"ENV:MPImage"
		)
		(makedir
			"ENVARC:MPImage"
		)
		(set #pnmtopng
			(askstring
				(prompt "Enter your command to run pnmtopng")
				(help '"%s" should be used to in place of the input and '
						"output files. Depending on how pnmtopng was compiled "
						"you may/may not need to supply < before the input file "
						"and/or > before the output file.")
				(default 'pnmtopng "%s" >"%s"')
			)
		)
		(textfile
			(dest "ENV:MPImage/pnmtopng")
			(append #pnmtopng)
		)
		(textfile
			(dest "ENVARC:MPImage/pnmtopng")
			(append #pnmtopng)
		)
		(set #pngtopnm
			(askstring
				(prompt "Enter your command to run pngtopnm")
				(help '"%s" should be used to in place of the input and '
						"output files. Depending on how pngtopnm was compiled "
						"you may/may not need to supply < before the input file "
						"and/or > before the output file.")
				(default 'pngtopnm "%s" >"%s"')
			)
		)
		(textfile
			(dest "ENV:MPImage/pngtopnm")
			(append #pngtopnm)
		)
		(textfile
			(dest "ENVARC:MPImage/pngtopnm")
			(append #pngtopnm)
		)
	)
)

(complete 100)
