; 
; Installer-Script for AmigaNCP
;
; $VER: AmigaNCP-Install 1.1 (26.10.96)
;

;
; Strings
; 

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

(set #install-msg
(cat	"Installing AmigaNCP Release 1.9\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 vernum (getversion "C:SetPatch"))
	(set ver (/ vernum 65536 ) )
	(set rev (- vernum (* ver 65536 ) ) )
	(if ( OR ( (> ver 40) (AND ( = ver 40 ) ( >= rev 16 ) ) ) )
		(set setpatchok 1)
		(message (#setpatchold ver rev ) )
	)
))
;
;
; 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 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:NCP.config") 0 )
(
	(set s3amode (askchoice
		(choices "Psion S3 (or HC) - 9600 baud" "Psion S3a (or MC) - 19200 baud" "Psion S3c and slow Amiga - 38400 baud" "Psion S3c - 57600 baud" )
		(default 0 )
		(prompt #whats)
		(help @askchoice-help)
	))
	(set baud 9600)
	(if ( = 1 s3amode ) (set baud 19200))
	(if ( = 2 s3amode ) (set baud 38400))
	(if ( = 3 s3amode ) (set baud 57600))
	(textfile 
		(dest "ENV:NCP.config")
		(append ( "DEVICE=serial.device UNIT=0 BAUD=%ld" baud ) )
	)
	(run "copy ENV:NCP.config ENVARC:NCP.config")
))
(complete 100)
