# Select your audio output device.  Current choices are:
#
#   Sun:    Sun workstation with audio hardware.
#   HP:     HP9000s700 with audio hardware.
#   X11:    The X11 window system.
#   Indigo: SGI Indigo workstation.
#   Linux:  IBM PC Console running Linux.
#   AdLib:  AdLib/SoundBlaster FM chip.
#   OSS:    Open Sound System /dev/dsp device.
#
# Adding a new device is as simple as creating a new implementation of the
# beep.h interface.  See beep*.c for examples.  Please send any additions
# to the authors!
#
#DEVICE = Sun
#DEVICE = HP
#DEVICE = X11
#DEVICE = Indigo
DEVICE = Linux
#DEVICE = AdLib
#DEVICE = OSS

#
# For termio a la System V, add -DUSG to DEFINES. (Linux in particular needs
#   this.)
#
# For alternate random number generator, add either -DUSELRAND for lrand48(),
#   or -DUSERAND for (ugh) rand(). Default is -DUSERANDOM for random().
#
# Define SIGRET to be your signal handler return type if not "void".
#
# Define BSDSIGS or POSIXSIGS, depending on what kind of signals you
#   have. "Old-style" signals are not currently supported. Default is BSDSIGS.
#
# If the same speaker making the morse code beeps will also make ^G beeps
#   (which occur when you get a letter wrong), you may want to #define
#   ERROR_VOLUME to be 1.; this will cause the ^G beeps to be made using
#   the same routines that do the morse-code beeps, possibly preventing
#   conflicts. (If you prefer quieter error beeps, you can use anything
#   between 0. and 1.; if you want it the same volume as the morse-code
#   beeps, use "-DERROR_VOLUME=volume". If you don't like the pitch of
#   the error tone, you can override the default by #defining ERROR_FREQ to
#   be your favorite wake-up alarm frequency, in hertz.)
#
# On a Sun workstation you may want to compile with -DFULLVOLUME (see beepSun.c
#   for more details).
#
# If you want the morse to generate all punctuation marks, compile
#   with -DALLPUNCTUATION (see README and morse.c for details).
# If you want the morse to generate all procedure signs, compile
#   with -DALLPROSIGNS (see README and morse.c for details).
# If you want the morse to generate all international extensions,
#   compile with -DALLINTERNATIONAL (see README and morse.c for details).
#
#DEFINES = -DUSG -DUSELRAND -DPOSIXSIGS
DEFINES = -DUSG
#DEFINES = -DUSG -DERROR_VOLUME=1. -DERROR_FREQ=2000.
#DEFINES = -DFULLVOLUME
#DEFINES = 

# The flags necessary to link with the X11 libraries.
#X11LIBS = -L/usr/X11/lib -lX11 -lsocket -lnsl
X11LIBS = -L/usr/X11/lib -lX11

# Your favorite C compiler
CC	= gcc
#CC	= cc

# Any additional flags your favorite C compiler requires to work.
#CFLAGS  = -O -I/usr/X11/include -DSVR4 -DSYSV386 ${DEFINES}
CFLAGS  = -O3 -m486 ${DEFINES}

default:
	make test

morse:	morse${DEVICE}
	rm -f $@
	ln morse${DEVICE} $@

morseSun:	morse.o beepSun.o
	$(CC) -o $@ morse.o beepSun.o -L/usr/demo/SOUND -laudio -lm

morseHP:	morse.o beepHP.o alarm.o
	$(CC) -o $@ morse.o beepHP.o alarm.o -lm

morseX11:	morse.o beepX11.o alarm.o
	$(CC) -o $@ morse.o beepX11.o alarm.o $(X11LIBS)

morseIndigo:	morse.o beepIndigo.o
	$(CC) -o $@ morse.o beepIndigo.o -laudio -lm

morseLinux:	morse.o beepLinux.o alarm.o
	$(CC) -o $@ morse.o beepLinux.o alarm.o -lm

morseAdLib:	morse.o beepAdLib.o alarm.o
	$(CC) $(CFLAGS) -o $@ morse.o beepAdLib.o alarm.o -lm
	strip $@
	chown root:root $@
	chmod a+sx $@

morseOSS:	morse.o beepOSS.o
	$(CC) $(CFLAGS) -o $@ morse.o beepOSS.o -lm

QSO:
	cd qso; make
	ln qso/QSO ./QSO

#
# "Jocks find quartz glyph, vex BMW." is my attempt to win Stephen J. Gould's
# prize (a copy of all his books) for the first person who can come up with a
# "perfect pangram": a meaningful sentence consisting entirely of common
# English words, with no abbreviations or proper names, that contains each
# letter exactly once. He rejected it because it contains "BMW", alas, but
# he did say it's the closest he's seen so far. - Joe Dellinger
#
test:	morse QSO
	\rm -f junk
	cat test_input > junk
	qso/QSO >> junk
	# ./morse -v .04 -w 24 -l -e < junk
	\rm -f junk

testqso:	morse QSO
	qso/QSO | ./morse -v .04 -w 20 -l -e

all:	morse QSO

clean:
	rm -f *.o morse QSO morseSun morseHP morseX11 morseIndigo morseLinux morseAdLib morseOSS
	rm -f junk
	cd qso; make clean


morse.o:	beep.h Makefile
beepSun.o:	beep.h
beepHP.o:	beep.h alarm.h
beepX11.o:	beep.h alarm.h
beepIndigo.o:	beep.h
beepLinux.o:	beep.h alarm.h
beepAdLib.o:	beep.h alarm.h
beepOSS.o:	beep.h
alarm.o:	alarm.h
