OSDN Git Service

Make sure -L and -I's for our source tree are always before system include
[pg-rex/syncrep.git] / src / bin / psql / Makefile
1 #-------------------------------------------------------------------------
2 #
3 # Makefile for src/bin/psql
4 #
5 # Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
6 # Portions Copyright (c) 1994, Regents of the University of California
7 #
8 # $Header: /cvsroot/pgsql/src/bin/psql/Makefile,v 1.29 2001/02/20 19:20:29 petere Exp $
9 #
10 #-------------------------------------------------------------------------
11
12 subdir = src/bin/psql
13 top_builddir = ../../..
14 include $(top_builddir)/src/Makefile.global
15
16 REFDOCDIR= $(top_srcdir)/doc/src/sgml/ref
17
18 override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS)
19
20 OBJS=command.o common.o help.o input.o stringutils.o mainloop.o \
21         copy.o startup.o prompt.o variables.o large_obj.o print.o describe.o \
22         tab-complete.o
23
24 all: submake psql
25
26 ifdef STRDUP
27 OBJS+=$(top_builddir)/src/utils/strdup.o
28
29 $(top_builddir)/src/utils/strdup.o:
30         $(MAKE) -C $(top_builddir)/src/utils strdup.o
31 endif
32
33 # Move these to the utils directory?
34
35 ifdef STRERROR
36 OBJS+=$(top_builddir)/src/backend/port/strerror.o
37
38 $(top_builddir)/src/backend/port/strerror.o:
39         $(MAKE) -C $(top_builddir)/src/backend/port strerror.o
40 endif
41
42 ifdef SNPRINTF
43 OBJS+=$(top_builddir)/src/backend/port/snprintf.o
44
45 $(top_builddir)/src/backend/port/snprintf.o:
46         $(MAKE) -C $(top_builddir)/src/backend/port snprintf.o
47 endif
48
49 # End of hacks for picking up backend 'port' modules
50
51 psql: $(OBJS) $(libpq_builddir)/libpq.a
52         $(CC) $(CFLAGS) $(OBJS) $(libpq) $(LDFLAGS) $(LIBS) -o $@
53
54 help.o: $(srcdir)/sql_help.h
55
56 ifdef PERL
57 $(srcdir)/sql_help.h: create_help.pl $(wildcard $(REFDOCDIR)/*.sgml)
58         $(PERL) $< $(REFDOCDIR) $@
59 else
60 $(srcdir)/sql_help.h:
61         @echo "*** Perl is needed to build psql help."
62 endif
63
64 .PHONY: submake
65
66 submake:
67         $(MAKE) -C $(libpq_builddir) all
68
69 distprep: $(srcdir)/sql_help.h
70
71 install: all installdirs
72         $(INSTALL_PROGRAM) psql$(X) $(DESTDIR)$(bindir)/psql$(X)
73
74 installdirs:
75         $(mkinstalldirs) $(DESTDIR)$(bindir)
76
77 uninstall:
78         rm -f $(DESTDIR)$(bindir)/psql$(X)
79
80 depend dep:
81         $(CC) -MM -MG $(CFLAGS) *.c >depend
82
83 clean distclean:
84         rm -f psql$(X) $(OBJS)
85
86 maintainer-clean: distclean
87         rm -f $(srcdir)/sql_help.h
88
89 ifeq (depend,$(wildcard depend))
90 include depend
91 endif