# A makefile for the stuff now in libg++/etc

GXX = g++

# g++ compliation flags:
# the fchar-charconst flag is mandatory for some stream ops to work sensibly

GFLAGS = -g -O -fchar-charconst  -fsave-memoized -fno-defer-pop -I../g++-include 

.SUFFIXES: .cc
.cc.o:
	$(GXX) $(GFLAGS) -c  $<

PROGS= fib generic-queue search keyhash \
      tsort make-tsort-input genkey patricia getopt # 

all: progs tests 

progs: $(PROGS)

tests: $(PROGS)
	-./fib 1000
	-./generic-queue < ./generic-queue.cc
	-./make-tsort-input 20 | ./tsort
	-./keyhash < ./keyhash.cc
	-./search 1000
	-./genkey 1000 200 > input
	-./patricia ./input ./input | grep -v "is found"
	-./getopt -a -b20 -10     

fib: fib.o
	$(GXX) fib.o -o fib

getopt: getopt.h getopt.cc
	$(GXX) -DTEST getopt.cc -o getopt

generic-queue: generic-queue.o
	$(GXX) generic-queue.o -o generic-queue

tsort: make-tsort-input tsort.o
	$(GXX) tsort.o -o tsort


make-tsort-input: make-tsort-input.o
	$(GXX) make-tsort-input.o -o make-tsort-input

keyhash: keyhash.o
	$(GXX) keyhash.o -o keyhash

search: search.o
	$(GXX) search.o -o search

genkey: genPatkey.o
	$(GXX) $(GFLAGS) -o genkey genPatkey.o
   
Patmain.o: Patricia.h 

patricia: Patmain.o
	$(GXX) $(GFLAGS) -o patricia Patmain.o


clean:
	rm -f *.o $(PROGS) core input C++.hack*

