From: Jakub Jirutka Date: Thu, 21 Jul 2022 17:38:00 +0200 Subject: [PATCH] Set SONAME and build with -fPIC --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ # Do not specify CFLAGS or LIBS on the make invocation line - specify # XCFLAGS or XLIBS instead. Make ignores any lines in the makefile that # set a variable that was set on the command line. -CFLAGS += $(XCFLAGS) -Iinclude +CFLAGS += $(XCFLAGS) -Iinclude -fPIC LIBS += $(XLIBS) -lm ifneq ($(threading),no) @@ -85,7 +85,7 @@ $(LINK_CMD) $(OUT)/%.$(SO): - $(LINK_CMD) $(LIB_LDFLAGS) $(THIRD_LIBS) $(LIBCRYPTO_LIBS) + $(LINK_CMD) $(LIB_LDFLAGS) -Wl,-soname,$(notdir $@).$(SOVERSION) $(THIRD_LIBS) $(LIBCRYPTO_LIBS) $(OUT)/%.def: $(OUT)/%.$(SO) $(GENDEF_CMD) @@ -371,8 +371,12 @@ # --- Update version string header --- -VERSION = $(shell git describe --tags) +VERSION = $(shell test -d .git \ + && git describe --tags 2>/dev/null \ + || sed -n 's/.* FZ_VERSION "\([^"]\+\)"/\1/p' include/mupdf/fitz/version.h) +SOVERSION = $(basename $(VERSION)) + version: sed -i~ -e '/FZ_VERSION /s/".*"/"'$(VERSION)'"/' include/mupdf/fitz/version.h @@ -410,7 +414,7 @@ install -m 644 include/mupdf/pdf/*.h $(DESTDIR)$(incdir)/mupdf/pdf ifneq ($(LIBS_TO_INSTALL_IN_LIB),) install -d $(DESTDIR)$(libdir) - install -m 644 $(LIBS_TO_INSTALL_IN_LIB) $(DESTDIR)$(libdir) + install -m 755 $(LIBS_TO_INSTALL_IN_LIB) $(DESTDIR)$(libdir) endif install-apps: apps