1# Makefile for the Citus extension 2 3citus_subdir = src/backend/distributed 4citus_top_builddir = ../../.. 5safestringlib_srcdir = $(citus_abs_top_srcdir)/vendor/safestringlib 6safestringlib_builddir = $(citus_top_builddir)/vendor/safestringlib/build 7safestringlib_a = $(safestringlib_builddir)/libsafestring_static.a 8safestringlib_sources = $(wildcard $(safestringlib_srcdir)/safeclib/*) 9 10MODULE_big = citus 11EXTENSION = citus 12 13template_sql_files = $(patsubst $(citus_abs_srcdir)/%,%,$(wildcard $(citus_abs_srcdir)/sql/*.sql)) 14template_downgrade_sql_files = $(patsubst $(citus_abs_srcdir)/sql/downgrades/%,%,$(wildcard $(citus_abs_srcdir)/sql/downgrades/*.sql)) 15generated_sql_files = $(patsubst %,$(citus_abs_srcdir)/build/%,$(template_sql_files)) 16generated_downgrade_sql_files += $(patsubst %,$(citus_abs_srcdir)/build/sql/%,$(template_downgrade_sql_files)) 17# All citus--*.sql files that are used to upgrade between versions 18DATA_built = $(generated_sql_files) 19 20# directories with source files 21SUBDIRS = . commands connection ddl deparser executor metadata operations planner progress relay safeclib test transaction utils worker 22# columnar modules 23SUBDIRS += ../columnar 24# enterprise modules 25SUBDIRS += 26 27# Symlinks are not copied over to the build directory if a separete build 28# directory is used during configure (such as on CI) 29ENSURE_SUBDIRS_EXIST := $(shell mkdir -p $(SUBDIRS)) 30 31# That patsubst rule searches all directories listed in SUBDIRS for .c 32# files, and adds the corresponding .o files to OBJS 33OBJS += \ 34 $(patsubst $(citus_abs_srcdir)/%.c,%.o,$(foreach dir,$(SUBDIRS), $(sort $(wildcard $(citus_abs_srcdir)/$(dir)/*.c)))) 35 36# be explicit about the default target 37all: 38 39NO_PGXS = 1 40 41SHLIB_LINK = $(libpq) 42 43include $(citus_top_builddir)/Makefile.global 44 45# make sure citus_version.o is recompiled whenever any change is made to the binary or any 46# other artifact being installed to reflect the correct gitref for every build 47CITUS_VERSION_INVALIDATE := $(filter-out utils/citus_version.o,$(OBJS)) 48CITUS_VERSION_INVALIDATE += $(generated_sql_files) 49ifneq ($(wildcard $(citus_top_builddir)/.git/.*),) 50 CITUS_VERSION_INVALIDATE += $(citus_top_builddir)/.git/index 51endif 52utils/citus_version.o: $(CITUS_VERSION_INVALIDATE) 53 54SHLIB_LINK += $(filter -lssl -lcrypto -lssleay32 -leay32, $(LIBS)) 55 56override CPPFLAGS += -I$(libpq_srcdir) -I$(safestringlib_srcdir)/include 57 58SQL_DEPDIR=.deps/sql 59SQL_BUILDDIR=build/sql 60 61$(generated_sql_files): $(citus_abs_srcdir)/build/%: % 62 @mkdir -p $(citus_abs_srcdir)/$(SQL_DEPDIR) $(citus_abs_srcdir)/$(SQL_BUILDDIR) 63 @# -MF is used to store dependency files(.Po) in another directory for separation 64 @# -MT is used to change the target of the rule emitted by dependency generation. 65 @# -P is used to inhibit generation of linemarkers in the output from the preprocessor. 66 @# -undef is used to not predefine any system-specific or GCC-specific macros. 67 @# `man cpp` for further information 68 cd $(citus_abs_srcdir) && cpp -undef -w -P -MMD -MP -MF$(SQL_DEPDIR)/$(*F).Po -MT$@ $< > $@ 69 70$(generated_downgrade_sql_files): $(citus_abs_srcdir)/build/sql/%: sql/downgrades/% 71 @mkdir -p $(citus_abs_srcdir)/$(SQL_DEPDIR) $(citus_abs_srcdir)/$(SQL_BUILDDIR) 72 @# -MF is used to store dependency files(.Po) in another directory for separation 73 @# -MT is used to change the target of the rule emitted by dependency generation. 74 @# -P is used to inhibit generation of linemarkers in the output from the preprocessor. 75 @# -undef is used to not predefine any system-specific or GCC-specific macros. 76 @# `man cpp` for further information 77 cd $(citus_abs_srcdir) && cpp -undef -w -P -MMD -MP -MF$(SQL_DEPDIR)/$(*F).Po -MT$@ $< > $@ 78 79SQL_Po_files := $(wildcard $(SQL_DEPDIR)/*.Po) 80ifneq (,$(SQL_Po_files)) 81include $(SQL_Po_files) 82endif 83 84.PHONY: clean-full install install-downgrades install-all 85 86cleanup-before-install: 87 rm -f $(DESTDIR)$(datadir)/$(datamoduledir)/citus* 88 89install: cleanup-before-install 90 91# install and install-downgrades should be run sequentially 92install-all: install 93 $(MAKE) install-downgrades 94 95install-downgrades: $(generated_downgrade_sql_files) 96 $(INSTALL_DATA) $(generated_downgrade_sql_files) '$(DESTDIR)$(datadir)/$(datamoduledir)/' 97 98clean-full: 99 $(MAKE) clean 100 rm -rf $(safestringlib_builddir) 101