Skip to content

Commit 92a1884

Browse files
committed
fix: compilation with standard PGXS target
Using the EXTENSION variable implicitly requires a .control file. Also ensure `all` is the default target.
1 parent cea7ab6 commit 92a1884

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

Makefile

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,11 @@ ifeq ($(COVERAGE), 1)
1717
PG_CFLAGS += --coverage
1818
endif
1919

20-
EXTENSION = supautils
21-
MODULE_big = $(EXTENSION)
20+
MODULE_big = supautils
2221

2322
SRC_DIR = src
24-
BUILD_DIR ?= build
2523

2624
SRC = $(wildcard src/*.c)
27-
OBJS = $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o, $(SRC))
2825

2926
PG_VERSION = $(strip $(shell $(PG_CONFIG) --version | $(GREP) -oP '(?<=PostgreSQL )[0-9]+'))
3027
# 0 is true
@@ -56,6 +53,8 @@ EXTRA_CLEAN = $(GENERATED_OUT)
5653

5754
PGXS := $(shell $(PG_CONFIG) --pgxs)
5855

56+
.DEFAULT_GOAL := all
57+
5958
ifeq ($(OS), Linux)
6059
DL_SUFFIX=so
6160
else ifeq ($(OS), Darwin)
@@ -68,7 +67,15 @@ else
6867
DL_SUFFIX=dylib
6968
endif
7069

71-
build: $(BUILD_DIR)/$(EXTENSION).$(DL_SUFFIX) test/init.conf
70+
PG_CPPFLAGS := $(CPPFLAGS) -DTEST=1
71+
72+
ifdef BUILD_DIR
73+
OBJS = $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o, $(SRC))
74+
else
75+
OBJS = $(patsubst $(SRC_DIR)/%.c, src/%.o, $(SRC)) # if no BUILD_DIR, just build on src so standard PGXS `make` works
76+
endif
77+
78+
build: $(BUILD_DIR)/$(MODULE_big).$(DL_SUFFIX) test/init.conf
7279

7380
.PHONY: test/init.conf
7481
test/init.conf: test/init.conf.in
@@ -82,16 +89,14 @@ else
8289
$? > $@
8390
endif
8491

85-
PG_CPPFLAGS := $(CPPFLAGS) -DTEST=1
86-
8792
$(BUILD_DIR)/.gitignore:
8893
mkdir -p $(BUILD_DIR)
8994
echo "*" > $(BUILD_DIR)/.gitignore
9095

9196
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c $(BUILD_DIR)/.gitignore
9297
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
9398

94-
$(BUILD_DIR)/$(EXTENSION).$(DL_SUFFIX): $(EXTENSION).$(DL_SUFFIX)
99+
$(BUILD_DIR)/$(MODULE_big).$(DL_SUFFIX): $(MODULE_big).$(DL_SUFFIX)
95100
mv $? $@
96101

97102
include $(PGXS)

nix/xpg.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ let
33
dep = fetchFromGitHub {
44
owner = "steve-chavez";
55
repo = "xpg";
6-
rev = "v1.3.0";
7-
sha256 = "sha256-jDELiBbnCpRXIpod7msnhMfGcrW0pR3snDQ5T81nO0I=";
6+
rev = "v1.3.2";
7+
sha256 = "sha256-ooYqMOQD9y+/87wBd33Mvbpsx+FwEMdZoibGRM4gvBk=";
88
};
99
xpg = import dep;
1010
in

0 commit comments

Comments
 (0)