postgres_fdw: Refactor transaction rollback code to avoid code duplication.
[pgsql.git] / src / backend / common.mk
blob663e9f886ced2a77a08be854201c596db34de503
2 # Common make rules for backend
4 # src/backend/common.mk
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.
11 subsysfilename = objfiles.txt
13 SUBDIROBJS = $(SUBDIRS:%=%/$(subsysfilename))
15 # top-level backend directory obviously has its own "all" target
16 ifneq ($(subdir), src/backend)
17 all: $(subsysfilename)
18 endif
20 SUBSYS.o: $(SUBDIROBJS) $(OBJS)
21 $(LD) $(LDREL) $(LDOUT) $@ $^
23 objfiles.txt: Makefile $(SUBDIROBJS) $(OBJS)
24 # Don't rebuild the list if only the OBJS have changed.
25 $(if $(filter-out $(OBJS),$?),( $(if $(SUBDIROBJS),cat $(SUBDIROBJS); )echo $(addprefix $(subdir)/,$(OBJS)) ) >$@,touch $@)
27 ifeq ($(with_llvm), yes)
28 objfiles.txt: $(patsubst %.o,%.bc, $(OBJS))
29 endif
31 # make function to expand objfiles.txt contents
32 expand_subsys = $(foreach file,$(1),$(if $(filter %/objfiles.txt,$(file)),$(patsubst ../../src/backend/%,%,$(addprefix $(top_builddir)/,$(shell cat $(file)))),$(file)))
34 # Parallel make trickery
35 $(SUBDIROBJS): $(SUBDIRS:%=%-recursive) ;
37 .PHONY: $(SUBDIRS:%=%-recursive)
38 $(SUBDIRS:%=%-recursive):
39 $(MAKE) -C $(subst -recursive,,$@) all
41 $(call recurse,clean)
42 clean: clean-local
43 clean-local:
44 rm -f $(subsysfilename) $(OBJS) $(patsubst %.o,%.bc, $(OBJS))
46 $(call recurse,coverage)
47 $(call recurse,install)