]> granicus.if.org Git - postgresql/blob - src/backend/Makefile
1997-06-15 Paul Eggert <eggert@twinsun.com>
[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.25 1997/09/19 19:44:30 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 all: postgres $(POSTGRES_IMP) global1.bki.source local1_template1.bki.source
55
56 postgres: $(OBJS) ../utils/version.o
57         $(CC) -o postgres $(OBJS) ../utils/version.o $(LDFLAGS)
58
59 $(OBJS): $(DIRS:%=%.dir)
60
61 $(DIRS:%=%.dir):
62         $(MAKE) -C $(subst .dir,,$@) all PORTNAME=$(PORTNAME)
63
64 ../utils/version.o:
65         $(MAKE) -C ../utils version.o        
66
67 global1.bki.source local1_template1.bki.source: catalog/$@
68         cp catalog/$@ .
69
70 catalog/global1.bki.source catalog/local1_template1.bki.source:
71         $(MAKE) -C catalog $@
72
73 # The postgres.o target is needed by the rule in Makefile.global that
74 # creates the exports file when MAKE_EXPORTS = true.
75 postgres.o: $(OBJS)
76         $(CC) -r -o postgres.o $(OBJS) $(LDFLAGS)
77
78
79 ############################################################################
80 # The following targets are specified in make commands that appear in the
81 # make files in our subdirectories.
82
83 parse.h: 
84         $(MAKE) -C parser parse.h
85         cp parser/parse.h .
86
87 fmgr.h:
88         $(MAKE) -C utils fmgr.h
89         cp utils/fmgr.h .
90
91 #############################################################################
92 clean:
93         rm -f postgres $(POSTGRES_IMP) fmgr.h parse.h \
94             global1.bki.source local1_template1.bki.source
95         for i in $(DIRS); do $(MAKE) -C $$i clean PORTNAME=$(PORTNAME); done
96
97 .DEFAULT:
98         for i in $(DIRS); do $(MAKE) -C $$i $@ PORTNAME=$(PORTNAME); done
99
100 #############################################################################
101 #
102 # Installation.
103 #
104 # Install the backend program (postgres) to the binary directory and 
105 # make a link as "postmaster".  Install the bki files templates and sample 
106 # files to the library directory.
107 #
108 # (History:  Before Release 2, make install generated a bki.source file
109 # and then used build parameters to convert it to a bki file, then installed
110 # that bki file in the /files subdirectory of the default data directory.
111 # Initdb then used the bki file to generate the database catalog classes.
112 # That had to change because (1) there can be more than one database system,
113 # and (2) the parameters of a database system should be set at initdb time,
114 # not at postgres build time.
115
116 install: $(LIBDIR) $(BINDIR) $(HEADERDIR) postgres $(POSTGRES_IMP) fmgr.h\
117          global1.bki.source local1_template1.bki.source \
118          libpq/pg_hba.conf.sample optimizer/geqo/pg_geqo.sample
119         
120         $(INSTALL) $(INSTL_EXE_OPTS) postgres $(BINDIR)/postgres
121 ifeq ($(MAKE_EXPORTS), true)
122         $(INSTALL) $(INSTLOPTS) $(POSTGRES_IMP) $(LIBDIR)/$(POSTGRES_IMP)
123 endif
124         @rm -f $(BINDIR)/postmaster
125         ln -s postgres $(BINDIR)postmaster
126         $(INSTALL) $(INSTLOPTS) fmgr.h $(HEADERDIR)/fmgr.h
127         $(INSTALL) $(INSTLOPTS) global1.bki.source \
128           $(LIBDIR)/global1.bki.source
129         $(INSTALL) $(INSTLOPTS) local1_template1.bki.source \
130           $(LIBDIR)/local1_template1.bki.source
131         $(INSTALL) $(INSTLOPTS) libpq/pg_hba.conf.sample \
132           $(LIBDIR)/pg_hba.conf.sample
133         $(INSTALL) $(INSTLOPTS) optimizer/geqo/pg_geqo.sample \
134           $(LIBDIR)/pg_geqo.sample
135
136 $(BINDIR) $(LIBDIR) $(HEADERDIR): 
137         mkdir $@
138
139 #############################################################################
140 #
141 # Support for code development.
142 #
143 # Use target "quick" to build "postgres" when you know all the subsystems 
144 # are up to date.  It saves the time of doing all the submakes.
145 .PHONY: quick
146 quick: $(OBJS)
147         $(CC) -o postgres $(OBJS) $(LDFLAGS)
148
149 #
150 # Build the file, "./ID", used by the "gid" (grep-for-identifier) tool
151 #
152 IDFILE= ID
153 .PHONY: $(IDFILE)
154 $(IDFILE):
155         ./makeID $(PORTNAME)
156
157 #
158 # Special rule to generate cpp'd version of a .c file.  This is
159 # especially useful given all the hellish macro processing going on.
160 # The cpp'd version has a .C suffix.  To create foo.C from foo.c, just
161 # type
162 #       make foo.C
163 #
164 %.cpp:  %.c
165         $(CC) -E $(CFLAGS) $(<:.C=.c) | cat -s | cb | tr -s '\012*' '\012' \
166             > $(@F)