/*
 * Directory in which the sound files should be installed
 */
SOUND_DIR = $(LIBDIR)/xbiff++

/*
 * Set this to a colon-separated list of directories to search for sound
 * files.  This will only get used if users haven't set their SOUND_PATH
 * envvar
 */
#ifndef SoftwareWarehouse
SOUND_PATH_DEF = -DSOUND_PATH=\"$(SOUND_DIR)\"
#endif

/*
 * Uncomment the following line to compile this with HP's proprietary
 * audio driver support (Software Warehouse uses AudioFile instead)
 */
#ifndef SoftwareWarehouse
#ifdef HPArchitecture
#define HaveAudioApplication

#ifndef SoftwareWarehouse
#if ProjectX < 5
MOTIF = Motif1.1
#else
MOTIF = Motif1.2
#endif
MOTIF_INCL = -I/usr/include/$(MOTIF)
#endif

#endif
#endif

/* Uncomment the following line to compile this with AudioFile support
 *
 * Currently, both HP's Alib and AudioFile's AF library define both
 * "_ADefaultError" and "_ADefaultIOError", so can't support both at once.
 */
#ifndef HaveAudioApplication
#if !(defined(SunArchitecture) && OSMajorVersion > 4)
#define HaveAudioFile
#endif
#endif

/* This file should do the right thing for all other systems.
 */

#if defined(SparcArchitecture) && OSMajorVersion < 5
   SPARC_SRCS = play.c
   SPARC_OBJS = play.o
# if OSMinorVersion < 1
   SPARC_LIBS =
   SPARC_INCL =
   SPARC_DEFS = -DSUNOS4_0_3
# else						/* Sparc and 4.1 */
  OSPARC_LIBS = /usr/sww/lib/libaudio.a
   SPARC_LIBS = -L/usr/sww/lib -laudio
   SPARC_INCL = -I/usr/sww/include/SOUND
   SPARC_DEFS = 
# endif
#else
   SPARC_SRCS =
   SPARC_OBJS =
   SPARC_LIBS =
   SPARC_INCL =
   SPARC_DEFS =
#endif

#ifdef HaveAudioFile
#if defined(SparcArchitecture) && OSMajorVersion < 5
XCOMM  SunOS CC can't deal with ANSIfied AF headers
     CC = gcc
#endif
     AF_SRCS = aplay.c
     AF_OBJS = aplay.o
     AF_LIBS = -L/usr/sww/AF/lib -lAFext -lAF
     AF_INCL = -I/usr/sww/AF/include
     AF_DEFS = -DUSE_AUDIOFILE
#else
     AF_SRCS =
     AF_OBJS =
     AF_LIBS =
     AF_INCL =
     AF_DEFS =
#endif

#ifdef HaveAudioApplication
     AA_SRCS = aaplay.c
     AA_OBJS = aaplay.o
     AA_LIBS = -L/usr/lib -lAt -lAlib
     AA_INCL = -I/usr/include/audio ${MOTIF_INCL}
#if HasGcc
     AA_DEFS = -DAAPI
#else
     AA_DEFS = +e -DAAPI
#endif
#else
     AA_SRCS =
     AA_OBJS =
     AA_LIBS =
     AA_INCL =
     AA_DEFS =
#endif

#ifdef HPArchitecture
   HP_SRCS = hpplay.c
   HP_OBJS = hpplay.o
   HP_LIBS =
   HP_INCL =
   HP_DEFS = -DUSE_HPDEV
#else
   HP_SRCS =
   HP_OBJS =
   HP_LIBS =
   HP_INCL =
   HP_DEFS =
#endif

  AUDIO_SRCS = ${SPARC_SRCS} ${AF_SRCS} ${AA_SRCS} ${HP_SRCS}
  AUDIO_OBJS = ${SPARC_OBJS} ${AF_OBJS} ${AA_OBJS} ${HP_OBJS}
  AUDIO_LIBS = ${SPARC_LIBS} ${AF_LIBS} ${AA_LIBS} ${HP_LIBS}
  AUDIO_INCL = ${SPARC_INCL} ${AF_INCL} ${AA_INCL} ${HP_INCL}
  AUDIO_DEFS = ${SPARC_DEFS} ${AF_DEFS} ${AA_DEFS} ${HP_DEFS}

#ifndef MathLibrary
#ifdef HPArchitecture
#define MathLibrary	-Wl,-a,shared -lm
#else
#define MathLibrary	-lm
#endif
#endif

        DEPLIBS = XawClientDepLibs
LOCAL_LIBRARIES = XawClientLibs
           SRCS = xbiff.c SSMailbox.c scanmbox.c regexp.c regsub.c \
		  strtoken.c strsep.c locate.c findsnd.c \
		  ${AUDIO_SRCS}
           OBJS = xbiff.o SSMailbox.o scanmbox.o regexp.o regsub.o \
		  strtoken.o strsep.o locate.o findsnd.o \
		  ${AUDIO_OBJS}
       INCLUDES = $(TOP_INCLUDES) ${AUDIO_INCL}
  SYS_LIBRARIES = ${AUDIO_LIBS} MathLibrary
        DEFINES = -DSHAPE ${AUDIO_DEFS} ${ILLEGAL_DEFS} ${SOUND_PATH_DEF}
      LDOPTIONS = -L$(USRLIBDIR) $(CDEBUGFLAGS) $(CCOPTIONS)

ComplexProgramTarget(xbiff++)
InstallNonExec(NoMail.au,$(SOUND_DIR))
InstallNonExec(ahhh.au,$(SOUND_DIR))
InstallNonExec(bark.au,$(SOUND_DIR))
InstallNonExec(bass_snap.au,$(SOUND_DIR))
InstallNonExec(hammer.au,$(SOUND_DIR))
InstallNonExec(whip.au,$(SOUND_DIR))

regexp.o:	regexp.h regmagic.h
regsub.o:	regmagic.h
strsep.o:	strtok.h
strtoken.o:	strtok.h
SSMailbox.o:	SSMailboxP.h SSMailbox.h regexp.h
xbiff.o:	SSMailboxP.h SSMailbox.h

TARFILES= README CHANGES TODO Imakefile *.[ch] *.man *.au
xbiff++.tar::
	tar -cvf $@ $(TARFILES)
xbiff++.tar.gz::
	gtar -cvzf $@ $(TARFILES)
