#
# This is a sample server, Z39.50 library, and a user interface stub
#  The Z39.50 library was primariy written by Harry Morris and the search
#  engine was primarily written by Brewster Kahle.
#  -brewster 4/90

# Common customizations:
#  If a namespace resolver is not used (gethostbyname),
#   set RESOLVER to nothing, otherwise -lresolv
#  gcc vs cc:  This library was written on a bunch of ANSI routines.
#   the ones that did not exist in gcc or for non-ANSI cc are in ustubs.c
# for old BSD cc or System V, see cflags below

SERVER_CMD = ../bin/waisserver	# command name for the wais server
INDEX_CMD  = ../bin/waisindex 	# command name for indexing files
UI_LIB =     ../bin/ui.a	# file name of the ui library

RM = rm -f
AR = ar 
ARFLAGS = r
#
# Files.
#

# List of source files for saber.

SOURCES =	\
		cutil.c \
		futil.c \
		ir.c \
		ircfiles.c \
		irfileio.c \
		irfiles.c \
		irretrvl.c \
		irtfiles.c \
		panic.c \
		sockets.c \
		stoplist.c \
		transprt.c \
		ui.c \
		ustubs.c \
		wmessage.c \
		wprot.c \
		wutil.c \
		zprot.c \
		zutil.c \
 		irsearch.c \
 		ztype1.c \
		docid.c

INV_SRC  =	$(SOURCES) \
		sersrch.c \
		irhash.c \
		irinv.c		

INDEX_SRC=	irbuild.c

SERVER_SRC=	$(INV_SRC) \
		server.c

# List of object files for saber and regular compilation.
# Should correspond to source files.

OBJECTS =	\
		cutil.o \
		futil.o \
		ir.o \
		ircfiles.o \
		irfileio.o \
		irfiles.o \
		irretrvl.o \
		irtfiles.o \
		panic.o \
		sockets.o \
		stoplist.o \
		transprt.o \
		ui.o \
		ustubs.o \
		wmessage.o \
		wprot.o \
		wutil.o \
		zprot.o \
		zutil.o \
 		irsearch.o \
 		ztype1.o \
		docid.o

INV_OBJ  =	$(OBJECTS) \
		sersrch.o \
		irhash.o \
		irinv.o		

INDEX_OBJ=	irbuild.o

SERVER_OBJ=	$(INV_OBJ) \
		server.o \
		../bin/libftw.a

#
# Compilation.
#

# C Compiler.  Use either cc or gcc.
#CC = gcc

# Compiler & linker flags.
# Compiler debug flag.  Use -g for debugging, -O for optimization.
# for antique bsd add -DBSD 
# for System V add -DSYSV 
# for XENIX add -M3e -Zi
# -DSECURE_SERVER for waisserver to setuid to uucp after startup.
CFLAGS = -g -DSECURE_SERVER -DRELEVANCE_FEEDBACK

# dealing with taking an intenet name and resolving it.  
# set to -lresolv or nothing
RESOLVER=	#-lresolv 

default:	$(INDEX_CMD) $(SERVER_CMD) $(UI_LIB) 

$(INDEX_CMD):	$(INV_OBJ) $(INDEX_OBJ) 
		$(CC) $(CFLAGS) -o $(INDEX_CMD) $(INV_OBJ) $(INDEX_OBJ) -lm;

$(SERVER_CMD):	$(SERVER_OBJ)
		$(CC) $(CFLAGS) -o $(SERVER_CMD) $(SERVER_OBJ) -lm;

$(UI_LIB):	$(INV_OBJ)
		$(AR) $(ARFLAGS) $(UI_LIB) $(INV_OBJ)
		ranlib $(UI_LIB)


# Remove objects and library.
clean:
	$(RM) *.o
	$(RM) *~
	$(RM) \#*\#
	$(RM) .nfs*  # NFS lossage
	$(RM) *.elc
	$(RM) $(SERVER_CMD)
	$(RM) $(INDEX_CMD)
	$(RM) SearchLog
	$(RM)  core

