-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
48 lines (41 loc) · 1.76 KB
/
Copy pathMakefile
File metadata and controls
48 lines (41 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# pg_ladybug Makefile — PGXS, plain C
# Links to liblbug at build time (compile-time linking).
MODULE_big = pg_ladybug
EXTENSION = pg_ladybug
DATA = pg_ladybug--1.0.sql
OBJS = $(WIN32RES) pg_ladybug.o ladybug_bridge.o ladybug_bridge_guard.o
PG_CPPFLAGS = -I.
# Search the vendored lib/ *before* any system liblbug (PG_LDFLAGS is
# prepended to LDFLAGS by PGXS, so it wins over -L paths baked into pg_config,
# e.g. an older liblbug installed under /opt/homebrew/lib).
PG_LDFLAGS = -L$(CURDIR)/lib
SHLIB_LINK = -L$(CURDIR)/lib -llbug -Wl,-rpath,$(CURDIR)/lib
PG_CONFIG ?= pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
# Link the C++ runtime: ladybug_bridge_guard.o is C++ (compiled with $(CXX))
# and PGXS links the shared library with the C driver ($(CC)), so the C++
# runtime must be pulled in explicitly. Without it the link fails with
# undefined symbols for std::exception / __cxa_throw.
ifeq ($(PORTNAME), darwin)
SHLIB_LINK += -lc++
else
SHLIB_LINK += -lstdc++
endif
# Convenience test targets (local postgres, requires liblbug.so)
# -------------------------------------------------------------------
# Quick test: build, install, run test.sql against the default cluster
.PHONY: test test-install
test: install
@echo "Running tests... (set ladybug.lib_path if liblbug is available)"
psql -U postgres -v ON_ERROR_STOP=1 -f test.sql
test-install: install
createdb -U postgres pg_ladybug_test 2>/dev/null || true
psql -U postgres -d pg_ladybug_test -v ON_ERROR_STOP=1 -f test.sql
# Download liblbug shared library (requires gh CLI or curl)
.PHONY: download-liblbug
download-liblbug:
@mkdir -p $(CURDIR)/lib
LBUG_TARGET_DIR=$(CURDIR)/lib LBUG_LIB_KIND=shared bash scripts/download-liblbug.sh
@echo "liblbug downloaded to $(CURDIR)/lib/"
@ls -la $(CURDIR)/lib/