; *** Cyclone installation scipt ***
; (C) 1994 - 1996 by M. Timmermans
; Marcel Timmermans
; A. Dekenstr 22
; 6836 RM ARNHEM
; HOLLAND
; EMAIL: mtimmerm@worldaccess.nl
;
; Release 1 (16.05.96)
; Using installer version 43.1 (AT)
; Remove confirm at startup (not compatible with old installers)


(welcome "Welcome to the Cyclone Modula-2 Compiler installation!")

(
        (complete 0)

        (set update-Cyclone (exists "am2:"))

        (if (not update-Cyclone)
         ;get destination dir for the Complete Compiler
         (
          (set mydest
                (askdir
                        (prompt "Select the path where you want to put the Cyclone.\n A drawer will be created.")
                        (help   "The directory where you store the complete system\n"
                                @askfile-help
                        )
                        (default "ram:") ; 
                        (disk)
                    
                )
          )
          (complete 1)
          (set mmdest (tackon mydest "Cyclone")) 
          (set @default-dest mmdest)
         )
         (
           (Message ("Start updating the Cyclone Modula-2 Compiler!"))
           (set mmdest "am2:")
           (set @default-dest mmdest)
         )
        )

        (complete 3)

        (if (exists "Cyclone.lha")
         (
          (set Compiler (askbool
            (prompt "Installing Compiler Archive?")
            (default 1)
            (help "This arcive containing f.e. Compiler, linker makeutil etc!"))
          )


          (if Compiler(
             (copyfiles
                (prompt ("Copying Cyclone.LHA to %s." mmdest))
                (help @copyfiles-help)
                (source "Cyclone.LHA")
                (dest mmdest)
                (infos)
             )

             (set @execute-dir mmdest)

             (working "Unpacking the Cyclone Modula-2 Compiler\n\nPlease wait a moment ...")
             (set myarg (cat "lha  \"x\" \"" (tackon mmdest "Cyclone.lha\"") 
                " >\"CON:10/10/600/100/Unpacking Cyclone .../INACTIVE/AUTO\" "))

             (run myarg)
             (set arg (tackon mmdest "Cyclone.lha"))
             (delete arg
              (safe)
             )
             (protect (tackon mmdest "cmc") "parwed")
             (protect (tackon mmdest "cmm") "parwed")
             (protect (tackon mmdest "cml") "parwed")
             (protect (tackon mmdest "cmpm") "parwed")
             (protect (tackon mmdest "cmerr") "parwed")
             (protect (tackon mmdest "cmLibLink") "parwed")
           )
          )
         )
        )

        (complete 20)
 
          (set modules (askbool
             (prompt "Installing Modules?")
             (default 1)
             (help "The am2:modules directory will be overwritten!"))
          )

          (if modules(
        
 	  (set modules
		(askfile
		        (prompt (cat  
					"Please select the modules archive for Cyclone\n"
					"(Usually named 'CycloneModules.lha').\n\n"
					"It will be unarchived automatically."))
			(help @askfile-help)
			(default "ram:")
		)
	  )
	  (if (exists modules)
	       (
                 (set @execute-dir mmdest)
                 (working "Unpacking the Cyclone Modula-2 Modules\n\nPlease wait a moment ...")
                 (set myarg (cat "lha \"x\" \"" modules 
                   "\" >\"CON:10/10/600/100/Unpacking Modules .../INACTIVE/AUTO\" "))
		 (set failed (run myarg))
			(if (<> 0 failed)
				(
					((set failed_text "Unarchiving of the modules archive failed.")
					 (message end_text))
					)
					(
						(set modules 1)
                                                (protect (tackon mmdest "Modules/BuildAll") "sarwed")
					)
			)
		)
	 )
         )
        )

        (complete 40)


        (copyfiles
           (prompt ("Copying What's Cylcone to %s." mmdest))
           (help @copyfiles-help)
           (source "What's Cyclone")
           (dest mmdest)
           (infos)
        )

        (set InstallDocs (askbool
          (prompt "Installing Docs?")
          (default 1)
          (help "The docs could give anwsers to your questions!"))
        )

        (complete 45)

         (if InstallDocs (
             (if (exists "Cyclone.guide")
              (
               (copyfiles
                 (prompt ("Copying Cyclone.guide to %s." mmdest))
                 (help @copyfiles-help)
                 (source "Cyclone.guide")
                 (dest mmdest)
                 (infos)
               )
               (copyfiles
                 (prompt ("Copying Threads.guide to %s." mmdest))
                 (help @copyfiles-help)
                 (source "Threads.guide")
                 (dest mmdest)
                 (infos)
               )
               (copyfiles
                 (prompt ("Copying History.doc to %s." mmdest))
                 (help @copyfiles-help)
                 (source "history.doc")
                 (dest mmdest)
                 (infos)
               )
               (copyfiles
                 (prompt ("Copying todo.txt to %s." mmdest))
                 (help @copyfiles-help)
                 (source "todo.txt")
                 (dest mmdest)
                 (infos)
               )
              )
             )
  
             (complete 50)
        
             (if (exists "Betatesters.doc")

               (copyfiles
                 (prompt ("Copying BetaTesters.doc to %s." mmdest))
                 (help @copyfiles-help)
                 (source "Betatesters.doc")
                 (dest mmdest)
                 (infos)
               )
             )
             (if (exists "ccc.doc")

               (copyfiles
                 (prompt ("Copying ccc.doc to %s." mmdest))
                 (help @copyfiles-help)
                 (source "ccc.doc")
                 (dest mmdest)
                 (infos)
               )
             )
           )
         )

        (complete 55)

        (if (exists "PDTools.lha")
         (
  
          (set pd (askbool
             (prompt "Installing third party tools?")
             (default 1)
             (help "Here you find some third party tools!"))
          )


          (if pd(
             (copyfiles
                   (prompt ("Copying PDTools.LHA to %s." mmdest))
                   (help @copyfiles-help)
                   (source "PDTools.LHA")
                   (dest mmdest)
                   (infos)
             )
 
             (set @execute-dir mmdest)

             (working "Unpacking the Cyclone third party tools\n\nPlease wait a moment ...")
              (set myarg (cat "lha  \"x\" \"" (tackon mmdest "PDTools.lha\"") 
                " >\"CON:10/10/600/100/Unpacking tools .../INACTIVE/AUTO\" "))

             (run myarg)
             (set arg (tackon mmdest "PDTools.lha"))
             (delete arg
              (safe)
             )
            )
          )
         )
        )

        (complete 60)


         (set InstallDemos (askbool
             (prompt "Do you want to have the demos installed?")
             (default 1)
             (help "Installation of Cyclone demo files"))
         )

        (complete 61)

        (if installDemos(

	(set installDemos
		(askfile
		        (prompt (cat  
					"Please select the demos archive for Cyclone\n"
					"(Usually named 'CycloneDemos.lha').\n\n"
					"It will be unarchived automatically."))
			(help @askfile-help)
			(default "ram:")
		)
	)

        (complete 62)

        (if (exists installDemos)
	       (
                 (set @execute-dir mmdest)
                 (working "Unpacking the Cyclone Modula-2 Demos\n\nPlease wait a moment ...")
                 (set myarg (cat "lha \"x\" \"" installDemos
                   "\" >\"CON:10/10/600/100/Unpacking Demos .../INACTIVE/AUTO\" "))
		 (set failed (run myarg))
			(if (<> 0 failed)
				(
					((set failed_text "Unarchiving of the demos archive failed.")
					 (message end_text))
					)
					(
						(set installDemos 1)
					)
			)
		)
	  )

         )
        )

        (complete 90)

        (if (not update-Cyclone) 
          (startup "Cyclone"
	    (prompt 
                "Add \"ASSIGN am2: " mmdest "\" to \"S:user-startup\" so that your system will be properly configured to use Cyclone.")
            (help "This assign is needed for Cyclone to work properly.")
            (command "assign am2: " mmdest "\n")
          )
        )
        

;        (message "To start working with the compiler you need to start "
;                  "the script file am2:modules/BuildAll first.\n"
;                  "This script will compile all the available modules.\n")

        (message ("The Cyclone Modula-2 Compiler is installed. Thank you for installing this product!"))

	(set end_text (cat "Hope you like Cyclone! Don't hesitate to "
					"send me comments, bugreports and suggestions."))

        (complete 100)
	(exit end_text)

)

