# Compiling XEvil 2.X

Steve Hardt
last modified 01/17/2000

##

Windows (NT,95,98)

Requires Microsoft Visual C++ to compile. If you have version 5.0, you can use the workspace file already in the distribution. I've successfully built XEvil with Visual C++ 4.2. You'll have to make your own project, though. Other compilers should work, but I haven't tried them.

1. Download xevilsrc.zip and unzip it somewhere.
2. At a command prompt, type:

subst x: <directory where you put the source>

If the directory name has spaces in it, put quote marks around the directory name, e.g,

subst x: "e:\my files\xevil2.0b7"

3. If you have VC++ 5.0,

1. Run VC++ 5.0
2. Open the project, "x:\win32\xevil.dsw".

4. If you have VC++ 4.2, or the .dsw file doesn't work for some reason.

1. Make a new project called xevil in the directory "x:\win32".
2. Add all the cpp files in x:\win32 and x:\cmn. (Don't add the ones in x:\x11, they are for UNIX.)
3. Add the libraries "x:\win32\ddraw.lib", "x:\win32\dsound.lib"
4. Go to the "Projects | Settings" dialog. Switch to the "Link" tab. Look at the "Object/libraries modules" text field. Add "winmm.lib ole32.lib" if they aren't already there.

5. Select the "Tools | Options" menu.

1. Go to the "Directories" tab and look at directories for "Include Files". Add "x:\cmn" and "x:\win32" to the list of include directories.
2. Go to the "Tabs" tab. Set the toggle to "Insert spaces" and set "Tab size" and "Indent size" to 2. This is not strictly necessary, but helps make the formatting look right. This also helps if you want to contribute code back to xevil.com. We disallow tab characters in your code, use spaces instead. See the coding standards documentation on www.xevil.com for more details.

6. Compile and run.

##

UNIX/X

Requires:

- C++ compiler. I've used a variety of compilers, g++, CC, cfront, etc.

- Must have the C++ iostream libraries, i.e. iostream.h, strstream.h, etc. These will generally be installed along with your C++ compiler.

- Xlib libraries and include files. Does not require Motif or any widget set.

- Include files are often somewhere like /usr/X11R6/include or /usr/openwin/include.
- libX11.a or libX11.so are often somewhere like /usr/lib or /usr/X11/lib

- The X Pixmap libraries (XPM). You should be able to get these on the net. You may have to compile XPM source to generate libraries for your machine.

- xpm.h and libXpm.a (or libXpm.so)

I have built and run XEvil on the following UNIX platforms:

- Red Hat Linux
- SGI IRIX
- Sun, Solaris and SunOS
- HPUX
- AIX
- FreeBSD
- Open Caldera Linux
- Alpha OSF
- Solaris x86

XEvil should build without much trouble on other UNIX system that meet the above requirements. I only have certain UNIX machines at my disposal. So, one benefit of distributing XEvil source is that other people can build XEvil on platforms not available to me.

### Building XEvil on UNIX

1. Unzip xevilsrc.zip to some directory

1. There's a trick here. All the text files are Windows-style, with CRLF for line breaks (as opposed to just LF which is standard UNIX). In emacs, you'll see a bunch of '^M' in the code. You can use "unzip -a" to auto-convert text files. But, this corrupts several of the binary files. The binary files are just needed for the Windows build, so you might not care about them at all. You can use the csh script unzipxevil to convert the text files without corrupting the binary files.

2. Look at the value of your HOSTTYPE environment variable and look for a corresponding entry in config.mk. Set the HOSTTYPE environment variable if necessary, make a new entry in config.mk if necessary. As described below, set the symbols in config.mk to correspond to your specific machine.
3. Type "make". The new executable will be built in the directory given by OBJ_DIR.

### Meanings of symbols in config.mk

CC
  C++ compiler to use. Probably g++ or CC.
LIBS
  Libraries to use. Usually "-lXpm -lX11 -lm". For some odd reason I needed to add "-ldnet_stub" for the Alpha I was using and "-lsocket -lnsl" for Sun 4 machines on Project Athena.
INCL_DIRS
  Where to look for the include files.
LIBS_DIRS
  Where to look for libraries.
LINK_FLAGS
  Command line options for the link phase of compiling. I generally try to build XEvil with static linking.
CFLAGS
  Command line options for compiling. You can use any flags your compiler understands as well as the XEvil-specific ones given in the next section.
OBJ_DIR
  Output directory for building the executable and object files. You can build XEvil for several UNIX platforms in the same directory tree by assigning different values to OBJ_DIR for different platforms.
PCKG_NAME
  Used to tar up the executable for distribution. E.g. if PCKG_NAME="irix", then create xevil2.0.irix.tar.Z.

### Additional options for CFLAGS

-DUSE_RANDOM
  Use the random() function instead of rand() to generate random numbers. random() is a better pseudo-number generator than rand(). Use this unless random() is not available on your machine.
-DRANDOM_NEEDS_PROTOTYPES
  If you are using random() and for some reason the prototypes for random() and srandom() do not appear in <math.h>.
-DUSE_SELECT_H
  Use if you need <sys/select.h> for the prototypes for select().
-DSELECT_NEEDS_PROTOTYPES
  Use if the prototypes for select() still do not show up after trying -DUSE_SELECT_H.
-DXEVIL_KEYSET=<keyset-name>
  Different UNIX/X machines have different keyboard layouts. Use -DXEVIL_KEYSET to specify at compile-time one of the sets of keyboard controls for XEvil. This gives the default value that can be overridden with the -keys command line option or with the "Set Controls" button at run-time. Look in x11/ui.h at the UIkeyset enum for possible values.
-DPROTECTED_IS_PUBLIC
  Some compilers have a broken idea of what "protected" means in an inherited class. Try this flag if you get an error like "method <some method> is protected in this context". It makes (ick) all protected class members into public members.
-DCLOCKS_PER_SEC=<clocks-per-sec>
  In some cases, the symbol CLOCKS_PER_SEC is not defined anywhere and you must manually define it. This is the conversion from the unit of time given by the clock() function to seconds. If you don't know what the value is for your system, try -DCLOCKS_PER_SEC=1000000L This is the most common value.
-DMATH_H_IS_CC
  Use this if you get strange errors from the include file math.h. Usually math.h is written in C, so the XEvil source includes it as a C include file. Sometimes, however, math.h is in C++, so it should be included as a C++ include file.
-DNO_PRAGMAS
  g++ uses "#pragma interface" and "#pragma implementation" compiler directives to do some code optimization. In theory, other C/C++ compilers should ignore unknown pragmas. But, some compilers whine about it, so use -DNO_PRAGMAS to avoid these warning messages.
-DUSE_UINT_NET_LENGTH
-DUSE_ULONG_NET_LENGTH
  Use "unsigned int" or "unsigned long" for the type of the last argument to accept() and recvfrom(). Default is "int".
-DNO_SETPRECISION
  Only for setting the number of significant digits in the statistics printed when XEvil exits. Would you believe that some HP systems actually crash if you set the number of significant digits in an output stream.
-DIO_COOKIE_HACK
  Some really weird linux system needs a type defined for _IO_cookie_io_functions_t. Don't ask me, I just work here.

Steve Hardt
satan@xevil.com
http://www.xevil.com