;---------------------------------------------------------------
;
; Installer script for ADoc
; $VER: 36.0 (24.04.94)
; Written by Denis GOUNELLE
;
;---------------------------------------------------------------
;
(complete 0)
(set ProgVer  "3.13")
(set ProgName "ADoc")
(set KickVer  (/ (getversion) 65536))
(set SCFlag   (if (AND (> KickVer 35) (exists "S:.SoftConfig")) 1 0))
;
(set InstallOpt
	(askoptions (prompt "Which part of the program whould you like to install ?")
		    (help @askoptions-help)
		    (choices "Program" "Locales" "ReqTools.library")
	)
)
;
;--------------------- Install the program --------------------
;
(complete 20)
(if (BITAND InstallOpt 1)
	((set ProgDir (askdir
		(prompt "Select the directory where to install ADoc")
		(help "The program will be copied in this directory. You may want to install ADoc in a directory which is in your default path.")
		(default "SYS:Utilities/")
		)
	 )
	 (copyfiles (prompt "Installing program")
		(help @copyfiles-help)
		(source ProgName)
		(newname "ADoc")
		(dest ProgDir)
		(infos)
	 )
	 (if SCFlag (run (cat "SoftConfig ADD ADoc " (tackon ProgDir "ADoc") " FILE " ProgVer)))
	)
)
;
;--------------------- Install the locale --------------------
;
(complete 40)
(if (BITAND InstallOpt 2)
	((set Langage (askchoice (prompt "Which locale do you want to install ?")
				(help @askchoice-help)
				(choices "deutsch" "français" "none")))
	 (if (= Langage 0) (set LocaleName "deutsch"))
	 (if (= Langage 1) (set LocaleName "français"))
	 (if (NOT (= Langage 2))
		((set LocaleSrc (tackon "catalogs" LocaleName))
		 (set LocaleDst (tackon "LOCALE:" LocaleSrc))
		 (set LocaleName "ADoc.catalog")
		 (if (NOT (exists LocaleDst)) (makedir LocaleDst (prompt "Creating locale directory") (help @makedir-help)))
		 (copyfiles (prompt "Installing locale")
			(help @copyfiles-help)
			(source (tackon LocaleSrc LocaleName))
			(dest LocaleDst)
		 )
		 (if SCFlag
			((run (cat "SoftConfig ADD " LocaleName " " (tackon LocaleDst LocaleName) " FILE " ProgVer))
			 (run (cat "SoftConfig ATTACH ADoc " LocaleName))
			)
		))
	))
)
;
;--------------------- Install ReqTools.library --------------------
;
(complete 60)
(if (BITAND InstallOpt 4)
	((if (> KickVer 35) (set LibExt "20") (set LibExt "13"))
	 (copylib (prompt "Installing reqtools.library")
		(help @copylib-help)
		(source (cat "/libs/reqtools.library" LibExt))
		(dest "LIBS:")
		(newname "reqtools.library")
		(confirm)
	))
)
;
(if (exists "LIBS:reqtools.library")
	((set RTVer  (getversion "LIBS:reqtools.library"))
	 (set RTNVer (/ RTVer 65536))
	 (set RTSVer ("%ld.%ld" RTNVer (- RTVer (* RTNVer 65536))))
	 (if SCFlag
		((run (cat "SoftConfig ADD reqtools.library LIBS:reqtools.library FILE " RTSVer))
		 (run "SoftConfig ATTACH ADoc reqtools.library")
		)
	))
)
;
;--------------------- Install ADOC: --------------------
;
(complete 80)
(set ADocDir (askdir
	 (prompt "Which directory assign to ADOC: ?")
	 (help "Select the directory where are (or will be) installed the documentation files to use with ADoc")
	 (default (expandpath "ADOC:"))
	 (newpath))
)
(makeassign "ADOC" ADocDir)
(if SCFlag
	((run (cat "SoftConfig ADD ADOC: " ADocDir " ASSIGN " ProgVer))
	 (run "SoftConfig ATTACH ADoc ADOC:")
	)
	(startup "ADoc" (prompt "Updating your S:User-Startup file")
		(help "Adding the ADOC: assign to your startup sequence")
		(command (cat "Assign ADOC: " ADocDir "\n"))
	)
)
;
(complete 100)
(set @default-dest ProgDir)

