; $VER: Install_cc65 1.0 (2.6.2010) © Stefan Haubenthal

(set #help-bin "Choose location of archiver, assembler, compiler, compiler driver, disassembler, resource compiler, linker, object dumper and character converter.")
(set #help-inc "Choose location of ANSI and target platform headers. The new directory is called 'include' resp. 'asminc'.")
(set #help-lib "Choose location of runtime objects and target platform libraries. The new directory is called 'lib'. If necessary CC65_LIB will be set.")

(if (run "which sh")
	(message "The compiler driver (cl65) is missing a Unix shell (sh)."))

(copyfiles
	(source "//src/")
	(dest
		(set #dir-bin (askdir (prompt "Copy binaries (should be part of execution path)") (help #help-bin) (default @default-dest)))
	)
	(choices "ar65/ar65" "ca65/ca65" "cc65/cc65" "cl65/cl65" "da65/da65" "grc/grc" "ld65/ld65" "od65/od65" "co65/co65" "chrcvt/chrcvt")
)

(complete 25)
(copyfiles
	(source "//include/")
	(dest
		(set #dir-inc (tackon (set #dir-home (askdir (prompt "Copy C headers (directory will be created)") (help #help-inc) (default @default-dest))) "include"))
	)
	(all)
)

(complete 50)
(copyfiles
	(source "//asminc/")
	(dest
		(set #dir-inc (tackon (askdir (prompt "Copy assembler headers (directory will be created)") (help #help-inc) (default #dir-home)) "asminc"))
	)
	(all)
)

(complete 75)
(copyfiles
	(source "//libsrc/")
	(dest
		(set #dir-lib (tackon (askdir (prompt "Copy libraries (directory will be created)") (help #help-lib) (default #dir-home)) "lib"))
	)
	(pattern "#?.(lib|o)")
)

(complete 90)
(run "setenv CC65_HOME SAVE" #dir-home (confirm) (prompt "Set environment variable for compiler home?") (help "CC65_HOME will be saved in 'ENVARC:'."))
;(if (not (= (tackon #dir-home "include") #dir-inc))
;	(run "setenv CC65_INC SAVE" #dir-inc)
(if (not (= (tackon #dir-home "lib") #dir-lib))
	(run "setenv CC65_LIB SAVE" #dir-lib))
;(run "resident cc" (tackon #dir-bin "cl65"))

(complete 100)
(message "The cross-compiler is now ready, just type 'cl65 --help' in a shell.")
