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
11subsysfilename = objfiles.txt
12
13SUBDIROBJS = $(SUBDIRS:%=%/$(subsysfilename))
14
15# top-level backend directory obviously has its own "all" target
16ifneq ($(subdir), src/backend)
17all: $(subsysfilename)
18endif
19
20SUBSYS.o: $(SUBDIROBJS) $(OBJS)
21	$(LD) $(LDREL) $(LDOUT) $@ $^
22
23objfiles.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 $@)
26
27ifeq ($(with_llvm), yes)
28objfiles.txt: $(patsubst %.o,%.bc, $(OBJS))
29endif
30
31# make function to expand objfiles.txt contents
32expand_subsys = $(foreach file,$(1),$(if $(filter %/objfiles.txt,$(file)),$(patsubst ../../src/backend/%,%,$(addprefix $(top_builddir)/,$(shell cat $(file)))),$(file)))
33
34# Parallel make trickery
35$(SUBDIROBJS): $(SUBDIRS:%=%-recursive) ;
36
37.PHONY: $(SUBDIRS:%=%-recursive)
38$(SUBDIRS:%=%-recursive):
39	$(MAKE) -C $(subst -recursive,,$@) all
40
41$(call recurse,clean)
42clean: clean-local
43clean-local:
44	rm -f $(subsysfilename) $(OBJS) $(patsubst %.o,%.bc, $(OBJS))
45
46$(call recurse,coverage)
47$(call recurse,install)
48