#-------------------------------------------------------------------------
#
# GNUMakefile.in--
#    Build and install psqlodbc (Postgres ODBC driver).
#
# Copyright (c) 1994, Regents of the University of California
#
#
# IDENTIFICATION
#    $Header: /cvsroot/pgsql/src/interfaces/odbc/Attic/GNUmakefile.in,v 1.12 2000/03/02 02:01:00 momjian Exp $
#
#-------------------------------------------------------------------------
@SET_MAKE@

NAME = psqlodbc
SRCDIR= @top_srcdir@
ODBCSRCDIR= @srcdir@
include $(SRCDIR)/Makefile.global

include Version.mk

FIND= @find@
# assuming gnu tar and split here
TAR= @tar@
SPLIT= @split@

CFLAGS += -I. @DEFS@

SOURCES = *.c *.h *.in Config.mk \
	TODO.txt Version.mk config.guess config.sub configure \
	install-sh license.txt notice.txt odbcinst.ini \
	psqlodbc.def \
	psqlodbc.rc readme.txt

OBJS = info.o bind.o columninfo.o connection.o convert.o drvconn.o \
        environ.o execute.o lobj.o misc.o options.o \
        pgtypes.o psqlodbc.o qresult.o results.o socket.o parse.o statement.o \
        gpps.o tuple.o tuplelist.o dlg_specific.o $(OBJX)

SHLIB_LINK= $(LD_FLAGS)

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

LDFLAGS_SL+= $(LDFLAGS_ODBC)

.PHONY: install install-ini beforeinstall-headers install-headers

install: $(HEADERDIR) $(LIBDIR) $(ODBCINST) install-headers \
	install-ini install-lib $(install-shlib-dep)

$(HEADERDIR) $(LIBDIR) $(ODBCINST):
	mkdir -p $@

install-headers: beforeinstall-headers isql.h isqlext.h iodbc.h
	$(INSTALL) $(INSTLOPTS) iodbc.h $(HEADERDIR)/iodbc/iodbc.h
	$(INSTALL) $(INSTLOPTS) isql.h $(HEADERDIR)/iodbc/isql.h
	$(INSTALL) $(INSTLOPTS) isqlext.h $(HEADERDIR)/iodbc/isqlext.h

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

install-ini: odbcinst.ini
	$(INSTALL) $(INSTL_LIB_OPTS) odbcinst.ini $(ODBCINST)/odbcinst.ini

.PHONY: clean

clean: clean-shlib
	-rm -f lib$(NAME).a $(OBJS)

.PHONY: distclean

distclean: clean
	-rm -f config.h GNUmakefile Makefile.global
	-rm -f config.cache config.log config.status
ifeq ($(PORTNAME), win)
	@if [ $SRCDIR != $ODBCSRCDIR ]; then rm -f template makefiles port; fi
else
	@if [ $SRCDIR ne $ODBCSRCDIR ]; then rm -f template makefiles port; fi
endif

.PHONY: standalone

standalone:
	@if test "$SRCDIR" = "$ODBCSRCDIR"; then \
		echo "****************************************************"; \
		echo "Note: This was a standalone installation already"; \
		echo "This may produce a slightly inconsistant tar file..."; \
		echo "You should use the original tar file instead"; \
		echo "****************************************************"; \
	fi
	-rm -f psqlodbc-$(SO_MAJOR_VERSION)$(SO_MINOR_VERSION).tar.gz
	$(TAR) -chf psqlodbc-$(SO_MAJOR_VERSION)$(SO_MINOR_VERSION).tar \
	    $(SOURCES) -C @top_srcdir@ makefiles template Makefile.shlib
	gzip psqlodbc-$(SO_MAJOR_VERSION)$(SO_MINOR_VERSION).tar

.PHONY: integrated

integrated:
	-rm -f psqlodbc-$(SO_MAJOR_VERSION)$(SO_MINOR_VERSION)-int.tar.gz
	$(TAR) -cf psqlodbc-$(SO_MAJOR_VERSION)$(SO_MINOR_VERSION)-int.tar $(SOURCES)
	gzip psqlodbc-$(SO_MAJOR_VERSION)$(SO_MINOR_VERSION)-int.tar

depend dep:
	$(CC) -MM $(CFLAGS) *.c >depend

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