Almost working libpq

develop
Jef Roosens 2021-08-28 13:53:13 +02:00
parent c912c0aa0b
commit 85cfe6290c
Signed by untrusted user: Jef Roosens
GPG Key ID: 955C0660072F691F
1 changed files with 49 additions and 6 deletions

View File

@ -1,24 +1,67 @@
PQ_VER ?= 11.12 PQ_VER ?= 11.12
SSL_VER ?= 1.1.1k SSL_VER ?= 1.1.1k
OUT_DIR ?= out/deps # This is such a lovely oneliner
# NOTE: $(dir PATH) outputs a trailing slash
OUT_DIR ?= $(dir $(abspath $(lastword $(MAKEFILE_LIST))))out/deps
# Generated variables for ease of use
PREFIX := $(OUT_DIR)/prefix
OPENSSL_DIR := $(OUT_DIR)/openssl-$(SSL_VER)
PQ_DIR := $(OUT_DIR)/postgresql-$(PQ_VER)
CORES != nproc
export CC=musl-gcc -fPIC -pie -static
export LD_LIBRARY_PATH=$(PREFIX)
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
export CC = musl-gcc -fPIC -pie -static
# TODO check for header files (openssl-dev, libpq-dev) both for Arch & Ubuntu # TODO check for header files (openssl-dev, libpq-dev) both for Arch & Ubuntu
# Create the out dir
$(shell mkdir -p "$(PREFIX)")
all: openssl all: openssl
.PHONY: all .PHONY: all
# =====OPENSSL===== # =====OPENSSL=====
# Download the source code # Download the source code & configure the project
$(OUT_DIR)/openssl-$(SSL_VER)/Configure: $(OPENSSL_DIR)/Configure:
mkdir -p '$(OUT_DIR)'
curl -sSL "https://www.openssl.org/source/openssl-$(SSL_VER).tar.gz" | \ curl -sSL "https://www.openssl.org/source/openssl-$(SSL_VER).tar.gz" | \
tar -C "$(OUT_DIR)" -xz tar -C "$(OUT_DIR)" -xz
cd "$(OPENSSL_DIR)" && \
CC="$$CC -idirafter /usr/include" ./Configure \
no-zlib \
no-shared \
--prefix="$(PREFIX)" \
--openssldir="$(PREFIX)/ssl" \
linux-x86_64
# Build OpenSSL # Build OpenSSL
openssl: $(OUT_DIR)/openssl-$(SSL_VER)/Configure openssl: $(OPENSSL_DIR)/Configure
C_INCLUDE_PATH="$(PREFIX)/include" $(MAKE) -C "$(OPENSSL_DIR)" depend
$(MAKE) -C "$(OPENSSL_DIR)" -j$(CORES)
$(MAKE) -C "$(OPENSSL_DIR)" install_sw
.PHONY: openssl .PHONY: openssl
# =====LIBPQ=====
# Download the source code & configure the project
$(PQ_DIR)/configure:
curl -sSL "https://ftp.postgresql.org/pub/source/v$(PQ_VER)/postgresql-$(PQ_VER).tar.gz" | \
tar -C "$(OUT_DIR)" -xz
cd "$(PQ_DIR)" && \
LDFLAGS="-L$(PREFIX)/lib" CFLAGS="-I$(PREFIX)/include" ./configure \
--without-readline \
--without-zlib \
--with-openssl \
--prefix="$(PREFIX)" \
--host=x86_64-unknown-linux-musl
libpq: $(PQ_DIR)/configure
make -C "$(PQ_DIR)/src/interfaces/libpq" -j$(CORES) all-static-lib
make -C "$(PQ_DIR)/src/interfaces/libpq" install install-lib-static
make -C "$(PQ_DIR)/src/bin/pg_config" -j $(CORES)
make -C "$(PQ_DIR)/src/bin/pg_config" install
.PHONY: libpq