From dfd227da33e53dbc001607ef9761967ce8315476 Mon Sep 17 00:00:00 2001 From: Yorick de Wid Date: Sat, 24 Oct 2020 19:14:04 +0200 Subject: [PATCH] Update project build process, now using PGXS --- Makefile | 25 ++++++++++--------------- iban--1.0.0.sql | 2 +- iban.control | 4 ++-- iban.cc => iban.cpp | 18 ++++++------------ specification.h | 1 + 5 files changed, 20 insertions(+), 30 deletions(-) rename iban.cc => iban.cpp (98%) diff --git a/Makefile b/Makefile index 5215b16..80d7400 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,13 @@ -INCLUDEDIRS := -I. -INCLUDEDIRS += -I$(shell pg_config --includedir-server) -INCLUDEDIRS += -I$(shell pg_config --includedir) -LIBDIR = -L$(shell pg_config --libdir) -# This is where the shared object should be installed -LIBINSTALL = $(shell pg_config --pkglibdir) -CFLAGS += -std=c++14 -fpic +MODULES = iban -all: iban.so +EXTENSION = iban +DATA = iban--1.0.0.sql +PGFILEDESC = "iban - IBAN datatype and functions" -iban.so: iban.cc - $(CC) $(CFLAGS) -o iban.o -c iban.cc $(INCLUDEDIRS) - $(CC) -Wl,--gc-sections -shared -o iban.so iban.o $(LIBDIR) -lpq -lm -lstdc++ - cp iban.so $(LIBINSTALL) +PG_CXXFLAGS = -std=c++14 -fPIC -clean: - @$(RM) -rf *.o - @$(RM) -rf iban.so +PG_LDFLAGS = -lstdc++ + +PG_CONFIG = pg_config +PGXS := $(shell $(PG_CONFIG) --pgxs) +include $(PGXS) diff --git a/iban--1.0.0.sql b/iban--1.0.0.sql index 5d8fd85..261ea8f 100644 --- a/iban--1.0.0.sql +++ b/iban--1.0.0.sql @@ -1,6 +1,6 @@ --- IBAN datatype and verificator -*- sql -*- --- ---- Copyright © 2016 Yorick de Wid +--- Copyright © 2016-2020 Yorick de Wid --- --- This program is free software: you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by diff --git a/iban.control b/iban.control index 9ecffc4..5aef456 100644 --- a/iban.control +++ b/iban.control @@ -1,5 +1,5 @@ # iban extension -comment = 'IBAN verification' +comment = 'IBAN functionality for PostgreSQL' default_version = '1.0.0' module_pathname = '$libdir/iban' -relocatable = true \ No newline at end of file +relocatable = true diff --git a/iban.cc b/iban.cpp similarity index 98% rename from iban.cc rename to iban.cpp index 8b3cefc..e863b65 100644 --- a/iban.cc +++ b/iban.cpp @@ -19,11 +19,11 @@ extern "C" { -#include -#include -#include -#include -#include + +#include "postgres.h" +#include "utils/builtins.h" +#include "libpq/pqformat.h" + } #include @@ -35,18 +35,12 @@ extern "C" #include "specification.h" #include "validate.h" -#define PG_RETURN_IBAN_P(x) PG_RETURN_POINTER(x) +// #define PG_RETURN_IBAN_P(x) PG_RETURN_POINTER(x) extern "C" { PG_MODULE_MAGIC; - extern Datum ibanin(PG_FUNCTION_ARGS); - extern Datum ibanout(PG_FUNCTION_ARGS); - extern Datum ibanrecv(PG_FUNCTION_ARGS); - extern Datum ibansend(PG_FUNCTION_ARGS); - extern Datum iban_validate(PG_FUNCTION_ARGS); - typedef char Iban; } diff --git a/specification.h b/specification.h index 9da6390..4eb059a 100644 --- a/specification.h +++ b/specification.h @@ -1,4 +1,5 @@ #pragma once + #include class Specification {