1 #-------------------------------------------------------------------------
3 # Makefile for the postgres backend
5 # Copyright (c) 1994, Regents of the University of California
7 # $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.63 2000/07/19 16:29:44 petere Exp $
9 #-------------------------------------------------------------------------
13 include ../Makefile.global
15 DIRS := access bootstrap catalog parser commands executor lib libpq \
16 main nodes optimizer port postmaster regex rewrite \
23 OBJS := $(DIRS:%=%/SUBSYS.o)
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
29 OBJS+= bootstrap/bootstrap.o
33 ##########################################################################
35 all: postgres $(POSTGRES_IMP)
37 ifneq ($(PORTNAME), win)
40 $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
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)
56 # Parallel make trickery
57 $(OBJS): $(DIRS:%=%-recursive)
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
65 ifeq ($(MAKE_DLL), true)
67 DLLLIBS := -L/usr/local/lib -lcygipc -lcrypt -lcygwin -lkernel32
69 postgres.def: $(DLLOBJS)
70 $(DLLTOOL) --export-all --output-def $@ $(DLLOBJS)
72 libpostgres.a: $(DLLOBJS) $(top_builddir)/src/utils/dllinit.o postgres.def
73 $(DLLTOOL) --dllname postgres.exe --def postgres.def --output-lib $@
77 $(top_builddir)/src/utils/dllinit.o: $(top_srcdir)/src/utils/dllinit.c
78 $(MAKE) -C $(top_builddir)/src/utils dllinit.o
80 # The postgres.o target is needed by the rule in Makefile.global that
81 # creates the exports file when MAKE_EXPORTS = true.
83 $(CC) $(LDREL) $(LDOUT) $@ $^ $(LDFLAGS)
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!
90 $(srcdir)/parser/parse.h: parser/gram.y
91 $(MAKE) -C parser parse.h
93 utils/fmgroids.h: utils/Gen_fmgrtab.sh $(top_srcdir)/src/include/catalog/pg_proc.h
94 $(MAKE) -C utils fmgroids.h
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.
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 .
104 $(top_builddir)/src/include/utils/fmgroids.h: utils/fmgroids.h
105 cd $(dir $@) && rm -f $(notdir $@) && \
106 $(LN_S) ../../../$(subdir)/utils/fmgroids.h .
109 ##########################################################################
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
117 ##########################################################################
119 install: all installdirs install-bin
120 ifeq ($(PORTNAME), win)
121 ifeq ($(MAKE_DLL), true)
122 $(INSTALL_DATA) libpostgres.a $(libdir)/libpostgres.a
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
131 $(mkinstalldirs) $(bindir) $(libdir) $(datadir)
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)
143 ##########################################################################
146 rm -f $(bindir)/postgres$(X) $(bindir)/postmaster
147 ifeq ($(MAKE_EXPORTS), true)
148 rm -f $(libdir)/$(POSTGRES_IMP)
150 ifeq ($(PORTNAME), win)
151 ifeq ($(MAKE_DLL), true)
152 rm -f $(libdir)/libpostgres.a
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
161 ##########################################################################
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
172 for i in $(DIRS); do $(MAKE) -C $$i clean || exit; done
175 rm -f port/Makefile port/tas.s port/dynloader.c
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
187 ##########################################################################
189 # Support for code development.
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.
195 $(CC) -o postgres $(OBJS) $(LDFLAGS)
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