mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-06 21:12:55 +00:00
* Add submodule postgres-15 * Support pg_15 in pgxn/neon * Renamed zenith -> neon in Makefile * fix name of codestyle check * Refactor build system to prepare for building multiple Postgres versions. Rename "vendor/postgres" to "vendor/postgres-v14" Change Postgres build and install directory paths to be version-specific: - tmp_install/build -> pg_install/build/14 - tmp_install/* -> pg_install/14/* And Makefile targets: - "make postgres" -> "make postgres-v14" - "make postgres-headers" -> "make postgres-v14-headers" - etc. Add Makefile aliases: - "make postgres" to build "postgres-v14" and in future, "postgres-v15" - similarly for "make postgres-headers" Fix POSTGRES_DISTRIB_DIR path in pytest scripts * Make postgres version a variable in codestyle workflow * Support vendor/postgres-v15 in codestyle check workflow * Support postgres-v15 building in Makefile * fix pg version in Dockerfile.compute-node * fix kaniko path * Build neon extensions in version-specific directories * fix obsolete mentions of vendor/postgres * use vendor/postgres-v14 in Dockerfile.compute-node.legacy * Use PG_VERSION_NUM to gate dependencies in inmem_smgr.c * Use versioned ECR repositories and image names for compute-node. The image name format is compute-node-vXX, where XX is postgres major version number. For now only v14 is supported. Old format unversioned name (compute-node) is left, because cloud repo depends on it. * update vendor/postgres submodule url (zenith->neondatabase rename) * Fix postgres path in python tests after rebase * fix path in regress test * Use separate dockerfiles to build compute-node: Dockerfile.compute-node-v15 should be identical to Dockerfile.compute-node-v14 except for the version number. This is a hack, because Kaniko doesn't support build ARGs properly * bump vendor/postgres-v14 and vendor/postgres-v15 * Don't use Kaniko cache for v14 and v15 compute-node images * Build compute-node images for different versions in different jobs Co-authored-by: Heikki Linnakangas <heikki@neon.tech>
197 lines
7.4 KiB
Makefile
197 lines
7.4 KiB
Makefile
ROOT_PROJECT_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
|
|
|
# Where to install Postgres, default is ./pg_install, maybe useful for package managers
|
|
POSTGRES_INSTALL_DIR ?= $(ROOT_PROJECT_DIR)/pg_install/
|
|
|
|
#
|
|
# We differentiate between release / debug build types using the BUILD_TYPE
|
|
# environment variable.
|
|
#
|
|
BUILD_TYPE ?= debug
|
|
ifeq ($(BUILD_TYPE),release)
|
|
PG_CONFIGURE_OPTS = --enable-debug --with-openssl
|
|
PG_CFLAGS = -O2 -g3 $(CFLAGS)
|
|
# Unfortunately, `--profile=...` is a nightly feature
|
|
CARGO_BUILD_FLAGS += --release
|
|
else ifeq ($(BUILD_TYPE),debug)
|
|
PG_CONFIGURE_OPTS = --enable-debug --with-openssl --enable-cassert --enable-depend
|
|
PG_CFLAGS = -O0 -g3 $(CFLAGS)
|
|
else
|
|
$(error Bad build type '$(BUILD_TYPE)', see Makefile for options)
|
|
endif
|
|
|
|
# Seccomp BPF is only available for Linux
|
|
UNAME_S := $(shell uname -s)
|
|
ifeq ($(UNAME_S),Linux)
|
|
PG_CONFIGURE_OPTS += --with-libseccomp
|
|
endif
|
|
|
|
|
|
# macOS with brew-installed openssl requires explicit paths
|
|
# It can be configured with OPENSSL_PREFIX variable
|
|
UNAME_S := $(shell uname -s)
|
|
ifeq ($(UNAME_S),Darwin)
|
|
OPENSSL_PREFIX ?= $(shell brew --prefix openssl@3)
|
|
PG_CONFIGURE_OPTS += --with-includes=$(OPENSSL_PREFIX)/include --with-libraries=$(OPENSSL_PREFIX)/lib
|
|
endif
|
|
|
|
# Choose whether we should be silent or verbose
|
|
CARGO_BUILD_FLAGS += --$(if $(filter s,$(MAKEFLAGS)),quiet,verbose)
|
|
# Fix for a corner case when make doesn't pass a jobserver
|
|
CARGO_BUILD_FLAGS += $(filter -j1,$(MAKEFLAGS))
|
|
|
|
# This option has a side effect of passing make jobserver to cargo.
|
|
# However, we shouldn't do this if `make -n` (--dry-run) has been asked.
|
|
CARGO_CMD_PREFIX += $(if $(filter n,$(MAKEFLAGS)),,+)
|
|
# Force cargo not to print progress bar
|
|
CARGO_CMD_PREFIX += CARGO_TERM_PROGRESS_WHEN=never CI=1
|
|
|
|
#
|
|
# Top level Makefile to build Neon and PostgreSQL
|
|
#
|
|
.PHONY: all
|
|
all: neon postgres neon-pg-ext
|
|
|
|
### Neon Rust bits
|
|
#
|
|
# The 'postgres_ffi' depends on the Postgres headers.
|
|
.PHONY: neon
|
|
neon: postgres-v14-headers
|
|
+@echo "Compiling Neon"
|
|
$(CARGO_CMD_PREFIX) cargo build $(CARGO_BUILD_FLAGS)
|
|
|
|
### PostgreSQL parts
|
|
# The rules are duplicated for Postgres v14 and 15. We may want to refactor
|
|
# to avoid the duplication in the future, but it's tolerable for now.
|
|
#
|
|
$(POSTGRES_INSTALL_DIR)/build/v14/config.status:
|
|
+@echo "Configuring Postgres v14 build"
|
|
mkdir -p $(POSTGRES_INSTALL_DIR)/build/v14
|
|
(cd $(POSTGRES_INSTALL_DIR)/build/v14 && \
|
|
$(ROOT_PROJECT_DIR)/vendor/postgres-v14/configure CFLAGS='$(PG_CFLAGS)' \
|
|
$(PG_CONFIGURE_OPTS) \
|
|
--prefix=$(abspath $(POSTGRES_INSTALL_DIR))/v14 > configure.log)
|
|
|
|
$(POSTGRES_INSTALL_DIR)/build/v15/config.status:
|
|
+@echo "Configuring Postgres v15 build"
|
|
mkdir -p $(POSTGRES_INSTALL_DIR)/build/v15
|
|
(cd $(POSTGRES_INSTALL_DIR)/build/v15 && \
|
|
$(ROOT_PROJECT_DIR)/vendor/postgres-v15/configure CFLAGS='$(PG_CFLAGS)' \
|
|
$(PG_CONFIGURE_OPTS) \
|
|
--prefix=$(abspath $(POSTGRES_INSTALL_DIR))/v15 > configure.log)
|
|
|
|
# nicer alias to run 'configure'
|
|
.PHONY: postgres-v14-configure
|
|
postgres-v14-configure: $(POSTGRES_INSTALL_DIR)/build/v14/config.status
|
|
|
|
.PHONY: postgres-v15-configure
|
|
postgres-v15-configure: $(POSTGRES_INSTALL_DIR)/build/v15/config.status
|
|
|
|
# Install the PostgreSQL header files into $(POSTGRES_INSTALL_DIR)/<version>/include
|
|
.PHONY: postgres-v14-headers
|
|
postgres-v14-headers: postgres-v14-configure
|
|
+@echo "Installing PostgreSQL v14 headers"
|
|
$(MAKE) -C $(POSTGRES_INSTALL_DIR)/build/v14/src/include MAKELEVEL=0 install
|
|
|
|
.PHONY: postgres-v15-headers
|
|
postgres-v15-headers: postgres-v15-configure
|
|
+@echo "Installing PostgreSQL v15 headers"
|
|
$(MAKE) -C $(POSTGRES_INSTALL_DIR)/build/v15/src/include MAKELEVEL=0 install
|
|
|
|
# Compile and install PostgreSQL
|
|
.PHONY: postgres-v14
|
|
postgres-v14: postgres-v14-configure \
|
|
postgres-v14-headers # to prevent `make install` conflicts with neon's `postgres-headers`
|
|
+@echo "Compiling PostgreSQL v14"
|
|
$(MAKE) -C $(POSTGRES_INSTALL_DIR)/build/v14 MAKELEVEL=0 install
|
|
+@echo "Compiling libpq v14"
|
|
$(MAKE) -C $(POSTGRES_INSTALL_DIR)/build/v14/src/interfaces/libpq install
|
|
+@echo "Compiling pg_buffercache v14"
|
|
$(MAKE) -C $(POSTGRES_INSTALL_DIR)/build/v14/contrib/pg_buffercache install
|
|
+@echo "Compiling pageinspect v14"
|
|
$(MAKE) -C $(POSTGRES_INSTALL_DIR)/build/v14/contrib/pageinspect install
|
|
|
|
.PHONY: postgres-v15
|
|
postgres-v15: postgres-v15-configure \
|
|
postgres-v15-headers # to prevent `make install` conflicts with neon's `postgres-headers`
|
|
+@echo "Compiling PostgreSQL v15"
|
|
$(MAKE) -C $(POSTGRES_INSTALL_DIR)/build/v15 MAKELEVEL=0 install
|
|
+@echo "Compiling libpq v15"
|
|
$(MAKE) -C $(POSTGRES_INSTALL_DIR)/build/v15/src/interfaces/libpq install
|
|
+@echo "Compiling pg_buffercache v15"
|
|
$(MAKE) -C $(POSTGRES_INSTALL_DIR)/build/v15/contrib/pg_buffercache install
|
|
+@echo "Compiling pageinspect v15"
|
|
$(MAKE) -C $(POSTGRES_INSTALL_DIR)/build/v15/contrib/pageinspect install
|
|
|
|
# shorthand to build all Postgres versions
|
|
postgres: postgres-v14 postgres-v15
|
|
|
|
.PHONY: postgres-v14-clean
|
|
postgres-v14-clean:
|
|
$(MAKE) -C $(POSTGRES_INSTALL_DIR)/build/v14 MAKELEVEL=0 clean
|
|
$(MAKE) -C $(POSTGRES_INSTALL_DIR)/build/v14/contrib/pg_buffercache clean
|
|
$(MAKE) -C $(POSTGRES_INSTALL_DIR)/build/v14/contrib/pageinspect clean
|
|
$(MAKE) -C $(POSTGRES_INSTALL_DIR)/build/v14/src/interfaces/libpq clean
|
|
|
|
.PHONY: postgres-v15-clean
|
|
postgres-v15-clean:
|
|
$(MAKE) -C $(POSTGRES_INSTALL_DIR)/build/v15 MAKELEVEL=0 clean
|
|
$(MAKE) -C $(POSTGRES_INSTALL_DIR)/build/v15/contrib/pg_buffercache clean
|
|
$(MAKE) -C $(POSTGRES_INSTALL_DIR)/build/v15/contrib/pageinspect clean
|
|
$(MAKE) -C $(POSTGRES_INSTALL_DIR)/build/v15/src/interfaces/libpq clean
|
|
|
|
neon-pg-ext-v14: postgres-v14
|
|
+@echo "Compiling neon v14"
|
|
mkdir -p $(POSTGRES_INSTALL_DIR)/build/neon-v14
|
|
(cd $(POSTGRES_INSTALL_DIR)/build/neon-v14 && \
|
|
$(MAKE) PG_CONFIG=$(POSTGRES_INSTALL_DIR)/v14/bin/pg_config \
|
|
-f $(ROOT_PROJECT_DIR)/pgxn/neon/Makefile install)
|
|
+@echo "Compiling neon_test_utils" v14
|
|
mkdir -p $(POSTGRES_INSTALL_DIR)/build/neon-test-utils-v14
|
|
(cd $(POSTGRES_INSTALL_DIR)/build/neon-test-utils-v14 && \
|
|
$(MAKE) PG_CONFIG=$(POSTGRES_INSTALL_DIR)/v14/bin/pg_config \
|
|
-f $(ROOT_PROJECT_DIR)/pgxn/neon_test_utils/Makefile install)
|
|
|
|
neon-pg-ext-v15: postgres-v15
|
|
+@echo "Compiling neon v15"
|
|
mkdir -p $(POSTGRES_INSTALL_DIR)/build/neon-v15
|
|
(cd $(POSTGRES_INSTALL_DIR)/build/neon-v15 && \
|
|
$(MAKE) PG_CONFIG=$(POSTGRES_INSTALL_DIR)/v15/bin/pg_config \
|
|
-f $(ROOT_PROJECT_DIR)/pgxn/neon/Makefile install)
|
|
+@echo "Compiling neon_test_utils" v15
|
|
mkdir -p $(POSTGRES_INSTALL_DIR)/build/neon-test-utils-v15
|
|
(cd $(POSTGRES_INSTALL_DIR)/build/neon-test-utils-v15 && \
|
|
$(MAKE) PG_CONFIG=$(POSTGRES_INSTALL_DIR)/v15/bin/pg_config \
|
|
-f $(ROOT_PROJECT_DIR)/pgxn/neon_test_utils/Makefile install)
|
|
|
|
.PHONY: neon-pg-ext-clean
|
|
$(MAKE) -C $(ROOT_PROJECT_DIR)/pgxn/neon clean
|
|
$(MAKE) -C $(ROOT_PROJECT_DIR)/pgxn/neon_test_utils clean
|
|
|
|
neon-pg-ext: neon-pg-ext-v14 neon-pg-ext-v15
|
|
postgres-headers: postgres-v14-headers postgres-v15-headers
|
|
postgres-clean: postgres-v14-clean postgres-v15-clean
|
|
|
|
# This doesn't remove the effects of 'configure'.
|
|
.PHONY: clean
|
|
clean:
|
|
cd $(POSTGRES_INSTALL_DIR)/build/v14 && $(MAKE) clean
|
|
cd $(POSTGRES_INSTALL_DIR)/build/v15 && $(MAKE) clean
|
|
$(CARGO_CMD_PREFIX) cargo clean
|
|
cd pgxn/neon && $(MAKE) clean
|
|
cd pgxn/neon_test_utils && $(MAKE) clean
|
|
|
|
# This removes everything
|
|
.PHONY: distclean
|
|
distclean:
|
|
rm -rf $(POSTGRES_INSTALL_DIR)
|
|
$(CARGO_CMD_PREFIX) cargo clean
|
|
|
|
.PHONY: fmt
|
|
fmt:
|
|
./pre-commit.py --fix-inplace
|
|
|
|
.PHONY: setup-pre-commit-hook
|
|
setup-pre-commit-hook:
|
|
ln -s -f $(ROOT_PROJECT_DIR)/pre-commit.py .git/hooks/pre-commit
|