;
;  ChkTeX.install v1.0, installs the ChkTeX program
;  Copyright (C) 1995 Jens T. Berger Thielemann
;
;  This program is free software; you can redistribute it and/or modify
;  it under the terms of the GNU General Public License as published by
;  the Free Software Foundation; either version 2 of the License, or
;  (at your option) any later version.
;
;  This program is distributed in the hope that it will be useful,
;  but WITHOUT ANY WARRANTY; without even the implied warranty of
;  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;  GNU General Public License for more details.
;
;  You should have received a copy of the GNU General Public License
;  along with this program; if not, write to the Free Software
;  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
;
;  Contact the author at:
;      Jens Berger
;      Spektrumvn. 4
;      N-0666 Oslo
;      Norway
;      E-mail: <jensthi@ifi.uio.no>
;
;
;

(set @app-name "ChkTeX")

(welcome)

(set
	@default-dest
	(askdir
		(prompt "Where do you wish ChkTeX installed?")
		(default "C:")
		(help
			"You can here select where you wish to install the "
			"main ChkTeX executable program.\n"
			@askdir-help
		)
	)
)

(copyfiles
	(source "ChkTeX")
	(dest @default-dest)
)

(if
	(=
		@user-level
		2
	)
	(set
		install
		(askbool
			(prompt "Install environment files?")
			(help
				"If you select `yes', the default environment files will "
				"be installed. They will initialize ChkTeX to a `normal' "
				"behaviour, and give a good starting-point for "
				"modification.\n"
			)
			(default 1)
		)
	)
	(set
		install
		1
	)
)

(if
	(=
		install
		1
	)
	(
		(set
			tmpscript
			"T:ChkTeX.install.tmpscript"
		)

		(textfile
			(dest tmpscript)
			(append
				"failat 31\n"
				"Version exec.library VERSION 36\n"
				"If ERROR\n"
				"	SetEnv Installer-Result 10\n"
				"Else\n"
				"	If WARN\n"
				"		SetEnv Installer-Result 5\n"
				"	Else\n"
				"		SetEnv Installer-Result 0\n"
				"	Endif\n"
				"Endif\n"
			)
		)

		(execute tmpscript)

		(set
			HasNewOS
			(getenv "Installer-Result")
		)

		(delete tmpscript)

		(if
			(=
				HasNewOS
				0
			)
			(set
				ConfigPath
				"ENVARC:"
			)
			(set
				ConfigPath
				"S:"
			)
		)

		(copyfiles
			(source ".chktexrc")
			(dest ConfigPath)
		)

		(if
			(=
				ConfigPath
				"ENVARC:"
			)
			(copyfiles
				(source ".chktexrc")
				(dest "ENV:")
			)
		)
	)
)

(copyfiles
	(source "")
	(dest "HELP:")
	(choices
		"COPYING"
		"ChkTeX.readme"
	)
	(prompt "Which documentation files do you wish to install?")
	(help
		"If you would like to have the documentation online, you have "
		"the possibility here. It might be nice for future reference.\n"
		@copyfiles-help
	)
	(confirm)
)



(if
	(=
		2
		(exists
			"LOCALE:"
			(noreq)
		)
	)
	(
		(set
		catalog
			(select
				(askchoice
					(prompt "Which language do you wish to install?")
					(choices "English" "Norsk")
					(help
						"ChkTeX can support other languages than English, "
						"you can here select which one you would like.\n"
						"If your OS does not support languages (i.e. OS < 2.1),"
						"select 'English'."
						@askchoice-help
					)
					(default 0)
				)
				""
				"norsk"
			)
		)

		(if
			(<>
				catalog
				""
			)
			(copyfiles
				(source
					(cat
						"Catalogs/"
						catalog
						"/ChkTeX.catalog"
					)
				)
				(dest
					(cat
						"LOCALE:Catalogs/"
						catalog
					)
				)
			)
		)
	)
)
