Skip to content

Commit e89edd4

Browse files
committed
Apply PR 260 to enable building a shared library
bellard#260
1 parent a8b2d7c commit e89edd4

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,6 @@ unicode_gen
2929
run_octane
3030
run_sunspider_like
3131
libwinpthread*.dll
32+
33+
libquickjs.so.2025.04.26
34+
tags

Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ endif
3535
#CONFIG_WIN32=y
3636
# use link time optimization (smaller and faster executables but slower build)
3737
#CONFIG_LTO=y
38+
# also build libquickjs as a shared library
39+
#CONFIG_SHARED=y
3840
# consider warnings as errors (for development)
3941
#CONFIG_WERROR=y
4042
# force 32 bit build on x86_64
@@ -216,6 +218,10 @@ PROGS+=libquickjs.a
216218
ifdef CONFIG_LTO
217219
PROGS+=libquickjs.lto.a
218220
endif
221+
ifdef CONFIG_SHARED
222+
SO_VERSION=$(shell sed 's/-/./g' VERSION)
223+
PROGS+=libquickjs.so.$(SO_VERSION)
224+
endif
219225

220226
# examples
221227
ifeq ($(CROSS_PREFIX),)
@@ -307,6 +313,11 @@ endif # CONFIG_LTO
307313
libquickjs.fuzz.a: $(patsubst %.o, %.fuzz.o, $(QJS_LIB_OBJS))
308314
$(AR) rcs $@ $^
309315

316+
ifdef CONFIG_SHARED
317+
libquickjs.so.$(SO_VERSION): $(patsubst %.o, %.pic.o, $(QJS_LIB_OBJS))
318+
$(CC) -shared -Wl,-soname,$@ $(LDFLAGS) -o $@ $^
319+
endif # CONFIG_SHARED
320+
310321
repl.c: $(QJSC) repl.js
311322
$(QJSC) -s -c -o $@ -m repl.js
312323

@@ -372,6 +383,10 @@ install: all
372383
install -m644 libquickjs.a "$(DESTDIR)$(PREFIX)/lib/quickjs"
373384
ifdef CONFIG_LTO
374385
install -m644 libquickjs.lto.a "$(DESTDIR)$(PREFIX)/lib/quickjs"
386+
endif
387+
ifdef CONFIG_SHARED
388+
install -Dm755 libquickjs.so.$(SO_VERSION) "$(DESTDIR)$(PREFIX)/lib"
389+
ln -s libquickjs.so.$(SO_VERSION) "$(DESTDIR)$(PREFIX)/lib/libquickjs.so"
375390
endif
376391
mkdir -p "$(DESTDIR)$(PREFIX)/include/quickjs"
377392
install -m644 quickjs.h quickjs-libc.h "$(DESTDIR)$(PREFIX)/include/quickjs"

0 commit comments

Comments
 (0)