]> granicus.if.org Git - postgresql/blob - src/backend/common.mk
We don't need to rebuild objfiles.txt every time an object file changes.
[postgresql] / src / backend / common.mk
1 #
2 # Common make rules for backend
3 #
4 # $PostgreSQL: pgsql/src/backend/common.mk,v 1.3 2008/02/26 07:20:38 petere Exp $
5 #
6
7 # When including this file, set OBJS to the object files created in
8 # this directory and SUBDIRS to subdirectories containing more things
9 # to build.
10
11 ifdef PARTIAL_LINKING
12 # old style: linking using SUBSYS.o
13 subsysfilename = SUBSYS.o
14 else
15 # new style: linking all object files at once
16 subsysfilename = objfiles.txt
17 endif
18
19 SUBDIROBJS = $(SUBDIRS:%=%/$(subsysfilename))
20
21 # top-level backend directory obviously has its own "all" target
22 ifneq ($(subdir), src/backend)
23 all: $(subsysfilename)
24 endif
25
26 SUBSYS.o: $(SUBDIROBJS) $(OBJS)
27         $(LD) $(LDREL) $(LDOUT) $@ $^
28
29 objfiles.txt:: $(MAKEFILE_LIST)
30         ( $(if $(SUBDIROBJS),cat $(SUBDIROBJS); )echo $(addprefix $(subdir)/,$(OBJS)) ) >$@
31
32 objfiles.txt:: $(SUBDIROBJS) $(OBJS)
33         touch $@
34
35 # make function to expand objfiles.txt contents
36 expand_subsys = $(foreach file,$(filter %/objfiles.txt,$(1)),$(patsubst ../../src/backend/%,%,$(addprefix $(top_builddir)/,$(shell cat $(file))))) $(filter-out %/objfiles.txt,$(1))
37
38 # Parallel make trickery
39 $(SUBDIROBJS): $(SUBDIRS:%=%-recursive) ;
40
41 .PHONY: $(SUBDIRS:%=%-recursive)
42 $(SUBDIRS:%=%-recursive):
43         $(MAKE) -C $(subst -recursive,,$@) all
44
45 clean: clean-local
46 clean-local:
47 ifdef SUBDIRS
48         for dir in $(SUBDIRS); do $(MAKE) -C $$dir clean || exit; done
49 endif
50         rm -f $(subsysfilename) $(OBJS)