OSDN Git Service

Add distprep target to take some of the job of the release_prep script.
[pg-rex/syncrep.git] / src / backend / Makefile
1 #-------------------------------------------------------------------------
2 #
3 # Makefile for the postgres backend
4 #
5 # Copyright (c) 1994, Regents of the University of California
6 #
7 # $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.63 2000/07/19 16:29:44 petere Exp $
8 #
9 #-------------------------------------------------------------------------
10
11 subdir = src/backend
12 top_builddir = ../..
13 include ../Makefile.global
14
15 DIRS := access bootstrap catalog parser commands executor lib libpq \
16         main nodes optimizer port postmaster regex rewrite \
17         storage tcop utils
18
19 ifdef TIOGA
20 DIRS += tioga
21 endif
22
23 OBJS := $(DIRS:%=%/SUBSYS.o)
24
25 ifeq ($(PORTNAME), qnx4)
26 # This file crashes qnx4's wlink and is therefore not in
27 # bootstrap/SUBSYS.o on that platform. (Wotta hack ... is it still
28 # necessary?)
29 OBJS+= bootstrap/bootstrap.o
30 endif
31
32
33 ##########################################################################
34
35 all: postgres $(POSTGRES_IMP)
36
37 ifneq ($(PORTNAME), win)
38
39 postgres: $(OBJS)
40         $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
41
42 else # win
43
44 # No points for style here. How about encapsulating some of these
45 # commands into variables?
46 postgres: $(DLLOBJS) $(top_builddir)/src/utils/dllinit.o postgres.def libpostgres.a
47         dlltool --dllname $@$(X) --output-exp $@.exp --def postgres.def
48         gcc -g -o $@$(X) -Wl,--base-file,$@.base $@.exp $(DLLOBJS) $(DLLLIBS)
49         dlltool --dllname $@$(X) --base-file $@.base --output-exp $@.exp --def postgres.def
50         gcc -g -o $@$(X) $@.exp $(DLLOBJS) $(DLLLIBS)
51         rm $@.exp $@.base
52
53 endif # win
54
55
56 # Parallel make trickery
57 $(OBJS): $(DIRS:%=%-recursive)
58
59 .PHONY: $(DIRS:%=%-recursive)
60 # Update the commonly used headers before building the subdirectories
61 $(DIRS:%=%-recursive): $(top_srcdir)/src/include/parser/parse.h $(top_builddir)/src/include/utils/fmgroids.h
62         $(MAKE) -C $(subst -recursive,,$@) all
63
64
65 ifeq ($(MAKE_DLL), true)
66 DLLOBJS := $(OBJS)
67 DLLLIBS := -L/usr/local/lib -lcygipc -lcrypt -lcygwin -lkernel32
68
69 postgres.def: $(DLLOBJS)
70         $(DLLTOOL) --export-all --output-def $@ $(DLLOBJS)
71
72 libpostgres.a: $(DLLOBJS) $(top_builddir)/src/utils/dllinit.o postgres.def
73         $(DLLTOOL) --dllname postgres.exe --def postgres.def --output-lib $@
74 endif # MAKE_DLL
75
76
77 $(top_builddir)/src/utils/dllinit.o: $(top_srcdir)/src/utils/dllinit.c
78         $(MAKE) -C $(top_builddir)/src/utils dllinit.o
79
80 # The postgres.o target is needed by the rule in Makefile.global that
81 # creates the exports file when MAKE_EXPORTS = true.
82 postgres.o: $(OBJS)
83         $(CC) $(LDREL) $(LDOUT) $@ $^ $(LDFLAGS)
84
85
86 # The following targets are specified in make commands that appear in
87 # the make files in our subdirectories. Note that it's important we
88 # match the dependencies shown in the subdirectory makefiles!
89
90 $(srcdir)/parser/parse.h: parser/gram.y
91         $(MAKE) -C parser parse.h
92
93 utils/fmgroids.h: utils/Gen_fmgrtab.sh $(top_srcdir)/src/include/catalog/pg_proc.h
94         $(MAKE) -C utils fmgroids.h
95
96 # Make symlinks for these headers in the include directory. That way
97 # we can cut down on the -I options. Also, a symlink is automatically
98 # up to date when we update the base file.
99
100 $(top_builddir)/src/include/parser/parse.h: $(srcdir)/parser/parse.h
101         cd $(dir $@) && rm -f $(notdir $@) && \
102             $(LN_S) ../../../$(subdir)/parser/parse.h .
103
104 $(top_builddir)/src/include/utils/fmgroids.h: utils/fmgroids.h
105         cd $(dir $@) && rm -f $(notdir $@) && \
106             $(LN_S) ../../../$(subdir)/utils/fmgroids.h .
107
108
109 ##########################################################################
110
111 distprep:
112         $(MAKE) -C parser       gram.c parse.h scan.c
113         $(MAKE) -C bootstrap    bootparse.c bootstrap_tokens.h bootscanner.c
114         $(MAKE) -C utils/misc   guc-file.c
115
116
117 ##########################################################################
118
119 install: all installdirs install-bin
120 ifeq ($(PORTNAME), win)
121 ifeq ($(MAKE_DLL), true)
122         $(INSTALL_DATA) libpostgres.a $(libdir)/libpostgres.a
123 endif
124 endif
125         $(MAKE) -C catalog install-bki
126         $(INSTALL_DATA) libpq/pg_hba.conf.sample $(datadir)/pg_hba.conf.sample
127         $(INSTALL_DATA) libpq/pg_ident.conf.sample $(datadir)/pg_ident.conf.sample
128         $(INSTALL_DATA) utils/misc/postgresql.conf.sample $(datadir)/postgresql.conf.sample
129
130 installdirs:
131         $(mkinstalldirs) $(bindir) $(libdir) $(datadir)
132
133 install-bin: postgres $(POSTGRES_IMP) installdirs
134         $(INSTALL_PROGRAM) postgres$(X) $(bindir)/postgres$(X)
135         @rm -f $(bindir)/postmaster
136         ln -s postgres$(X) $(bindir)/postmaster
137 ifeq ($(MAKE_EXPORTS), true)
138         $(INSTALL_DATA) $(POSTGRES_IMP) $(libdir)/$(POSTGRES_IMP)
139 endif
140
141 .PHONY: install-bin
142
143 ##########################################################################
144
145 uninstall:
146         rm -f $(bindir)/postgres$(X) $(bindir)/postmaster
147 ifeq ($(MAKE_EXPORTS), true)
148         rm -f $(libdir)/$(POSTGRES_IMP)
149 endif
150 ifeq ($(PORTNAME), win)
151 ifeq ($(MAKE_DLL), true)
152         rm -f $(libdir)/libpostgres.a
153 endif
154 endif
155         $(MAKE) -C catalog uninstall-bki
156         rm -f $(datadir)/pg_hba.conf.sample \
157               $(datadir)/pg_ident.conf.sample \
158               $(datadir)/postgresql.conf.sample
159
160
161 ##########################################################################
162
163 clean:
164         rm -f postgres$(X) $(POSTGRES_IMP) \
165                 $(top_srcdir)/src/include/parser/parse.h \
166                 $(top_builddir)/src/include/utils/fmgroids.h
167 ifeq ($(PORTNAME), win)
168 ifeq ($(MAKE_DLL), true)
169         rm -f postgres.dll postgres.def libpostgres.a
170 endif
171 endif
172         for i in $(DIRS); do $(MAKE) -C $$i clean || exit; done
173
174 distclean: clean
175         rm -f port/Makefile port/tas.s port/dynloader.c
176
177 maintainer-clean: distclean
178         rm -f $(srcdir)/bootstrap/bootparse.c \
179               $(srcdir)/bootstrap/bootscanner.c \
180               $(srcdir)/bootstrap/bootstrap_tokens.h \
181               $(srcdir)/parser/gram.c \
182               $(srcdir)/parser/scan.c \
183               $(srcdir)/parser/parse.h \
184               $(srcdir)/utils/misc/guc-file.c
185
186
187 ##########################################################################
188 #
189 # Support for code development.
190 #
191 # Use target "quick" to build "postgres" when you know all the subsystems 
192 # are up to date.  It saves the time of doing all the submakes.
193 .PHONY: quick
194 quick: $(OBJS)
195         $(CC) -o postgres $(OBJS) $(LDFLAGS)
196
197 depend dep: $(top_srcdir)/src/include/parser/parse.h $(top_builddir)/src/include/utils/fmgroids.h
198         for i in $(DIRS); do $(MAKE) -C $$i $@; done