#-------------------------------------------------------------------------
#
# 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.24 2000/04/22 22:39:15 tgl Exp $
#
#-------------------------------------------------------------------------

NAME= pq++
SO_MAJOR_VERSION= 3
SO_MINOR_VERSION= 1

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

CXX=@CXX@
CXXFLAGS=@CXXFLAGS@

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

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

ifdef KRBVERS
CXXFLAGS+= $(KRBFLAGS)
endif

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

ifeq ($(PORTNAME), win)
SHLIB_LINK+= --driver-name g++ $(LIBPQ)
else
SHLIB_LINK= $(LIBPQ)
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_SL)


.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
