#
# Makefile for the libident library
#
# This is slightly tuned for a 4BSD system (like SunOS 4). Remove the ranlib
# calls if you don't have ranlib.

# NEXTSTEP 3.x Multi-Architecture-Binary (FAT) compiles
# If you want compile only for one specific platform, specifiy
#       "-arch m68k" for Motorola 600[34]0
# or
#       "-arch i386" for Intel i486
# (The Multi-Architecture-Binary is about double as big as the
#  Single-Architecture-Binary)
NEXTARCHS=-arch m68k -arch i386

# This is where you want to install the library
LIBDIR=/usr/local/lib
# And this is where the header file ident.h goes
INCDIR=/usr/local/include
# And the manual page
MANDIR=/usr/local/man/man3

#
# Add -g for debugging information
#
# Add -DNOSTRINGH if your system has no string.h
# Add -DNEED_STRDUP if your system has no strdup()
# Add -DNEED_STRCHR if your system no strchr()
#
# Use this for old BSD systems (like Sequents Dynix):
# 
# CFLAGS=-O -DNOSTRINGH -DSIGRETURNTYPE=int
#
# For NeXT with NeXTSTEP 3.0 use:
# 	CFLAGS=-O -Wall -s -object -DNEED_STRDUP -DNeXT3
# For NeXT with NeXTSTEP 3.1 use:
# 	CFLAGS=-O -Wall -s -object -DNEED_STRDUP -DNeXT3 $(NEXTARCHS)
CFLAGS = -O

OBJS = ident.o id_open.o id_close.o id_query.o id_parse.o

all: libident.a testers

libident.a:	$(OBJS)
	-rm -f libident.a
	ar cq libident.a $(OBJS)
	-ranlib libident.a

testers: lookup-tester ident-tester

ident-tester: libident.a ident-tester.o
	$(CC) $(CFLAGS) -o ident-tester ident-tester.o -L. -lident -lsocket -lnsl

lookup-tester: libident.a lookup-tester.o
	$(CC) $(CFLAGS) -o lookup-tester lookup-tester.o -L. -lident -lsocket -lnsl


ident.o:	 ident.c         ident.h
id_open.o:	 id_open.c       ident.h
id_close.o:	 id_close.c      ident.h
id_query.o:	 id_query.c      ident.h
id_parse.o:	 id_parse.c      ident.h
ident-tester.o:  ident-tester.c  ident.h
lookup-tester.o: lookup-tester.c ident.h

install:
	-rm -f $(LIBDIR)/libident.a
	cp libident.a $(LIBDIR)/libident.a
	-ranlib $(LIBDIR)/libident.a
	-rm -f $(INCDIR)/ident.h
	cp ident.h $(INCDIR)/ident.h
	-rm -f $(MANDIR)/ident.3
	cp ident.3 $(MANDIR)/ident.3

clean:
	-rm -f libident.a ident-tester lookup-tester *~ core *.o \#*
