#
# Makefile for src/bin/psql
#
-# Copyright (c) 1994, Regents of the University of California
+# Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
+# Portions Copyright (c) 1994, Regents of the University of California
#
-# $Header: /cvsroot/pgsql/src/bin/psql/Makefile,v 1.21 2000/06/27 00:31:41 petere Exp $
+# $PostgreSQL: pgsql/src/bin/psql/Makefile,v 1.70 2010/07/05 18:54:38 tgl Exp $
#
#-------------------------------------------------------------------------
+PGFILEDESC = "psql - the PostgreSQL interactive terminal"
+PGAPPICON=win32
+
subdir = src/bin/psql
top_builddir = ../../..
-include ../../Makefile.global
+include $(top_builddir)/src/Makefile.global
REFDOCDIR= $(top_srcdir)/doc/src/sgml/ref
-CFLAGS+= -I$(LIBPQDIR)
-
-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
+override CPPFLAGS := -I. -I$(srcdir) -I$(libpq_srcdir) -I$(top_srcdir)/src/bin/pg_dump $(CPPFLAGS)
-all: submake psql$(X)
+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 mbprint.o dumputils.o keywords.o kwlookup.o \
+ sql_help.o \
+ $(WIN32RES)
-ifdef STRDUP
-OBJS+=$(top_builddir)/src/utils/strdup.o
+FLEXFLAGS = -Cfe
-$(top_builddir)/src/utils/strdup.o:
- $(MAKE) -C $(top_builddir)/src/utils strdup.o
-endif
-# Move these to the utils directory?
+all: submake-libpq submake-libpgport psql
-ifdef STRERROR
-OBJS+=$(top_builddir)/src/backend/port/strerror.o
-
-$(top_builddir)/src/backend/port/strerror.o:
- $(MAKE) -C $(top_builddir)/src/backend/port strerror.o
-endif
+psql: $(OBJS) $(libpq_builddir)/libpq.a
+ $(CC) $(CFLAGS) $(OBJS) $(libpq_pgport) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
-ifdef SNPRINTF
-OBJS+=$(top_builddir)/src/backend/port/snprintf.o
+help.o: sql_help.h
-$(top_builddir)/src/backend/port/snprintf.o:
- $(MAKE) -C $(top_builddir)/src/backend/port snprintf.o
-endif
+dumputils.c keywords.c: % : $(top_srcdir)/src/bin/pg_dump/%
+ rm -f $@ && $(LN_S) $< .
-# End of hacks for picking up backend 'port' modules
+kwlookup.c: % : $(top_srcdir)/src/backend/parser/%
+ rm -f $@ && $(LN_S) $< .
-psql$(X): $(OBJS) $(LIBPQDIR)/libpq.a
- $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBPQ) $(LDFLAGS)
+sql_help.c: sql_help.h ;
+sql_help.h: create_help.pl $(wildcard $(REFDOCDIR)/*.sgml)
+ $(PERL) $< $(REFDOCDIR) $*
-help.o: $(srcdir)/sql_help.h
+# psqlscan is compiled as part of mainloop
+mainloop.o: psqlscan.c
-ifdef PERL
-$(srcdir)/sql_help.h: create_help.pl $(wildcard $(REFDOCDIR)/*.sgml)
- $(PERL) $< $(REFDOCDIR) $@
+psqlscan.c: psqlscan.l
+ifdef FLEX
+ $(FLEX) $(FLEXFLAGS) -o'$@' $<
else
-$(srcdir)/sql_help.h:
- @echo "*** Perl is needed to build psql help."
+ @$(missing) flex $< $@
endif
-.PHONY: submake
-
-submake:
- $(MAKE) -C $(LIBPQDIR) libpq.a
+distprep: sql_help.h psqlscan.c
install: all installdirs
- $(INSTALL_PROGRAM) psql$(X) $(bindir)/psql$(X)
+ $(INSTALL_PROGRAM) psql$(X) '$(DESTDIR)$(bindir)/psql$(X)'
+ $(INSTALL_DATA) $(srcdir)/psqlrc.sample '$(DESTDIR)$(datadir)/psqlrc.sample'
installdirs:
- $(mkinstalldirs) $(bindir)
+ $(MKDIR_P) '$(DESTDIR)$(bindir)'
uninstall:
- rm -f $(bindir)/psql$(X)
-
-depend dep:
- $(CC) -MM -MG $(CFLAGS) *.c >depend
+ rm -f '$(DESTDIR)$(bindir)/psql$(X)' '$(DESTDIR)$(datadir)/psqlrc.sample'
+# psqlscan.c is in the distribution tarball, so is not cleaned here
clean distclean:
- rm -f psql$(X) $(OBJS)
+ rm -f psql$(X) $(OBJS) dumputils.c keywords.c kwlookup.c
maintainer-clean: distclean
- rm -f sql_help.h
-
-ifeq (depend,$(wildcard depend))
-include depend
-endif
+ rm -f sql_help.h sql_help.c psqlscan.c