; 
; Installer-Script for AmigaNCP
;
; $VER: AmigaNCP-Install 0.5 (24.02.95)
;

;
; Strings
; 

(set #install-msg
(cat	"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 #copyicons-msg "Installing Default Icon Tree")

(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"
))
(set #copydev-msg "Copying Developer files")
(set #whats "What Psion computer do you own?")
(set #need20 "AmigaNCP requires OS 2.04 or better!" )

;
; Determine if running on an 68020++
;
(procedure checkv20
	(if (>= (database "cpu") 68020 )
		(set v20-flag 1)
	)
)
;
;
; GO!
;
;
(set vernum (getversion "LIBS:version.library"))
(set ver (/ vernum 65536 ) )
(set rev (- vernum (* ver 65536 ) ) )

(if (< ver 37 )
(
	(abort #need20)
))
(welcome)
(set default-dest
	(askdir
		(prompt #install-msg)
		(help @askdir-help)
		(default @default-dest)
	)
)
(complete 1)
(set @default-dest
	(tackon default-dest "AmigaNCP")
)
(makedir @default-dest (infos))
(makedir (tackon @default-dest "Docs" ) (infos))
(makedir (tackon @default-dest "Tools" ) (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
			(askdir
				(prompt #copycat-where)
				(help @askdir-help)
				(default "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 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)
(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)" "Psion S3a (or MC)")
		(default 0 )
		(prompt #whats)
		(help @askchoice-help)
	))
	(if s3amode (
		(textfile 
			(dest "ENV:NCP.config")
			(append "DEVICE=serial.device UNIT=0 BAUD=19200")
		)
	)
	(
		(textfile 
			(dest "ENV:NCP.config")
			(append "DEVICE=serial.device UNIT=0 BAUD=9600")
		)
	))
	(run "copy ENV:NCP.config ENVARC:NCP.config")
))
(complete 100)
