#
# Top level make of the WAIS system
#   brewster 2/91
#   jonathan 6/91

# $Log:	Makefile-release,v $
# Revision 1.8  92/05/07  15:54:08  jonathan
# Updated for release.
# 
# Revision 1.7  92/03/26  18:29:59  jonathan
# Fixed some broken make lines.
# 
# Revision 1.6  92/03/07  19:45:01  jonathan
# Added recommendation for IBM.
# 
# Revision 1.5  92/02/27  10:07:24  jonathan
# got rid of automatic setting of TOP.  Used Simon's approach instead.
 
# Revision 1.4  92/02/13  12:27:53  jonathan
# Removed references to seeker.
# 
# Revision 1.3  92/02/13  12:05:17  jonathan
# Removed release targets.
# 
# Revision 1.2  92/02/13  11:57:56  jonathan
# Added $Log for RCS.
# 
#
# common customizations:
# see the CFLAGS variable for pointers.
#
# to do:
# create the scripts, install the pointer to this version if it is the
# newest.
#
# SGIs want this uncommented
# SHELL=/bin/sh

RELEASE = freeWAIS-0.3

RM = /bin/rm -f
AR = ar 

# on SGIs set this to true
# RANLIB = true
RANLIB = ranlib

# on IBM RS6000 this should be c89.
# CC = cc
CC = gcc

# 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 = ..

SUPDIR = $(TOP)/ir

# 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 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 SGIs with gcc
# CFLAGS = -I$(SUPDIR) -DTELL_USER -DSECURE_SERVER -DRELEVANCE_FEEDBACK -DUSG -DBOOLEANS -DPARTIALWORD -DLITERAL -DSOUND -DBIBDB
#
# Use this version of CFLAGS for DECstation with gcc
# CFLAGS = -ansi -I$(SUPDIR) -DTELL_USER -DUSG -DSECURE_SERVER -DRELEVANCE_FEEDBACK -DBOOLEANS -DPARTIALWORD -DLITERAL -DSOUND -DBIBDB -DULTRIX
#
# Use this version of CFLAGS for DECstation with cc
# CFLAGS = -I$(SUPDIR) -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$(SUPDIR) -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$(SUPDIR) -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$(SUPDIR) -DTELL_USER -DUSG -DSECURE_SERVER -DRELEVANCE_FEEDBACK -DBOOLEANS -DPARTIALWORD -DLITERAL -DSOUND -DBIBDB -DLINUX

CFLAGS = -ansi -I$(SUPDIR) -DTELL_USER -DUSG -DSECURE_SERVER -DRELEVANCE_FEEDBACK -DBOOLEANS -DPARTIALWORD -DLITERAL -DSOUND -DBIBDB

# Solaris should use
#LIB = -ltcpip -lsocket -lnsl
# SGIs should use this
#LIB= -lmalloc
LIB=

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

#Solaris machines don't use -k
MFLAGS = -k

MAKE = make $(MFLAGS) 

#default: config.h lib ir ui bin doc x tags
default: config.h lib ir ui bin x check
	@echo "Welcome to WAIS"

config.h: config
	./config >config.h

config: config.c
	$(CC) $(CFLAGS) -o config config.c

lib::
	cd lib; $(MAKE) CC=$(CC) CFLAGS="$(CFLAGS)" RANLIB=$(RANLIB) TOP=$(TOP)

ir::
	cd ir; $(MAKE) CC=$(CC) CFLAGS="$(CFLAGS)" RANLIB=$(RANLIB) \
		TOP=$(TOP) LIB=$(LIB)

waisindex::
	cd ir; $(MAKE) waisindex CC=$(CC) CFLAGS="$(CFLAGS)" \
		RANLIB=$(RANLIB) TOP=$(TOP) LIB=$(LIB)

waisserver::
	cd ir; $(MAKE) waisserver CC=$(CC) CFLAGS="$(CFLAGS)" \
		RANLIB=$(RANLIB) TOP=$(TOP) LIB=$(LIB)

ui::
	cd ui; $(MAKE) CC=$(CC) CFLAGS="$(CFLAGS)" TOP=$(TOP) \
		CURSESLIB=$(CURSESLIB) LIB=$(LIB)

# NeXT and ULTRIX don't have an env command, so this doesn't work.
# try going to the x directory and just doing a make -k
# you may have to edit the CFLAGS in the Makefile yourself.

x::
	cd x; xmkmf; make depend; make
#	cd x; (env TOP=$(TOP) CC=$(CC) CFLAGS="$(CFLAGS)" MAKE="$(MAKE)" ./makex.sh)

bin::
	cd bin; $(MAKE) CC=$(CC) CFLAGS="$(CFLAGS)" TOP=$(TOP)

test::
	@echo $(MAKE) CC=$(CC) CFLAGS="$(CFLAGS)" TOP=$(TOP)

check::
	cd wais-test; $(MAKE)

# to make the emacs tags table for meta-.:
tags: 	
	etags -f TAGS ir/*.[ch]
	etags -af TAGS ui/*.[ch]
	etags -af TAGS x/*.[ch]

# Remove objects and library.
clean:
	$(RM) *%
	$(RM) *~
	$(RM) \#*\#
	$(RM) core
	$(RM) TAGS
	$(RM) -r SearchLog
	$(RM) wais-sources/wais-docs*
	$(RM) config config.h
	cd lib; make $@
	cd ir; make $@
	cd ui; make  $@
	cd bin; make  $@
	cd wais-test; make $@
	cd x; make $@

rlocks:
	$@
	cd lib; $@
	cd ir; $@
	cd ui;  $@
	cd bin;  $@
	cd doc;  $@
	cd x; $@
