Makefile 6.58 KB
Newer Older
1 2
#-------------------------------------------------------------------------
#
3
# Makefile for the postgres backend
4 5 6
#
# Copyright (c) 1994, Regents of the University of California
#
7
# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.73 2001/06/02 18:25:17 petere Exp $
8 9 10
#
#-------------------------------------------------------------------------

11 12
subdir = src/backend
top_builddir = ../..
13
include $(top_builddir)/src/Makefile.global
14

15 16
DIRS := access bootstrap catalog parser commands executor lib libpq \
	main nodes optimizer port postmaster regex rewrite \
17
	storage tcop utils
18 19

ifdef TIOGA
20
DIRS += tioga
21 22
endif

23
OBJS := $(DIRS:%=%/SUBSYS.o)
24

25
ifeq ($(PORTNAME), qnx4)
26 27
# This file crashes qnx4's wlink and is therefore not in
# bootstrap/SUBSYS.o on that platform. (Wotta hack ... is it still
28 29
# necessary?) [ Yes, until the Watcom compiler goes open source it's
# effectively unsupported ]
30
OBJS+= bootstrap/bootstrap.o
31
endif
32

33

34
##########################################################################
35

36
all: postgres $(POSTGRES_IMP)
37 38 39
ifeq ($(enable_nls), yes)
	$(MAKE) -C po all
endif
40

41
ifneq ($(PORTNAME), win)
42

43
postgres: $(OBJS)
44
	$(CC) $(CFLAGS) $(LDFLAGS) $(export_dynamic) $^ $(LIBS) -o $@
45

46
else # win
47

48 49
# No points for style here. How about encapsulating some of these
# commands into variables?
50
postgres: $(OBJS) $(top_builddir)/src/utils/dllinit.o postgres.def libpostgres.a
51
	dlltool --dllname $@$(X) --output-exp $@.exp --def postgres.def
52
	gcc -g -o $@$(X) -Wl,--base-file,$@.base $@.exp $(OBJS) $(DLLLIBS)
53
	dlltool --dllname $@$(X) --base-file $@.base --output-exp $@.exp --def postgres.def
54
	gcc -g -o $@$(X) $@.exp $(OBJS) $(DLLLIBS)
55 56
	rm $@.exp $@.base

57 58
endif # win

59

60
# Parallel make trickery
61
$(OBJS): $(DIRS:%=%-recursive)
62

63 64
.PHONY: $(DIRS:%=%-recursive)
# Update the commonly used headers before building the subdirectories
65
$(DIRS:%=%-recursive): $(top_builddir)/src/include/parser/parse.h $(top_builddir)/src/include/utils/fmgroids.h
66
	$(MAKE) -C $(subst -recursive,,$@) all
67

68 69

ifeq ($(MAKE_DLL), true)
70

71 72
postgres.def: $(OBJS)
	$(DLLTOOL) --export-all --output-def $@ $(OBJS)
73

74
libpostgres.a: $(OBJS) $(top_builddir)/src/utils/dllinit.o postgres.def
75
	$(DLLTOOL) --dllname postgres.exe --def postgres.def --output-lib $@
76

77 78 79 80 81
endif # MAKE_DLL


$(top_builddir)/src/utils/dllinit.o: $(top_srcdir)/src/utils/dllinit.c
	$(MAKE) -C $(top_builddir)/src/utils dllinit.o
82

83 84 85
# The postgres.o target is needed by the rule in Makefile.global that
# creates the exports file when MAKE_EXPORTS = true.
postgres.o: $(OBJS)
86
	$(CC) $(LDREL) $(LDFLAGS) $^ $(LIBS) -o $@
87 88


89 90 91
# The following targets are specified in make commands that appear in
# the make files in our subdirectories. Note that it's important we
# match the dependencies shown in the subdirectory makefiles!
92

93 94
$(srcdir)/parser/parse.h: parser/gram.y
	$(MAKE) -C parser parse.h
95

96 97
utils/fmgroids.h: utils/Gen_fmgrtab.sh $(top_srcdir)/src/include/catalog/pg_proc.h
	$(MAKE) -C utils fmgroids.h
98

99 100 101
# Make symlinks for these headers in the include directory. That way
# we can cut down on the -I options. Also, a symlink is automatically
# up to date when we update the base file.
102

103
$(top_builddir)/src/include/parser/parse.h: $(srcdir)/parser/parse.h
104
	prereqdir=`cd $(dir $<) >/dev/null && pwd` && \
105 106
	  cd $(dir $@) && rm -f $(notdir $@) && \
	  $(LN_S) $$prereqdir/$(notdir $<) .
107

108 109 110
$(top_builddir)/src/include/utils/fmgroids.h: utils/fmgroids.h
	cd $(dir $@) && rm -f $(notdir $@) && \
	    $(LN_S) ../../../$(subdir)/utils/fmgroids.h .
111

112

113 114 115 116 117 118
##########################################################################

distprep:
	$(MAKE) -C parser	gram.c parse.h scan.c
	$(MAKE) -C bootstrap	bootparse.c bootstrap_tokens.h bootscanner.c
	$(MAKE) -C utils/misc	guc-file.c
119 120 121
ifeq ($(enable_nls), yes)
	$(MAKE) -C po $@
endif
122

123 124
##########################################################################

125
install: all installdirs install-bin
126 127
ifeq ($(PORTNAME), win)
ifeq ($(MAKE_DLL), true)
128
	$(INSTALL_DATA) libpostgres.a $(DESTDIR)$(libdir)/libpostgres.a
129 130
endif
endif
131
	$(MAKE) -C catalog install-bki
132 133 134
	$(INSTALL_DATA) $(srcdir)/libpq/pg_hba.conf.sample $(DESTDIR)$(datadir)/pg_hba.conf.sample
	$(INSTALL_DATA) $(srcdir)/libpq/pg_ident.conf.sample $(DESTDIR)$(datadir)/pg_ident.conf.sample
	$(INSTALL_DATA) $(srcdir)/utils/misc/postgresql.conf.sample $(DESTDIR)$(datadir)/postgresql.conf.sample
135 136 137
ifeq ($(enable_nls), yes)
	$(MAKE) -C po $@
endif
138

139
installdirs:
140
	$(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(libdir) $(DESTDIR)$(datadir)
141 142 143
ifeq ($(enable_nls), yes)
	$(MAKE) -C po $@
endif
144

145
install-bin: postgres $(POSTGRES_IMP) installdirs
146 147 148
	$(INSTALL_PROGRAM) postgres$(X) $(DESTDIR)$(bindir)/postgres$(X)
	@rm -f $(DESTDIR)$(bindir)/postmaster
	ln -s postgres$(X) $(DESTDIR)$(bindir)/postmaster
149
ifeq ($(MAKE_EXPORTS), true)
150
	$(INSTALL_DATA) $(POSTGRES_IMP) $(DESTDIR)$(libdir)/$(POSTGRES_IMP)
151 152
endif

153
.PHONY: install-bin
154

155 156 157
##########################################################################

uninstall:
158
	rm -f $(DESTDIR)$(bindir)/postgres$(X) $(DESTDIR)$(bindir)/postmaster
159
ifeq ($(MAKE_EXPORTS), true)
160
	rm -f $(DESTDIR)$(libdir)/$(POSTGRES_IMP)
161
endif
162 163
ifeq ($(PORTNAME), win)
ifeq ($(MAKE_DLL), true)
164
	rm -f $(DESTDIR)$(libdir)/libpostgres.a
165 166
endif
endif
167
	$(MAKE) -C catalog uninstall-bki
168 169 170
	rm -f $(DESTDIR)$(datadir)/pg_hba.conf.sample \
	      $(DESTDIR)$(datadir)/pg_ident.conf.sample \
	      $(DESTDIR)$(datadir)/postgresql.conf.sample
171 172 173
ifeq ($(enable_nls), yes)
	$(MAKE) -C po $@
endif
174

175

176
##########################################################################
177

178 179 180 181 182 183 184 185 186
clean:
	rm -f postgres$(X) $(POSTGRES_IMP) \
		$(top_srcdir)/src/include/parser/parse.h \
		$(top_builddir)/src/include/utils/fmgroids.h
ifeq ($(PORTNAME), win)
ifeq ($(MAKE_DLL), true)
	rm -f postgres.dll postgres.def libpostgres.a
endif
endif
187
	for i in $(DIRS); do $(MAKE) -C $$i clean || exit; done
188 189 190
ifeq ($(enable_nls), yes)
	$(MAKE) -C po $@
endif
191

192 193
distclean: clean
	rm -f port/Makefile port/tas.s port/dynloader.c
194

195 196 197 198 199 200 201 202
maintainer-clean: distclean
	rm -f $(srcdir)/bootstrap/bootparse.c \
	      $(srcdir)/bootstrap/bootscanner.c \
	      $(srcdir)/bootstrap/bootstrap_tokens.h \
	      $(srcdir)/parser/gram.c \
	      $(srcdir)/parser/scan.c \
	      $(srcdir)/parser/parse.h \
	      $(srcdir)/utils/misc/guc-file.c
203
	$(MAKE) -C po maintainer-clean
204 205


206
##########################################################################
207 208 209
#
# Support for code development.
#
210 211 212 213
# Use target "quick" to build "postgres" when you know all the subsystems 
# are up to date.  It saves the time of doing all the submakes.
.PHONY: quick
quick: $(OBJS)
214
	$(CC) $(CFLAGS) $(LDFLAGS) $(export_dynamic) $^ $(LIBS) -o postgres
215

216 217
depend dep: $(top_srcdir)/src/include/parser/parse.h $(top_builddir)/src/include/utils/fmgroids.h
	for i in $(DIRS); do $(MAKE) -C $$i $@; done