;
; $PROJECT: cli.datatype
;
; $VER: Install 39.1 (06.08.95)
;
; by
;
; Stefan Ruppert , Windthorststrasse 5 , 65439 Floersheim , GERMANY
;
; (C) Copyright 1995
; All Rights Reserved !
;
; $HISTORY:
;
; 06.08.95 : 039.001 : initial
;

(set cpu (database "cpu"))

(set #datatype "cli.datatype")
(set #prefs    "cli.prefs")
(set #datatype-desc "(DMS|Lha|Tar|Tar-GZip)")

(set mode
	  (askchoice
			(prompt @app-name)
			(help @askchoice-help)
			(choices "Install" "Remove")
	  )
)

(if mode
		  (set pmode "Remove")
		  (set pmode "Install")
)

; get classes dir
(set classdir
		  (askdir
					 (prompt "Where do the Classes belong")
					 (help @askdir-help)
					 (default "SYS:Classes")
		  )
)

; now do install or remove
(if mode
		  ; Remove
		  (
					 ; Show what we are doing
					 (working "Removing " @app-name)

					 ; Remove the non-standard pieces
					 (delete (tackon (tackon classdir "datatypes") #datatype))
					 (run (cat "delete " (tackon "devs:datatypes" (cat #datatype-desc "#?"))))

					 ; Don't want to use the confusing "Installation Complete" message
					 ; when what we really did was remove things...
					 (message "The \"" @app-name "\" components "
								 "that you specified have been successfully removed")
					 (exit (quiet))
		  )

		  ; Install
		  (
					 (working "Installing " @app-name)

					 (set #dtname (tackon "classes/datatypes" #datatype))

					 (if (OR (= cpu "68000") (= cpu "68010")) (set #proc 0))
					 (if (OR (= cpu "68020") (= cpu "68030") (= cpu "68040") (= cpu "68060")) (set #proc 1))

					 ; choose cpu type
					 (set #proc
						(askchoice
							(prompt (cat "There are different versions of \"" #datatype "\", each one optimized "
											 "for a specific CPU type. Please select one: "))
							(choices "MC68000" "MC68020")
							(help (cat "  Select here the CPU type that is installed in your system. "
									"\n\n  Currently, this is a MC" cpu ".\n\n  If you select a certain CPU type "
									"in the choice box, the \"" #datatype "\" will run on any CPU which "
									"type is higher or equal to the selection. However, it won't "
									"run on a system equipped with a lower type.\n\n"
									@askchoice-help)
							)
							(default #proc)
						)
					 )

					 (if (= 0 #proc) (set #suffix ".000"))
					 (if (= 1 #proc) (set #suffix ".020"))

					 (copylib
								(prompt (cat "Copying the Datatype"))
								(help @copylib-help)
								(source (cat (tackon "classes/datatypes" (cat #datatype #suffix))))
								(dest (tackon classdir "Datatypes"))
								(newname #datatype)
								(confirm)
					 )

					 ; Install the descriptors
					 (copyfiles
								(prompt "Copying the Descriptors")
								(help @copyfiles-help)
								(source "devs/datatypes")
								(dest "DEVS:DataTypes")
								(pattern "#?")
								(infos)
								(confirm)
					 )

					 ; Install prefs file
					 (if     (askbool
										  (prompt "Install Prefs file ?")
										  (help @askbool-help)
								)
								(
										  (copyfiles
													 (help @copyfiles-help)
													 (source (tackon "envarc/datatypes" #prefs))
													 (dest "EnvArc:DataTypes")
										  )
										  (copyfiles
													 (help @copyfiles-help)
													 (source (tackon "envarc/datatypes" #prefs))
													 (dest "Env:DataTypes")
										  )
								)
					 )

					 ; install doc file
					 (copyfiles
								(prompt "Copying autodoc file")
								(help @copyfiles-help)
								(source "doc")
								(dest "AutoDocs:")
								(pattern "#?")
								(confirm)
					 )

					 ; install AmigaGuide file
					 (copyfiles
								(prompt "Copying AmigaGuide file")
								(help @copyfiles-help)
								(source "help")
								(dest "AmigaGuide:")
								(pattern "#?")
								(confirm)
					 )

					 ; Tell the system about the new descriptors
					 (run "C:AddDataTypes Refresh")

		  )
)

(set @default-dest classdir)

