; Installation program for the Commodore's Installer utility

(complete 0)

(set name
	(askdir
		(prompt "Where do you want to install EpsLab ?\n(a drawer named EpsLab \
will be created if it doesn't exists)")
		(help @askdir-help)
		(default "")
	)
)

(set name (tackon name "EpsLab"))

(if (NOT (exists name))
	(makedir name
			(infos)
	)
)

(set @default-dest name)

(if (exists (tackon name "EpsLab.info"))
	(message (cat "Warning: tooltypes from the old version will be "
				"lost: remember to save them before you proceed.")
	)
)

(set vernum (/ (getversion) 65536))   ; se version >37: c'è localizzazione

(if (> vernum 37)
	(set local
		(askbool
			(prompt "Do you want to install the support file for the italian language ?")
			(help local-help)
			(default 0)
		)
	)
	(set local 0)
)

(if local
	(if (and (= @user-level 2) (exists "LOCALE:catalogs/italiano"))
		(set sysdest
			(askchoice
				(prompt "Where do you want to install the localization file ?")
				(help @askchoice-help)
				(choices "in the same drawer as EpsLab" "in LOCALE:")
				(default 1)
			)
		)
	)
)

(if (not (exists "LOCALE:catalogs/italiano"))
	(set sysdest 0)
)

(complete 25)

(set maincpu (database "cpu"))

;(if (AND (<> maincpu "68000") (<> maincpu "68010"))
;	(set fpu
;		(askchoice
;			(prompt "Do you have a math coprocessor installed ?")
;			(help @askchoice-help)
;			(choices "Yes" "No" "I don't know")
;			(default 0)
;		)
;	)
;
	(set fpu 1)
;)

(if (<> fpu 0)
	(copylib
		(source "/Libs/post.library")
		(dest "LIBS:")
		(confirm)
		(prompt "About to install 'post.library'")
		(help "If you want to EpsLab to render full preview images instead of \
crossboxes, you should install post.library")
	)

	(copylib
		(source "/Libs/post.library.2620")
		(dest "LIBS:")
		(newname "post.library")
		(confirm)
		(prompt "About to install 'post.library' (FPU version)")
		(help "If you want to EpsLab to render full preview images instead of \
crossboxes, you should install post.library")
	)
)	

(complete 50)

(if (exists "LIBS:post.library")
	(
	 (if (not (exists "PSFONTS:" (noreq)))
		(
		 (set psf 
			(askdir
				(prompt "You need a drawer to store PostScript fonts\n(no new \
drawers will be created)")
				(help @askdir-help)
				(default "sys:")
			)
		 )
		 (startup "EpsLab"
			(command (cat "assign PSFONTS: " psf))
			(prompt "An assign needs to be added to your User-Startup.")
			(help @startup-help)
		 )
		 (makeassign "PSFONTS" psf)
		)
	 )
	 (copyfiles
			(source "/PS/FunkyFont")
			(dest "PSFONTS:")
			(optional nofail)
	 )
	 (copyfiles
			(source "/PS/afms/FunkyFont.afm")
			(dest "PSFONTS:afms")
			(optional nofail)
	 )
	)
)

(complete 75)

(copyfiles
	(infos)
	(source "/EpsLab")
    (dest name)
)

(copyfiles
	(source "/PS/init.ps")
    (dest name)
)

(tooltype
    (dest (tackon name "EpsLab"))
	(noposition)
)

(complete 90)

(if local
 	(if sysdest
		(copyfiles
			(source "/catalogs/italiano/EpsLab.catalog")
			(dest "LOCALE:catalogs/italiano")
		)
        (
			(makedir (tackon name "catalogs"))
			(copyfiles
				(source "/catalogs/italiano/EpsLab.catalog")
				(dest (tackon name "catalogs/italiano"))
            )
		)
    )
)

(complete 100)

