;
; $PROJECT: c.datatype
;
; $VER: Install 39.3 (07.08.95)
;
; by
;
; Stefan Ruppert , Windthorststraße 5 , 65439 Flörsheim , GERMANY
;
; (C) Copyright 1995
; All Rights Reserved !
;
; $HISTORY:
;
; 07.08.95 : 039.003 : now remove section works
; 09.07.95 : 039.002 : some portions from Marius Gröger (CPU selection)
; 12.03.95 : 039.001 : initial
;

(set cpu (database "cpu"))

(set #datatype "c.datatype")
(set #base 1)
(set #basesuffix ".020")
(set #datatype-desc (cat "C(%|++)-Source"))

(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 devs:datatypes/" #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 (= cpu "68020")                      (set #proc 1))
					 (if (= cpu "68030")                      (set #proc 2))
					 (if (OR (= cpu "68040") (= cpu "68060")) (set #proc 3))

					 ; 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" "MC68030" "MC68040")
							(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"))
					 (if (= 2 #proc) (set #suffix ".030"))
					 (if (= 3 #proc) (set #suffix ".040"))

					 (if (= #proc #base)
						  (run (cat "copy classes/datatypes/" #datatype #basesuffix " classes/datatypes/" #datatype))
						  ; else
						  (run (cat "misc/spatch -oclasses/datatypes/" #datatype " -pclasses/datatypes/c.datatype" #suffix ".pch classes/datatypes/" #datatype #basesuffix))
					 )

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

					 ; 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 "envarc/datatypes/c.prefs")
													 (dest "EnvArc:DataTypes")
										  )
										  (copyfiles
													 (help @copyfiles-help)
													 (source "envarc/datatypes/c.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)

