# Makefile generated by configure on Mon Jun 17 22:01:01 EDT 1996
# Makefile for LQ-Text, a full text retrieval package by Liam R. Quin
#
# $Id: Makefile,v 1.17 94/05/23 20:49:39 lee Exp Locker: lee $
#
# If you have not already done so, please read the file lq-text/INSTALL
# before changing this file.
#
# If you need to edit it, see ../config.dir/Makefile.dfl, change
# it as necessary, and then configure again.
#
# Operating system for which this Makefile was generated:
OS = $OS

#
# This Makefile is made up of several sections:
# [1] general definitions
# [2] machine specific definitions
# [3] definitions generated by configure

# Do this first for sanity...:
SHELL=/bin/sh

## [1] General Definitions
##General:

### Some global configuration options.

# You should also look at h/globals.h for more things to change.
#
# Please read and edit this file down to the point marked
# `End of configuration section'.  See also PORTING in this directory,
# and the files in the ../doc directory.
# You shouldn't have to edit any other lq-text Makefiles.  If you do,
# please let me know.  Just doing a "make" in this directory should
# build everything (after editing this file and h/globals.h appropriately).
#
# You might have to work to get "db" (e.g. db.1.85) to work; if so,
# you can build with sdbm, as described here.  db is faster, sometimes
# halving indexing times.  Also use sdbm if you get messages about mmap
# being undefined (see h/globals.h).
#
# DEFS are included in CFLAGS, passed to the C compiler:
# If ASCIITRACE is defined, you can get extra debugging output using -t99
# (or some other number), but there is a slight performance penalty for
# including this, and you'd need to understand the code.

# If you are using sdbm and get messages about L_SET or L_SEEK being
# undefined, add -DSVID to cflaGS (there are other changes, but
# this is a useful symptom...)
#
# -DMALLCTRACE makes malloc.c produce masses of output...
#
# -DCURSESX, if present, says that we have the System V.3.1 or later
# curses that has A_STANDOUT and in which box(win, 0, 0) draws a neat box
# with vt100 characters.  If you're not sure, if the string ACS appears
# in /usr/include/curses.h you should probably use -DCURSESX.
#

##[2] Machine-specific definitions from config.dir/$HARDWARE/$OS/Makefile.tpl
##Machine-specific: (do not change THIS line, configure uses it)
# by default, no definitions need to be overridden.

##End of section [2]


## [3] definitions generated by configure

CFLAGS_GCC_WARN=-Wall -Wtraditional -Wpointer-arith -Wcast-qual -Wshadow -Wconversion -Waggregate-return -Wmissing-prototypes -Wmissing-declarations -Winline 
# I'm not ready for the following warnings yet:
# -Wwrite-strings -Wstrict-prototypes -Wnested-externs -Wredundant-decls -Wcast-align

# -fno-gnu-linker 

CFLAGS_GCC_OPT=-O3 -fomit-frame-pointer -ffast-math -fstrength-reduce -funroll-loops -fexpensive-optimizations -mhard-float
# removed: -finline-functions 


CFLAGS_OPT=-O3
# CFLAGS_OPT=-O4 -Qoption iropt -l4
CFLAGS_DBG=-g -ggdb3
# CFLAGS_DBG=
# CFLAGS_LOCAL=
CFLAGS_LOCAL=$(CFLAGS_GCC_WARN) $(CFLAGS_GCC_DBG) $(CFLAGS_GCC_OPT)
# LDFLAGS_LOCAL=
# CC=cc $(CFLAGS_DBG) $(CFLAGS_OPT)
CC=gcc $(CFLAGS_DBG)
# CC=cc -pg
LD=${CC}

#end

# installation directories:

DESTDIR=/opt/lqtext
INSTALLDIR_BIN=$(DESTDIR)/bin
INSTALLDIR_MAN=$(DESTDIR)/man
INSTALLDIR_LIB=$(DESTDIR)/lib

# confgure options:

# program to run on a .a file before using it: 
RANLIB=ranlib

# LD options to use ndbm (usually empty or -lndbm): 
NDBM_LIB=

TOP=/home/lee/src/lq-text/src

SDB_INC=-I$(TOP)/src/sdbm
SDB_LIB=-L$(TOP)/src/sdbm -lsdbm
DB_VERSION=1.85
DB_MACH=bsd.4.4
# DB_INC=-I$(TOP)/src/db.$(DB_VERSION)/PORT/$(DB_MACH) -I$(TOP)/src/db.$(DB_VERSION)/PORT/$(DB_MACH)/include
DB_INC=-I/usr/include/db3/
# DB_LIB=-L$(TOP)/src/db.$(DB_VERSION)/PORT/$(DB_MACH) -ldb
DB_LIB=-ldb-3.3
WHICHDBM="dbnative"
DBMINC=$(DB_INC)
DBMLIBS=$(DB_LIB)
# MKDBM=db
MKDBM=

##End of section [3]

##[4] Database-specific definitions
##Database-specific: (do not change THIS line, configure uses it)

# This section is not currently updated automatically.
# In the future, configure may be able to read an existing lq-text
# database configuration and make that the default.

##End of section [4]

##[5] Other changes
##Manual: (do not change THIS line, configure uses it)

# Put your own changes here to override anything configure does that you
# don't like, but that is not mchine or database specific...

##End of section [5].

# and the file mode for executables:
MODE=751

# Lqshow is the document browser.
LQSHOW=$(INSTALLDIR_BIN)/lqshow
LQFILE=$(INSTALLDIR_BIN)/lqfile

# If you have -lmalloc, use it...
# MALLOC=-lmalloc # faster version of malloc
# MALLOC=/usr/lib/debug/mallocmap.o /usr/lib/debug/malloc.o # debug on SunOS 
MALLOC= # BSD Unix doesn't have malloc(3X), only malloc(3)

# CURSES is for linking with curses, and should include termcap on BSD
# systems.  TERMCAP is for linking with only the low-level libtermcap or
# libterminfo library.  Programs use CURSES or TERMCAP but not both.

# CURSES=-lcursesX -ltermcap # ultrix -- cursesx
# CURSES=-lcurses -ltermcap
# TERMCAP=-ltermcap
# linux:
TERMCAP=-lcurses
CURSES=-lcurses
# TERMCAP=-ltermlib # SYSV

DEFS=-DASCIITRACE
CFLAGS= $(CFLAGS_LOCAL) $(DBMINC) $(DEFS) -D$(WHICHDBM) $$(EXTRA)

# Lint flags vary wildly between systems.
# LINTFLAGS=-xv
LINTFLAGS=-a -b -c -h -x 

###
### End of configuration section.  See also the PORTING file.
###
### You should not need to modify the makefile beyond this point.

# Note that liblqerror must be made first so that error.h is installed!
DIRS=liblqerror liblqtext liblqutil filters regex lqtext menu # test
MKTARGETS=lib bin $(MKDBM) $(DIRS)

# Make all does a local install (in src/bin src/lib src/testbin) too...
all: local

.SUFFIXES: .c .o .src .obj

.c.src:
	#load $(CFLAGS) $<

.o.obj:
	#load $(CFLAGS) $<

saber_src:
	$(MAKE) $(MFLAGS) MAKEWHAT=saber_src $(MKTARGETS)

saber_obj:
	$(MAKE) $(MFLAGS) MAKEWHAT=saber_obj $(MKTARGETS)

tidy:
	$(MAKE) -i $(MFLAGS) MAKEWHAT=tidy $(MKTARGETS)
	rm -f core

clean:
	$(MAKE) $(MFLAGS) MAKEWHAT=clean $(MKTARGETS)
	rm -f lib/* bin/* testbin/* core *.o m.log make.log tags ID

depend:
	$(MAKE) -i $(MFLAGS) MAKEWHAT=depend $(MKTARGETS)

local:: lib
	$(MAKE) $(MFLAGS) $(MKTARGETS)

install: libs
	-@test -d $(INSTALLDIR_LIB) || mkdir -p $(INSTALLDIR_LIB)
	-@test -d $(INSTALLDIR_BIN) || mkdir -p $(INSTALLDIR_BIN)
	$(MAKE) $(MFLAGS) MAKEWHAT=install DESTDIR="$(DESTDIR)" $(MKTARGETS)
	( cd lib ; for i in `ls | grep -v '\.a$$'`; do \
	    install -s -c -m $(MODE) $$i ${INSTALLDIR_LIB}/$$i; \
	  done ; \
	)
	-@test -d $(INSTALLDIR_MAN) || mkdir -p $(INSTALLDIR_MAN)
	@-echo Binary Installation complete
	@-echo Now install manual pages from ../doc if appropriate,
	@-echo with make installdocs

installdocs:
	cd ../doc; \
	$(MAKE) $(MFLAGS) MALLOC='$(MALLOC)' \
	CFLAGS='$(CFLAGS)' CC='$(CC)' \
	DESTDIR="$(DESTDIR)" \
	WHICHDBM='$(WHICHDBM)' TERMCAP='$(TERMCAP)' RANLIB='$(RANLIB)' \
	DBMLIBS="${DBMLIBS}" LINTFLAGS='$(LINTFLAGS)' install

lint:
	$(MAKE) $(MFLAGS) MAKEWHAT=lint $(MKTARGETS)

libs:
	@test -d ${INSTALLDIR_LIB} || mkdir ${INSTALLDIR_LIB}
	$(MAKE) $(MFLAGS) MAKEWHAT=install $(MKDBM) liblqerror
	$(MAKE) $(MFLAGS) MAKEWHAT=install $(MKDBM) liblqtext
	$(MAKE) $(MFLAGS) MAKEWHAT=install $(MKDBM) liblqutil
	-@echo libraries up to date

ID:
	mkid `find h $(DIRS) -name '*.[ch]' -print`

# Note to lib and bin:
# If the mkdir -p bombs out, there is a shell-script mkdir you can use
# in the utils directory.  The -p means to create parent directores as needed.

lib:: # see note above about mkdir
	-@test -d lib || mkdir lib
	-@test -d $(INSTALLDIR_LIB) || mkdir -p $(INSTALLDIR_LIB)

bin::  # see note above about mkdir
	-@test -d bin || mkdir bin
	-@test -d $(INSTALLDIR_BIN) || mkdir -p $(INSTALLDIR_BIN)

filters::
	cd filters; \
	$(MAKE) $(MFLAGS) MALLOC='$(MALLOC)' \
	CFLAGS='$(CFLAGS)' CC='$(CC)' \
	DESTDIR="$(DESTDIR)" \
	WHICHDBM='$(WHICHDBM)' TERMCAP='$(TERMCAP)' RANLIB='$(RANLIB)' \
	DBMLIBS="${DBMLIBS}" LINTFLAGS='$(LINTFLAGS)' $(MAKEWHAT) 

liblqtext::
	cd liblqtext; \
	$(MAKE) $(MFLAGS) MALLOC='$(MALLOC)' \
	CFLAGS='$(CFLAGS)' CC='$(CC)' \
	DESTDIR="$(DESTDIR)" \
	WHICHDBM='$(WHICHDBM)' TERMCAP='$(TERMCAP)' RANLIB='$(RANLIB)' \
	DBMLIBS="${DBMLIBS}" LINTFLAGS='$(LINTFLAGS)' $(MAKEWHAT)

# For regex, we don't override CFLAGS.... but include them with $(ADDFLAGS).
regex::
	cd regex; \
	$(MAKE) $(MFLAGS) MALLOC='$(MALLOC)' \
	ADDFLAGS='$(CFLAGS)' CC='$(CC)' \
	DESTDIR="$(DESTDIR)" \
	RANLIB='$(RANLIB)' LINTFLAGS='$(LINTFLAGS)' $(MAKEWHAT)

liblqutil::
	cd liblqutil; \
	$(MAKE) $(MFLAGS) MALLOC='$(MALLOC)' \
	CFLAGS='$(CFLAGS)' CC='$(CC)' \
	DESTDIR="$(DESTDIR)" \
	WHICHDBM='$(WHICHDBM)' TERMCAP='$(TERMCAP)' RANLIB='$(RANLIB)' \
	DBMLIBS="${DBMLIBS}" LINTFLAGS='$(LINTFLAGS)' $(MAKEWHAT)


liblqerror::
	cd liblqerror; \
	$(MAKE) $(MFLAGS) MALLOC='$(MALLOC)' \
	CFLAGS='$(CFLAGS)' CC='$(CC)' \
	DESTDIR="$(DESTDIR)" \
	WHICHDBM='$(WHICHDBM)' TERMCAP='$(TERMCAP)' RANLIB='$(RANLIB)' \
	DBMLIBS="${DBMLIBS}" LINTFLAGS='$(LINTFLAGS)' $(MAKEWHAT)

lqtext::
	cd lqtext; \
	$(MAKE) $(MFLAGS) MALLOC='$(MALLOC)' \
	CFLAGS='$(CFLAGS)' CC='$(CC)' \
	DESTDIR="$(DESTDIR)" \
	WHICHDBM='$(WHICHDBM)' CURSES='$(CURSES)' TERMCAP='$(TERMCAP)' RANLIB='$(RANLIB)' \
	DBMLIBS="${DBMLIBS}" LINTFLAGS='$(LINTFLAGS)' $(MAKEWHAT)

sdbm::
	cd sdbm; \
	$(MAKE) $(MFLAGS) MALLOC='$(MALLOC)' CFLAGS='$(CFLAGS)' \
	CC='$(CC)' WHICHDBM='$(WHICHDBM)' TERMCAP='$(TERMCAP)' \
	RANLIB='$(RANLIB)' \
	DBMLIBS="${DBMLIBS}" LINTFLAGS='$(LINTFLAGS)' $(MAKEWHAT)

db::
	cd db.$(DB_VERSION)/PORT/$(DB_MACH); \
	$(MAKE) $(MFLAGS) MALLOC='$(MALLOC)' CFLAGS='$(CFLAGS)' \
	CC='$(CC)' WHICHDBM='$(WHICHDBM)' TERMCAP='$(TERMCAP)' \
	DESTDIR="$(DESTDIR)" \
	RANLIB='$(RANLIB)' \
	DBMLIBS="${DBMLIBS}" LINTFLAGS='$(LINTFLAGS)' \
	MACH='$(DB_MACH)' $(MAKEWHAT)

test::
	cd test; \
	$(MAKE) $(MFLAGS) MALLOC='$(MALLOC)' \
	CFLAGS='$(CFLAGS)' CC='$(CC)' \
	WHICHDBM='$(WHICHDBM)' TERMCAP='$(TERMCAP)' \
	OWNER='$(OWNER)' RANLIB='$(RANLIB)' \
	DBMLIBS="${DBMLIBS}" LINTFLAGS='$(LINTFLAGS)' $(MAKEWHAT)

menu::
	cd menu; \
	$(MAKE) $(MFLAGS) MALLOC='$(MALLOC)' CFLAGS='$(CFLAGS)' \
	MALLOC='$(MALLOC)' RANLIB='$(RANLIB)' \
	DESTDIR="$(DESTDIR)" \
	CFLAGS='$(CFLAGS) -DLQSHOW=\"$(LQSHOW)\" -DLQFILE=\"$(LQFILE)\" ' \
	CC='$(CC)' WHICHDBM='$(WHICHDBM)' CURSES='$(CURSES)' TERMCAP='$(TERMCAP)' \
	DBMLIBS="${DBMLIBS}" LINTFLAGS='$(LINTFLAGS)' $(MAKEWHAT)


tags::
	ctags $(WHICHDBM)/*.[hc] h/*.h `echo $(DIRS) | tr ' ' '\012' | sed -e 's;$$;/*.[ch];'`

