Mercurial > hgrepos > Python2 > PyMuPDF
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 1:1d09e1dec1d9 | 2:b50eed0cc0ef |
|---|---|
| 1 # Configuration for the Makefile | |
| 2 | |
| 3 # We use $OS from environment if set. | |
| 4 ifeq ($(OS),) | |
| 5 OS := $(shell uname) | |
| 6 endif | |
| 7 | |
| 8 WARNING_CFLAGS := -Wall -Wsign-compare | |
| 9 | |
| 10 # Feature configuration options | |
| 11 | |
| 12 build_suffix := | |
| 13 | |
| 14 ifeq ($(brotli),no) | |
| 15 CFLAGS += -DFZ_ENABLE_BROTLI=0 | |
| 16 USE_BROTLI := no | |
| 17 else | |
| 18 USE_BROTLI := yes | |
| 19 endif | |
| 20 | |
| 21 ifeq ($(mujs),no) | |
| 22 CFLAGS += -DFZ_ENABLE_JS=0 | |
| 23 USE_MUJS := no | |
| 24 else | |
| 25 USE_MUJS := yes | |
| 26 endif | |
| 27 | |
| 28 ifeq ($(html),no) | |
| 29 USE_HARFBUZZ := no | |
| 30 USE_GUMBO := no | |
| 31 CFLAGS += -DFZ_ENABLE_HTML_ENGINE=0 | |
| 32 CFLAGS += -DFZ_ENABLE_HTML=0 | |
| 33 CFLAGS += -DFZ_ENABLE_EPUB=0 | |
| 34 CFLAGS += -DFZ_ENABLE_FB2=0 | |
| 35 CFLAGS += -DFZ_ENABLE_MOBI=0 | |
| 36 CFLAGS += -DFZ_ENABLE_OFFICE=0 | |
| 37 CFLAGS += -DFZ_ENABLE_TXT=0 | |
| 38 else | |
| 39 USE_HARFBUZZ := yes | |
| 40 USE_GUMBO := yes | |
| 41 endif | |
| 42 | |
| 43 ifeq ($(xps),no) | |
| 44 CFLAGS += -DFZ_ENABLE_XPS=0 | |
| 45 endif | |
| 46 | |
| 47 ifeq ($(svg),no) | |
| 48 CFLAGS += -DFZ_ENABLE_SVG=0 | |
| 49 endif | |
| 50 | |
| 51 ifeq ($(extract),no) | |
| 52 USE_EXTRACT := no | |
| 53 CFLAGS += -DFZ_ENABLE_DOCX_OUTPUT=0 | |
| 54 else | |
| 55 USE_EXTRACT := yes | |
| 56 endif | |
| 57 | |
| 58 ifeq ($(tesseract),yes) | |
| 59 build_suffix := $(build_suffix)-tesseract | |
| 60 USE_TESSERACT := yes | |
| 61 endif | |
| 62 | |
| 63 ifeq ($(barcode),yes) | |
| 64 build_suffix := $(build_suffix)-barcode | |
| 65 USE_ZXINGCPP := yes | |
| 66 else | |
| 67 CFLAGS += -DFZ_ENABLE_BARCODE=0 | |
| 68 endif | |
| 69 | |
| 70 ifeq ($(tofu),yes) | |
| 71 build_suffix := $(build_suffix)-tofu | |
| 72 CFLAGS += -DTOFU | |
| 73 endif | |
| 74 | |
| 75 ifeq ($(tofu_cjk),yes) | |
| 76 build_suffix := $(build_suffix)-tofu_cjk | |
| 77 CFLAGS += -DTOFU_CJK | |
| 78 endif | |
| 79 | |
| 80 ifeq ($(tofu_cjk_ext),yes) | |
| 81 build_suffix := $(build_suffix)-tofu_cjk_ext | |
| 82 CFLAGS += -DTOFU_CJK_EXT | |
| 83 endif | |
| 84 | |
| 85 ifeq ($(tofu_cjk_lang),yes) | |
| 86 build_suffix := $(build_suffix)-tofu_cjk_lang | |
| 87 CFLAGS += -DTOFU_CJK_LANG | |
| 88 endif | |
| 89 | |
| 90 ifeq ($(archive),yes) | |
| 91 build_suffix := $(build_suffix)-archive | |
| 92 USE_LIBARCHIVE := yes | |
| 93 endif | |
| 94 | |
| 95 ifeq ($(commercial),yes) | |
| 96 build_suffix := $(build_suffix)-commercial | |
| 97 CFLAGS += -DHAVE_SMARTOFFICE | |
| 98 HAVE_SMARTOFFICE := yes | |
| 99 endif | |
| 100 | |
| 101 # System specific features | |
| 102 | |
| 103 ifeq ($(findstring -fembed-bitcode,$(XCFLAGS)),) | |
| 104 # clang does not support these in combination with -fembed-bitcode | |
| 105 CFLAGS += -ffunction-sections -fdata-sections | |
| 106 endif | |
| 107 | |
| 108 ifeq ($(OS),Darwin) | |
| 109 LDREMOVEUNREACH := -Wl,-dead_strip | |
| 110 SO := dylib | |
| 111 else | |
| 112 LDREMOVEUNREACH := -Wl,--gc-sections | |
| 113 SO := so | |
| 114 endif | |
| 115 | |
| 116 SANITIZE_FLAGS += -fsanitize=address | |
| 117 SANITIZE_FLAGS += -fsanitize=leak | |
| 118 | |
| 119 ifeq ($(shared),yes) | |
| 120 ifeq ($(findstring shared-, $(build_prefix)),) | |
| 121 override build_prefix := $(build_prefix)shared- | |
| 122 endif | |
| 123 LIB_CFLAGS = -fPIC | |
| 124 ifeq ($(OS),Darwin) | |
| 125 LIB_LDFLAGS = -dynamiclib | |
| 126 else ifeq ($(OS),wasm) | |
| 127 LIB_LDFLAGS = -shared -sSIDE_MODULE | |
| 128 EXE_LDFLAGS = -sMAIN_MODULE | |
| 129 else ifeq ($(OS),wasm-mt) | |
| 130 LIB_LDFLAGS = -shared -sSIDE_MODULE | |
| 131 EXE_LDFLAGS = -sMAIN_MODULE | |
| 132 else ifeq ($(OS),pyodide) | |
| 133 LIB_LDFLAGS = -shared -sSIDE_MODULE | |
| 134 EXE_LDFLAGS = -sMAIN_MODULE | |
| 135 | |
| 136 # Pyodide's ld does not support -b so we cannot use it to create object | |
| 137 # files containing font data, so leave HAVE_OBJCOPY unset. And we need | |
| 138 # extra memory when linking. | |
| 139 LDFLAGS += -sTOTAL_MEMORY=48MB | |
| 140 else ifeq ($(OS),Linux) | |
| 141 LIB_LDFLAGS = -shared -Wl,-soname,$(notdir $@) | |
| 142 else | |
| 143 LIB_LDFLAGS = -shared | |
| 144 endif | |
| 145 else | |
| 146 LIB_CFLAGS = | |
| 147 LIB_LDFLAGS = | |
| 148 endif | |
| 149 | |
| 150 ifeq ($(build),debug) | |
| 151 CFLAGS += -pipe -g | |
| 152 LDFLAGS += -g | |
| 153 else ifeq ($(build),release) | |
| 154 CFLAGS += -pipe -O2 -DNDEBUG | |
| 155 LDFLAGS += $(LDREMOVEUNREACH) -Wl,-s | |
| 156 else ifeq ($(build),small) | |
| 157 CFLAGS += -pipe -Os -DNDEBUG | |
| 158 LDFLAGS += $(LDREMOVEUNREACH) -Wl,-s | |
| 159 else ifeq ($(build),valgrind) | |
| 160 CFLAGS += -pipe -O2 -DNDEBUG -DPACIFY_VALGRIND | |
| 161 LDFLAGS += $(LDREMOVEUNREACH) -Wl,-s | |
| 162 else ifeq ($(build),sanitize) | |
| 163 CFLAGS += -pipe -g $(SANITIZE_FLAGS) | |
| 164 LDFLAGS += -g $(SANITIZE_FLAGS) | |
| 165 else ifeq ($(build),sanitize-release) | |
| 166 CFLAGS += -pipe -O2 -DNDEBUG $(SANITIZE_FLAGS) | |
| 167 LDFLAGS += $(LDREMOVEUNREACH) -Wl,-s $(SANITIZE_FLAGS) | |
| 168 else ifeq ($(build),profile) | |
| 169 CFLAGS += -pipe -O2 -DNDEBUG -pg | |
| 170 LDFLAGS += -pg | |
| 171 else ifeq ($(build),coverage) | |
| 172 CFLAGS += -pipe -g -pg -fprofile-arcs -ftest-coverage | |
| 173 LIBS += -lgcov | |
| 174 else ifeq ($(build),native) | |
| 175 CFLAGS += -pipe -O2 -DNDEBUG -march=native | |
| 176 LDFLAGS += $(LDREMOVEUNREACH) -Wl,-s | |
| 177 else ifeq ($(build),memento) | |
| 178 CFLAGS += -pipe -g -DMEMENTO -DMEMENTO_MUPDF_HACKS | |
| 179 LDFLAGS += -g -rdynamic | |
| 180 ifneq ($(HAVE_LIBDL),no) | |
| 181 CFLAGS += -DHAVE_LIBDL | |
| 182 ifeq ($(OS),OpenBSD) | |
| 183 LIBS += -L /usr/local/lib -l execinfo | |
| 184 else | |
| 185 LIBS += -ldl | |
| 186 endif | |
| 187 endif | |
| 188 else ifeq ($(build),gperf) | |
| 189 CFLAGS += -pipe -O2 -DNDEBUG -DGPERF | |
| 190 LIBS += -lprofiler | |
| 191 else | |
| 192 $(error unknown build setting: '$(build)') | |
| 193 endif | |
| 194 | |
| 195 # Default system libraries | |
| 196 SYS_FREETYPE_LIBS := -lfreetype2 | |
| 197 SYS_HARFBUZZ_LIBS := -lharfbuzz | |
| 198 SYS_JBIG2DEC_LIBS := -ljbig2dec | |
| 199 SYS_JPEGXR_LIBS := -ljpegxr | |
| 200 SYS_LCMS2_LIBS := -llcms2 | |
| 201 SYS_LIBJPEG_LIBS := -ljpeg | |
| 202 SYS_MUJS_LIBS := -lmujs | |
| 203 SYS_OPENJPEG_LIBS := -lopenjp2 | |
| 204 SYS_ZLIB_LIBS := -lz | |
| 205 SYS_BROTLI_LIBS := -lbrotlidec -lbrotlienc | |
| 206 SYS_TESSERACT_LIBS := -ltesseract | |
| 207 SYS_LEPTONICA_LIBS := -llept | |
| 208 SYS_LIBARCHIVE_LIBS := -larchive | |
| 209 SYS_ZXINGCPP_LIBS := -lzxing-cpp -lzint | |
| 210 | |
| 211 ifneq "$(CLUSTER)" "" | |
| 212 CFLAGS += -DCLUSTER | |
| 213 endif | |
| 214 | |
| 215 ifeq ($(OS),Darwin) | |
| 216 HAVE_GLUT := yes | |
| 217 SYS_GLUT_CFLAGS := -Wno-deprecated-declarations | |
| 218 SYS_GLUT_LIBS := -framework GLUT -framework OpenGL | |
| 219 CC = xcrun cc | |
| 220 AR = xcrun ar | |
| 221 LD = xcrun ld | |
| 222 RANLIB = xcrun ranlib | |
| 223 | |
| 224 ifneq ($(ARCHFLAGS),) | |
| 225 $(warning "MacOS with ARCHFLAGS set. Assuming we are building for arm64, and setting HAVE_LIBCRYPTO to no.") | |
| 226 HAVE_LIBCRYPTO := no | |
| 227 else ifeq (, $(shell command -v pkg-config)) | |
| 228 $(warning "No pkg-config found, install it for proper integration of libcrypto") | |
| 229 else | |
| 230 HAVE_LIBCRYPTO := $(shell pkg-config --exists 'libcrypto >= 1.1.0' && echo yes) | |
| 231 ifeq ($(HAVE_LIBCRYPTO),yes) | |
| 232 LIBCRYPTO_CFLAGS := $(shell pkg-config --cflags libcrypto) -DHAVE_LIBCRYPTO | |
| 233 LIBCRYPTO_LIBS := $(shell pkg-config --libs libcrypto) | |
| 234 endif | |
| 235 endif | |
| 236 | |
| 237 else | |
| 238 | |
| 239 ifeq ($(OS),Linux) | |
| 240 HAVE_OBJCOPY := yes | |
| 241 endif | |
| 242 | |
| 243 ifeq ($(OS),OpenBSD) | |
| 244 LDFLAGS += -pthread | |
| 245 endif | |
| 246 | |
| 247 ifeq ($(shell pkg-config --exists 'freetype2 >= 18.3.12' && echo yes),yes) | |
| 248 SYS_FREETYPE_CFLAGS := $(shell pkg-config --cflags freetype2) | |
| 249 SYS_FREETYPE_LIBS := $(shell pkg-config --libs freetype2) | |
| 250 endif | |
| 251 ifeq ($(shell pkg-config --exists 'gumbo >= 0.10.0' && echo yes),yes) | |
| 252 SYS_GUMBO_CFLAGS := $(shell pkg-config --cflags gumbo) | |
| 253 SYS_GUMBO_LIBS := $(shell pkg-config --libs gumbo) | |
| 254 endif | |
| 255 ifeq ($(shell pkg-config --exists 'harfbuzz >= 2.0.0' && echo yes),yes) | |
| 256 SYS_HARFBUZZ_CFLAGS := $(shell pkg-config --cflags harfbuzz) | |
| 257 SYS_HARFBUZZ_LIBS := $(shell pkg-config --libs harfbuzz) | |
| 258 endif | |
| 259 ifeq ($(shell pkg-config --exists lcms2 && echo yes),yes) | |
| 260 SYS_LCMS2_CFLAGS := $(shell pkg-config --cflags lcms2) | |
| 261 SYS_LCMS2_LIBS := $(shell pkg-config --libs lcms2) | |
| 262 endif | |
| 263 ifeq ($(shell pkg-config --exists libjpeg && echo yes),yes) | |
| 264 SYS_LIBJPEG_CFLAGS := $(shell pkg-config --cflags libjpeg) | |
| 265 SYS_LIBJPEG_LIBS := $(shell pkg-config --libs libjpeg) | |
| 266 endif | |
| 267 ifeq ($(shell pkg-config --exists 'libopenjp2 >= 2.1.0' && echo yes),yes) | |
| 268 SYS_OPENJPEG_CFLAGS := $(shell pkg-config --cflags libopenjp2) | |
| 269 SYS_OPENJPEG_LIBS := $(shell pkg-config --libs libopenjp2) | |
| 270 endif | |
| 271 ifeq ($(shell pkg-config --exists 'zlib >= 1.2.6' && echo yes),yes) | |
| 272 SYS_ZLIB_CFLAGS := $(shell pkg-config --cflags zlib) | |
| 273 SYS_ZLIB_LIBS := $(shell pkg-config --libs zlib) | |
| 274 endif | |
| 275 ifeq ($(shell pkg-config --exists 'libbrotlidec libbrotlienc >= 0.6.0' && echo yes),yes) | |
| 276 SYS_BROTLI_CFLAGS := $(shell pkg-config --cflags libbrotlidec libbrotlienc) | |
| 277 SYS_BROTLI_LIBS := $(shell pkg-config --libs libbrotlidec libbrotlienc) | |
| 278 endif | |
| 279 | |
| 280 HAVE_SYS_LEPTONICA := $(shell pkg-config --exists 'lept >= 1.7.4' && echo yes) | |
| 281 ifeq ($(HAVE_SYS_LEPTONICA),yes) | |
| 282 SYS_LEPTONICA_CFLAGS := $(shell pkg-config --cflags lept) | |
| 283 SYS_LEPTONICA_LIBS := $(shell pkg-config --libs lept) | |
| 284 endif | |
| 285 | |
| 286 HAVE_SYS_TESSERACT := $(shell pkg-config --exists 'tesseract >= 4.0.0' && echo yes) | |
| 287 ifeq ($(HAVE_SYS_TESSERACT),yes) | |
| 288 SYS_TESSERACT_CFLAGS := $(shell pkg-config --cflags tesseract) | |
| 289 SYS_TESSERACT_LIBS := $(shell pkg-config --libs tesseract) | |
| 290 endif | |
| 291 | |
| 292 HAVE_SYS_LIBARCHIVE := $(shell pkg-config --exists 'libarchive' && echo yes) | |
| 293 ifeq ($(HAVE_SYS_LIBARCHIVE),yes) | |
| 294 SYS_LIBARCHIVE_CFLAGS := $(shell pkg-config --cflags libarchive) | |
| 295 SYS_LIBARCHIVE_LIBS := $(shell pkg-config --libs libarchive) | |
| 296 endif | |
| 297 | |
| 298 HAVE_SYS_ZXINGCPP := $(shell pkg-config --exists 'zxing >= 2.0.0' && echo yes) | |
| 299 ifeq ($(HAVE_SYS_ZXINGCPP),yes) | |
| 300 SYS_ZXINGCPP_CFLAGS := $(shell pkg-config --cflags zxing) | |
| 301 SYS_ZXINGCPP_LIBS := $(shell pkg-config --libs zxing) | |
| 302 endif | |
| 303 | |
| 304 HAVE_SYS_CURL := $(shell pkg-config --exists libcurl && echo yes) | |
| 305 ifeq ($(HAVE_SYS_CURL),yes) | |
| 306 SYS_CURL_CFLAGS := $(shell pkg-config --cflags libcurl) | |
| 307 SYS_CURL_LIBS := $(shell pkg-config --libs libcurl) | |
| 308 endif | |
| 309 | |
| 310 ifeq ($(HAVE_GLUT),) | |
| 311 HAVE_GLUT := $(shell pkg-config --exists gl x11 xrandr && echo yes) | |
| 312 endif | |
| 313 ifeq ($(HAVE_GLUT),yes) | |
| 314 SYS_GL_CFLAGS := $(shell pkg-config --cflags gl x11 xrandr) | |
| 315 SYS_GL_LIBS := $(shell pkg-config --libs gl x11 xrandr) | |
| 316 ifeq ($(shell pkg-config --exists glut && echo yes),yes) | |
| 317 SYS_GLUT_CFLAGS := $(shell pkg-config --cflags glut) | |
| 318 SYS_GLUT_LIBS := $(shell pkg-config --libs glut) | |
| 319 else | |
| 320 SYS_GLUT_CFLAGS := | |
| 321 SYS_GLUT_LIBS := -lglut | |
| 322 endif | |
| 323 endif | |
| 324 | |
| 325 ifeq ($(HAVE_X11),) | |
| 326 HAVE_X11 := $(shell pkg-config --exists x11 xext && echo yes) | |
| 327 endif | |
| 328 ifeq ($(HAVE_X11),yes) | |
| 329 X11_CFLAGS := $(shell pkg-config --cflags x11 xext) | |
| 330 X11_LIBS := $(shell pkg-config --libs x11 xext) | |
| 331 endif | |
| 332 | |
| 333 ifeq ($(HAVE_LIBCRYPTO),) | |
| 334 HAVE_LIBCRYPTO := $(shell pkg-config --exists 'libcrypto >= 1.1.0' && echo yes) | |
| 335 endif | |
| 336 ifeq ($(HAVE_LIBCRYPTO),yes) | |
| 337 LIBCRYPTO_CFLAGS := $(shell pkg-config --cflags libcrypto) -DHAVE_LIBCRYPTO | |
| 338 LIBCRYPTO_LIBS := $(shell pkg-config --libs libcrypto) | |
| 339 endif | |
| 340 | |
| 341 HAVE_PTHREAD := yes | |
| 342 ifeq ($(HAVE_PTHREAD),yes) | |
| 343 PTHREAD_CFLAGS := | |
| 344 PTHREAD_LIBS := -lpthread | |
| 345 endif | |
| 346 | |
| 347 endif | |
| 348 | |
| 349 # The following section has various cross compilation configurations. | |
| 350 # | |
| 351 # Invoke these as: | |
| 352 # make OS=wasm | |
| 353 # | |
| 354 # This does rely on the generated directory being populated with the font files. | |
| 355 # Run 'make generate' before doing the cross compile. | |
| 356 | |
| 357 ifeq "$(OS)" "wasm" | |
| 358 build_prefix += wasm/ | |
| 359 CC = emcc | |
| 360 CXX = em++ | |
| 361 AR = emar | |
| 362 HAVE_GLUT=no | |
| 363 HAVE_X11=no | |
| 364 HAVE_OBJCOPY=no | |
| 365 HAVE_LIBCRYPTO=no | |
| 366 CFLAGS += -mno-nontrapping-fptoint | |
| 367 CFLAGS += -fwasm-exceptions | |
| 368 CFLAGS += -sSUPPORT_LONGJMP=wasm | |
| 369 endif | |
| 370 | |
| 371 ifeq "$(OS)" "wasm-mt" | |
| 372 build_prefix += wasm-mt/ | |
| 373 CC = emcc | |
| 374 CXX = em++ | |
| 375 AR = emar | |
| 376 HAVE_GLUT=no | |
| 377 HAVE_X11=no | |
| 378 HAVE_OBJCOPY=no | |
| 379 HAVE_LIBCRYPTO=no | |
| 380 CFLAGS += -mno-nontrapping-fptoint | |
| 381 CFLAGS += -fwasm-exceptions | |
| 382 CFLAGS += -sSUPPORT_LONGJMP=wasm | |
| 383 CFLAGS += -pthread | |
| 384 endif | |
| 385 | |
| 386 ifeq "$(OS)" "pyodide" | |
| 387 build_prefix += $(OS)/ | |
| 388 # We use the provided $CC and $CXX. | |
| 389 AR = emar | |
| 390 HAVE_GLUT=no | |
| 391 HAVE_X11=no | |
| 392 HAVE_OBJCOPY=no | |
| 393 HAVE_LIBCRYPTO=no | |
| 394 CFLAGS += -pthread | |
| 395 endif |
