# PD version of scandir/ftw/alphasort 
# 
# $Log: Makefile,v $
# Revision 1.1  1993/02/16  15:08:58  freewais
# Initial revision
#
# Revision 1.9  92/04/03  12:58:38  morris
# made it work with gcc
# 
# Revision 1.8  92/03/02  14:34:53  jonathan
# changed an errant rm to $(RM), per balze@think.com
# 
# Revision 1.7  92/02/16  18:39:35  jonathan
# Added directives for anytostring
# 
# 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     = /local/usr/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=

LIBFTW		= $(LIBDIR)/libftw.a

# 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$(SUPDIR) -DTELL_USER -DSECURE_SERVER -DRELEVANCE_FEEDBACK -DUSG -DBOOLEANS -DPARTIALWORD -DLITERAL -DSOUND -DBIBDB
#CFLAGS = +O3 +z -I$(SUPDIR) -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$(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
#
# Use this version of CFLAGS for A/UX with cc
# CFLAGS = -g -I$(SUPDIR) -DA_UX -DTELL_USER -DUSG -DSECURE_SERVER -DRELEVANCE_FEEDBACK -DBOOLEANS -DPARTIALWORD -DLITERAL -DSOUND -DBIBDB
#
# Flag definitions
CFLAGS	= -ansi -DUSG -DTELL_USER -DUSG -DSECURE_SERVER -DRELEVANCE_FEEDBACK -DBOOLEANS -DPARTIALWORD -DLITERAL -DSOUND -DBIBDB
LFLAGS	=
RMFLAGS	= -f
MFLAGS	= -k

#
# Targets to build
DEST	      = $(TOP)/bin

# For HPUX shared libraries set SHARED=shared
SHARED=

EXTHDRS	      = /usr/include/stdio.h \
		/usr/include/sys/stat.h \
		/usr/include/sys/types.h

HDRS	= pdftw.h

TRUNC	= $(DEST)/trunc

ANY	= $(DEST)/stringtoany

TOBJ	= trunc.o

AOBJ	= stringtoany.o

LIBRARY	= $(DEST)/libftw.a
LIBSL	= $(DEST)/libftw.sl

# Uncomment alphasort and scandir in OBJS and SRCS for Solaris
OBJS	= freedir.o \
		ftw.o 
#		alphasort.o \
#		scandir.o

SRCS	= freedir.c \
		ftw.c 
#		alphasort.c \
#		scandir.c 

TESTOBJS	= ftwtest.o ftwtest scantest.o scantest

all:		$(LIBRARY) $(TRUNC) $(ANY) $(SHARED)

$(LIBRARY):	$(OBJS)
		$(RM) $(RMFLAGS) $@
		$(AR) $(ARFLAGS) $@ $(OBJS)
		$(RANLIB) $(LIBRARY)

$(TRUNC):	$(TOBJ)
		$(CC) -o $@ $(TOBJ)

$(ANY):		$(AOBJ)
		$(CC) -o $@ $(AOBJ)

shared:         $(OBJS)
		ld -s -b -o $(LIBSL) $(OBJS)

test:		ftwtest.o scantest.o
		$(CC)  $(CFLAGS) ftwtest.o $(LIBRARY)  -o ftwtest
		$(CC)  $(CFLAGS) scantest.o $(LIBRARY)  -o scantest
		ftwtest /tmp
		scantest /tmp

clean:
	$(RM) $(RMFLAGS) *%
	$(RM) $(RMFLAGS) *.o
	$(RM) $(RMFLAGS) *~
	$(RM) $(RMFLAGS) \#*\#
	$(RM) $(RMFLAGS) .nfs*  # NFS Lossage
	$(RM) $(RMFLAGS) core
	$(RM) $(RMFLAGS) $(OBJS) $(TOBJ) $(TESTOBJS) $(LIBRARY) $(TRUNC) $(ANY)

alphasort.o: pdftw.h 
