# Makefile for core utilities of the strings db suite.
#
# See COPYING for distribution and licensing information.
#
# Copyright (c) 1997 Amelia A. Lewis
#
# $Id: Makefile 58 2005-09-20 22:14:23Z amyzing $
#
# Revised for 0.5.4

CC=gcc
#CFLAGS=-Wall -O2
CFLAGS=-Wall -O2
EXTRAFLAGS=-DUSE_REGEX
LDFLAGS=-s
LIBDIR=../lib
LIB=$(LIBDIR)/libstr.a

BINDIR=/usr/local/bin
MANDIR=/usr/local/share/man/man1
MANSUFFIX=.1str
LIBMANDIR=/usr/local/share/man/man3
LIBMANSUFFIX=.3str

TARGETS=idxstr lsstr getstr dumpstr grepstr delstr cyclestr edstr keystr getkey

all: $(TARGETS)

# need to revise so that if shared created, link that way, not to static

# Creation tools #
idxstr: idxstr.o $(LIB)
	$(CC) $(LDFLAGS) -o $@ idxstr.o $(LIB)

keystr: keystr.o $(LIB)
	$(CC) $(LDFLAGS) -o $@ keystr.o $(LIB)

# Retrieval tools #
# Retrieve all sorts of useful information
lsstr: lsstr.o $(LIB)
	$(CC) $(LDFLAGS) -o $@ lsstr.o $(LIB)
# get one
getstr: getstr.o $(LIB)
	$(CC) $(LDFLAGS) -o $@ getstr.o $(LIB)

# this one retrieves by key
getkey: getkey.o $(LIB)
	$(CC) $(LDFLAGS) -o $@ getkey.o $(LIB)

# dump data in index order
dumpstr: dumpstr.o $(LIB)
	$(CC) $(LDFLAGS) -o $@ dumpstr.o $(LIB)

# retrieve by regex or by string comparison
grepstr: grepstr.o $(LIB)
	$(CC) $(LDFLAGS) -o $@ grepstr.o $(LIB)

# Maintenance tools #
delstr: delstr.o $(LIB)
	$(CC) $(LDFLAGS) -o $@ delstr.o $(LIB)

cyclestr: cyclestr.o $(LIB)
	$(CC) $(LDFLAGS) -o $@ cyclestr.o $(LIB)

edstr: edstr.o $(LIB)
	$(CC) $(LDFLAGS) -o $@ edstr.o $(LIB)

# admin tasks
install:
	cp $(TARGETS) $(BINDIR)
	mkdir -p $(MANDIR)
	for i in $(TARGETS) ; do cp man/$$i".man" $(MANDIR)/$$i$(MANSUFFIX) ; done

clean:
	-rm -f ${TARGETS} *.o
