--- makefile.unix.old	Thu Jul  9 06:18:58 1998
+++ makefile.unix	Thu Jul  9 06:30:01 1998
@@ -36,7 +36,7 @@
 # GNU MAKE is MANDATORY !!!
 # so please give me the path...
 # if GNU make is "native" use this
-MAKE	= make
+MAKE	= gmake
 # else ...
 # MAKE=/usr/people/jantonio/bin/gmake
 
@@ -63,7 +63,7 @@
 # LD	= $(CC) -Wl,-warn-common
 
 # *** How to install executable? ( some OS's doesn't support install command )
-INSTALL = cp
+INSTALL = install
 
 # *** set to aproppiate flag if want to debug/optimize
 # normal
@@ -72,14 +72,15 @@
 # DBGFLAGS    = -ggdb
 
 ### normal optimization flags
-OPTFLAGS    = -O -Wall
+# OPTFLAGS    = -O -Wall
 
 # use these for debugging on x86-gcc
 # OPTFLAGS    = -O2 -m486 -Wall
 ### to get full optimization under gcc/x Intel based OS's.. ( !!else comment!! )
-# OPTFLAGS     = -O3 -m486 -Wall -Wno-parentheses -funroll-loops \
-#   -fstrength-reduce -fomit-frame-pointer -ffast-math -malign-functions=2 \
-#   -malign-jumps=2 -malign-loops=2
+# you might want to change "-O" to "-O3 -m486"
+OPTFLAGS     = -O -Wall -Wno-parentheses -funroll-loops \
+  -fstrength-reduce -fomit-frame-pointer -ffast-math -malign-functions=4 \
+  -malign-jumps=4 -malign-loops=4
 ### for Linux/X11/PowerPC use following opts
 # OPTFLAGS     = -O3 -Wall -Wno-parentheses -funroll-loops \
 #  -fstrength-reduce -fomit-frame-pointer -ffast-math -fsigned-char
@@ -87,15 +88,15 @@
 # *** Does your compiler supports inline funcs?. use appropiate item:
 # do not use IL = inline : wont work due to Z80 and 6809 stuffs
 # if strict ansi used set IL to "static"
-# IL	= '-DINLINE=static inline'
-IL     = -DINLINE=static
+IL	= '-DINLINE=static inline'
+# IL     = -DINLINE=static
 
 ##############################################################################
 # *** Capabilities
 ##############################################################################
 
 # *** To disable joystick support comment next line
-# JOY		= -DUSE_JOYSTICK
+JOY		= -DUSE_JOYSTICK
 
 # *** To disable  mouse support comment next line
 MOUSE		= -DUSE_MOUSE
@@ -108,10 +109,10 @@
 # and choose polling method ( event processing or device polling )
 # use provided program "xlistdev" to now available ones
 # and dont forget to include library in linker definition !!
-# JS	= -DX11_JOYSTICK
-# JSNAME = \"Joystick\"
-# JSPOLL  = -DUSE_X11_JOYEVENTS
-# JSLIB   = -lXi
+JS	= -DX11_JOYSTICK
+JSNAME = \"joy0\"
+JSPOLL  = -DUSE_X11_JOYEVENTS
+JSLIB   = -lXi
 
 # On iX86 based OS's, if supported, you can use standard joystick driver
 # JS	= -DI386_JOYSTICK
@@ -123,13 +124,13 @@
 # *** X-Mame uses the XPM library to make snapshots. If you want to, uncomment
 # following section to support them ( you should have libxpm available :-) )
 # COMMENT IT if your are compiling for Linux's SVGALIB arch
-# XPM	= -DHAS_XPM
-# XPMLIB	= -lXpm -L/usr/X11R6/lib
+XPM	= -DHAS_XPM
+XPMLIB	= -lXpm -L/usr/X11R6/lib
  
 # *** If you haven't  the MIT-Shared Memory X Extensions, comment the following:
 # ( Test if available by mean of xdpyinfo command )
 # Comment it if compiling to svgalib xmame
-# MSHM	= -DUSE_MITSHM
+MSHM	= -DUSE_MITSHM
 
 # *** Does your system support gettimeofday() function? If do, we encourage you
 # to enable this feature . Else .... comment it :-(
@@ -164,18 +165,22 @@
 # *** Select destination directory for your compiled program , manual page
 # and binary distribution ( if you want to... )
 # ( only needed to install, not to compile... )
-DESTDIR = /usr/games
-MANDIR = /usr/local/man/man6
+DESTDIR = ${PREFIX}/bin
+MANDIR = ${PREFIX}/man/man6
 DISTDIR = /home/ftp/pub/emulators/mame
 
-# *** Where the ROM source tree ?
-MDIR = \"/usr/games/lib/mame\"
+# where to put docs and libs
+DOCDIR = ${PREFIX}/lib/mame
+LIBDIR = ${PREFIX}/lib/mame
+
+### Where the ROM source tree ?
+MDIR = \"${PREFIX}/lib/mame\"
 
 # *** Where to store high scores ?
-SDIR = \"/usr/games/lib/mame\"
+SDIR = \"${PREFIX}/lib/mame/hi\"
 
 # *** Where resides global configuration file ?
-MRC = \"/usr/games/lib/mame/xmamerc\"
+MRC = \"${PREFIX}/lib/mame/xmamerc\"
 
 # *** Use this definition as default X Display
 DP = \":0.0\"
@@ -197,13 +202,15 @@
 # you might decide to use these feature. Otherwise, you should use a 
 # timer based audio code and ajust in src/unix/sound.h AUDIO_TIMER_FREQ item
 #
-S_TIM = -DDONTUSE_TIMER
+# S_TIM = -DDONTUSE_TIMER
 # S_TIM = -DUSE_TIMER
+S_TIM = 
 
 # *** When using timer, you should provide the frequency to generate audio sample
 # frames in your system. See readme.unix notes about these item
 #
-S_AFR =	-DAUDIO_TIMER_FREQ=50
+# S_AFR =	-DAUDIO_TIMER_FREQ=50
+S_AFR = 
 
 # Dont modify next line !!
 SOUND_OPTS = $(S_LIN) $(S_TIM) $(S_AFR)
@@ -220,13 +227,13 @@
 ######## Alpha/Linux/X11
 # ARCH  = linux_alpha
 ######## ix86/Linux/X11
-ARCH  = linux
+# ARCH  = linux
 ######## ix86/Linux/SVGALIB
 # ARCH	= svgalib
 ######## ix86/Linux/GGI *New* *New* *New* Please test - no mouse or joy yet
 # ARCH  = ggi
 ######## ix86/FreeBSD/X11 and ix86/BSDi/X11
-# ARCH  = FREEBSD
+ARCH  = FREEBSD
 ######## ix86/NetBSD/X11
 # ARCH  = netbsd_i386
 ######## Sparc/SunOS/X11 ( no sound )
@@ -700,18 +707,38 @@
 obj/I86/I86.o:		src/I86/I86.c src/I86/I86.h \
 			src/I86/instr.h
 
-install: install-bin install-man
+install: install-dirs install-bin install-man install-extra
 	@echo X-Mame $(VERSION) for $(ARCH) installation completed
 
+install-dirs:
+	@echo "making all directories..."
+	-mkdir -p ${DESTDIR} ${MANDIR} $[DOCDIR} ${LIBDIR} \
+		${LIBDIR}/cfg ${LIBDIR}/hi ${LIBDIR}/roms ${LIBDIR}/samples
+
 install-bin: $(INST.$(ARCH)) xmame.$(ARCH)
 
 install-man:
 	@echo installing manual pages under $(MANDIR) ...
-	$(INSTALL) doc/xmame.man $(MANDIR)/xmame.6
+	mkdir -p ${MANDIR}
+	$(INSTALL) -c -o bin -g bin -m 444  doc/xmame.man $(MANDIR)/xmame.6
+
+install-extra:
+	${INSTALL} -c -o bin -g bin -m 444 doc/cheat.dat ${DOCDIR}
+	${INSTALL} -c -o bin -g bin -m 444 README.port ${DOCDIR}
+	mkdir -p ${LIBDIR}
+	mkdir -p ${LIBDIR}/cfg
+	mkdir -p ${LIBDIR}/hi
+	mkdir -p ${LIBDIR}/roms
+	mkdir -p ${LIBDIR}/samples
+	chown -R root.games ${LIBDIR}
+	chmod -R g+w ${LIBDIR}
+	${INSTALL} -c -o root -g games -m 111 mov ${LIBDIR}/mov
+	${INSTALL} -c -o root -g games -m 111 conv2zip ${LIBDIR}/conv2zip
 
 doinstall:
 	@echo installing binaries under $(DESTDIR)...
-	$(INSTALL) xmame.$(ARCH) $(DESTDIR)/xmame
+	mkdir -p ${DESTDIR}
+	$(INSTALL) -c -o root -g games -m 2111 xmame.$(ARCH) $(DESTDIR)/xmame
 
 # Every SVGALIB-based software must be run setuid. Beware security !!!
 doinstallsvgalib:
