#-------------------------------------------------------------------------
#
# 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.17 1999/09/07 18:10:49 tgl Exp $
#
#-------------------------------------------------------------------------

NAME= pq++
SO_MAJOR_VERSION= 3
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
endif

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

#CXXFLAGS+= -DDEBUG

ifdef KRBVERS
CXXFLAGS+= $(KRBFLAGS)
endif

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

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

# For CC on IRIX, must use CC as linker/archiver of C++ libraries
ifeq ($(PORTNAME), irix5)
  ifeq ($(CXX), CC)
    AR = CC
    AROPT = -ar -o
    LD = CC
  endif
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 = 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: clean-shlib
	rm -f libpq++.a $(OBJS)
	$(MAKE) -C examples clean

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

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