#
#  GNU makefile for Libpq++, C++ frontend to postgres(pglite)
#
# /usr/local/devel/pglite/cvs/src/libpq++/GNUmakefile,v 1.1 1995/01/10 00:41:06 jolly Exp
#

PORTNAME = alpha

#
# by default, object files are placed in and port-specific object directory
#
OBJDIR    = obj.$(PORTNAME)

CC = cc
CXX = g++

#
# If you plan to use Kerberos for authentication...
#
# Comment out KRBVERS if you do not use Kerberos.
# 	Set KRBVERS to "4" for Kerberos v4, "5" for Kerberos v5.
#	XXX Edit the default Kerberos variables below!
#
#KRBVERS=	5

#
# Globally pass Kerberos file locations.
#	these are used in the postmaster and all libpq applications.
#
#	Adjust KRBINCS and KRBLIBS to reflect where you have Kerberos
#		include files and libraries installed.
#	PG_KRB_SRVNAM is the name under which POSTGRES is registered in
#		the Kerberos database (KDC).
#	PG_KRB_SRVTAB is the location of the server's keytab file.
#
ifdef KRBVERS
KRBINCS= -I/usr/athena/include
KRBLIBS= -L/usr/athena/lib
KRBFLAGS+= ${KRBINCS} -DPG_KRB_SRVNAM='"postgres_dbms"'
ifeq ($(KRBVERS),4)
KRBFLAGS+= -DKRB4
KRBFLAGS+= -DPG_KRB_SRVTAB='"/etc/srvtab"'
KRBLIBS+= -lkrb -ldes
else 
ifeq ($(KRBVERS),5)
KRBFLAGS+= -DKRB5
KRBFLAGS+= -DPG_KRB_SRVTAB='"FILE:/krb5/srvtab.postgres"'
KRBLIBS+= -lkrb5 -lcrypto -lcom_err -lisode
endif
endif 
endif

#
# And where libpq goes, so goes the authentication stuff...
#

PG_INCLUDES = -I/private/pglite/src/backend\
		-I/private/pglite/src/backend/include\
		-I/private/pglite/src/backend/include/port/$(PORTNAME)
	

CXXFLAGS = $(PG_INCLUDES) -g

ifdef KRBVERS
LDADD += $(KRBLIBS)
CXXFLAGS += $(KRBFLAGS)
endif

SRCS =  pgenv.cc\
	pgmisc.cc\
	pgconn.cc\
	pgresult.cc\
	fe-auth.cc

#
# by default, the SRCS variable contains all the sources for a subsystem
# OBJS is the .o's for those sources.  Like anything else, may be overridden
# by the subsystem makefile
#
OBJS = $(patsubst %.cc, $(OBJDIR)/%.o, $(SRCS))

all: $(OBJS)

testlibpq: $(OBJDIR)/testlibpq.o $(OBJS) 
#	$(CXX) $(OBJDIR)/testlibpq.o $(OBJS) /private/pglite/src/libpq/obj/libpq.a -o $@ 
	$(CXX) $(OBJDIR)/testlibpq.o $(OBJS) $(LDADD) -o $@

clean: 
	rm $(OBJS) $(OBJDIR)/testlibpq.o testlibpq

$(OBJDIR)/%.o: %.cc
	$(CXX) $(CXXFLAGS) -c $< -o $@	


