;  *** Man installation scipt ***

(set #install-msg
(cat "\n\nMan installation script.\n"
     "This script installs the MAN commodity on your Amiga.\n\n"
     "Read the documentation for\n"
     "more information on the distribution\n"
     "and commercial usage of Man.\n\n"
     "Man © 1991-1994 Markus Hillenbrand\n"
     "All rights reserved."
))

(set #bad-kick         "You must be using Kickstart 2.04 to install using this script!")
(set #copying-reqtools "Copying reqtools.library to Libs:...")

(message #install-msg)
(welcome "Welcome to the Man installation!")

(if (< (/ (getversion) 65536) 37)
(
    (abort #bad-kick)
))    

(if (exists "S:Man.cfg")
(
    (delete "S:Man.cfg")
))

(set reqtoolslib "libs20/reqtools.library")
(set catalogdir  "catalogs/")

(copylib
        (prompt "\n" #copying-reqtools)
        (help @copylib-help)
        (source reqtoolslib)
        (dest "Libs:")
        (confirm)
) 

(if (exists "SYS:WBStartUp/Man")
(
    (copylib (prompt "\nInstalling Man-Commodity\n")
    	     	 (help @copylib-help)
				 (source "Man")
	          (dest "SYS:WBStartUp")
	          (confirm)
    )
))

(set #which-language "\nWhich languages should be installed?") 
(set old_level @user-level)
(set default_lang 2)

(if (exists "SYS:Locale")
(
	(if (exists "LOCALE:")
	(
		(user 1)
		(set lang (askoptions (prompt #which-language)
									 (help 	#which-language-help)
									 (choices
										 "Deutsch"
										 "English"
										 "Svenska")
							       (default default_lang)
					 )
		)
		(user old_level)

		(set n 0)
		(while (set language (select n
										"deutsch"
										"english"
										"svenska"
										""))
		(
			(if (IN lang n)
			(
				(if (<> 2 n)
				(
					(makedir (cat "LOCALE:Catalogs/" language))
					(copyfiles (source (cat catalogdir language))
								  (dest (cat "LOCALE:Catalogs/" language))
								  (all)
					)
				))
			))
			(set n (+ n 1))
		))
	))
))

(set #which-manpages "\nWhich man pages should be installed?") 
(set #which-manhelp  "Specify the useful man pages")
(set old_level @user-level)
(set manpagedir "Pages/")

(
   ;get destination dir for ManPages
   (set mydest
        (askdir
               (prompt "Select the directory where you want to put the man pages:")
               (help   "The directory where you store the man pages should be on a "
                       "hard drive. A directory will NOT be created!!\n\n"
               )
               (default "Work:")
               (disk)
        )
   )

	(user 1)
	(set lang (askoptions (prompt #which-manpages)
								 (help 	#which-manhelp)
								 (choices
									 "Man"
									 "Dir"
									 "List"
									 "Why")
				 )
	)
	(user old_level)

	(set n 0)
	(while (set language (select n
									"Man.man"
									"Dir.man"
									"List.man"
									"Why.man"
									""))
	(
		(if (IN lang n)
		(
			(if (<> 200 n)
			(
				(makedir (cat "LOCALE:Catalogs/" language))
				(copyfiles (source (cat manpagedir language))
							  (dest mydest)
							  (all)
				)
			))
		))
		(set n (+ n 1))
	))
)

