1#-------------------------------------------------------------------------
2#
3# Makefile for src/bin/psql
4#
5# Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
6# Portions Copyright (c) 1994, Regents of the University of California
7#
8# src/bin/psql/Makefile
9#
10#-------------------------------------------------------------------------
11
12PGFILEDESC = "psql - the PostgreSQL interactive terminal"
13PGAPPICON=win32
14
15subdir = src/bin/psql
16top_builddir = ../../..
17include $(top_builddir)/src/Makefile.global
18
19REFDOCDIR= $(top_srcdir)/doc/src/sgml/ref
20
21override CPPFLAGS := -I. -I$(srcdir) -I$(libpq_srcdir) $(CPPFLAGS)
22LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_pgport)
23
24OBJS=	command.o common.o conditional.o copy.o crosstabview.o \
25	describe.o help.o input.o large_obj.o mainloop.o \
26	prompt.o psqlscanslash.o sql_help.o startup.o stringutils.o \
27	tab-complete.o variables.o \
28	$(WIN32RES)
29
30
31all: psql
32
33psql: $(OBJS) | submake-libpq submake-libpgport submake-libpgfeutils
34	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
35
36help.o: sql_help.h
37
38# See notes in src/backend/parser/Makefile about the following two rules
39sql_help.c: sql_help.h
40	touch $@
41
42sql_help.h: create_help.pl $(wildcard $(REFDOCDIR)/*.sgml)
43	$(PERL) $< $(REFDOCDIR) $*
44
45psqlscanslash.c: FLEXFLAGS = -Cfe -p -p
46psqlscanslash.c: FLEX_NO_BACKUP=yes
47psqlscanslash.c: FLEX_FIX_WARNING=yes
48
49distprep: sql_help.h sql_help.c psqlscanslash.c
50
51install: all installdirs
52	$(INSTALL_PROGRAM) psql$(X) '$(DESTDIR)$(bindir)/psql$(X)'
53	$(INSTALL_DATA) $(srcdir)/psqlrc.sample '$(DESTDIR)$(datadir)/psqlrc.sample'
54
55installdirs:
56	$(MKDIR_P) '$(DESTDIR)$(bindir)' '$(DESTDIR)$(datadir)'
57
58uninstall:
59	rm -f '$(DESTDIR)$(bindir)/psql$(X)' '$(DESTDIR)$(datadir)/psqlrc.sample'
60
61clean distclean:
62	rm -f psql$(X) $(OBJS) lex.backup
63
64# files removed here are supposed to be in the distribution tarball,
65# so do not clean them in the clean/distclean rules
66maintainer-clean: distclean
67	rm -f sql_help.h sql_help.c psqlscanslash.c
68