]> granicus.if.org Git - postgresql/blob - src/backend/Makefile
Use $(LD_ADD) from Makefile.global instead of $(LDADD), which doesn't exist...
[postgresql] / src / backend / Makefile
1 #-------------------------------------------------------------------------
2 #
3 # Makefile--
4 #   Makefile for the postgres backend (and the postmaster)
5 #
6 # Copyright (c) 1994, Regents of the University of California
7 #
8 # Functional notes:
9 #
10 #   Parallel make:  
11 #
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 
14 #     once.  
15 #
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).
25 #
26 #
27 #
28 # Implementation notes:
29 #
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.
34 #
35 #
36 # IDENTIFICATION
37 #    $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.21 1997/03/25 08:14:25 scrappy Exp $
38 #
39 #-------------------------------------------------------------------------
40
41 SRCDIR = ..
42 include ../Makefile.global
43
44 DIRS = access bootstrap catalog commands executor lib libpq \
45         main nodes optimizer parser port postmaster regex rewrite \
46         storage tcop utils
47
48 ifdef TIOGA
49 DIRS += tioga
50 endif
51
52 OBJS = $(DIRS:%=%/SUBSYS.o)
53
54 ifeq ($(MAKE_EXPORTS), true)
55 EXP = postgres$(EXPSUFF)
56 else
57 EXP =
58 endif
59
60 all: postgres $(EXP) global1.bki.source local1_template1.bki.source
61
62 postgres: $(OBJS) ../utils/version.o
63         gcc -o postgres $(LDFLAGS) $(OBJS) ../utils/version.o $(LD_ADD) 
64
65 $(OBJS): $(DIRS:%=%.dir)
66
67 $(DIRS:%=%.dir):
68         $(MAKE) -C $(subst .dir,,$@) all PORTNAME=$(PORTNAME)
69
70 ../utils/version.o:
71         $(MAKE) -C ../utils version.o        
72
73 global1.bki.source local1_template1.bki.source: catalog/$@
74         cp catalog/$@ .
75
76 catalog/global1.bki.source catalog/local1_template1.bki.source:
77         $(MAKE) -C catalog $@
78
79 # The postgres.o target is needed by the rule in Makefile.global that
80 # creates the exports file when MAKE_EXPORTS = true.
81 postgres.o: $(OBJS)
82         $(CC) $(LDFLAGS) -r -o postgres.o $(OBJS) $(LD_ADD)
83
84
85 ############################################################################
86 # The following targets are specified in make commands that appear in the
87 # make files in our subdirectories.
88
89 parse.h: 
90         $(MAKE) -C parser parse.h
91         cp parser/parse.h .
92
93 fmgr.h:
94         $(MAKE) -C utils fmgr.h
95         cp utils/fmgr.h .
96
97 #############################################################################
98 clean:
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
102
103 .DEFAULT:
104         for i in $(DIRS); do $(MAKE) -C $$i $@ PORTNAME=$(PORTNAME); done
105
106 #############################################################################
107 #
108 # Installation.
109 #
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.
113 #
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.
121
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
125         
126         $(INSTALL) $(INSTL_EXE_OPTS) postgres $(BINDIR)/postgres
127 ifeq ($(MAKE_EXPORTS), true)
128         $(INSTALL) $(INSTLOPTS) postgres$(EXPSUFF) $(LIBDIR)/postgres$(EXPSUFF)
129 endif
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
141
142 $(BINDIR) $(LIBDIR) $(HEADERDIR): 
143         mkdir $@
144
145 #############################################################################
146 #
147 # Support for code development.
148 #
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.
151 .PHONY: quick
152 quick: $(OBJS)
153         $(CC) $(LDFLAGS) -o postgres $(OBJS) $(LD_ADD)
154
155 #
156 # Build the file, "./ID", used by the "gid" (grep-for-identifier) tool
157 #
158 IDFILE= ID
159 .PHONY: $(IDFILE)
160 $(IDFILE):
161         ./makeID $(PORTNAME)
162
163 #
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
167 # type
168 #       make foo.C
169 #
170 %.cpp:  %.c
171         $(CC) -E $(CFLAGS) $(<:.C=.c) | cat -s | cb | tr -s '\012*' '\012' \
172             > $(@F)