; 
; Installer-Script for AmigaNCP
;
; $VER: AmigaNCP-Install 1.3 (25.04.99)
;

;
; Strings
; 

(set #startup-msg
(cat	"\nWelcome to AmigaNCP Release 2.0\n===============================\n\n"
		"© 1993-99 Oliver Wagner\n<owagner@vapor.com>\nAll Rights Reserved\n\n"
		"Internet support:\n"
		"http://www.vapor.com/\n"
		"ftp: ftp.vapor.com, /pub/amigancp/"
))

(set #install-msg
(cat	"Installing AmigaNCP Release 2.0\n\n"
		"Where do you want AmigaNCP be installed?\nA drawer named"
		"'AmigaNCP' will be automatically created."
))

(set #copylib-msg "Installing amigancp.library")
(set #copylib-where "Please select a directory for \"amigancp.library\".")
(set #copycat-msg "Installing catalogs")
(set #copycat-where "Please select a directory for the language catalogs.")
(set #copyserv-msg "Installing NCP Services")
(set #copydoc-msg "Installing Docs")
(set #copytools-msg "Installing Tools")
(set #copyreg-msg "Installing Registration Utility")
(set #copyicons-msg "Installing Default Icon Tree")
(set #copysub-msg "Installing Submission Material")

(set #wantdev-msg 
(cat	"Do you want to install the Developer\n"
		"Documentation and associated support files?\n\n"
		"These files are needed only when you want\n"
		"to develop applications using \"amigancp.library\"\n"
		"or want to do a catalog translation to another\n"
		"language.\n"
))
(set #copydev-msg "Copying Developer files")
(set #whats "What Psion computer do you own?\n\nThis choice will determine the baud rate used\nto access the serial port")
(set #need20 "AmigaNCP requires OS 2.04 or better!" )

(set #setpatchold "WARNING!\n========\nYour SetPatch Version %ld.%ld is TOO OLD!\n\nYou MUST at least have version 40.16 installed\nfor AmigaNCP to work properly, otherwise you\nwill experience crashes and memory losses!\n\nThe current version of SetPatch is included on the AmigaNCP registration disk or available from the Vapor support sites.")

;
; Determine if running on an 68020++
;
(procedure checkv20
	(if (>= (database "cpu") 68020 )
		(set v20-flag 1)
	)
)

;
; Check for SetPatch 40.16 or higher
;

(procedure verifysetpatch
(
(set vernum1 (getversion "c:setpatch")) (set ver1 (/ vernum1 65536)) 
(set rev1 (- vernum1 (* ver1 65536) ) ) (set setpatchver (cat ver1 "." rev1))
(if (< setpatchVer current_setpatch) (message #updatesetpatch) )

	(set vernum (getversion "C:SetPatch"))
	(set ver (/ vernum 65536 ) )
	(set rev (- vernum (* ver 65536 ) ) )
	(set setpatchver (cat ver "." rev))
	(set current_setpatch "40.16")
	(if (< setpatchver current_setpatch) 
		(message (#setpatchold ver rev ) )
		(set setpatchok 1)
	)
))
;
;
; GO!
;
;
(set vernum (getversion "LIBS:version.library"))
(set ver (/ vernum 65536 ) )
(set rev (- vernum (* ver 65536 ) ) )

(if (< ver 37 )
(
	(abort #need20)
))
(set olduserlevel (user 1))
(message #startup-msg)
(user olduserlevel)
(welcome)
(set default-dest
	(askdir
		(prompt #install-msg)
		(help @askdir-help)
		(default @default-dest)
	)
)
(complete 1)
(set @default-dest
	(tackon default-dest "AmigaNCP")
)
(complete 2)
(set olduserlevel (user 1))
(verifysetpatch)
(user olduserlevel)
(complete 3)
(makedir @default-dest (infos))
(makedir (tackon @default-dest "Docs" ) (infos))
(makedir (tackon @default-dest "Tools" ) (infos))
(makedir (tackon @default-dest "Submissions" ) (infos))
(makedir (tackon @default-dest "Registration" ) (infos))
(makedir (tackon @default-dest "Icons" ))
(complete 2)
;
; Copy lib
;
(set #libname "libs/amigancp.library")
(checkv20)
(if v20-flag
(
	(set #libname "libs/amigancp.library.020")
))
(copyfiles
	(help @copyfiles-help)
	(prompt #copylib-msg)
	(confirm)
	(source #libname)
	(newname "amigancp.library")
	(dest
		(askdir
			(prompt #copylib-where)
			(help @askdir-help)
			(default "LIBS:")
		)
	)
)
(complete 10)
(if (> ver 37 )
(
	(copyfiles
		(source "Catalogs")
		(prompt #copycat-msg)
		(help @copyfiles-help)
		(dest "LOCALE:Catalogs")
		(confirm)
		(all)
	)
))
(complete 20)
(copyfiles
	(source "")
	(pattern "AmigaNCP#?")
	(prompt #copyserv-msg)
	(help @copyfiles-help)
	(confirm)
	(infos)
	(dest @default-dest)
)
(complete 34)
(copyfiles
	(source "Icons")
	(prompt #copyicons-msg)
	(help @copyfiles-help)
	(dest (tackon @default-dest "Icons" ) )
	(all)
	(infos)
)
(complete 36)
(copyfiles
	(source "Submissions")
	(prompt #copysub-msg)
	(help @copyfiles-help)
	(dest (tackon @default-dest "Submissions" ) )
	(all)
	(infos)
)
(complete 38)
(delete (tackon @default-dest "Icons.info" ))
(complete 39)
(foreach "" "AmigaNCP#?"
	(tooltype (
		(dest (tackon @default-dest @each-name ) )
		(noposition)
	)
))
(complete 40)
(copyfiles
	(source "Docs")
	(prompt #copydoc-msg)
	(help @copyfiles-help)
	(confirm)
	(infos)
	(all)
	(dest (tackon @default-dest "Docs" ) )
)
(complete 60)
(copyfiles
	(source "Tools")
	(prompt #copytools-msg)
	(help @copyfiles-help)
	(confirm)
	(infos)
	(all)
	(dest (tackon @default-dest "Tools" ) )
)
(complete 70)
(copyfiles
	(source "Registration")
	(prompt #copyreg-msg)
	(help @copyfiles-help)
	(confirm)
	(infos)
	(all)
	(dest (tackon @default-dest "Registration" ) )
)
(complete 78)
(copyfiles
	(help @copyfiles-help)
	(prompt #copylib-msg)
	(source "Registration/vapor_registration.library")
	(dest "LIBS:")
)
(complete 79)
(copyfiles
	(help @copyfiles-help)
	(prompt #copylib-msg)
	(source "Libs/vapor_toolkit.library")
	(dest "LIBS:")
)
(complete 80)
(if (askbool
		(prompt #wantdev-msg)
		(help #wantdev-msg)
		(default 1)
	)
(
	(set devdir (tackon @default-dest "Developer"))
	(makedir devdir (infos))
	(copyfiles
		(source "Developer")
		(prompt #copydev-msg)
		(help @copyfiles-help)
		(dest devdir)
		(confirm)
		(infos)
		(all)
	)
))
(complete 90)
(if ( = (exists "ENV:AmigaNCP.config") 0 )
(
	(run (tackon @default-dest "AmigaNCP-Prefs" ) )
))
(complete 100)
