; Install script for AmiComSys 1.17
;
; $VER: AmiComSys-install 1.4 (03.03.98) Håkan Parting
(set highcpu 1)

; ** set system variables **
(set cpu (database "cpu"))
(if (= cpu 68000) (set #cpu 0))
(if (= cpu 68010) (set #cpu 1))
(if (= cpu 68020) (set #cpu 2))
(if (= cpu 68030) (set #cpu 3))
(if (= cpu 68040) (set #cpu 4))
(if (> (exists ("sys:libs/68060.library")) 0) (set #cpu 5) )
(set osver (/ (getversion) 65536))
(set foundbetterstring 0)

; set texts
(set #nonlist "AmiComSys requires the MUI-costum-class\nNList.mcc version 19+ by Gilles Masson\n\nIt must be installed before AmiComSys\nPlease, download it from Aminet:dev/mui/MCC_NList0.75.lha\nAnd install it with the included installer script\nThen try to install AmiComSys again ...")
(set #nomui "AmiComSys requires Magic User Interface (MUI) 3.8!\n\nYou can find it on Aminet:dev/gui/mui38usr.lha")
(set #wrongcpu0 "This archive does only include a version for 68020 and\nhigher.\n\nYou may download a 68000 version from\nhttp://hem.passagen.se/hparting/amigapa.html\nAt the bottom of the page\n\nInstallation is aborted")
(set #wrongcpu2 "This archive does only include a version for 68000 and\nhigher. A version for 68020 and higher is available\nat http://hem.passagen.se/hparting/amigapa.html\nor\nAminet:comm/net/AmiComSysMUI.lha")
(set #noamarquee "AmiComSys requires AMarquee.library version 47+ by Jeremy Friesner!\n\nPlease download it from Aminet:comm/net/AMarquee1_47.lha")
(set #seldocs "Select which documentation you want to install!")
(set #selscr "Do you want to install the following Arexx-scripts?\nThey may be executed at different occasions.\nIf you already have a costum version of these you\nshould not check the checkboxes infront of the names.")
(set #selscrhelp "The NotifyArexx.amicomsys may be executed when someone is\nconnecting or disconnecting. A simple example is included in this\narchive, but a more versatile one can be found at\nAminet:comm/net/ACS-Notify.lha and is written by Scott Beardwood\nThe MessageArexx.amicomsys script may be executed when someone\nmessage you. There is a simple example script in this archive.\nThese scripts does only work if you have registered AmiComSys.")
(set #readmefile "AmiComSysMUI1.17.readme");
(set #notextinput "If you are using Amiga Kickstart 36, 37 or 38\nAmiComSys requires the costum MUI class\nTextinput.mcc.\nThis class couldn't be found in\nyour LIBS:/mui directory.\n\nPlease download it from\nftp://ftp.vapor.com/misc/textinpt_13.XX.lzx\nwhere XX is 34 or higher.");

(message
 	"Welcome to the AmiComSys 1.17 installer!\n\n"
	"You may either use this for a first\n"
	"time install or for updating a former\n"
	"version of AmiComSys.\n\n\n"
	"AmiComSys © Håkan Parting 1997-1998\n"
	"68020 version\n"
	"Requires:\n"
	"MUI 3.8+ © Stefan Stuntz\n"
	"AMarquee 1.47+ © Jeremy Friesner\n"
	"NList.mcc 19+ © Gilles Masson\n"
	"BetterString.mcc © Allan Odgaard\n"	
)

(if (< (exists "MUI:") 2) (exit #nomui) )
(if (exists "LIBS:muimaster.library") (
	(set muiver (/(getversion "LIBS:muimaster.library") 65536))
))
(if (< muiver 19) ( 
	(exit #nomui)
))

(set muiver 0)
(if (exists "LIBS:MUI/NList.mcc") (
	(set muiver (/(getversion "LIBS:MUI/NList.mcc") 65536))
))
(if (< muiver 19) ( 
	(exit #nonlist)
))

(set amaver 0)
(if (exists "LIBS:amarquee.library") (
	(set amaver (/(getversion "LIBS:amarquee.library") 65536))
))
(if (< amaver 47) ( 
	(exit #noamarquee)
))

(set texver 0)
(if (< osver 39) (
	(if (exists "LIBS:mui/Textinput.mcc") (
		(set texver (/(getversion "LIBS:mui/Textinput.mcc") 65536))
	))
	(if (< texver 13) ( 
		(exit #notextinput)
	))
	(if (exists "LIBS:mui/BetterString.mcc") (
		(set foundbetterstring 1)
	))
))

(welcome)
(set cpuVal (askchoice (choices "68000" "68010" "68020" "68030"
		                 "68040" "68060"
	    			)
				(prompt "Please, select the processor your Amiga have")
	        	(help   "Recommended is to leave it as default")
          		(default #cpu)
  		)
)

(if (= highcpu 1) (if (< cpuVal 2) (exit #wrongcpu0) ))
(if (= highcpu 0) (if (> cpuVal 1) (message #wrongcpu2) ))

(set DefDir (getassign "MIAMI"))
(if (= DefDir "") (set DefDir (getassign "AmiTCP")) )
(if (= DefDir "") (set DefDir (getassign "Inet")) )

(set #target (askdir	(prompt "Where do you want to install AmiComSys?\nA directory named AmiComSys will be created.")
						(help "Select a directory, where you want to install AmiComSys!\nA directory named AmiComSys will be created there.")
						(default @default-dest)
))

(set instdir (tackon #target "AmiComSys"))
(set @default-dest instdir)

(makedir instdir (infos))

; copy over files

(copyfiles (source "AmiComSys") (dest instdir) )

(if (= (exists (tackon instdir "AmiComSys.info")) 1))
(
	(makedir (tackon instdir "icons") (infos))
	(copyfiles (source "AmiComSys.info") (dest (tackon instdir "icons")))
)
(if (= (exists (tackon instdir "AmiComSys.info")) 0))
	(copyfiles (source "AmiComSys.info") (dest instdir))

;(tooltype (dest (tackon instdir "AmiComSys")) (settooltype "PROGDIR" instdir) )

(copyfiles (source "Contrib") (dest (tackon instdir "Contrib")) (all) (infos))
(copyfiles (source "Register") (dest (tackon instdir "Register")) (all) (infos))

(copyfiles (source "Rexx") (pattern "~(NotifyArexx.amicomsys|MessageArexx.amicomsys)") (dest (tackon instdir "Rexx")))

(set arscrp (askoptions (choices "NotifyArexx.amicomsys" "MessageArexx.amicomsys")
					(prompt #selscr)
					(help #selscrhelp)
					(default 0)
))

(if (<> arscrp 0) (
	(if (IN arscrp 0) (copyfiles (source "Rexx/NotifyArexx.amicomsys") (dest (tackon instdir "Rexx"))))
	(if (IN arscrp 1) (copyfiles (source "Rexx/MessageArexx.amicomsys") (dest (tackon instdir "Rexx"))))
))

; install docs
(set docs (askoptions (choices "AmiComSysMUI.guide" "AmiComSys.readme" "BetterString.readme" "Readme.mui")
				(prompt #seldocs)
				(help #seldocs)
				(default 15)
))

(if (<> docs 0) (
	(if (IN docs 1) (copyfiles (source #readmefile) (dest instdir) (newname "AmiComSys.readme") (infos) ) )
	(if (IN docs 0) (
		(set #doctarget (askdir (prompt "Where do you want to install the guide?")
				(default instdir)
				(help "Select where to install the documentation.\nRecommended is the AmiComSys directory\nor your HELP: directory.")
		))
		(copyfiles (source "AmiComSysMUI.guide") (dest #doctarget) (infos))
	))
	(if (IN docs 2) (
		(copyfiles (source "mui/libs/mui/BetterString.doc") (dest instdir) (infos))
	))
	(if (IN docs 3) (
		(copyfiles (source "Readme.mui") (dest instdir) (infos))
	))
))

(if (= foundbetterstring 1) (
(delete "LIBS:mui/BetterString.mcc" (prompt "Do you want to delete the MUI costum class\nBetterString.mcc?\nIt will hang your system when you open MUI-prefs!" )
         (help "This MUI costum class does hang your system on a Kickstart V37 Amiga.")
         (confirm "average")
         (optional "oknodelete" "force")
)
))


(if (> osver 38) (
(copylib (prompt #prompt_copy "\n\nBetterString.mcc" )
         (help @copylib-help)
         (confirm "average")
         (source "mui/libs/mui/BetterString.mcc")
         (dest "LIBS:mui/")
         (optional "oknodelete" "force")
)

(copylib (prompt #prompt_copy "\n\nBetterString.mcp" )
         (help @copylib-help)
         (confirm "average")
         (source "mui/libs/mui/BetterString.mcp")
         (dest "LIBS:mui/")
         (optional "oknodelete" "force")
)
))
(message "Thanks for using AmiComSys!\n\n"
		"If the MUI-costum class Newstring.mcc is installed\nit will be used instead of BetterString.mcc\nfor almost every string-gadget. This is optional\nin the General settings - Program page -Various tab\n"
		"You should now start AmiComSys and configure it.\nMost important is that you enter a login name\nand your emailaddress.\nThe emailaddress is your unique name on server\nIt will not be visible for any other user.\n"
		"\nPlease support further development by registering. Read guide for more info.")
