		Porting LyX to Windows NT
		========================= 
		Steven van Dijk (steven@cs.uu.nl)

I am assuming that the following are installed:
	- Cygwin b20.1 : http://sourceware.cygnus.com/cygwin/
	- perl: if you want to import LaTeX-files (available from www.perl.org)
	- ispell: if you want spelling checking (get ftp://ftp.franken.de/pub/win32/develop/gnuwin32/ \
		cygwin32/porters/Humblet_Pierre_A/B20/ispell-3.1-cygwin-b20.1-bin.tar.gz)
	- chktex: if you want to check your spelling (get it at CTAN, for example ftp://ftp.cs.uu.nl/ \
		pub/tex-archive/support/chktex/msdos)
	- ghostscript: if you want inline viewing of pictures (get it at http://www.cs.wisc.edu/ \ 	
		~ghost/index.html)
	- xlib and xpm: the site of Cygwin provides links to distributions
	- xlib: get ftp://ftp.franken.de/pub/win32/develop/gnuwin32/cygwin32/porters/Okhapkin_Sergey/ \
		ports/X11R6.4-cygwinb20.tar.bz2. This distribution unfortunately contains the XOpenIM-bug. Unzip with bunzip2.
		
	- xpm : get ftp://ftp.x.org/contrib/libraries/xpm-3.4k.tar.gz and compile the library (contact me if you run into troubles, although it shouldn't be hard)
	- xforms : ftp://ftp.cs.uu.nl/pub/XFORMS/NT/GnuWIN32/bxform-0881.zip 
		(this is a tarred gzip and confusingly named (DON'T take the 
		other file in that dir)).
	- X-server : see the pointers at http://www.rahul.net/kenton/xsites.html#XMicrosoft. 
		You MUST have the X-server running or you will get the following error:
		
			command_prompt> lyx
			lyx: Can't open display LOCALHOST:0.0--error 111
	
If you've got all the right stuff, porting LyX to WinNT/9x is very easy. Take 
the following steps:

- get LyX:

	get the file lyx-1.0.0.tar.gz at www.lyx.org

- untarring the archive:

	gunzip -c lyx-1_0_0.gz | tar xf 
	cd lyx-1.0.0
	
- running configure:

	./configure --with-extra-lib=/usr/xforms/FORMS --with-extra-inc=/usr/xforms/FORMS \
		--prefix=/apps/lyx-1.0.0

	Obviously, the paths should point to your own FORMS directory. If you omit the --prefix option, 
	the default is /usr/local which is uncommon on WinNT systems. Also, if you try Program Files, you 
	get in trouble because of the space in the name.

	configure puts the line '#define HAVE_XOPENIM 1' in src/config.h. Comment it, or
	LyX will crash.

- compiling:

	LyX has the feature that you can give it commands through a pipe. If you want this kind of
	sophisticated behaviour, you should get Linux/FreeBSD, because the Cygwin library does not support
	the needed function call. However, if you are like me, you can not even imagine why such a feature
	is useful, let alone use it. :-) Before you can compile, you have to disable the function call or
	you will get an undefined reference error (the prototype is defined as it is a POSIX function, but 
	the function is not implemented). So, edit the file stat.h in
	cygwin\H-i586-cygwin32\i586-cygwin32\include\sys. Comment the line that says
	
	int	_EXFUN(mkfifo,( char *__path, mode_t __mode ));
	
	and add 
	
	#define mkfifo(p,m) (0)
	
	Do 'make' to make it all.

- installing:

	You'll have to have work-arounds for the fact that the compiler generates a lyx.exe file and the 
	makefile thinks it is named just lyx. Since all programs you port have this problem, you better 
	change it once and for good. An alternative is using --program-suffix=.exe (as an option when
	running ./configure) but that will make your personal directory named ~/.lyx.exe, which is
	untolerable. Use the following replacements for install and strip:
	
	install:
	========================================
	#
	# Install Preprocessor for the gnu-win32 "make install" command.
	#
	# To use:
	#   - locate the original install.exe (should be somewhere
	#     in <cygnuspath>\bin\)
	#   - rename it to cyg_install.exe, i.e
	#     mv install.exe cyg_install.exe
	#   - copy this file to <cygnuspath>/bin/install
	#
	# Note:
	#   No warranty implicit or explicit is given.
	#   You may copy, distribute and use as you see fit.
	#   USE AT YOU OWN RISK.
	#
	# changed: M.Hirmke                email: mh@mike.franken.de
	#   changed ginstall to cyg_install, because some packages are looking
	#   for ginstall
	#
	# changed: Dr David Coe            email: david@coent.demon.co.uk
	#   "I seem to remember earnie's script gave trouble (in X11 or lesstif
	#    make install) when both <exec.exe> and <exec> are present
	#    simultaneously). The attached helped."
	#
	# changed: Dr Pierre A. Humblet    email: humblet@eurecom.fr
	#    Modify logic to work when several files are installed in a
	#    directory, some with the .exe extension and others without.

	tstr=""
	while test $# -gt 1;
	do
		if test -e $1.exe;
		then
			suffix=".exe";
		else
			suffix="";
		fi
		tstr="${tstr}${1}${suffix} "
		shift;
	done
	if test -d $1
	then
		suffix="";
	fi
	tstr="${tstr}${1}${suffix}"

	eval "cyg_install.exe $tstr";
	exit	
	========================================

	strip:
	========================================
	#! /bin/sh

	# file: strip
	# move strip to cyg_strip and replace it with this script.

	if test -e $1.exe;
	then
		suffix=".exe";
	else
		suffix="";
	fi
	file="$1$suffix"

	eval "cyg_strip.exe $file";
	exit
	========================================

	You can do the install by typing 'make install' and make will do that thing it does.
	
- running:

	You can run lyx now (use the complete path). It is installed in /usr/local/bin or your own
	provided prefix so this should be in your path. Also, every shared library you use (libX11,
	cygwin.dll) should be in your path. Please do not forget that the variables DISPLAY and HOME
	should be set to sensible values.

	reLyX (importing an LaTeX-file) will probably complain about getlogin not being defined. 
	Change line 135 of \usr\local\share\lyx\reLyX\MakePreamble.pm from

		$nm = getlogin || getpwuid($<);

	to
	
		$nm = `whoami`; chop $nm; 

	A port of Ispell can be obtained and interfaces without problems with LyX. The same goes for 
	ghostscript (for inline viewing of pictures) and ChkTex. 
		
	Have fun! Don't forget to mention to everybody you know how great LyX is! Yes, that DOES include 
	the milkman.