/*
 * Copyright 1994 Network Computing Devices, Inc.
 *
 * Permission to use, copy, modify, distribute, and sell this software and
 * its documentation for any purpose is hereby granted without fee, provided
 * that the above copyright notice appear in all copies and that both that
 * copyright notice and this permission notice appear in supporting
 * documentation, and that the name Network Computing Devices, Inc. not be
 * used in advertising or publicity pertaining to distribution of this 
 * software without specific, written prior permission.
 * 
 * THIS SOFTWARE IS PROVIDED 'AS-IS'.  NETWORK COMPUTING DEVICES, INC.,
 * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT
 * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
 * PARTICULAR PURPOSE, OR NONINFRINGEMENT.  IN NO EVENT SHALL NETWORK
 * COMPUTING DEVICES, INC., BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING
 * SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA,
 * OR PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF
 * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF OR IN
 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 * 
 * $Id: Imakefile,v 1.17 2004/09/11 19:23:33 jon Exp $
 * $NCDId: @(#)Imakefile,v 1.21 1996/09/04 23:06:02 greg Exp $
 */

#include "../../config/NetAudio.tmpl"

#include <Threads.tmpl>

#if ProjectX < 5
/* Pre-X11R5 compatability */
#ifndef NormalLibX
#define NormalLibX	YES
#endif
#endif /* ProjectX < 5 */

#ifndef NormalLibAudio
#define NormalLibAudio NormalLibX
#endif
#ifndef SharedLibAudio
#define SharedLibAudio SharedLibX
#endif
#ifndef DebugLibAudio
#define DebugLibAudio DebugLibX
#endif
#ifndef ProfileLibAudio
#define ProfileLibAudio ProfileLibX
#endif

#define DoDebugLib DebugLibAudio
#define DoProfileLib ProfileLibAudio


/* must include <Library.tmpl> *after* the above 4 lines */
#include <Library.tmpl>

#if SystemV && !SystemV4 && !defined(XFree86Version) && !defined(AIXArchitecture)
   SYSV_DEFINES = -DAU_NOT_STDC_ENV -D_AuNEEDBCOPYFUNC -DNEED_FAKE_XWIN
#endif

XCOMM JET - hmmm.
#if (defined(FreeBSDArchitecture) || defined(BSDArchitecture)) && defined(HasBSD44Sockets)
	EXTRA_DEFINES = -DBSD44SOCKETS
#endif

XCOMM JET - see if we should avoid streams
#if (SystemV || SystemV4) 
/* JET - streams are just too problematic.  UNIX/TCP CONN will do fine */
#undef ConnectionFlags
#define ConnectionFlags -DTCPCONN -DUNIXCONN
#endif

#if Malloc0ReturnsNull
 MALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
#endif

#if ProjectX < 5
    COMPAT_SRCS = AuGetBest.c
    COMPAT_OBJS = AuGetBest.o
#endif /* ProjectX < 5 */

     EDB_DEFINES = -DERRORDB=\"$(LIBDIR)/AuErrorDB\"

        DEFINES = $(MALLOC_DEFINES) $(SYSV_DEFINES)
   CONN_DEFINES = ConnectionFlags

HEADERS = Alibint.h Alibnet.h Xtutil.h audiolib.h audioutil.h snd.h wave.h    \
          voc.h aiff.h sound.h soundlib.h fileutil.h 8svx.h Astreams.h \
	  audio.h Afuncproto.h Afuncs.h Amd.h Amd.h Aos.h Aosdefs.h Aproto.h \
	  mutex.h release.h

   SRCS = AlibAsync.c Alibint.c AuErrDes.c AuFreeEData.c CloseSvr.c ConnSvr.c \
          CrFlow.c DesFlow.c Flush.c HandleEv.c IDOfEvent.c KillClient.c      \
          NextEvent.c OpenSvr.c ReqEvent.c ScanEvents.c ScanTEvent.c	      \
          SetElState.c GetElState.c SetElement.c GetElement.c SvrName.c Sync.c \
          ReadEl.c WriteEl.c Util.c SetElParms.c GetDevAttr.c	      \
          SetDevAttr.c CrBucket.c DesBucket.c GetBucAttr.c ListBucket.c	      \
          ListDevice.c GetSvrTime.c SetClsDwnMd.c GetClsDwnMd.c		      \
	  convutil.c fileutil.c monitor.c bcache.c			      \
	  globals.c Astreams.c ErrHndlr.c $(COMPAT_SRCS)		      \
          snd.c wave.c voc.c aiff.c 8svx.c sound.c soundlib.c mutex.c

   OBJS = AlibAsync.o Alibint.o AuErrDes.o AuFreeEData.o CloseSvr.o ConnSvr.o \
          CrFlow.o DesFlow.o Flush.o HandleEv.o IDOfEvent.o KillClient.o      \
          NextEvent.o OpenSvr.o ReqEvent.o ScanEvents.o ScanTEvent.o	      \
          SetElState.o GetElState.o SetElement.o GetElement.o SvrName.o Sync.o \
          Xtutil.o ReadEl.o WriteEl.o Util.o SetElParms.o GetDevAttr.o	      \
          SetDevAttr.o CrBucket.o DesBucket.o GetBucAttr.o ListBucket.o	      \
          ListDevice.o GetSvrTime.o SetClsDwnMd.o GetClsDwnMd.o		      \
	  convutil.o fileutil.o monitor.o bcache.o			      \
	  globals.o Astreams.o ErrHndlr.o $(COMPAT_OBJS)		      \
          snd.o wave.o voc.o aiff.o 8svx.o sound.o soundlib.o mutex.o

#if ProjectX >= 5
LibraryObjectRule()

SpecialLibObjectRule(ConnSvr.o,/**/,$(CONN_DEFINES))
SpecialLibObjectRule(AuErrDes.o,/**/,$(CONN_DEFINES) $(EDB_DEFINES))
SpecialLibObjectRule(OpenSvr.o,/**/,$(CONN_DEFINES))
SpecialLibObjectRule(Alibint.o,/**/,$(CONN_DEFINES))
SpecialLibObjectRule(Astreams.o,/**/,$(CONN_DEFINES))
SpecialLibObjectRule(globals.o,/**/,$(CONN_DEFINES))
#else 
/* Pre-X11R5 compatability */
NormalLibraryObjectRule()

all:: libaudio.a

SpecialObjectRule(ConnSvr.o,/**/,$(CONN_DEFINES))
SpecialObjectRule(AuErrDes.o,/**/,$(CONN_DEFINES) $(EDB_DEFINES))
SpecialObjectRule(OpenSvr.o,/**/,$(CONN_DEFINES))
SpecialObjectRule(Alibint.o,/**/,$(CONN_DEFINES))
SpecialObjectRule(Astreams.o,/**/,$(CONN_DEFINES))
SpecialObjectRule(globals.o,/**/,$(CONN_DEFINES))

#endif
BuildIncludes($(HEADERS),audio,..)
InstallMultiple($(HEADERS),$(INCDIR))
#if ProjectX >= 5
InstallNonExecFile(AuErrorDB,$(LIBDIR))
#else
install::
	$(MKDIRHIER) $(LIBDIR)
InstallNonExec(AuErrorDB,$(LIBDIR))
#endif

#if defined(HPArchitecture)
XAULIB = 
#else
XAULIB = -lXau
#endif

#if defined(LinuxArchitecture)
REQUIREDLIBS = -L$(USRLIBDIR) -lXt $(XAULIB) -lm 
#endif

#if defined(cygwinArchitecture)
REQUIREDLIBS = $(LDPRELIB) $(XAUTHLIB) $(XTOOLLIB) $(XONLYLIB)
STD_INCLUDES = -I/usr/include
#endif                                                                        


#if DoSharedLib
#if DoNormalLib
#if ProjectX >= 5
SharedLibraryTarget(audio,$(SOAUDIOREV),$(OBJS),.,.)
#else
SharedLibraryTarget(audio,$(SOAUDIOREV),$(OBJS),shared,..)
#endif
#else
# if ProjectX >= 5
#ifdef WIN32
REQUIREDLIBS = $(XAUTHLIB) $(XTOOLLIB) $(XONLYLIB)
#endif /* WIN32 */
SharedLibraryTarget(audio,$(SOAUDIOREV),$(OBJS),unshared,..)
#else
SharedLibraryTarget(audio,$(SOAUDIOREV),$(OBJS),.,.)
#endif
#endif
#ifdef notyet
SharedLibraryDataTarget(audio,$(SOAUDIOREV),$(UNSHAREDOBJS))
#endif
InstallSharedLibrary(audio,$(SOAUDIOREV),$(USRLIBDIR))
#ifdef notyet
InstallSharedLibraryData(audio,$(SOAUDIOREV),$(USRLIBDIR))
#endif
#endif

#if DoNormalLib
NormalLibraryTarget(audio,$(OBJS))
InstallLibrary(audio,$(USRLIBDIR))
#endif

#if DoProfileLib
ProfiledLibraryTarget(audio,$(OBJS))
InstallLibrary(audio_p,$(USRLIBDIR))
#endif

#if DoDebugLib
DebuggedLibraryTarget(audio,$(OBJS))
InstallLibrary(audio_d,$(USRLIBDIR))
#endif

BuildReleaseHeader()

/* because nameaddr.c is conditionally included */
Astreams.o: nameaddr.c
Astreams.o: nameserver.c

depend:: $(SRCS)
  
DependTarget()
