#-------------------------------------------------------------------------
#
# Makefile.in--
#    Makefile for bin/psql
#
# Copyright (c) 1994, Regents of the University of California
#
#
# IDENTIFICATION
#    $Header: /cvsroot/pgsql/src/bin/psql/Attic/Makefile.in,v 1.24 2000/05/11 17:46:35 momjian Exp $
#
#-------------------------------------------------------------------------

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

DOCDIR= $(SRCDIR)/../doc/src/sgml/ref

CFLAGS+= -I$(LIBPQDIR)

#
# And where libpq goes, so goes the authentication stuff...
#
ifdef KRBVERS
LDFLAGS+= $(KRBLIBS)
CFLAGS+= $(KRBFLAGS)
endif

OBJS=command.o common.o help.o input.o stringutils.o mainloop.o \
	copy.o startup.o prompt.o variables.o large_obj.o print.o describe.o \
	tab-complete.o

all: submake psql

ifneq (@STRDUP@,)
OBJS+=$(SRCDIR)/utils/strdup.o

$(SRCDIR)/utils/strdup.o:
	$(MAKE) -C $(SRCDIR)/utils strdup.o
endif

# Move these to the utils directory?

ifneq (@STRERROR@,)
OBJS+=$(SRCDIR)/backend/port/strerror.o

$(SRCDIR)/backend/port/strerror.o:
	$(MAKE) -C $(SRCDIR)/backend/port strerror.o
endif

ifneq (@SNPRINTF@,)
OBJS+=$(SRCDIR)/backend/port/snprintf.o

$(SRCDIR)/backend/port/snprintf.o:
	$(MAKE) -C $(SRCDIR)/backend/port snprintf.o
endif

# End of hacks for picking up backend 'port' modules

psql: $(OBJS) $(LIBPQDIR)/libpq.a
	$(CC) $(CFLAGS) -o psql $(OBJS) $(LIBPQ) $(LDFLAGS)

help.o: sql_help.h

ifneq ($(strip $(PERL)),) 
sql_help.h: $(wildcard $(DOCDIR)/*.sgml) create_help.pl
	$(PERL) create_help.pl $(DOCDIR) sql_help.h 
else
sql_help.h:
	@echo "*** Perl is needed to build psql help."
endif

.PHONY: submake

submake:
	$(MAKE) -C $(LIBPQDIR) libpq.a

install: psql
	$(INSTALL) $(INSTL_EXE_OPTS) psql$(X) $(BINDIR)/psql$(X)

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

clean: 
	rm -f psql$(X) $(OBJS)

# Some people might get in trouble if they do a make clean and the
# sql_help.h is gone, for it needs the docs in the right place to be
# regenerated. -- (pe)

maintainer-clean: clean
	rm -f sql_help.h

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