# logresolve 2.0 - http://www.uunet.ca/~tomr/progs/logresolve/
# Tom Rathborne - tomr@uunet.ca - http://www.uunet.ca/~tomr/

# Please use GNU Make!
#
# 'make'            compiles everything (currently just logresolve)
# 'make logresolve' builds the program (same as just 'make' right now)
# 'make sweep'      cleans up (removes pieces)
# 'make clean'      cleans up (removes objects AND executables)

###### Compiler and flags 

# I prefer gcc, that's why it's the default.
COMPILER = gcc

# For best speed/compactness I use "CFLAGS = -O2 -s"
CFLAGS = -O1

###### Required libraries - varies by OS

# Linux, Irix and SunOS don't need anything special.

# Solaris needs socket and nameservice libraries:
# LIBS = -lsocket -lnsl

# Insert your favourite ndbm-compatible library here:
DBMLIB = -lgdbm

###### You shouldn't have to fiddle with anything down here.

OBJECTS = logresolve
SOURCES = logresolve.c lr-nsrec.c lr-stats.c lr-ip.c lr-hash.c lr-dbm.c
PIECES = $(SOURCES:.c=.o)

ALLDEPS = logresolve.h Makefile
INCLUDES = logresolve.h lr-dbm.h lr-hash.h lr-ip.h lr-nsrec.h lr-stats.h

.SUFFIXES: .c .o

.c.o: $(COMPILER) $(CFLAGS) -c $<

logresolve: $(PIECES)
	$(COMPILER) $(CFLAGS) $(LIBS) $(DBMLIB) -o logresolve $(PIECES)

sweep:
	rm -f $(PIECES)

clean:
	rm -f $(OBJECTS) $(PIECES)

$(PIECES) : $(ALLDEPS)
	$(COMPILER) $(CFLAGS) -c $*.c

### additional dependencies - anyone know a better way to do this?

logresolve.o: logresolve.c logresolve.h
lr-nsrec.o: lr-nsrec.c lr-nsrec.h
lr-stats.o: lr-stats.c lr-stats.h
lr-ip.o: lr-ip.c lr-ip.h lr-nsrec.h
lr-hash.o: lr-hash.c lr-hash.h lr-dbm.h lr-nsrec.h
lr-dbm.o: lr-dbm.c lr-dbm.h lr-nsrec.h

