#
#  Makefile for the Harvest Broker support software
#
#  William G. Camargo & Darren Hardy, July 1994
#
#  Makefile.in,v 1.30 1995/11/17 01:06:24 duane Exp
#

prefix = @prefix@
INSTALL_BINDIR	= $(prefix)/bin
INSTALL_LIBDIR	= $(prefix)/lib
INSTALL_UTILDIR	= $(prefix)/lib/broker
INSTALL_MANDIR 	= $(prefix)/man
INSTALL_CGI	= $(prefix)/cgi-bin

CC		= @CC@
INSTALL		= @INSTALL@
INSTALL_BIN 	= @INSTALL_PROGRAM@
INSTALL_FILE 	= @INSTALL_DATA@
RANLIB		= @RANLIB@
XTRA_LIBS	= @XTRA_LIBS@

#  Add -DDONT_FORMAT_KEYWORDS if you don't want to format Keywords values
DISPLAY_FLAGS	= 

DEBUG		= $(DEBUG_TOP) #-O #-g #-DDEBUG 
CFLAGS		= $(DEBUG) -I../../../../src/common/include
LDFLAGS		= -L../../../../src/common/lib
LIBS		= $(XTRA_LIBS)
UTIL		= util.o

CGI_PROGS	= BrokerAdmin BrokerQuery.pl DisplayObject HarvestGather 
PROGS		= $(CGI_PROGS)

all:	util.o $(PROGS) BrokerRestart

DisplayObject:	DisplayObject.o $(UTIL)
	$(CC) -o $@ $@.o $(UTIL) $(LDFLAGS) -ltemplate -lurl -lutil -lmd5 -lgdbm $(LIBS)

DisplayObject.o:	DisplayObject.c
	$(CC) $(CFLAGS) $(DISPLAY_FLAGS) -c DisplayObject.c

BrokerAdmin:	BrokerAdmin.o $(UTIL)
	$(CC) -o $@ $@.o $(UTIL) $(LDFLAGS) $(LIBS) -lutil

BrokerRestart:	BrokerRestart.o
	$(CC) -o $@ $@.o $(LDFLAGS) $(LIBS)

RegisterHSR:	RegisterHSR.o $(UTIL)
	$(CC) -o $@ $@.o $(UTIL) $(LDFLAGS) $(LIBS) -ltemplate -lutil

RegisterURL:	RegisterURL.o $(UTIL)
	$(CC) -o $@ $@.o $(UTIL) $(LDFLAGS) $(LIBS)

800Query:	800Query.o $(UTIL)
	$(CC) -o $@ $@.o $(UTIL) $(LDFLAGS) $(LIBS)

clean:	
	-rm -f core *.o BrokerAdmin DisplayObject

realclean:	clean
	-rm -f Makefile

install:	all
	@for f in BrokerRestart ; do \
		echo $(INSTALL_BIN) $$f $(INSTALL_UTILDIR)/$$f; \
		$(INSTALL_BIN) $$f $(INSTALL_UTILDIR)/$$f; \
	done
	@for f in $(CGI_PROGS); do \
		echo $(INSTALL_BIN) $$f $(INSTALL_CGI)/$$f.cgi; \
		$(INSTALL_BIN) $$f $(INSTALL_CGI)/$$f.cgi; \
	done
	@for f in cgiparse.pl; do \
		echo $(INSTALL_BIN) $$f $(INSTALL_CGI)/$$f; \
		$(INSTALL_BIN) $$f $(INSTALL_CGI)/$$f; \
	done
	@if [ ! -d $(INSTALL_CGI)/lib ]; then \
		mkdir $(INSTALL_CGI)/lib; \
		chmod go+x $(INSTALL_CGI)/lib; \
	fi
	$(INSTALL_FILE) BrokerQuery.cf $(INSTALL_CGI)/lib; 
	$(INSTALL_FILE) Sample.cf $(INSTALL_CGI)/lib; 
