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

# common customizations:
# see the CFLAGS variable for pointers.
#
# to do:
# create the scripts, install the pointer to this version if it is the
# newest.

RM = rm -f
AR = ar

CC = cc

# set this for your site.  This syntax only works in SunOS
# for other UNIX-like OS's set this to this directory.
TOP = /burchard/WAIS
#TOP = /proj/wais/latest

SUPDIR = $(TOP)/ir

# for old BSD add -DBSD
# for System V add -DSYSV 
# for XENIX add -M3e -Zi
# for NeXT add -DNeXT
# 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
# USG for Unix Dirent in lib
CFLAGS = -g -I$(SUPDIR) -DNeXT -DSECURE_SERVER -DRELEVANCE_FEEDBACK -DUSG

# this is a pretty good guess at the MAKE command.  -e seems to be
# SunOS specific too, so remove it for ULTRIX and NeXT.

MAKE = make -k CC=$(CC) "CFLAGS=$(CFLAGS)" TOP=$(TOP)

default: lib ir bin next-ui doc
	@echo "Welcome to WAIS"

lib::
	cd lib; $(MAKE) 

ir::
	cd ir; $(MAKE) 

ui::
	cd ui; $(MAKE)

next-ui::
	cd next-ui; $(MAKE)

# ULTRIX doesn'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; (env TOP=$(TOP) CC=$(CC) "CFLAGS=$(CFLAGS)" ./makex.sh)

bin::
	cd bin; $(MAKE)

doc::
	cd doc; $(MAKE)

test::
	@echo $(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) core
	$(RM) TAGS
	$(RM) -r SearchLog
	$(RM) wais-sources/wais-docs*
	cd lib; make $@
	cd ir; make $@
	cd ui; make  $@
	cd bin; make  $@
	cd doc; make  $@
	cd x; make $@
#	cd motif; make $@
#	cd seeker/src; make $@

RELEASE = wais-8-b3

REMOVEM = seeker xm motif to-release.txt ir/server-single.c

release:
	mkdir ../${RELEASE}
	tar cvf - . | (cd ../${RELEASE}; tar xf -)
	find ../${RELEASE} -name RCS -exec rm -rf {} ";"
	(cd ../${RELEASE}; make -k clean; rm -rf ${REMOVEM})
	find ../${RELEASE} -name Makefile -exec chmod a+w {} ";"
	(cd ..; tar cvf ${RELEASE}.tar ${RELEASE})
	(cd ..; compress -f ${RELEASE}.tar)

# when making a new release, change ir/version.h to say so.
distrib:
	mkdir ${TOP}-dist
	tar cvf - . | (cd ${TOP}-dist; tar xf -)
	find ${TOP}-dist -name RCS -exec rm -rf {} ";"
	(cd ${TOP}-dist; make -k clean; rm -rf seeker/timing seeker/db seeker/src/*_sig_data)
	(cd ..; tar cvf ${TOP}-dist.tar `basename ${TOP}-dist`)
	compress -f ${TOP}-dist.tar
	rm -rf ${TOP}-dist

expt:
	mkdir ${TOP}-expt
	tar cvf - . | (cd ${TOP}-expt; tar xf -)
	find ${TOP}-expt -name RCS -exec rm -rf {} ";"
	(cd ${TOP}-expt; make -k clean)
	(cd ..; tar cvf ${TOP}-expt.tar `basename ${TOP}-expt`)
	compress -f ${TOP}-expt.tar
	rm -rf ${TOP}-expt
