#
# $Header: /usr/people/postdev/src/bin/pg_ufp/RCS/Makefile,v 1.18 1994/09/28 15:12:56 postdev Exp $
#

.include <postgres.global.mk>

PROG= pg_ufp

SRCS= ufp.c dfmgr.c dynloader.c

.PATH:	${.CURDIR}/../../backend/port/${PORTNAME} \
	${.CURDIR}/../../backend/utils/fmgr

CFLAGS+= -I${.CURDIR}/../../backend/port/${PORTNAME} \
	 -I${.CURDIR}/../../backend/${MAKEOBJDIR} \
	 -I${.CURDIR}/../../backend
CFLAGS+= -DUFP
#CFLAGS+= -DUFPDEBUG -DUFPDEBUG_PROTO

#
# This is basically copied from the port/<foo>/Makefile.inc
# (minus the lex/yacc libraries).
# Unfortunately, it must be sync'd by hand.
#
.if (${PORTNAME} == "ultrix4" || \
     ${PORTNAME} == "sparc" || \
     ${PORTNAME} == "sparc_solaris")
LDADD+= -ldl
.elif (${PORTNAME} == "alpha")
# nothing
.elif (${PORTNAME} == "hpux")
CFLAGS+= -W l,-E
LDFLAGS+= -W l,-E
LDADD+= -ldld
.elif (${PORTNAME} == "aix")
LDADD+= -lld
HEADERS+= dlfcn.h
SRCS+= dlfcn.c

LDFLAGS+= -bE:${PROG}.exp

${PROG}.exp: ${PROG}.noexp
	mv -f ${.ALLSRC} ${PROG}
	mkldexport ${PROG} ${BINDIR} > ${.TARGET}
	mv -f ${PROG} ${.ALLSRC}

${PROG}.noexp: ${OBJS}
	touch -f ${PROG}.exp
	${CC} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD}

CLEANFILES+= ${PROG}.noexp ${PROG}.exp
.elif (${PORTNAME} == "linux")
LDFLAGS+= -N
LDADD+= -ldld
.else
# put the executable in OMAGIC format
.  if (${PORTNAME} != "irix5")
LDFLAGS+= -N
.  endif
.endif

.include <postgres.prog.mk>

.if defined(MAKE_EXPORTS)
${PROG}: ${PROG}.exp

installexp: ${PROG}.exp
.  if defined(OLD_MKDIR)
	@-if test ! -d ${DESTDIR}${LIBDIR}; \
	then mkdir ${DESTDIR}${LIBDIR}; fi
.  endif
	${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 444 \
	${PROG}.exp ${DESTDIR}${LIBDIR}/${PROG}.exp

all: installexp
.endif
