mupdf: fix cxx build on darwin

This commit is contained in:
Lily Foster 2024-09-18 17:58:29 -04:00 committed by Emily
parent b96572e6bc
commit 40dc82c7cd
4 changed files with 66 additions and 59 deletions

View File

@ -1,57 +0,0 @@
From 0f0ccfc01cfe72d96eafee57ec6c5107f09c7238 Mon Sep 17 00:00:00 2001
From: toonn <toonn@toonn.io>
Date: Wed, 9 Mar 2022 00:08:28 +0100
Subject: [PATCH 2/2] Add Darwin deps
---
Makerules | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/Makerules b/Makerules
index 6d52cca..a6bd0ed 100644
--- a/Makerules
+++ b/Makerules
@@ -153,6 +153,40 @@ else ifeq ($(OS),MACOS)
LIBCRYPTO_CFLAGS := $(shell pkg-config --cflags libcrypto) -DHAVE_LIBCRYPTO
LIBCRYPTO_LIBS := $(shell pkg-config --libs libcrypto)
endif
+ # Required for mupdf-gl
+ ifeq ($(shell pkg-config --exists harfbuzz && 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 libopenjp2 && 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 freetype2 && 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 && echo yes),yes)
+ SYS_GUMBO_CFLAGS := $(shell pkg-config --cflags gumbo)
+ SYS_GUMBO_LIBS := $(shell pkg-config --libs gumbo)
+ endif
+ # Required for mupdf-x11
+ HAVE_X11 := $(shell pkg-config --exists x11 xext && echo yes)
+ ifeq ($(HAVE_X11),yes)
+ X11_CFLAGS := $(shell pkg-config --cflags x11 xext)
+ X11_LIBS := $(shell pkg-config --libs x11 xext)
+ endif
+ # Required for mupdf-x11-curl
+ 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
+ HAVE_PTHREAD := yes
+ ifeq ($(HAVE_PTHREAD),yes)
+ PTHREAD_CFLAGS :=
+ PTHREAD_LIBS := -lpthread
+ endif
endif
else ifeq ($(OS),Linux)
--
2.17.2 (Apple Git-113)

View File

@ -69,8 +69,12 @@ stdenv.mkDerivation rec {
};
patches = [
./0002-Add-Darwin-deps.patch
./0003-Fix-cpp-build.patch
# Upstream makefile does not work with system deps on macOS by default, so
# we reuse the Linux section instead.
./fix-darwin-system-deps.patch
# Upstream C++ wrap script only defines fixed-sized integers on macOS but
# this is required on aarch64-linux too.
./fix-cpp-build.patch
];
postPatch = ''

View File

@ -0,0 +1,60 @@
diff --git a/Makerules b/Makerules
index f582dc061..2da5680b6 100644
--- a/Makerules
+++ b/Makerules
@@ -178,39 +178,20 @@ ifneq "$(CLUSTER)" ""
endif
ifeq ($(OS),Linux)
- LINUX_OR_OPENBSD := yes
+ LINUX_OR_OPENBSD_OR_MACOS := yes
endif
ifeq ($(OS),OpenBSD)
- LINUX_OR_OPENBSD := yes
+ LINUX_OR_OPENBSD_OR_MACOS := yes
+endif
+ifeq ($(OS),MACOS)
+ LINUX_OR_OPENBSD_OR_MACOS := yes
endif
ifeq ($(OS),MINGW)
WINDRES := windres
HAVE_WIN32 := yes
-else ifeq ($(OS),MACOS)
- 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 ($(LINUX_OR_OPENBSD),yes)
+else ifeq ($(LINUX_OR_OPENBSD_OR_MACOS),yes)
ifeq ($(OS),Linux)
HAVE_OBJCOPY := yes
@@ -274,6 +255,9 @@ else ifeq ($(LINUX_OR_OPENBSD),yes)
ifeq ($(OS),OpenBSD)
SYS_GLUT_CFLAGS := $(shell pkg-config --cflags glut gl)
SYS_GLUT_LIBS := $(shell pkg-config --libs glut gl)
+ else ifeq ($(OS),MACOS)
+ SYS_GLUT_CFLAGS := -Wno-deprecated-declarations
+ SYS_GLUT_LIBS := -framework GLUT -framework OpenGL
else
SYS_GLUT_CFLAGS :=
SYS_GLUT_LIBS := -lglut -lGL