mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-07-26 12:45:20 +03:00
56 lines
2 KiB
Diff
56 lines
2 KiB
Diff
From 788323f6f309bf0a9b20a2b3b60edac1e66e1a6f Mon Sep 17 00:00:00 2001
|
|
From: Jakub Jirutka <jakub@jirutka.cz>
|
|
Date: Tue, 6 Apr 2021 23:05:17 +0200
|
|
Subject: [PATCH] Build also as a shared library
|
|
|
|
---
|
|
Makefile | 13 ++++++++++++-
|
|
1 file changed, 12 insertions(+), 1 deletion(-)
|
|
|
|
Upstream-Issue: https://github.com/pganalyze/libpg_query/pull/100
|
|
|
|
diff --git a/Makefile b/Makefile
|
|
index 3ef335b..bf63e01 100644
|
|
--- a/Makefile
|
|
+++ b/Makefile
|
|
@@ -1,13 +1,21 @@
|
|
root_dir := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
|
+word-dot = $(word $2,$(subst ., ,$1))
|
|
|
|
TARGET = pg_query
|
|
ARLIB = lib$(TARGET).a
|
|
+SOLIB = lib$(TARGET).so
|
|
PGDIR = $(root_dir)/tmp/postgres
|
|
PGDIRBZ2 = $(root_dir)/tmp/postgres.tar.bz2
|
|
|
|
PG_VERSION = 13.2
|
|
+PG_VERSION_MAJOR = $(call word-dot,$(PG_VERSION),1)
|
|
PROTOC_VERSION = 3.14.0
|
|
|
|
+VERSION = 2.0.4
|
|
+VERSION_MAJOR = $(call word-dot,$(VERSION),1)
|
|
+
|
|
+SONAME = $(SOLIB).$(shell printf '%02d%02d' $(PG_VERSION_MAJOR) $(VERSION_MAJOR))
|
|
+
|
|
SRC_FILES := $(wildcard src/*.c src/postgres/*.c) vendor/protobuf-c/protobuf-c.c vendor/xxhash/xxhash.c protobuf/pg_query.pb-c.c
|
|
NOT_OBJ_FILES := src/pg_query_enum_defs.o src/pg_query_fingerprint_defs.o src/pg_query_fingerprint_conds.o src/pg_query_outfuncs_defs.o src/pg_query_outfuncs_conds.o src/pg_query_readfuncs_defs.o src/pg_query_readfuncs_conds.o src/postgres/guc-file.o src/postgres/scan.o src/pg_query_json_helper.o
|
|
OBJ_FILES := $(filter-out $(NOT_OBJ_FILES), $(SRC_FILES:.c=.o))
|
|
@@ -74,7 +82,7 @@ endif
|
|
|
|
all: examples test build
|
|
|
|
-build: $(ARLIB)
|
|
+build: $(ARLIB) $(SOLIB)
|
|
|
|
clean:
|
|
-@ $(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) $(EXAMPLES) $(TESTS)
|
|
@@ -146,6 +154,9 @@ extract_source: $(PGDIR)
|
|
$(ARLIB): $(OBJ_FILES) Makefile
|
|
@$(AR) $@ $(OBJ_FILES)
|
|
|
|
+$(SOLIB): $(OBJ_FILES) Makefile
|
|
+ @$(CC) $(CFLAGS) -shared -Wl,-soname,$(SONAME) $(LDFLAGS) -o $@ $(OBJ_FILES) $(LIBS)
|
|
+
|
|
protobuf/pg_query.pb-c.c protobuf/pg_query.pb-c.h: protobuf/pg_query.proto
|
|
ifneq ($(shell which protoc-gen-c), )
|
|
protoc --c_out=. protobuf/pg_query.proto
|