--- Makefile.orig	1999-12-04 00:06:42 UTC
+++ Makefile
@@ -38,7 +38,7 @@
 #----------------------------------------------------------------------
 # If you are running a 386 you should comment this line out.
 #
-CPU=-m486
+#CPU=-m486
 
 #----------------------------------------------------------------------
 # If you are experiencing troubles (like core dumps!), then uncomment
@@ -47,7 +47,7 @@ CPU=-m486
 # adjust the STRIP option to suit compile mode:
 #
 #DEBUG=-g
-OPT=-O2
+#OPT=-O2
 
 #----------------------------------------------------------------------
 # When using 'DEBUG=-g' above, then comment out the 'strip' line:
@@ -59,7 +59,9 @@ STRIP=strip
 # This parameter indicates where the program binaries should be
 # placed (wavplay, wavrec, and xltwavplay)
 #
-INSTDIR=/usr/local/bin
+PREFIX?=/usr/local
+INSTDIR=$(PREFIX)/bin
+MANDIR=$(PREFIX)/man/man1
 
 #----------------------------------------------------------------------
 # Uncomment this line if you want to install the xltwavplay.res resource
@@ -81,14 +83,14 @@ RESDIR=/usr/X11R6/lib/X11/app-defaults
 # to disable the EDITRES facility. If you're not compiling xltwavplay
 # then this setting can be left asis.
 #
-#NOEDITRES=-DNO_EDITRES
+NOEDITRES=-DNO_EDITRES
 
 #----------------------------------------------------------------------
 # If you COMMENTED OUT the NOEDITRES line, then UNCOMMENT this line.
 # If you UNCOMMENTED the NOEDITRES line, then COMMENT out this line.
 # (ie. do the opposite of NOEDITRES)
 #
-LIBXMU=-lXmu
+#LIBXMU=-lXmu
 
 #----------------------------------------------------------------------
 # These are the non X load options (for wavplay/wavrec)
@@ -106,7 +108,13 @@ XLDOPTS=-L/usr/X11R6/lib/ -L/usr/local/l
 # only the standard getopt() routine. When commented out, the long options like --help
 # are recognized, with the help of the getopt_long() routine.
 #
-#STDGETOPTS= -DUSE_GETOPT_STD
+STDGETOPTS= -DUSE_GETOPT_STD
+
+#----------------------------------------------------------------------
+#
+# Uncomment this when compiling on FreeBSD.
+
+EXTRAOPTS=-DFREEBSD -D__GNU_LIBRARY__
 
 #----------------------------------------------------------------------
 # The next option specifies the pathname that the xltwavplay X client should exec
@@ -133,7 +141,7 @@ PLAYPATH= -DWAVPLAYPATH=\"$(INSTDIR)/wav
 # Environment variable DSPPATH will override this value at runtime, if
 # present.
 #
-#DSPPATH= -DAUDIODEV=\"/dev/dsp\"
+DSPPATH= -DAUDIODEV=\"/dev/audio\"
 
 #----------------------------------------------------------------------
 # Semaphore IPC Key for the Play & Record locks (Default is 0x33333333)
@@ -163,19 +171,19 @@ INSTALL=install
 # this should be unecessary if the appropriate symlinks are
 # installed).
 #
-#CUSTINCL= -I/usr/X11R6/include/X11 -I/usr/local/lesstif/include/Xm
+#CUSTINCL= -I${LOCALBASE}/include/X11 -I${LOCALBASE}/include/Xm -I/${LOCALBASE}/include
 
 #----------------------------------------------------------------------
 # Normally, you shouldn't need to change anything beyond this point:
 #----------------------------------------------------------------------
 .SUFFIXES: .c .cc .h .o
 
-CUSTMOPTS=$(STDGETOPTS) $(PLAYPATH) $(DSPMIN) $(DSPMAX) $(DSPPATH) $(DSPLOCKS) $(USERES) $(NOEDITRES) $(SCHED_PRIORITY)
+CUSTMOPTS=$(STDGETOPTS) $(EXTRAOPTS) $(PLAYPATH) $(DSPMIN) $(DSPMAX) $(DSPPATH) $(DSPLOCKS) $(USERES) $(NOEDITRES) $(SCHED_PRIORITY)
 ELF=	# -fPIC
 INCL=	-I. $(CUSTINCL)
-CCFLAGS= -c $(DEBUG)$(OPT) $(CPU) $(ELF) -fhandle-exceptions $(CUSTMOPTS) -Wall -Wstrict-prototypes
-CFLAGS= -c $(DEBUG)$(OPT) $(CPU) $(ELF) -Wall -Wstrict-prototypes $(CUSTMOPTS)
-CC=	gcc
+CCFLAGS+= -c $(DEBUG)$(OPT) $(CPU) $(ELF) -fhandle-exceptions $(CUSTMOPTS) -Wall -Wstrict-prototypes
+CFLAGS+= -c $(DEBUG)$(OPT) $(CPU) $(ELF) -Wall -Wstrict-prototypes $(CUSTMOPTS)
+CC?=	gcc
 CP=	g++
 
 HDRFIL= client.h server.h wavfile.h wavplay.h xltwavplay.h xmsprint.h
@@ -189,9 +197,9 @@ WVDMPO= wavdump.o
 .c.o:
 	$(CC) $(CFLAGS) $(INCL) $<
 
-all:	wavplay wavrec xltwavplay
+all:	wavplay wavrec
 
-no_x:	wavplay wavrec
+with_x:	wavplay wavrec xltwavplay
 
 # wavdump: $(WVDMPO)
 #	$(CP) $(WVDMPO) $(LDOPTS) $(DEBUG) -o wavdump -lRIFF
@@ -209,18 +217,21 @@ xltwavplay: $(CLNOBJ) xltwavplay.o
 	$(STRIP) xltwavplay
 	ls -l xltwavplay
 
-install: install_wavplay install_xltwavplay
+install: install_wavplay install_man
 
-install_no_x: install_wavplay
+install_with_x: install_wavplay install_xltwavplay install_man
 
 install_wavplay: wavplay wavrec
-	@[ ! -d "$(INSTDIR)" ] && echo "You do not have a directory $(INSTDIR); Check INSTDIR in make file." && exit 13 || :
-	$(INSTALL) -o root -g root -m 555 wavplay $(INSTDIR)
+	mkdir -p $(INSTDIR)
+	${BSD_INSTALL_PROGRAM} wavplay $(INSTDIR)
 	rm -f $(INSTDIR)/wavrec
 	ln $(INSTDIR)/wavplay $(INSTDIR)/wavrec
-	@[ ! -z "$(SCHED_PRIORITY)" ] && echo "*** DO 'make setuid_root' IF YOU WANT REAL TIME SCHEDULING ***" || :
 	@echo
 
+install_man: wavplay.1
+	mkdir -p $(MANDIR)
+	${BSD_INSTALL_MAN} wavplay.1 $(MANDIR)
+
 xltwavplay_test: wavplay xltwavplay
 	WAVPLAYPATH=./wavplay ./xltwavplay
 
@@ -234,9 +245,9 @@ setuid_root:
 	@echo
 
 install_xltwavplay: xltwavplay
-	$(INSTALL) -o root -g root -m 555 xltwavplay $(INSTDIR)
+	${BSD_INSTALL_PROGRAM} xltwavplay $(INSTDIR)
 	@[ ! -z "$(USERES)" ] \
-		&& $(INSTALL) -o root -g root -m 555 xltwavplay.res $(RESDIR)/xltwavplay \
+		&& ${BSD_INSTALL_DATA} xltwavplay.res $(RESDIR)/xltwavplay \
 		&& ls -dlL $(RESDIR)/xltwavplay/xltwavplay.res \
 		|| rm -f $(RESDIR)/xltwavplay
 
