Skip to content

Commit

Permalink
Update for compilation in linux.
Browse files Browse the repository at this point in the history
* Updates Makefile for shared library build
* Removes extraneous include file
  • Loading branch information
JerrySievert committed Oct 15, 2024
1 parent caae51d commit cb60e2b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 15 deletions.
31 changes: 17 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: lintcheck format dep deps/quickjs cleandepend cleansql docs
.PHONY: lintcheck format cleandepend cleansql docs clean test all

PLJS_VERSION = 0.8.1

Expand All @@ -7,49 +7,50 @@ PGXS := $(shell $(PG_CONFIG) --pgxs)
INCLUDEDIR := ${shell $(PG_CONFIG) --includedir}
INCLUDEDIR_SERVER := ${shell $(PG_CONFIG) --includedir-server}


CP = cp
PG_CFLAGS += -fPIC -Wall -Wextra -Wno-unused-parameter -Wno-declaration-after-statement -Wno-cast-function-type -std=c11 -DPLJS_VERSION=\"$(PLJS_VERSION)\" -g -O0
SRCS = src/pljs.c src/cache.c src/functions.c src/types.c src/params.c
OBJS = src/pljs.o src/cache.o src/functions.o src/types.o src/params.o deps/quickjs/libquickjs.a
OBJS = deps/quickjs/libquickjs.a src/pljs.o src/cache.o src/functions.o src/types.o src/params.o
MODULE_big = pljs
EXTENSION = pljs
DATA = pljs.control pljs--$(PLJS_VERSION).sql
PG_CFLAGS += -fPIC -Wall -Wextra -Wno-unused-parameter -Wno-declaration-after-statement -Wno-cast-function-type -std=c11 -DPLJS_VERSION=\"$(PLJS_VERSION)\"
SHLIB_LINK = -Ldeps/quickjs -lquickjs

REGRESS = init-extension function json jsonb json_conv types bytea context \
cursor array_spread plv8_regressions memory_limits inline composites \
trigger procedure find_function



include $(PGXS)

dep: deps/quickjs

deps/quickjs:
all: pljs--$(PLJS_VERSION).sql

deps/quickjs/libquickjs.a:
mkdir -p deps
git submodule update --init --recursive
patch -p1 <patches/01-shared-lib-build
cd deps/quickjs && make libquickjs.a

deps/quickjs/libquickjs.a: deps/quickjs
cd deps/quickjs && make
deps/quickjs/quickjs.h: deps/quickjs/libquickjs.a

format:
clang-format -i $(SRCS) src/pljs.h

%.o: %.c pljs.h deps/quickjs/libquickjs.a

pljs--$(PLJS_VERSION).sql: pljs.sql
$(CP) pljs.sql pljs--$(PLJS_VERSION).sql


lintcheck:
clang-tidy $(SRCS) -- -I$(INCLUDEDIR) -I$(INCLUDEDIR_SERVER) -I$(PWD) --std=c11

.depend:
.depend: deps/quickjs/quickjs.h
$(RM) -f .depend
$(foreach SRC,$(SRCS),$(CC) $(PG_CFLAGS) -I$(INCLUDEDIR) -I$(INCLUDEDIR_SERVER) \
$(foreach SRC,$(SRCS),$(CC) $(CFLAGS) -I$(INCLUDEDIR) -I$(INCLUDEDIR_SERVER) \
-I$(PWD) -MM -MT $(SRC:.c=.o) $(SRC) >> .depend;)

include .depend

all: pljs--$(PLJS_VERSION).sql deps/quickjs/libquickjs.a

clean: cleandepend cleansql

Expand All @@ -61,3 +62,5 @@ cleansql:

docs:
doxygen src/Doxyfile

include .depend
14 changes: 14 additions & 0 deletions patches/01-shared-lib-build
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/Makefile b/Makefile
index cf88a72..ff629db 100644
--- a/Makefile
+++ b/Makefile
@@ -56,6 +56,9 @@ CONFIG_BIGNUM=y

OBJDIR=.obj

+# force compilation to be able to be relocated
+CFLAGS += -fPIC
+
ifdef CONFIG_ASAN
OBJDIR:=$(OBJDIR)/asan
endif
1 change: 0 additions & 1 deletion src/types.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "deps/quickjs/quickjs.h"

#include "pljs.h"
#include <sys/syslimits.h>

// helper functions that should really exist as part of quickjs.
static JSClassID JS_CLASS_OBJECT = 1;
Expand Down

0 comments on commit cb60e2b

Please sign in to comment.