#
# Top level make for freeWAIS indexer
#   warnock@clark.net 8/94
# common customizations:
# see the CFLAGS variable for pointers.
#
# SGIs want this uncommented
# SHELL=/bin/sh

RELEASE = freeWAIS-0.5

# For HP-UX build shared library
SHARED =
#SHARED = shared

# Where to install include files
INCDEST = /usr/local/include/wais

# Where to install libraries
LIBDEST = /usr/local/lib/wais

# Libraries to install
LIBINST = client.a client.sl inv.a inv.sl libftw.a libftw.sl sig.a sig.sl \
	wais.a wais.sl

#
# Some default programs
# CC = cc
CC	= gcc
RM	= /bin/rm
MV	= mv
MAKE	= make

# on AU/X and SGIs set this to true
# RANLIB = true
RANLIB 	= ranlib

#
# Directory definitions
#
# set this for your site.  This syntax only works in SunOS
# for other UNIX-like OS's set this to this directory.
#TOP:sh = pwd
# or fill in the blank for other OS's
#comment-me:
#       @echo You must set "\$$(TOP)" to point to the freeWAIS src directory
TOP     = /home/warnock/freeWAIS
INCLUDE = $(TOP)/include
LIBDIR  = $(TOP)/bin
BINDIR  = $(TOP)/bin
SRCDIR  = $(TOP)/src
UIDIR   = $(SRCDIR)/client/ui

# Library definitions
#
# Solaris should use
# LIB =  -ltcpip -lsocket -lnsl
#
# AU/X and SGIs should use this
# LIB= -lmalloc
#
# If a namespace resolver is not used (gethostbyname),
# set RESOLVER to nothing, otherwise -lresolv
#
RESOLVER=
LIB=

# There are different versions of curses which could be used, so set the
# library here
CURSESLIB = -lcurses

# For a smaller client, but with no local search,
# use this line this to:
# INV_LIB	= $(LIBDIR)/client.a
INV_LIB		= $(LIBDIR)/inv.a
PROTOCOL_LIB	= $(LIBDIR)/wais.a
LIBFTW		= $(LIBDIR)/libftw.a
SIG_LIB		= $(LIBDIR)/sig.a
LIBS		= $(LIBFTW) $(LIB) $(RESOLVER)
UI_LIB		= $(INV_LIB) $(PROTOCOL_LIB)
UI_SIG_LIB	= $(TOP)/ir/seeker_dummy.o $(SIG_LIB) $(PROTOCOL_LIB)

# compiler specific stuff
#
# for old 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
# USG for Unix Dirent in lib
# for SGIs running IRIX 4.0.1, add -cckr
# for NeXTSTEP add -DNeXT and -posix
# for Linux add -DLINUX
# for A/UX add -DA_UX
#
# For a little better security in the server, add -DSECURE_SERVER
# this sets the server user id to -u argument after startup.
# for relevance feedaback in the search engine, add -DRELEVANCE_FEEDBACK
#
#   dgg additions
# LITERAL == waisserver, search for "literal strings"
# BOOLEANS == waisserver, search with boolean AND, NOT operators
# PARTIALWORD == waisserver, search for partial words, hum* matches human, 
#   hummingbird, ...
# BIO == waisindex, waisserver changes including symbol indexing & search 
#   & bio data formats
#
# -DTELL_USER lets the server know who you are at connect time
# -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
# -DSTEM_WORDS to stem words during indexing and queries
#
# Note - the default Porter Stemmer removes trailing e's from words -
# variable becomes variabl  - this can impact the use of literals in
# searches!!!!!!!!!!
#
# -DLIST_STEMS to show stemmed words in server log and indexer output
# -DSOLARIS for SunOS 5.2 (Solaris 2.2) machines.
#
# Use this version of CFLAGS for HPUX 9.01 with cc
#CFLAGS = +O1 +z -I$(INCLUDE) -DTELL_USER -DSECURE_SERVER -DRELEVANCE_FEEDBACK -DUSG -DBOOLEANS -DPARTIALWORD -DLITERAL -DSOUND -DBIBDB
#CFLAGS = +O3 +z -I$(INCLUDE) -DNDEBUG -DBIO -DTELL_USER -DSECURE_SERVER -DRELEVANCE_FEEDBACK -DUSG -DBOOLEANS -DPARTIALWORD -DLITERAL -DSOUND -DBIBDB
#
# Use this version of CFLAGS for SGIs with gcc
# CFLAGS = -I$(INCLUDE) -DTELL_USER -DSECURE_SERVER -DRELEVANCE_FEEDBACK -DUSG -DBOOLEANS -DPARTIALWORD -DLITERAL -DSOUND -DBIBDB
#
# Use this version of CFLAGS for DECstation with gcc
# CFLAGS = -ansi -I$(INCLUDE) -DTELL_USER -DUSG -DSECURE_SERVER -DRELEVANCE_FEEDBACK -DBOOLEANS -DPARTIALWORD -DLITERAL -DSOUND -DBIBDB -DULTRIX
#
# Use this version of CFLAGS for DECstation with cc
# CFLAGS = -I$(INCLUDE) -DTELL_USER -DUSG -DSECURE_SERVER -DRELEVANCE_FEEDBACK -DBOOLEANS -DPARTIALWORD -DLITERAL -DSOUND -DBIBDB -DULTRIX
#
# Use this version of CFLAGS for DEC Alpha with gcc
# CFLAGS = -ansi -I$(INCLUDE) -DTELL_USER -DUSG -DSECURE_SERVER -DRELEVANCE_FEEDBACK -DBOOLEANS -DPARTIALWORD -DLITERAL -DSOUND -DBIBDB
#
# Use this version of CFLAGS on Sun with gcc (not Solaris)
# CFLAGS = -ansi -I$(INCLUDE) -DTELL_USER -DUSG -DSECURE_SERVER -DRELEVANCE_FEEDBACK -DBOOLEANS -DPARTIALWORD -DLITERAL -DSOUND -DBIBDB
#
# Use this version of CFLAGS for Linux with gcc
# CFLAGS = -O2 -ansi -m486 -fwritable-strings -I$(INCLUDE) -DTELL_USER -DUSG -DSECURE_SERVER -DRELEVANCE_FEEDBACK -DBOOLEANS -DPARTIALWORD -DLITERAL -DSOUND -DBIBDB -DLINUX
#
# Use this version of CFLAGS for HP/UX
# CFLAGS = -ansi -I$(INCLUDE) -DTELL_USER -DUSG -DSECURE_SERVER -DRELEVANCE_FEEDBACK -DBOOLEANS -DPARTIALWORD -DLITERAL -DSOUND -DBIBDB -Dhpux -D_HPUX_SOURCE
#
# Flag definitions
#CFLAGS = -O2 -ansi -m486 -fwritable-strings -I$(INCLUDE) -DTELL_USER -DUSG -DSECURE_SERVER -DRELEVANCE_FEEDBACK -DBOOLEANS -DPARTIALWORD -DLITERAL -DSOUND -DBIBDB -DLINUX

LFLAGS	=
RMFLAGS	= -f
MFLAGS	= -k

#
# Targets to build
default: waisindex install

waisindex: message waisindex.o $(PROTOCOL_LIB) $(INV_LIB) $(LIBFTW)
	@echo "Linking and creating waisindex executable"
	$(CC) $(LFLAGS) -o $@ $@.o $(INV_LIB) $(LIBS) $(PROTOCOL_LIB);

install:
	@echo "Installing waisindex"
	$(MV) waisindex $(BINDIR)

message:
	@echo "Compiling waisindex source"

waisindex.o: waisindex.c
	$(CC) $(CFLAGS) -I$(INCLUDE) -c $?

clean:
	$(RM) $(RMFLAGS) *.o *~ core \#*\#
	$(RM) $(RMFLAGS) $(BINDIR)/waisindex

