-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile.macos
More file actions
72 lines (53 loc) · 1.96 KB
/
Copy pathMakefile.macos
File metadata and controls
72 lines (53 loc) · 1.96 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# pgraft Makefile for macOS
# PostgreSQL extension using etcd-io/raft for distributed consensus
MODULE_big = pgraft
OBJS = src/pgraft.o src/pgraft_core.o src/pgraft_go.o src/pgraft_state.o src/pgraft_log.o src/pgraft_kv.o src/pgraft_kv_sql.o src/pgraft_sql.o src/pgraft_guc.o src/pgraft_util.o
EXTENSION = pgraft
DATA = pgraft--1.0.sql
PGFILEDESC = "pgraft - PostgreSQL extension with etcd-io/raft integration"
# PostgreSQL configuration - must be provided or defaults to pg_config in PATH
# Usage: make -f Makefile.macos PG_CONFIG=/path/to/pg_config
PG_CONFIG ?= pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
# Compiler flags
CFLAGS += -std=c99 -Wall -Wextra -Werror
CFLAGS += -I./include
# Override the default CFLAGS to ensure our include path is used
override CFLAGS += -I./include
# Extension-specific linker flags (macOS)
PG_LIBDIR := $(shell $(PG_CONFIG) --libdir)
SHLIB_LINK += -lpthread -lm -L$(PG_LIBDIR)
# Go Raft library (macOS uses .dylib)
GO_RAFT_LIB = src/pgraft_go.dylib
# Get PostgreSQL include paths for CGO
PG_INCLUDEDIR := $(shell $(PG_CONFIG) --includedir)
PG_INCLUDEDIR_SERVER := $(shell $(PG_CONFIG) --includedir-server)
# Build Go Raft library with CGO flags
$(GO_RAFT_LIB): src/pgraft_go.go src/go.mod
cd src && go mod tidy
cd src && CGO_ENABLED=1 CGO_CFLAGS="-I$(PG_INCLUDEDIR) -I$(PG_INCLUDEDIR_SERVER)" CGO_LDFLAGS="-L$(PG_LIBDIR)" go build -buildmode=c-shared -o pgraft_go.dylib pgraft_go.go
# Dependencies
$(OBJS): $(GO_RAFT_LIB)
# Clean target
clean: clean-extra
clean-extra:
rm -f src/*.o
rm -f src/pgraft_go.dylib
rm -f src/pgraft_go.h
# Installation
DESTDIR ?=
install: install-data install-go-lib
install-go-lib: $(GO_RAFT_LIB)
$(INSTALL_SHLIB) src/pgraft_go.dylib '$(DESTDIR)$(pkglibdir)/pgraft_go.dylib'
# Development flags
ifeq ($(DEBUG),1)
CFLAGS += -g -O0 -DDEBUG
else
CFLAGS += -O2 -DNDEBUG
endif
# Test target
test: all
@echo "Running pgraft tests..."
@echo "Tests would go here"
.PHONY: clean install test