#-------------------------------------------------------------------------
#
# 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.17 1999/11/08 15:59:59 momjian Exp $
#
#-------------------------------------------------------------------------

SRCDIR= ../..
include ../../Makefile.global

CFLAGS:= -I$(LIBPQDIR) $(CFLAGS)

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

ifdef MULTIBYTE
CFLAGS+= $(MBFLAGS)
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 \
@STRDUP@ @STRERROR2@

all: submake psql

psql: $(OBJS) $(LIBPQDIR)/libpq.a
	$(CC) -o psql -L$(LIBPQDIR) $(OBJS) -lpq $(LDFLAGS)

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

OBJS:
	$(CC) $(CFLAGS) -c $< -o $@

help.o: sql_help.h

ifneq ($(strip $(PERL)),) 
sql_help.h: $(wildcard ../../../doc/src/sgml/ref/*.sgml) create_help.pl
	$(PERL) create_help.pl sql_help.h 
else
sql_help.h:
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)

distclean: clean
	rm -f sql_help.h

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