1 #-------------------------------------------------------------------------
4 # Makefile for the postgres backend (and the postmaster)
6 # Copyright (c) 1994, Regents of the University of California
12 # This make file is set up so that you can do a parallel make (with
13 # the --jobs option of make) and make multiple subdirectories at
16 # However, the subdirectory make files are not so careful.
17 # Normally, the --jobs option would get passed down to those
18 # subdirectory makes, like any other make option, and they would
19 # fail. But there's a trick: Put a value (max number of
20 # processes) on the --jobs option, e.g. --jobs=4. Now, due to a
21 # special feature of make, the --jobs option will not get passed
22 # to the subdirectory makes. (make does this because if you only
23 # want 4 tasks running, then splitting the subdirectory makes into
24 # multiple tasks would violate your wishes).
28 # Implementation notes:
30 # We don't use $(LD) for linking. We use $(CC) instead. This is because
31 # the $(CC) program apparently can do linking too, and it has certain
32 # thinks like default options and search paths for libraries set up for
33 # it that the more primitive $(LD) doesn't have.
37 # $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.23 1997/04/04 10:38:49 scrappy Exp $
39 #-------------------------------------------------------------------------
42 include ../Makefile.global
44 DIRS = access bootstrap catalog commands executor lib libpq \
45 main nodes optimizer parser port postmaster regex rewrite \
52 OBJS = $(DIRS:%=%/SUBSYS.o)
54 ifeq ($(MAKE_EXPORTS), true)
55 EXP = postgres$(EXPSUFF)
60 all: postgres $(EXP) global1.bki.source local1_template1.bki.source
62 postgres: $(OBJS) ../utils/version.o
63 $(CC) -o postgres $(OBJS) ../utils/version.o $(LDFLAGS)
65 $(OBJS): $(DIRS:%=%.dir)
68 $(MAKE) -C $(subst .dir,,$@) all PORTNAME=$(PORTNAME)
71 $(MAKE) -C ../utils version.o
73 global1.bki.source local1_template1.bki.source: catalog/$@
76 catalog/global1.bki.source catalog/local1_template1.bki.source:
79 # The postgres.o target is needed by the rule in Makefile.global that
80 # creates the exports file when MAKE_EXPORTS = true.
82 $(CC) -r -o postgres.o $(OBJS) $(LDFLAGS)
85 ############################################################################
86 # The following targets are specified in make commands that appear in the
87 # make files in our subdirectories.
90 $(MAKE) -C parser parse.h
94 $(MAKE) -C utils fmgr.h
97 #############################################################################
99 rm -f postgres fmgr.h parse.h \
100 global1.bki.source local1_template1.bki.source
101 for i in $(DIRS); do $(MAKE) -C $$i clean PORTNAME=$(PORTNAME); done
104 for i in $(DIRS); do $(MAKE) -C $$i $@ PORTNAME=$(PORTNAME); done
106 #############################################################################
110 # Install the backend program (postgres) to the binary directory and
111 # make a link as "postmaster". Install the bki files templates and sample
112 # files to the library directory.
114 # (History: Before Release 2, make install generated a bki.source file
115 # and then used build parameters to convert it to a bki file, then installed
116 # that bki file in the /files subdirectory of the default data directory.
117 # Initdb then used the bki file to generate the database catalog classes.
118 # That had to change because (1) there can be more than one database system,
119 # and (2) the parameters of a database system should be set at initdb time,
120 # not at postgres build time.
122 install: $(LIBDIR) $(BINDIR) $(HEADERDIR) postgres $(EXP) fmgr.h\
123 global1.bki.source local1_template1.bki.source \
124 libpq/pg_hba.conf.sample optimizer/geqo/pg_geqo.sample
126 $(INSTALL) $(INSTL_EXE_OPTS) postgres $(BINDIR)/postgres
127 ifeq ($(MAKE_EXPORTS), true)
128 $(INSTALL) $(INSTLOPTS) postgres$(EXPSUFF) $(LIBDIR)/postgres$(EXPSUFF)
130 @rm -f $(BINDIR)/postmaster
131 cd $(BINDIR); ln -s postgres postmaster
132 $(INSTALL) $(INSTLOPTS) fmgr.h $(HEADERDIR)/fmgr.h
133 $(INSTALL) $(INSTLOPTS) global1.bki.source \
134 $(LIBDIR)/global1.bki.source
135 $(INSTALL) $(INSTLOPTS) local1_template1.bki.source \
136 $(LIBDIR)/local1_template1.bki.source
137 $(INSTALL) $(INSTLOPTS) libpq/pg_hba.conf.sample \
138 $(LIBDIR)/pg_hba.conf.sample
139 $(INSTALL) $(INSTLOPTS) optimizer/geqo/pg_geqo.sample \
140 $(LIBDIR)/pg_geqo.sample
142 $(BINDIR) $(LIBDIR) $(HEADERDIR):
145 #############################################################################
147 # Support for code development.
149 # Use target "quick" to build "postgres" when you know all the subsystems
150 # are up to date. It saves the time of doing all the submakes.
153 $(CC) -o postgres $(OBJS) $(LDFLAGS)
156 # Build the file, "./ID", used by the "gid" (grep-for-identifier) tool
164 # Special rule to generate cpp'd version of a .c file. This is
165 # especially useful given all the hellish macro processing going on.
166 # The cpp'd version has a .C suffix. To create foo.C from foo.c, just
171 $(CC) -E $(CFLAGS) $(<:.C=.c) | cat -s | cb | tr -s '\012*' '\012' \