summaryrefslogtreecommitdiffstats
path: root/src/backend/common.mk
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:17:33 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:17:33 +0000
commit5e45211a64149b3c659b90ff2de6fa982a5a93ed (patch)
tree739caf8c461053357daa9f162bef34516c7bf452 /src/backend/common.mk
parentInitial commit. (diff)
downloadpostgresql-15-5e45211a64149b3c659b90ff2de6fa982a5a93ed.tar.xz
postgresql-15-5e45211a64149b3c659b90ff2de6fa982a5a93ed.zip
Adding upstream version 15.5.upstream/15.5
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/backend/common.mk')
-rw-r--r--src/backend/common.mk47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/backend/common.mk b/src/backend/common.mk
new file mode 100644
index 0000000..663e9f8
--- /dev/null
+++ b/src/backend/common.mk
@@ -0,0 +1,47 @@
+#
+# Common make rules for backend
+#
+# src/backend/common.mk
+#
+
+# When including this file, set OBJS to the object files created in
+# this directory and SUBDIRS to subdirectories containing more things
+# to build.
+
+subsysfilename = objfiles.txt
+
+SUBDIROBJS = $(SUBDIRS:%=%/$(subsysfilename))
+
+# top-level backend directory obviously has its own "all" target
+ifneq ($(subdir), src/backend)
+all: $(subsysfilename)
+endif
+
+SUBSYS.o: $(SUBDIROBJS) $(OBJS)
+ $(LD) $(LDREL) $(LDOUT) $@ $^
+
+objfiles.txt: Makefile $(SUBDIROBJS) $(OBJS)
+# Don't rebuild the list if only the OBJS have changed.
+ $(if $(filter-out $(OBJS),$?),( $(if $(SUBDIROBJS),cat $(SUBDIROBJS); )echo $(addprefix $(subdir)/,$(OBJS)) ) >$@,touch $@)
+
+ifeq ($(with_llvm), yes)
+objfiles.txt: $(patsubst %.o,%.bc, $(OBJS))
+endif
+
+# make function to expand objfiles.txt contents
+expand_subsys = $(foreach file,$(1),$(if $(filter %/objfiles.txt,$(file)),$(patsubst ../../src/backend/%,%,$(addprefix $(top_builddir)/,$(shell cat $(file)))),$(file)))
+
+# Parallel make trickery
+$(SUBDIROBJS): $(SUBDIRS:%=%-recursive) ;
+
+.PHONY: $(SUBDIRS:%=%-recursive)
+$(SUBDIRS:%=%-recursive):
+ $(MAKE) -C $(subst -recursive,,$@) all
+
+$(call recurse,clean)
+clean: clean-local
+clean-local:
+ rm -f $(subsysfilename) $(OBJS) $(patsubst %.o,%.bc, $(OBJS))
+
+$(call recurse,coverage)
+$(call recurse,install)