OSDN Git Service

Split the LDFLAGS make variable into two parts: LDFLAGS is now used for
[pg-rex/syncrep.git] / src / bin / psql / Makefile
index 55133cd..8227b43 100644 (file)
@@ -1,88 +1,76 @@
 #-------------------------------------------------------------------------
 #
-# Makefile.inc--
-#    Makefile for bin/psql
+# 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
 #
-#
-# IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/bin/psql/Makefile,v 1.10 1996/11/09 06:24:39 momjian Exp $
+# $PostgreSQL: pgsql/src/bin/psql/Makefile,v 1.70 2010/07/05 18:54:38 tgl Exp $
 #
 #-------------------------------------------------------------------------
 
-SRCDIR = ../..
-LIBPQDIR = $(SRCDIR)/libpq
-include ../../Makefile.global
+PGFILEDESC = "psql - the PostgreSQL interactive terminal"
+PGAPPICON=win32
 
-INCLUDE_OPT := \
-               -I$(LIBPQDIR) \
-               -I$(SRCDIR)/include
+subdir = src/bin/psql
+top_builddir = ../../..
+include $(top_builddir)/src/Makefile.global
 
-CFLAGS += $(INCLUDE_OPT)
-#
-#USE_READLINE is set in Makefile.global
-# 
-
-ifeq ($(USE_READLINE), true)
-   CFLAGS += $(READLINE_INC) $(HISTORY_INC)
-
-   LIBCURSES=  -lcurses 
-   LD_ADD += $(READLINE_LIB) $(HISTORY_LIB) $(LIBCURSES)
-
-   ifeq ($(PORTNAME), ultrix4)
-   LD_ADD += -ltermcap
-   else
-   ifeq ($(PORTNAME), sparc)
-   LD_ADD += -ltermcap
-   else
-   ifeq ($(PORTNAME), linux)
-   LD_ADD += -ltermcap
-   else
-   ifeq ($(PORTNAME), next)
-   LD_ADD += -ltermcap
-   else
-   ifeq ($(PORTNAME), bsdi)
-   LD_ADD += -ltermcap
-   else
-   ifeq ($(PORTNAME), BSD44_derived)
-   LD_ADD += -ltermcap
-   endif
-   endif
-   endif
-   endif
-   endif
-   endif
-else
-   CFLAGS += -DNOREADLINE
-endif
+REFDOCDIR= $(top_srcdir)/doc/src/sgml/ref
 
-OBJS= psql.o stringutils.o 
+override CPPFLAGS := -I. -I$(srcdir) -I$(libpq_srcdir) -I$(top_srcdir)/src/bin/pg_dump $(CPPFLAGS)
 
-ifneq ($(USE_READLINE), true)
-OBJS+= rlstubs.o
-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 mbprint.o dumputils.o keywords.o kwlookup.o \
+       sql_help.o \
+       $(WIN32RES)
+
+FLEXFLAGS = -Cfe
 
-all: psql
 
-psql: $(OBJS) $(LIBPQDIR)/libpq.a
-       $(CC) $(LDFLAGS) -o psql -L$(LIBPQDIR) $(OBJS) -lpq $(LD_ADD)
+all: submake-libpq submake-libpgport psql
 
-$(srcdir)/libpq/libpq.a:
-       $(MAKE) -C $(LIBPQDIR) libpq.a
+psql: $(OBJS) $(libpq_builddir)/libpq.a
+       $(CC) $(CFLAGS) $(OBJS) $(libpq_pgport) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
 
-install:
-       $(INSTALL) $(INSTL_EXE_OPTS) psql $(DESTDIR)$(BINDIR)/psql
+help.o: sql_help.h
 
-depend dep:
-       $(CC) -MM $(INCLUDE_OPT) *.c >depend
+dumputils.c keywords.c: % : $(top_srcdir)/src/bin/pg_dump/%
+       rm -f $@ && $(LN_S) $< .
 
-clean: 
-       rm -f psql $(OBJS) 
+kwlookup.c: % : $(top_srcdir)/src/backend/parser/%
+       rm -f $@ && $(LN_S) $< .
 
-ifeq (depend,$(wildcard depend))
-include depend
+sql_help.c: sql_help.h ;
+sql_help.h: create_help.pl $(wildcard $(REFDOCDIR)/*.sgml)
+       $(PERL) $< $(REFDOCDIR) $*
+
+# psqlscan is compiled as part of mainloop
+mainloop.o: psqlscan.c
+
+psqlscan.c: psqlscan.l
+ifdef FLEX
+       $(FLEX) $(FLEXFLAGS) -o'$@' $<
+else
+       @$(missing) flex $< $@
 endif
 
+distprep: sql_help.h psqlscan.c
+
+install: all installdirs
+       $(INSTALL_PROGRAM) psql$(X) '$(DESTDIR)$(bindir)/psql$(X)'
+       $(INSTALL_DATA) $(srcdir)/psqlrc.sample '$(DESTDIR)$(datadir)/psqlrc.sample'
+
+installdirs:
+       $(MKDIR_P) '$(DESTDIR)$(bindir)'
+
+uninstall:
+       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) dumputils.c keywords.c kwlookup.c
 
+maintainer-clean: distclean
+       rm -f sql_help.h sql_help.c psqlscan.c