#
# $Id: Makefile,v 1.12 2006/09/02 00:37:52 edwin Exp $
#

PREFIX?=	/usr/local/
CC?=		gcc
AFLAGS=		-Wall -g

# WITHOUT_SETPROCTITLE=yes
# WITHOUT_TCPWRAPPER=yes

###############################################################################

.if !defined(WITHOUT_SETPROCTITLE)
MYCFLAGS+=	-DHAVE_SETPROCTITLE
.endif

.if !defined(WITHOUT_TCPWRAPPER)
MYCFLAGS+=	-DWITH_TCPWRAPPERS
MYLDFLAGS=	-lwrap
.endif

all: postgresql-relay postgresql-relay.8

postgresql-relay: postgresql-relay.o
.if !defined(WITHOUT_TCPWRAPPER)
	@echo "****** NOTE ***************************************************"
	@echo "If ${CC} complains about libwrap, you should edit the Makefile"
	@echo "and uncomment WITHOUT_TCPWRAPPER"
	@echo "***************************************************************"
.endif
	${CC} ${AFLAGS} ${LDFLAGS} -o $@ $? ${MYLDFLAGS}

postgresql-relay.o: postgresql-relay.c
.if !defined(WITHOUT_SETPROCTITLE)
	@echo "****** NOTE ***************************************************"
	@echo "If ${CC} complains about setproctitle(), you should edit the "
	@echo "Makefile and uncomment WITHOUT_SETPROCTITLE"
	@echo "***************************************************************"
.endif
	${CC} ${MYCFLAGS} ${AFLAGS} ${CFLAGS} -o $@ -c $?

postgresql-relay.8: postgresql-relay.pod
	pod2man --release="September 1, 2006" --date="September 1, 2006" --center="General Commands Manual" --section=8 $? > $@

install: postgresql-relay postgresql-relay.8
	install -u bin -g bin -m 755 postgresql-relay ${PREFIX}/bin
	install -u bin -g bin -m 644 postgresql-relay.8 ${PREFIX}/man/man8

clean:
	rm -f postgresql-relay *.o postgresql-relay.8
