Update project build process, now using PGXS

This commit is contained in:
Yorick de Wid 2020-10-24 19:14:04 +02:00
parent b9c9e61189
commit dfd227da33
5 changed files with 20 additions and 30 deletions

View File

@ -1,18 +1,13 @@
INCLUDEDIRS := -I. MODULES = iban
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
all: iban.so EXTENSION = iban
DATA = iban--1.0.0.sql
PGFILEDESC = "iban - IBAN datatype and functions"
iban.so: iban.cc PG_CXXFLAGS = -std=c++14 -fPIC
$(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)
clean: PG_LDFLAGS = -lstdc++
@$(RM) -rf *.o
@$(RM) -rf iban.so PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)

View File

@ -1,6 +1,6 @@
--- IBAN datatype and verificator -*- sql -*- --- IBAN datatype and verificator -*- sql -*-
--- ---
--- Copyright © 2016 Yorick de Wid <yorick17@outlook.com> --- Copyright © 2016-2020 Yorick de Wid <yorick17 at outlook dot com>
--- ---
--- This program is free software: you can redistribute it and/or modify --- 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 --- it under the terms of the GNU General Public License as published by

View File

@ -1,5 +1,5 @@
# iban extension # iban extension
comment = 'IBAN verification' comment = 'IBAN functionality for PostgreSQL'
default_version = '1.0.0' default_version = '1.0.0'
module_pathname = '$libdir/iban' module_pathname = '$libdir/iban'
relocatable = true relocatable = true

View File

@ -19,11 +19,11 @@
extern "C" extern "C"
{ {
#include <postgres.h>
#include <string.h> #include "postgres.h"
#include <fmgr.h> #include "utils/builtins.h"
#include <utils/builtins.h> #include "libpq/pqformat.h"
#include <libpq/pqformat.h>
} }
#include <iostream> #include <iostream>
@ -35,18 +35,12 @@ extern "C"
#include "specification.h" #include "specification.h"
#include "validate.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" extern "C"
{ {
PG_MODULE_MAGIC; 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; typedef char Iban;
} }

View File

@ -1,4 +1,5 @@
#pragma once #pragma once
#include <string> #include <string>
class Specification { class Specification {