#
#		 Copyright 1994 Christopher B. Liebman
#
#     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 Christopher B. Liebman not
#     be used in advertising or publicity pertaining to distribution of this
#     software without specific, written prior permission.
#
#    THIS SOFTWARE IS PROVIDED `AS-IS'.  CHRISTOPHER B. LIEBMAN, 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 CHRISTOPHER
#    B. LIEBMAN, 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.41 1994/03/08 02:40:38 liebman Exp $
#
#    Makefile for XFaces.
#

/*
 *  Undefine any of these to remove that feature.
 *
 * USE_XPM		- Allows xpm format pixmaps to be used for face images.
 * USE_SHAPE		- Allows the use of the shape extension for face
 *			  images.
 * USE_SOUND		- Enables sound support using netaudio (tested with
 *			  version 1.1)
 * USE_BUCKETS		- Store audio samples as buckets while they are active.
 * USE_XFACE		- Add in support for X-Face compressed image headers.
 * USE_POP		- Adds support for POP3 mailboxs.
 * LOOKUP_HOSTNAME	- Lookup host using gethostbyname() to allow aliases.
 *
 * Note: netaudio-1.1
 * USE_BUCKETS currently has a problem on both my Sparc10 SunOS 4.1.3 and
 * my SparcIPC SunOS 4.1.1.  When the bucket is played if tends to have an
 * audible glitch after the first 1/4 to 1/2 second!  The file ausun.patch
 * contains a fix for this.  Either apply the patch or undefine USE_BUCKETS!
*/

#define	USE_XPM
#define USE_SHAPE
#define	USE_XFACE
#define USE_SOUND
#define	USE_BUCKETS
#define USE_POP
#define LOOKUP_HOSTNAME

#
#  For debugging.
#
#	-DBINDING_DEBUG
#	-DFACEDB_DEBUG
#	-DPOP_DEBUG
#	-DRESOURCE_DEBUG
#	-DSEARCH_DEBUG
#	-DITEM_DEBUG
#	-DLOOKUP_DEBUG
#
#CDEBUGFLAGS= -Wall -g 
#CDEBUGFLAGS= -g

#ifdef USE_XFACE
XFACE_SRCS	= face_search_xface.c face_image_xface.c
XFACE_OBJS	= face_search_xface.o face_image_xface.o
XFACE_DEFS	= -DXFACE
#XFACE_LIBS	= -L../compface -lcompface
XFACE_LIBS	= -L/usr/local/lib -lcompface
#endif

#ifdef USE_XPM
XPM_SRCS	= face_image_xpm.c
XPM_OBJS	= face_image_xpm.o
XPM_INCL	= 
#XPL_INCL	= -I/usr/xpm/include
XPM_LIBS	= -lXpm
#XPM_LIBS	= -L/usr/xpm/lib -lXpm
XPM_DEFS	= -DXPM
#endif

#ifdef USE_SOUND
SOUND_SRCS	= face_sound.c
SOUND_OBJS	= face_sound.o
SOUND_INCL	= 
#SOUND_INCL	= -I/usr/audio/include
SOUND_LIBS	= -laudio
#SOUND_LIBS	= -L/usr/audio/lib -laudio
#ifdef USE_BUCKETS
SOUND_DEFS	= -DSOUND -DUSE_BUCKETS
#else
SOUND_DEFS	= -DSOUND
#endif
#endif

#ifdef USE_SHAPE
SHAPE_SRCS	= face_shape.c
SHAPE_OBJS	= face_shape.o
SHAPE_INCL	= 
SHAPE_LIBS	= 
SHAPE_DEFS	= -DSHAPE
#endif

#ifdef USE_POP
POP_SRCS	= pop_check.c
POP_OBJS	= pop_check.o
POP_INCL	= 
POP_LIBS	= 
POP_DEFS	= -DPOP
#endif

#ifdef LOOKUP_HOSTNAME
LHN_SRCS	= 
LHN_OBJS	= 
LHN_INCL	= 
LHN_LIBS	= 
LHN_DEFS	= -DLOOKUP_HOSTNAME
#endif

XFACES_VERSION_TAG=

HDRS	= Tiled.h \
	  TiledP.h \
	  faces.h \
	  face_command.h \
	  face_image.h \
	  face_search.h \
	  face_sound.h \
	  patchlevel.h \
	  regexp.h \
	  regmagic.h \
	  $(XFACE_HDRS)

SRCS	= Tiled.c \
	  cmd_check.c \
	  face_actions.c \
	  face_annotate.c \
	  face_binding.c \
	  face_command.c \
	  face_display.c \
	  face_image.c \
	  face_image_xbm.c \
	  face_search.c \
	  face_search_binding.c \
	  face_search_facedb.c \
	  face_search_resource.c \
	  face_search_uh.c \
	  mail_box.c \
	  mail_body.c \
	  mail_check.c  \
	  mail_file.c \
	  mail_header.c \
	  mail_items.c  \
	  mail_parse.c \
	  main.c \
	  path.c \
	  regexp.c \
	  regsub.c \
	  string.c \
	  $(SOUND_SRCS) $(XPM_SRCS) $(SHAPE_SRCS) $(XFACE_SRCS) $(POP_SRCS) \
	  $(LHN_OBJS)

OBJS	= Tiled.o \
	  cmd_check.o \
	  face_actions.o \
	  face_annotate.o \
	  face_binding.o \
	  face_command.o \
	  face_display.o \
	  face_image.o \
	  face_image_xbm.o \
	  face_search.o \
	  face_search_binding.o \
	  face_search_facedb.o \
	  face_search_resource.o \
	  face_search_uh.o \
	  mail_box.o \
	  mail_body.o \
	  mail_check.o  \
	  mail_file.o \
	  mail_header.o \
	  mail_items.o  \
	  mail_parse.o \
	  main.o \
	  path.o \
	  regexp.o \
	  regsub.o \
	  string.o \
	  $(SOUND_OBJS) $(XPM_OBJS) $(SHAPE_OBJS) $(XFACE_OBJS) $(POP_OBJS) \
	  $(LHN_OBJS)

OTHER_FILES	= BLURB README CHANGES CREDITS TODO COPYRIGHT ChangeLog \
		  Imakefile XFaces.ad xfaces.man ausun.patch \
		  Makefile.noimake
IMAGEDIR	= images

INCLUDES	= $(TOP_INCLUDES) $(SOUND_INCL) \
		  $(XPM_INCL) $(SHAPE_INCL) $(POP_INCL) $(LHN_INCL)
SYS_LIBRARIES	= $(SOUND_LIBS) -lm
#
#
# You will need to add -lnsl and -lsocket on some Solaris2 systems using
# openwindows. You may even need to add a -L/usr/openwin/lib before
# the XawClientLibs also.
#
LOCAL_LIBRARIES = $(XPM_LIBS) XawClientLibs $(XFACE_LIBS) $(POP_LIBS) \
		  $(LHN_LIBS)
DEFINES		= $(SOUND_DEFS) $(XPM_DEFS) $(SHAPE_DEFS) \
		  $(XFACE_DEFS) $(POP_DEFS) $(LHN_DEFS)

ComplexProgramTarget(xfaces)
InstallAppDefaults(XFaces)
InstallManPage(xfaces,$(MANDIR))

#
# A bit of a hack to make life easier.
#

distribution:
	(set -x;THIS_PLACE=`pwd`; \
	export THIS_PLACE; \
	if [ -z "$(XFACES_VERSION)" ]; then \
	    XFV=`grep XFACES_VERSION patchlevel.h|awk '{print $$3}'`; \
	else \
	    XFV=$(XFACES_VERSION);\
	fi; \
	XFT=XFACES_`echo $$XFV | sed 's/\./_/'`; \
	export XFT; \
	mkdir -p Distribution/xfaces-$$XFV; \
	cd Distribution/xfaces-$$XFV; \
	ln -s $$THIS_PLACE/RCS; \
	co -r$$XFT Imakefile; \
	xmkmf; \
	make XFACES_VERSION_TAG=$$XFT current; \
	rm RCS; \
	mkdir -p $(IMAGEDIR); \
	(cd $(IMAGEDIR); \
	ln -s $$THIS_PLACE/$(IMAGEDIR)/RCS; \
	co -r$$XFT Imakefile; \
	xmkmf; \
	make XFACES_VERSION_TAG=$$XFT current; \
	rm -f Makefile Makefile.bak Imakefile RCS); \
	cd ..; \
	tar cvf xfaces-$$XFV.tar xfaces-$$XFV; \
	compress xfaces-$$XFV.tar)

current:
	co -r$(XFACES_VERSION_TAG) $(HDRS) $(SRCS) $(OTHER_FILES)

tag:
	if [ ! -z "$(XFACES_VERSION_TAG)" ]; then \
	    for i in $(HDRS) $(SRCS) $(OTHER_FILES);do \
		head=`rlog -h $$i | grep '^head' | awk '{print $$2}'`; \
		rcs -N$(XFACES_VERSION_TAG):$$head $$i; \
	    done; \
	    (cd $(IMAGEDIR); \
	    make XFACES_VERSION_TAG=$(XFACES_VERSION_TAG) tag); \
	fi

files:
	@echo $(HDRS) $(SRCS) $(OTHER_FILES)
	
clean::
	rm -rf Distribution

