
#/* Copyright (c) CNIDR (Work in progress) */
#
#
# 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

# $Log: Makefile,v $
# Revision 1.1  1993/02/16  15:05:35  freewais
# Initial revision
#
# Revision 1.8  92/05/10  14:42:26  jonathan
# Changed CLIENT_LOCAL_SRC ot ui-local.c.  Added link to ui.c
# 
# Revision 1.7  92/04/30  12:30:22  jonathan
# Changed CC = to use cc instead.  It's the right thing to do...
# 
# Revision 1.6  92/04/28  17:09:05  jonathan
# Added lock.[co] to lists.
# 
# Revision 1.5  92/02/27  09:15:28  jonathan
# fixed compile line for ui-local.o
# 
# Revision 1.4  92/02/24  10:06:59  jonathan
# Removed -DBOOL from CFLAGS
# 
# Revision 1.3  92/02/13  13:02:44  jonathan
# Added CLIENT_LIB to default, and fixed rule.
# 
# Revision 1.2  92/02/13  12:28:26  jonathan
# Removed object and boolean sources from definitions.
# 
# Revision 1.1  92/02/13  11:55:08  jonathan
# Initial revision
# 
#

# 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
SERVER1_CMD	= ../bin/waisserver1	# command name for single task wais server
INDEX_CMD	= ../bin/waisindex 	# command name for indexing files
PROTOCOL_LIB 	= ../bin/wais.a		# file name of the protocol library
CLIENT_LIB 	= ../bin/client.a	# file name of the client library
INV_LIB 	= ../bin/inv.a		# file name of the inverted file library
SIG_LIB 	= ../bin/sig.a		# file name of the signature file library
LIBFTW		= ../bin/libftw.a	# support library

SHELL_UI_SRC = ../ui/shell-ui.c

RM = /bin/rm -f
AR = ar 
ARFLAGS = r
# on SGIs, set this to true
RANLIB = ranlib

#
# Files.
#

# List of source files for saber.

PROTOCOL_SRC = \
		cutil.c \
		syslog.c \
		futil.c \
		ircfiles.c \
		irfileio.c \
		irfiles.c \
		irtfiles.c \
		irkeywords.c \
		stemmer.c \
		panic.c \
		sockets.c \
		transprt.c \
		ustubs.c \
		wmessage.c \
		wprot.c \
		wutil.c \
		zprot.c \
		zutil.c \
 		ztype1.c \
		docid.c \
		list.c \
		lock.c

IR_SRC = \
		ir.c \
		irretrvl.c \
		stoplist.c \
 		irsearch.c \
		stemmer.c \
		synonym.c \
		trie.c

CLIENT_SRC = \
		ui.c

CLIENT_LOCAL_SRC = \
		ui-local.c

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

SIG_SRC  = 	$(SOURCES) \
		sighash.c \
		hash.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.

PROTOCOL_OBJ =	\
		cutil.o \
		syslog.o \
		futil.o \
		ircfiles.o \
		irfileio.o \
		irkeywords.o\
		irfiles.o \
		panic.o \
		sockets.o \
		transprt.o \
		ustubs.o \
		wmessage.o \
		wprot.o \
		wutil.o \
		zprot.o \
		zutil.o \
 		ztype1.o \
		docid.o \
		list.o \
		lock.o

IR_OBJS = \
		ir.o \
		irretrvl.o \
 		irsearch.o \
		irtfiles.o \
		stemmer.o \
		synonym.o \
		stoplist.o \
		trie.o

CLIENT_OBJS = \
		ui.o

CLIENT_LOCAL_OBJS = \
		ui-local.o

INV_OBJ  = 	$(IR_OBJS) \
		$(CLIENT_LOCAL_OBJS) \
		sersrch.o \
		irhash.o \
		hash.o \
		irinv.o

SIG_OBJ  = 	$(IR_OBJS) \
		$(CLIENT_LOCAL_OBJS) \
		sighash.o \
		hash.o

INDEX_OBJ	= irbuild.o ../../templates.o ../../whois/libwhois.a

SERVER_OBJ	= server.o ../../templates.o ../../whois/libwhois.a

SERVER1_OBJ	= server-single.o

#
# Compilation.
#

# C Compiler.  Use either cc or gcc.  Comment this out in release to
# inherit from top level.
#CC = cc
CC = gcc

# Compiler & linker flags.
# Compiler debug flag.  Use -g for debugging, -O for optimization.
# for antique bsd add -DBSD 
# for newer BSD that needs to use <sys/dir.h>, add -DBSD43
# for System V add -DSYSV 
# for XENIX add -M3e -Zi
# -DSECURE_SERVER for waisserver to setuid to uucp after startup.
#
# -- dgg additions for biology data
# -DPARTIALWORD (waisserver) for partial word matches, hum* matches human, hummingbird, ...
# -DBOOLEANS (waisserver) for boolean AND, NOT patches (dgg)
# -DLITERAL (waisserver) search for "literal strings" (dgg)
# -DBIO for biology source patches, including symbol usage (dgg, 12oct92)
#
# -DUSE_SYSLOG if you want logging to be done with syslog rather than
#   fprintf
# -DNEED_VSYSLOG if your C library does not have a vsyslog() function
#   in it (and you defined USE_SYSLOG)
# -DDUMPCORE will force the waisserver to dump the core when aborting
#   otherwise the core will not be dumped
# -DEND_MERGE if you want to merge the index files at the end of an
#  index process otherwise they are merged as we go along

CFLAGS = -g -I../../whois -I../.. -DSECURE_SERVER -DRELEVANCE_FEEDBACK -DUSG -DBOOLEANS -DPARTIALWORD -DLITERAL -DLOCAL_SEARCH -DFIELD_INDEX
#CFLAGS = -g -DSECURE_SERVER -DRELEVANCE_FEEDBACK -DUSG -DBOOLEANS -DLITERAL -DLOCAL_SEARCH -DFIELDI

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

default:	$(PROTOCOL_LIB) \
		$(INV_LIB) \
		$(SIG_LIB) \
		$(CLIENT_LIB) \
		$(INDEX_CMD) \
		$(SERVER_CMD)

$(CLIENT_LOCAL_OBJS): $(CLIENT_LOCAL_SRC)
		$(CC) $(CFLAGS) -DLOCAL_SEARCH -c $(CLIENT_LOCAL_SRC)

$(PROTOCOL_LIB): $(PROTOCOL_OBJ)
		$(AR) $(ARFLAGS) $@ $(PROTOCOL_OBJ)
		$(RANLIB) $@

$(CLIENT_LIB): $(CLIENT_OBJS)
		$(AR) $(ARFLAGS) $@ $(CLIENT_OBJS)
		$(RANLIB) $@

$(INV_LIB): 	$(INV_OBJ)
		$(AR) $(ARFLAGS) $@ $(INV_OBJ)
		$(RANLIB) $@

$(SIG_LIB): 	$(SIG_OBJ)
		$(AR) $(ARFLAGS) $@ $(SIG_OBJ)
		$(RANLIB) $@

$(INDEX_CMD):	$(INDEX_OBJ) $(PROTOCOL_LIB) $(INV_LIB) $(LIBFTW)
		$(RM) $@
		$(CC) $(CFLAGS) -o $@ $(INDEX_OBJ) \
		 $(INV_LIB) $(PROTOCOL_LIB) $(LIBFTW) -lm;

$(SERVER_CMD):	$(SERVER_OBJ) $(PROTOCOL_LIB) $(INV_LIB) $(LIBFTW)
		$(RM) $@
		$(CC) $(CFLAGS) -o $@ $(SERVER_OBJ) \
		 $(INV_LIB) $(PROTOCOL_LIB) $(LIBFTW) -lm;

$(SERVER1_CMD):	$(SERVER1_OBJ) $(PROTOCOL_LIB) $(INV_LIB) $(LIBFTW)
		$(RM) $@
		$(CC) $(CFLAGS) -o $@ $(SERVER1_OBJ) \
		 $(INV_LIB) $(PROTOCOL_LIB) $(LIBFTW) -lm;

#
# Saber loading.  Tuned for Saber 3.0
#

# Load source code into saber.
index_src:	$(INV_SRC) $(INDEX_SRC)
		#suppress 53
		#suppress 529
		#suppress 530
		#suppress 558
		#suppress 590
		#suppress 592
		#suppress 701 on strspn 
		#suppress 701 on strlen 
		#suppress 701 on strcspn
		#suppress 594 on waislog
		#load $(CFLAGS) $(INV_SRC) $(INDEX_SRC)

CSFLAGS = -D_ansi_prototypes -Dsparc -I/usr/include/cs/6.0.2 -I/usr/include 

index_sig_src:	$(INDEX_SRC)
		#suppress 53
		#suppress 529
		#suppress 530
		#suppress 558
		#suppress 590
		#suppress 560 
		#suppress 591 
		#suppress 592 
		#suppress 594 
		#suppress 701 
		#suppress 594 on waislog
		#load $(CFLAGS) $(INDEX_SRC) $(SIG_SRC)
		#load $(CFLAGS) $(CSFLAGS) ../seeker/add_words..c
		#load $(CFLAGS) $(CSFLAGS) ../seeker/seeker_sigs..c
		#load $(CFLAGS) $(CSFLAGS) ../seeker/seeker_search..c
		#load $(CFLAGS) $(CSFLAGS) ../seeker/combine..c
		#load $(CFLAGS) $(CSFLAGS) ../seeker/probe..c
		#load $(CFLAGS) ../seeker/select.c
		#load ../bin/utlib.a ../bin/search_lib.a ../bin/build_lib.a
		#load /usr/local/lib/libcsrt-6.0.2.a
		#load /usr/local/lib/libparis.a
		#load /usr/lib/libm.a

server_src:	$(INV_SRC) $(SERVER_SRC)
		#suppress 53
		#suppress 529
		#suppress 530
		#suppress 558
		#suppress 590
		#suppress 592
		#suppress 701 on strspn 
		#suppress 701 on strlen 
		#suppress 701 on strcspn 
		#suppress 65 on cprintf
		#suppress 594 on waislog
		#load $(CFLAGS) $(INV_SRC) $(SERVER_SRC)
		#load /usr/lib/libm.a

shell_ui_src:	$(INV_SRC) $(SHELL_UI_SRC)
		#suppress 35
		#suppress 53
		#suppress 57
		#suppress 530
		#suppress 529
		#suppress 558
		#suppress 590
		#suppress 592
		#suppress 701 on strspn 
		#suppress 701 on strlen 
		#suppress 701 on strcspn
		#suppress 594 on waislog 
		#load $(CFLAGS) -I./ $(INV_SRC) $(SHELL_UI_SRC)
		#load /usr/lib/libm.a

screen_ui_src:	$(INV_SRC) ../ui/screen-ui.c
		#suppress 35
		#suppress 53
		#suppress 57
		#suppress 530
		#suppress 529
		#suppress 558
		#suppress 590
		#suppress 592
		#suppress 701 on strspn 
		#suppress 701 on strlen 
		#suppress 701 on strcspn
		#suppress 594 on waislog 
		#load $(CFLAGS) -I./ $(INV_SRC) ../ui/screen-ui.c
		#load /usr/lib/libm.a

ui_src:		$(INV_SRC) 
		#suppress 35
		#suppress 53
		#suppress 57
		#suppress 530
		#suppress 529
		#suppress 558
		#suppress 590
		#suppress 592
		#suppress 701 on strspn 
		#suppress 701 on strlen 
		#suppress 701 on strcspn
		#suppress 594 on waislog 
		#load $(CFLAGS) -I./ $(INV_SRC)
		#load /usr/lib/libm.a

pump_question_src:	$(INV_SRC) pump_question.c
		#suppress 35
		#suppress 53
		#suppress 57
		#suppress 530
		#suppress 529
		#suppress 558
		#suppress 590
		#suppress 592
		#suppress 701 on strspn 
		#suppress 701 on strlen 
		#suppress 701 on strcspn
		#suppress 594 on waislog 
		#load $(CFLAGS) -I./ $(INV_SRC) pump_question.c
		#load /usr/lib/libm.a

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

