diff mupdf-source/Makerules @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children 5ab937c03c27
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mupdf-source/Makerules	Mon Sep 15 11:43:07 2025 +0200
@@ -0,0 +1,395 @@
+# Configuration for the Makefile
+
+# We use $OS from environment if set.
+ifeq ($(OS),)
+  OS := $(shell uname)
+endif
+
+WARNING_CFLAGS := -Wall -Wsign-compare
+
+# Feature configuration options
+
+build_suffix :=
+
+ifeq ($(brotli),no)
+  CFLAGS += -DFZ_ENABLE_BROTLI=0
+  USE_BROTLI := no
+else
+  USE_BROTLI := yes
+endif
+
+ifeq ($(mujs),no)
+  CFLAGS += -DFZ_ENABLE_JS=0
+  USE_MUJS := no
+else
+  USE_MUJS := yes
+endif
+
+ifeq ($(html),no)
+  USE_HARFBUZZ := no
+  USE_GUMBO := no
+  CFLAGS += -DFZ_ENABLE_HTML_ENGINE=0
+  CFLAGS += -DFZ_ENABLE_HTML=0
+  CFLAGS += -DFZ_ENABLE_EPUB=0
+  CFLAGS += -DFZ_ENABLE_FB2=0
+  CFLAGS += -DFZ_ENABLE_MOBI=0
+  CFLAGS += -DFZ_ENABLE_OFFICE=0
+  CFLAGS += -DFZ_ENABLE_TXT=0
+else
+  USE_HARFBUZZ := yes
+  USE_GUMBO := yes
+endif
+
+ifeq ($(xps),no)
+  CFLAGS += -DFZ_ENABLE_XPS=0
+endif
+
+ifeq ($(svg),no)
+  CFLAGS += -DFZ_ENABLE_SVG=0
+endif
+
+ifeq ($(extract),no)
+  USE_EXTRACT := no
+  CFLAGS += -DFZ_ENABLE_DOCX_OUTPUT=0
+else
+  USE_EXTRACT := yes
+endif
+
+ifeq ($(tesseract),yes)
+  build_suffix := $(build_suffix)-tesseract
+  USE_TESSERACT := yes
+endif
+
+ifeq ($(barcode),yes)
+  build_suffix := $(build_suffix)-barcode
+  USE_ZXINGCPP := yes
+else
+  CFLAGS += -DFZ_ENABLE_BARCODE=0
+endif
+
+ifeq ($(tofu),yes)
+  build_suffix := $(build_suffix)-tofu
+  CFLAGS += -DTOFU
+endif
+
+ifeq ($(tofu_cjk),yes)
+  build_suffix := $(build_suffix)-tofu_cjk
+  CFLAGS += -DTOFU_CJK
+endif
+
+ifeq ($(tofu_cjk_ext),yes)
+  build_suffix := $(build_suffix)-tofu_cjk_ext
+  CFLAGS += -DTOFU_CJK_EXT
+endif
+
+ifeq ($(tofu_cjk_lang),yes)
+  build_suffix := $(build_suffix)-tofu_cjk_lang
+  CFLAGS += -DTOFU_CJK_LANG
+endif
+
+ifeq ($(archive),yes)
+  build_suffix := $(build_suffix)-archive
+  USE_LIBARCHIVE := yes
+endif
+
+ifeq ($(commercial),yes)
+  build_suffix := $(build_suffix)-commercial
+  CFLAGS += -DHAVE_SMARTOFFICE
+  HAVE_SMARTOFFICE := yes
+endif
+
+# System specific features
+
+ifeq ($(findstring -fembed-bitcode,$(XCFLAGS)),)
+  # clang does not support these in combination with -fembed-bitcode
+  CFLAGS += -ffunction-sections -fdata-sections
+endif
+
+ifeq ($(OS),Darwin)
+  LDREMOVEUNREACH := -Wl,-dead_strip
+  SO := dylib
+else
+  LDREMOVEUNREACH := -Wl,--gc-sections
+  SO := so
+endif
+
+SANITIZE_FLAGS += -fsanitize=address
+SANITIZE_FLAGS += -fsanitize=leak
+
+ifeq ($(shared),yes)
+  ifeq ($(findstring shared-, $(build_prefix)),)
+    override build_prefix := $(build_prefix)shared-
+  endif
+  LIB_CFLAGS = -fPIC
+  ifeq ($(OS),Darwin)
+    LIB_LDFLAGS = -dynamiclib
+  else ifeq ($(OS),wasm)
+    LIB_LDFLAGS = -shared -sSIDE_MODULE
+    EXE_LDFLAGS = -sMAIN_MODULE
+  else ifeq ($(OS),wasm-mt)
+    LIB_LDFLAGS = -shared -sSIDE_MODULE
+    EXE_LDFLAGS = -sMAIN_MODULE
+  else ifeq ($(OS),pyodide)
+    LIB_LDFLAGS = -shared -sSIDE_MODULE
+    EXE_LDFLAGS = -sMAIN_MODULE
+
+    # Pyodide's ld does not support -b so we cannot use it to create object
+    # files containing font data, so leave HAVE_OBJCOPY unset. And we need
+    # extra memory when linking.
+    LDFLAGS += -sTOTAL_MEMORY=48MB
+  else ifeq ($(OS),Linux)
+    LIB_LDFLAGS = -shared -Wl,-soname,$(notdir $@)
+  else
+    LIB_LDFLAGS = -shared
+  endif
+else
+  LIB_CFLAGS =
+  LIB_LDFLAGS =
+endif
+
+ifeq ($(build),debug)
+  CFLAGS += -pipe -g
+  LDFLAGS += -g
+else ifeq ($(build),release)
+  CFLAGS += -pipe -O2 -DNDEBUG
+  LDFLAGS += $(LDREMOVEUNREACH) -Wl,-s
+else ifeq ($(build),small)
+  CFLAGS += -pipe -Os -DNDEBUG
+  LDFLAGS += $(LDREMOVEUNREACH) -Wl,-s
+else ifeq ($(build),valgrind)
+  CFLAGS += -pipe -O2 -DNDEBUG -DPACIFY_VALGRIND
+  LDFLAGS += $(LDREMOVEUNREACH) -Wl,-s
+else ifeq ($(build),sanitize)
+  CFLAGS += -pipe -g $(SANITIZE_FLAGS)
+  LDFLAGS += -g $(SANITIZE_FLAGS)
+else ifeq ($(build),sanitize-release)
+  CFLAGS += -pipe -O2 -DNDEBUG $(SANITIZE_FLAGS)
+  LDFLAGS += $(LDREMOVEUNREACH) -Wl,-s $(SANITIZE_FLAGS)
+else ifeq ($(build),profile)
+  CFLAGS += -pipe -O2 -DNDEBUG -pg
+  LDFLAGS += -pg
+else ifeq ($(build),coverage)
+  CFLAGS += -pipe -g -pg -fprofile-arcs -ftest-coverage
+  LIBS += -lgcov
+else ifeq ($(build),native)
+  CFLAGS += -pipe -O2 -DNDEBUG -march=native
+  LDFLAGS += $(LDREMOVEUNREACH) -Wl,-s
+else ifeq ($(build),memento)
+  CFLAGS += -pipe -g -DMEMENTO -DMEMENTO_MUPDF_HACKS
+  LDFLAGS += -g -rdynamic
+  ifneq ($(HAVE_LIBDL),no)
+    CFLAGS += -DHAVE_LIBDL
+    ifeq ($(OS),OpenBSD)
+      LIBS += -L /usr/local/lib -l execinfo
+    else
+      LIBS += -ldl
+    endif
+  endif
+else ifeq ($(build),gperf)
+  CFLAGS += -pipe -O2 -DNDEBUG -DGPERF
+  LIBS += -lprofiler
+else
+  $(error unknown build setting: '$(build)')
+endif
+
+# Default system libraries
+SYS_FREETYPE_LIBS := -lfreetype2
+SYS_HARFBUZZ_LIBS := -lharfbuzz
+SYS_JBIG2DEC_LIBS := -ljbig2dec
+SYS_JPEGXR_LIBS := -ljpegxr
+SYS_LCMS2_LIBS := -llcms2
+SYS_LIBJPEG_LIBS := -ljpeg
+SYS_MUJS_LIBS := -lmujs
+SYS_OPENJPEG_LIBS := -lopenjp2
+SYS_ZLIB_LIBS := -lz
+SYS_BROTLI_LIBS := -lbrotlidec -lbrotlienc
+SYS_TESSERACT_LIBS := -ltesseract
+SYS_LEPTONICA_LIBS := -llept
+SYS_LIBARCHIVE_LIBS := -larchive
+SYS_ZXINGCPP_LIBS := -lzxing-cpp -lzint
+
+ifneq "$(CLUSTER)" ""
+  CFLAGS += -DCLUSTER
+endif
+
+ifeq ($(OS),Darwin)
+  HAVE_GLUT := yes
+  SYS_GLUT_CFLAGS := -Wno-deprecated-declarations
+  SYS_GLUT_LIBS := -framework GLUT -framework OpenGL
+  CC = xcrun cc
+  AR = xcrun ar
+  LD = xcrun ld
+  RANLIB = xcrun ranlib
+
+  ifneq ($(ARCHFLAGS),)
+    $(warning "MacOS with ARCHFLAGS set. Assuming we are building for arm64, and setting HAVE_LIBCRYPTO to no.")
+    HAVE_LIBCRYPTO := no
+  else ifeq (, $(shell command -v pkg-config))
+    $(warning "No pkg-config found, install it for proper integration of libcrypto")
+  else
+    HAVE_LIBCRYPTO := $(shell pkg-config --exists 'libcrypto >= 1.1.0' && echo yes)
+    ifeq ($(HAVE_LIBCRYPTO),yes)
+      LIBCRYPTO_CFLAGS := $(shell pkg-config --cflags libcrypto) -DHAVE_LIBCRYPTO
+      LIBCRYPTO_LIBS := $(shell pkg-config --libs libcrypto)
+    endif
+  endif
+
+else
+
+  ifeq ($(OS),Linux)
+    HAVE_OBJCOPY := yes
+  endif
+
+  ifeq ($(OS),OpenBSD)
+    LDFLAGS += -pthread
+  endif
+
+  ifeq ($(shell pkg-config --exists 'freetype2 >= 18.3.12' && echo yes),yes)
+    SYS_FREETYPE_CFLAGS := $(shell pkg-config --cflags freetype2)
+    SYS_FREETYPE_LIBS := $(shell pkg-config --libs freetype2)
+  endif
+  ifeq ($(shell pkg-config --exists 'gumbo >= 0.10.0' && echo yes),yes)
+    SYS_GUMBO_CFLAGS := $(shell pkg-config --cflags gumbo)
+    SYS_GUMBO_LIBS := $(shell pkg-config --libs gumbo)
+  endif
+  ifeq ($(shell pkg-config --exists 'harfbuzz >= 2.0.0' && echo yes),yes)
+    SYS_HARFBUZZ_CFLAGS := $(shell pkg-config --cflags harfbuzz)
+    SYS_HARFBUZZ_LIBS := $(shell pkg-config --libs harfbuzz)
+  endif
+  ifeq ($(shell pkg-config --exists lcms2 && echo yes),yes)
+    SYS_LCMS2_CFLAGS := $(shell pkg-config --cflags lcms2)
+    SYS_LCMS2_LIBS := $(shell pkg-config --libs lcms2)
+  endif
+  ifeq ($(shell pkg-config --exists libjpeg && echo yes),yes)
+    SYS_LIBJPEG_CFLAGS := $(shell pkg-config --cflags libjpeg)
+    SYS_LIBJPEG_LIBS := $(shell pkg-config --libs libjpeg)
+  endif
+  ifeq ($(shell pkg-config --exists 'libopenjp2 >= 2.1.0' && echo yes),yes)
+    SYS_OPENJPEG_CFLAGS := $(shell pkg-config --cflags libopenjp2)
+    SYS_OPENJPEG_LIBS := $(shell pkg-config --libs libopenjp2)
+  endif
+  ifeq ($(shell pkg-config --exists 'zlib >= 1.2.6' && echo yes),yes)
+    SYS_ZLIB_CFLAGS := $(shell pkg-config --cflags zlib)
+    SYS_ZLIB_LIBS := $(shell pkg-config --libs zlib)
+  endif
+  ifeq ($(shell pkg-config --exists 'libbrotlidec libbrotlienc >= 0.6.0' && echo yes),yes)
+    SYS_BROTLI_CFLAGS := $(shell pkg-config --cflags libbrotlidec libbrotlienc)
+    SYS_BROTLI_LIBS := $(shell pkg-config --libs libbrotlidec libbrotlienc)
+  endif
+
+  HAVE_SYS_LEPTONICA := $(shell pkg-config --exists 'lept >= 1.7.4' && echo yes)
+  ifeq ($(HAVE_SYS_LEPTONICA),yes)
+    SYS_LEPTONICA_CFLAGS := $(shell pkg-config --cflags lept)
+    SYS_LEPTONICA_LIBS := $(shell pkg-config --libs lept)
+  endif
+
+  HAVE_SYS_TESSERACT := $(shell pkg-config --exists 'tesseract >= 4.0.0' && echo yes)
+  ifeq ($(HAVE_SYS_TESSERACT),yes)
+    SYS_TESSERACT_CFLAGS := $(shell pkg-config --cflags tesseract)
+    SYS_TESSERACT_LIBS := $(shell pkg-config --libs tesseract)
+  endif
+
+  HAVE_SYS_LIBARCHIVE := $(shell pkg-config --exists 'libarchive' && echo yes)
+  ifeq ($(HAVE_SYS_LIBARCHIVE),yes)
+    SYS_LIBARCHIVE_CFLAGS := $(shell pkg-config --cflags libarchive)
+    SYS_LIBARCHIVE_LIBS := $(shell pkg-config --libs libarchive)
+  endif
+
+  HAVE_SYS_ZXINGCPP := $(shell pkg-config --exists 'zxing >= 2.0.0' && echo yes)
+  ifeq ($(HAVE_SYS_ZXINGCPP),yes)
+    SYS_ZXINGCPP_CFLAGS := $(shell pkg-config --cflags zxing)
+    SYS_ZXINGCPP_LIBS := $(shell pkg-config --libs zxing)
+  endif
+
+  HAVE_SYS_CURL := $(shell pkg-config --exists libcurl && echo yes)
+  ifeq ($(HAVE_SYS_CURL),yes)
+    SYS_CURL_CFLAGS := $(shell pkg-config --cflags libcurl)
+    SYS_CURL_LIBS := $(shell pkg-config --libs libcurl)
+  endif
+
+  ifeq ($(HAVE_GLUT),)
+    HAVE_GLUT := $(shell pkg-config --exists gl x11 xrandr && echo yes)
+  endif
+  ifeq ($(HAVE_GLUT),yes)
+    SYS_GL_CFLAGS := $(shell pkg-config --cflags gl x11 xrandr)
+    SYS_GL_LIBS := $(shell pkg-config --libs gl x11 xrandr)
+    ifeq ($(shell pkg-config --exists glut && echo yes),yes)
+      SYS_GLUT_CFLAGS := $(shell pkg-config --cflags glut)
+      SYS_GLUT_LIBS := $(shell pkg-config --libs glut)
+    else
+      SYS_GLUT_CFLAGS :=
+      SYS_GLUT_LIBS := -lglut
+    endif
+  endif
+
+  ifeq ($(HAVE_X11),)
+    HAVE_X11 := $(shell pkg-config --exists x11 xext && echo yes)
+  endif
+  ifeq ($(HAVE_X11),yes)
+    X11_CFLAGS := $(shell pkg-config --cflags x11 xext)
+    X11_LIBS := $(shell pkg-config --libs x11 xext)
+  endif
+
+  ifeq ($(HAVE_LIBCRYPTO),)
+    HAVE_LIBCRYPTO := $(shell pkg-config --exists 'libcrypto >= 1.1.0' && echo yes)
+  endif
+  ifeq ($(HAVE_LIBCRYPTO),yes)
+    LIBCRYPTO_CFLAGS := $(shell pkg-config --cflags libcrypto) -DHAVE_LIBCRYPTO
+    LIBCRYPTO_LIBS := $(shell pkg-config --libs libcrypto)
+  endif
+
+  HAVE_PTHREAD := yes
+  ifeq ($(HAVE_PTHREAD),yes)
+    PTHREAD_CFLAGS :=
+    PTHREAD_LIBS := -lpthread
+  endif
+
+endif
+
+# The following section has various cross compilation configurations.
+#
+# Invoke these as:
+#      make OS=wasm
+#
+# This does rely on the generated directory being populated with the font files.
+# Run 'make generate' before doing the cross compile.
+
+ifeq "$(OS)" "wasm"
+  build_prefix += wasm/
+  CC = emcc
+  CXX = em++
+  AR = emar
+  HAVE_GLUT=no
+  HAVE_X11=no
+  HAVE_OBJCOPY=no
+  HAVE_LIBCRYPTO=no
+  CFLAGS += -mno-nontrapping-fptoint
+  CFLAGS += -fwasm-exceptions
+  CFLAGS += -sSUPPORT_LONGJMP=wasm
+endif
+
+ifeq "$(OS)" "wasm-mt"
+  build_prefix += wasm-mt/
+  CC = emcc
+  CXX = em++
+  AR = emar
+  HAVE_GLUT=no
+  HAVE_X11=no
+  HAVE_OBJCOPY=no
+  HAVE_LIBCRYPTO=no
+  CFLAGS += -mno-nontrapping-fptoint
+  CFLAGS += -fwasm-exceptions
+  CFLAGS += -sSUPPORT_LONGJMP=wasm
+  CFLAGS += -pthread
+endif
+
+ifeq "$(OS)" "pyodide"
+  build_prefix += $(OS)/
+  # We use the provided $CC and $CXX.
+  AR = emar
+  HAVE_GLUT=no
+  HAVE_X11=no
+  HAVE_OBJCOPY=no
+  HAVE_LIBCRYPTO=no
+  CFLAGS += -pthread
+endif