(transcript "Installing Gcc v2.5.6 for AmigaDOS...")

; ==== Set default destination for gcc package

(set @default-dest "SYS:GCC")

; ==== Choose path where gcc tree is stored

(set gccdest
  (askdir
    (prompt "Please select Gcc directory.")
    (help @askdir-help)
    (default "SYS:GCC")
  )
)

(makeassign "GCC" gccdest)

(complete 5)

; ==== Copy ixemul.library

(copylib
  (help @copylib-help)
  (prompt "Installing ixemul.library...")
  (confirm)
  (source "GCC:Libs/ixemul.library")
  (dest
	(set ixemuldest
	  (askdir
	    (prompt "Please select a place for \"ixemul.library\".")
	    (help @askdir-help)
	    (default "LIBS:")
	  )
        )
  )
)

(complete 10)

; ==== Copy ixpipe-handler

(copyfiles
  (help @copylib-help)
  (prompt "Installing ixpipe-handler...")
  (source "GCC:ixpipe/ixpipe-handler")
  (confirm)
  (dest
	(set ixpipedest
	  (askdir
	    (prompt "Please select a place for \"ixpipe-handler\".")
	    (help @askdir-help)
	    (default "L:")
	  )
        )
  )
)

(complete 20)

; ==== Get Kickstart version number

(set vernum (getversion "exec.library" (resident)))
(set ver (/ vernum 65536))

(if (< ver 38)
(
  (textfile
    (help "This operation will preserve your existing Mountlist.")
    (prompt "You are not running Kickstart 2.0 or higher, adding to Mountlist.")
    (confirm)
    (dest "RAM:phbtmp")
    (include "DEVS:Mountlist")
    (include "GCC:ixpipe/Mountlist")
  )
  (run "copy RAM:phbtmp DEVS:Mountlist >T:result"
    (prompt "Running 'copy'")
    (help "This will only work from the CLI!")
  )
)
(
  (copyfiles
    (help @copylib-help)
    (prompt "Installing ixpipe Dosdriver ...")
    (source "GCC:ixpipe/IXPIPE")
    (dest "DEVS:dosdrivers")
  )
  (copyfiles
    (help @copylib-help)
    (prompt "Installing ixpipe Dosdriver icon ...")
    (source "GCC:ixpipe/IXPIPE.info")
    (dest "DEVS:dosdrivers")
  )
)
)


; ==== Copy ENV strings into ENVARC: ONLY when we're running 2.0 or more

(if (> ver 37)
  (copyfiles
    (help @copylib-help)
    (prompt "Installing variables into ENVARC:...")
    (confirm)
    (source "GCC:envarc")
    (all)
    (dest "ENVARC:")
  )
)

(complete 50)

(startup "Gcc-AmigaDOS"
  (help @startup-help)
  (prompt "Ready to add necessary Assigns to user-startup")
  (command "Assign GNU:	" gccdest)
  (command "\nAssign GCC:	GNU:")
  (command "\nAssign UNIX:	GCC:")
  (command "\nAssign USR:	GCC:")
  (command "\nAssign lib:	USR:lib")
  (command "\nAssign bin:	USR:bin")
  (command "\nAssign etc:	UNIX:etc")
  (command "\nAssign dev:	UNIX:dev")
  (command "\nAssign S:	GCC:S ADD")
  (command "\nAssign LOCAL:	USR:")
  (command "\nSet ESHELL bin:ksh")
  (command "\nPATH USR:bin add")
  (command "\nAssign tmp:	t:")
  (command (if (NOT (= "LIBS:" ixemuldest))
             "\nAssign LIBS:	"
           ))
  (command (if (NOT (= "LIBS:" ixemuldest))
             ixemuldest
           ))
  (command (if (NOT (= "LIBS:" ixemuldest))
             " ADD"
           ))
  (command (if (NOT (= "L:" ixpipedest))
             "\nAssign L:	"
           ))
  (command (if (NOT (= "L:" ixpipedest))
             ixpipedest
           ))
  (command (if (NOT (= "L:" ixpipedest))
             " ADD"
           ))
  (command (if (< ver 38)
              "\n#This is because you're not running OS 2.0 or more\nMount IXPIPE:"
           ))
  (command (if (< ver 38)
              "Setenv TERM amiga"
           ))
  (command (if (< ver 38)
              "Setenv LESSCHARSET latin1"
           ))
)

(message "Now you have to reboot to activate new environment.\n"
         "In case of errors, problems, whatever, please contact me at:"
         "\n\nemail: phb@colombo.telesys-innov.fr"
         "\nfidonet: 2:320/104.21 Ramses The Amiga Flying BBS")
