1# 2# Common make rules for backend 3# 4# src/backend/common.mk 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 11ifdef PARTIAL_LINKING 12# old style: linking using SUBSYS.o 13subsysfilename = SUBSYS.o 14else 15# new style: linking all object files at once 16subsysfilename = objfiles.txt 17endif 18 19SUBDIROBJS = $(SUBDIRS:%=%/$(subsysfilename)) 20 21# top-level backend directory obviously has its own "all" target 22ifneq ($(subdir), src/backend) 23all: $(subsysfilename) 24endif 25 26SUBSYS.o: $(SUBDIROBJS) $(OBJS) 27 $(LD) $(LDREL) $(LDOUT) $@ $^ 28 29objfiles.txt: Makefile $(SUBDIROBJS) $(OBJS) 30# Don't rebuild the list if only the OBJS have changed. 31 $(if $(filter-out $(OBJS),$?),( $(if $(SUBDIROBJS),cat $(SUBDIROBJS); )echo $(addprefix $(subdir)/,$(OBJS)) ) >$@,touch $@) 32 33# make function to expand objfiles.txt contents 34expand_subsys = $(foreach file,$(1),$(if $(filter %/objfiles.txt,$(file)),$(patsubst ../../src/backend/%,%,$(addprefix $(top_builddir)/,$(shell cat $(file)))),$(file))) 35 36# Parallel make trickery 37$(SUBDIROBJS): $(SUBDIRS:%=%-recursive) ; 38 39.PHONY: $(SUBDIRS:%=%-recursive) 40$(SUBDIRS:%=%-recursive): 41 $(MAKE) -C $(subst -recursive,,$@) all 42 43$(call recurse,clean) 44clean: clean-local 45clean-local: 46 rm -f $(subsysfilename) $(OBJS) 47 48$(call recurse,coverage) 49