#-------------------------------------------------------------------------
#
# Makefile
#    Makefile for libpq++ library
#
# Copyright (c) 1994, Regents of the University of California
#
# IDENTIFICATION
#    $Header: /cvsroot/pgsql/src/interfaces/libpq++/Attic/Makefile.in,v 1.11 1999/01/17 06:19:39 momjian Exp $
#
#-------------------------------------------------------------------------

NAME= pq++
SO_MAJOR_VERSION= 2
SO_MINOR_VERSION= 0

SRCDIR= @top_srcdir@
include $(SRCDIR)/Makefile.global

CXX=@CXX@

SRCHEADERDIR = $(SRCDIR)/include
LIBPQHEADERDIR = $(SRCHEADERDIR)/libpq

# We have to override -Werror, which makes warnings fatal, because we
# inevitably get the warning, "abstract declarator used as declaration"
# because of our inclusion of c.h and we don't know how to stop that.

ifeq ($(CXX), g++)
CXXFLAGS= -Wno-error
else
CXXFLAGS=
endif

CXXFLAGS+=   -I$(SRCDIR)/backend \
             -I$(SRCHEADERDIR) \
             -I$(LIBPQDIR)

#CXXFLAGS+= -DDEBUG

ifdef KRBVERS
CXXFLAGS+= $(KRBFLAGS)
endif

OBJS = pgenv.o pgconnection.o pgtransdb.o pgcursordb.o pglobject.o

ifeq ($(PORTNAME), win)
SHLIB_LINK+= -L../libpq -lpq -lstdc++
else
SHLIB_LINK= -L../libpq -lpq
endif

# Shared library stuff, also default 'all' target
include $(SRCDIR)/Makefile.shlib


# Pull shared-lib CFLAGS into CXXFLAGS
CXXFLAGS+= $(CFLAGS)


.PHONY: examples
examples:
	$(MAKE) -C examples all

.PHONY: install beforeinstall-headers install-headers 

install: install-headers install-lib $(install-shlib-dep)

LIBPGXXDIR = libpq++
LIBPGXXHEADERDIR = $(HEADERDIR)/$(LIBPGXXDIR)
MAINHEADER = libpq++.h
LIBPGXXHEADERS = pgenv.h \
		 pgconnection.h \
		 pgdatabase.h \
		 pgtransdb.h \
		 pgcursordb.h \
		 pglobject.h

install-headers: beforeinstall-headers $(MAINHEADER)
	@$(INSTALL) $(INSTLOPTS) $(MAINHEADER) $(HEADERDIR)/$(MAINHEADER)
	@for i in ${LIBPGXXHEADERS}; do \
		echo "Installing $(LIBPGXXHEADERDIR)/$$i."; \
		$(INSTALL) $(INSTLOPTS) $$i $(LIBPGXXHEADERDIR)/$$i; \
	done

beforeinstall-headers:
	@if [ ! -d $(HEADERDIR) ]; then mkdir $(HEADERDIR); fi
	@if [ ! -d $(LIBPGXXHEADERDIR) ]; then mkdir $(LIBPGXXHEADERDIR); fi

.PHONY: clean
clean:
	rm -f libpq++.a $(shlib) $(OBJS)
	$(MAKE) -C examples clean
ifeq ($(PORTNAME), win)
	rm -f pq++.def
endif

dep depend:
	$(CXX) -MM $(CXXFLAGS) *.cc >depend

ifeq (depend,$(wildcard depend))
include depend
endif
