Makefile 6.24 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.86 2002/09/04 15:45:50 tgl 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
OBJS := $(DIRS:%=%/SUBSYS.o)
20

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

29

30
##########################################################################
31

32
all: submake-libpgport postgres $(POSTGRES_IMP)
33

34
ifneq ($(PORTNAME), win)
35

36
postgres: $(OBJS)
37
	$(CC) $(CFLAGS) $(LDFLAGS) $(export_dynamic) $^ $(LIBS) -o $@
38

39
else # win
40

41
postgres: $(OBJS) $(DLLINIT) postgres.def libpostgres.a
42 43 44 45
	$(DLLTOOL) --dllname $@$(X) --output-exp $@.exp --def postgres.def
	$(CC) $(LDFLAGS) -o $@$(X) -Wl,--base-file,$@.base $@.exp $(OBJS) $(DLLLIBS)
	$(DLLTOOL) --dllname $@$(X) --base-file $@.base --output-exp $@.exp --def postgres.def
	$(CC) $(LDFLAGS) -o $@$(X) $@.exp $(OBJS) $(DLLLIBS)
46 47
	rm $@.exp $@.base

48 49
endif # win

50

51
# Parallel make trickery
52
$(OBJS): $(DIRS:%=%-recursive) ;
53

54 55
.PHONY: $(DIRS:%=%-recursive)
# Update the commonly used headers before building the subdirectories
56
$(DIRS:%=%-recursive): $(top_builddir)/src/include/parser/parse.h $(top_builddir)/src/include/utils/fmgroids.h
57
	$(MAKE) -C $(subst -recursive,,$@) all
58

59 60

ifeq ($(MAKE_DLL), true)
61

62 63
postgres.def: $(OBJS)
	$(DLLTOOL) --export-all --output-def $@ $(OBJS)
64

65
libpostgres.a: $(OBJS) $(DLLINIT) postgres.def
66
	$(DLLTOOL) --dllname postgres.exe --def postgres.def --output-lib $@
67

68 69 70
endif # MAKE_DLL


71
$(DLLINIT): $(DLLINIT:%.o=%.c)
72
	$(MAKE) -C $(@D) $(@F)
73

74 75 76
# The postgres.o target is needed by the rule in Makefile.global that
# creates the exports file when MAKE_EXPORTS = true.
postgres.o: $(OBJS)
77
	$(CC) $(LDREL) $(LDFLAGS) $^ $(LIBS) -o $@
78 79


80 81 82
# 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!
83

84 85
$(srcdir)/parser/parse.h: parser/gram.y
	$(MAKE) -C parser parse.h
86

87 88
utils/fmgroids.h: utils/Gen_fmgrtab.sh $(top_srcdir)/src/include/catalog/pg_proc.h
	$(MAKE) -C utils fmgroids.h
89

90 91 92
# 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.
93

94
$(top_builddir)/src/include/parser/parse.h: $(srcdir)/parser/parse.h
95
	prereqdir=`cd $(dir $<) >/dev/null && pwd` && \
96
	  cd $(dir $@) && rm -f $(notdir $@) && \
97
	  $(LN_S) "$$prereqdir/$(notdir $<)" .
98

99 100 101
$(top_builddir)/src/include/utils/fmgroids.h: utils/fmgroids.h
	cd $(dir $@) && rm -f $(notdir $@) && \
	    $(LN_S) ../../../$(subdir)/utils/fmgroids.h .
102

103

104 105 106 107 108 109
##########################################################################

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
110

111

112 113
##########################################################################

114
install: all installdirs install-bin
115 116
ifeq ($(PORTNAME), win)
ifeq ($(MAKE_DLL), true)
117
	$(INSTALL_DATA) libpostgres.a $(DESTDIR)$(libdir)/libpostgres.a
118 119
endif
endif
120
	$(MAKE) -C catalog install-bki
121 122 123
	$(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
124

125
install-bin: postgres $(POSTGRES_IMP) installdirs
126 127 128
	$(INSTALL_PROGRAM) postgres$(X) $(DESTDIR)$(bindir)/postgres$(X)
	@rm -f $(DESTDIR)$(bindir)/postmaster
	ln -s postgres$(X) $(DESTDIR)$(bindir)/postmaster
129
ifeq ($(MAKE_EXPORTS), true)
130
	$(INSTALL_DATA) $(POSTGRES_IMP) $(DESTDIR)$(pkglibdir)/$(POSTGRES_IMP)
131 132
endif

133
.PHONY: install-bin
134

135 136 137 138 139 140 141 142 143 144
installdirs:
	$(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(datadir)
ifeq ($(PORTNAME), win)
ifeq ($(MAKE_DLL), true)
	$(mkinstalldirs) $(DESTDIR)$(libdir)
endif
endif
ifeq ($(MAKE_EXPORTS), true)
	$(mkinstalldirs) $(DESTDIR)$(pkglibdir)
endif
145

146

147 148 149
##########################################################################

uninstall:
150
	rm -f $(DESTDIR)$(bindir)/postgres$(X) $(DESTDIR)$(bindir)/postmaster
151
ifeq ($(MAKE_EXPORTS), true)
152
	rm -f $(DESTDIR)$(pkglibdir)/$(POSTGRES_IMP)
153
endif
154 155
ifeq ($(PORTNAME), win)
ifeq ($(MAKE_DLL), true)
156
	rm -f $(DESTDIR)$(libdir)/libpostgres.a
157 158
endif
endif
159
	$(MAKE) -C catalog uninstall-bki
160 161 162
	rm -f $(DESTDIR)$(datadir)/pg_hba.conf.sample \
	      $(DESTDIR)$(datadir)/pg_ident.conf.sample \
	      $(DESTDIR)$(datadir)/postgresql.conf.sample
163

164

165
##########################################################################
166

167 168 169 170 171 172 173 174 175
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
176
	for i in $(DIRS); do $(MAKE) -C $$i clean || exit; done
177

178
distclean: clean
179
	rm -f port/tas.s port/dynloader.c port/pg_sema.c port/pg_shmem.c
180

181 182 183 184 185 186 187 188
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
189 190


191
##########################################################################
192 193 194
#
# Support for code development.
#
195 196 197 198
# 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)
199
	$(CC) $(CFLAGS) $(LDFLAGS) $(export_dynamic) $^ $(LIBS) -o postgres
200

201 202
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