Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.o
*.d
*.so
build.sh
.idea
Expand Down
24 changes: 23 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ OBJS = src/backend/age.o \
src/backend/utils/name_validation.o \
src/backend/utils/ag_guc.o

# Per-object header-dependency files (see "Automatic header-dependency
# tracking" below the PGXS include). One .d is generated beside each .o.
DEPFILES = $(OBJS:.o=.d)

# ===== Extension SQL & data files =====
EXTENSION = age

Expand Down Expand Up @@ -258,7 +262,8 @@ EXTRA_CLEAN = $(addprefix $(ag_regress_dir)/, $(ag_regress_out)) \
$(all_age_sql) \
$(age_init_sql) \
$(age_upgrade_test_sql) \
$(ag_regress_dir)/age_upgrade_cleanup.sh
$(ag_regress_dir)/age_upgrade_cleanup.sh \
$(DEPFILES)

GEN_KEYWORDLIST = $(PERL) -I ./tools/ ./tools/gen_keywordlist.pl
GEN_KEYWORDLIST_DEPS = ./tools/gen_keywordlist.pl tools/PerfectHash.pm
Expand All @@ -271,6 +276,23 @@ PG_CONFIG ?= pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)

# ===== Automatic header-dependency tracking =====
#
# AGE lists OBJS explicitly, and PGXS's built-in .deps tracking only runs when
# the *server* was built with --enable-depend (often off). Without the lines
# below, editing a header does NOT rebuild the .c files that include it, leaving
# STALE .o files. This is especially dangerous for node/struct headers: a stale
# ag_nodes.o keeps an old node_size, so _readExtensibleNode under-allocates and
# readNode corrupts the heap ("unrecognized node type: <garbage>").
#
# The compiler emits a .d file next to each object (-MMD = user headers only;
# -MP adds phony targets so deleting a header does not break the build). With
# "-o foo.o", -MMD writes "foo.d" automatically (no -MF, no basename clashes).
# On servers that DO set --enable-depend, PGXS appends its own "-MF .deps/*.Po"
# after $(CFLAGS) (last -MF wins), so this degrades cleanly to that mechanism.
override CFLAGS += -MMD -MP
-include $(DEPFILES)

# ===== Build rules =====

# 32-bit platform support: pass SIZEOF_DATUM=4 to enable (e.g., make SIZEOF_DATUM=4)
Expand Down
Loading