Skip to content

Commit 7fb87ce

Browse files
authored
[LibGD] : add Fontconfig_jll, FreeType2_jll, libheif_jll deps - switch to CMake (#11604)
* [LibGD] add `fontconfig` and `freetype` deps * rename * rename * try local libheif * build passing * restore libheif_jll * cleanup * cleanup * cleanup * revert gnuplot changes * cleanup * newline * consistency * up * switch to archive * up * older cmake * fix * constain deps * version * floating deps * restore and bump compat bounds * change version number * fix specifier * add patch and license * remove helper
1 parent bda117e commit 7fb87ce

File tree

2 files changed

+198
-19
lines changed

2 files changed

+198
-19
lines changed

L/LibGD/build_tarballs.jl

Lines changed: 56 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,57 @@
11
using BinaryBuilder, Pkg
22

3+
function yggdrasil_version(version::VersionNumber, offset::VersionNumber)
4+
max_offset = v"10.100.1000"
5+
@assert offset < max_offset
6+
VersionNumber(
7+
max_offset.major * version.major + offset.major,
8+
max_offset.minor * version.minor + offset.minor,
9+
max_offset.patch * version.patch + offset.patch
10+
)
11+
end
12+
313
name = "LibGD"
414
version = v"2.3.3"
15+
ygg_offset = v"0.0.0" # NOTE: increase on new build, reset on new upstream version
16+
ygg_version = yggdrasil_version(version, ygg_offset)
517

618
# Collection of sources required to complete build
719
sources = [
8-
GitSource("https://github.com/libgd/libgd.git",
9-
"b5319a41286107b53daa0e08e402aa1819764bdc")
20+
ArchiveSource("https://github.com/libgd/libgd/releases/download/gd-$version/libgd-$version.tar.gz",
21+
"dd3f1f0bb016edcc0b2d082e8229c822ad1d02223511997c80461481759b1ed2"),
22+
DirectorySource("./bundled")
1023
]
1124

1225
# Bash recipe for building across all platforms
1326
script = raw"""
14-
cd $WORKSPACE/srcdir/libgd
27+
cd $WORKSPACE/srcdir/libgd-*
28+
29+
# for release 2.3.3, remove in 2.3.4 (adapted from https://github.com/libgd/libgd/pull/828)
30+
atomic_patch -p1 -l ${WORKSPACE}/srcdir/patches/allow-mingw-for-webpng.patch
31+
32+
mkdir build
33+
34+
args+=(-DCMAKE_TOOLCHAIN_FILE=$CMAKE_TARGET_TOOLCHAIN)
35+
args+=(-DCMAKE_INSTALL_PREFIX=$prefix)
36+
args+=(-DCMAKE_BUILD_TYPE=RELEASE)
37+
38+
args+=(-DENABLE_FONTCONFIG=1)
39+
args+=(-DENABLE_GD_FORMATS=1)
40+
args+=(-DENABLE_FREETYPE=1)
41+
args+=(-DENABLE_ICONV=1)
42+
args+=(-DENABLE_JPEG=1)
43+
args+=(-DENABLE_TIFF=1)
44+
args+=(-DENABLE_HEIF=1)
45+
args+=(-DENABLE_AVIF=0) # FIXME: fails
46+
args+=(-DENABLE_WEBP=1)
47+
args+=(-DENABLE_PNG=1)
48+
49+
cmake -B build -S . "${args[@]}"
1550
16-
./bootstrap.sh
17-
./configure --prefix=${prefix} --build=${MACHTYPE} --host=${target} --with-png --with-jpeg --with-tiff --with-webp --with-zlib
51+
cmake --build build --parallel $nproc
52+
cmake --install build
1853
19-
# For some reasons (something must be off in the configure script), on some
20-
# platforms the build system tries to use iconv but without adding the `-liconv`
21-
# flag. Give a hint to make to use the right flag everywhere
22-
make -j${nproc} LIBICONV="-liconv" LTLIBICONV="-liconv"
23-
make install
54+
install_license COPYING
2455
"""
2556

2657
# These are the platforms we will build for by default, unless further
@@ -44,15 +75,21 @@ products = [
4475

4576
# Dependencies that must be installed before this package can be built
4677
dependencies = [
47-
Dependency(PackageSpec(name="JpegTurbo_jll", uuid="aacddb02-875f-59d6-b918-886e6ef4fbf8")),
48-
Dependency(PackageSpec(name="Zlib_jll", uuid="83775a58-1f1d-513f-b197-d71354ab007a")),
49-
Dependency(PackageSpec(name="libpng_jll", uuid="b53b4c65-9356-5827-b1ea-8c7a1a84506f")),
50-
# TODO: v4.3.0 is available, use that next time
51-
Dependency("Libtiff_jll"; compat="~4.5.1"),
52-
BuildDependency(PackageSpec(name="Xorg_xorgproto_jll", uuid = "c4d99508-4286-5418-9131-c86396af500b")),
53-
Dependency(PackageSpec(name="Libiconv_jll", uuid = "94ce4f54-9a6c-5748-9c1c-f9c7231a4531")),
54-
Dependency("libwebp_jll"; compat="1.2.4"),
78+
BuildDependency("Xorg_xorgproto_jll"),
79+
Dependency("Fontconfig_jll"),
80+
Dependency("FreeType2_jll"),
81+
Dependency("Libtiff_jll"; compat="~4.7.1"),
82+
Dependency("libwebp_jll"; compat="1.5.0"),
83+
Dependency("JpegTurbo_jll"),
84+
Dependency("Libiconv_jll"),
85+
Dependency("libheif_jll"),
86+
# Dependency("libavif_jll"), # FIXME: fails
87+
Dependency("libpng_jll"),
88+
Dependency("Zlib_jll"),
5589
]
5690

5791
# Build the tarballs, and possibly a `build.jl` as well.
58-
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; julia_compat="1.6")
92+
build_tarballs(
93+
ARGS, name, ygg_version, sources, script, platforms, products, dependencies;
94+
julia_compat="1.6", preferred_gcc_version = v"9"
95+
)
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
diff -ur libgd/cmake/modules/FindFontConfig.cmake libgd-patched/cmake/modules/FindFontConfig.cmake
2+
--- libgd/cmake/modules/FindFontConfig.cmake 2025-07-06 13:20:45.358034790 +0200
3+
+++ libgd-patched/cmake/modules/FindFontConfig.cmake 2025-07-06 13:21:19.111383452 +0200
4+
@@ -37,11 +37,11 @@
5+
6+
# use pkg-config to get the directories and then use these values
7+
# in the FIND_PATH() and FIND_LIBRARY() calls
8+
-if( NOT WIN32 )
9+
+if( NOT MSVC )
10+
find_package(PkgConfig)
11+
12+
pkg_check_modules(FONTCONFIG_PKG QUIET fontconfig)
13+
-endif( NOT WIN32 )
14+
+endif( NOT MSVC )
15+
16+
FIND_PATH(FONTCONFIG_INCLUDE_DIR NAMES fontconfig/fontconfig.h
17+
PATHS
18+
diff -ur libgd/cmake/modules/FindHEIF.cmake libgd-patched/cmake/modules/FindHEIF.cmake
19+
--- libgd/cmake/modules/FindHEIF.cmake 2025-07-06 13:20:45.358034790 +0200
20+
+++ libgd-patched/cmake/modules/FindHEIF.cmake 2025-07-06 13:21:19.112383432 +0200
21+
@@ -41,10 +41,10 @@
22+
23+
# use pkg-config to get the directories and then use these values
24+
# in the FIND_PATH() and FIND_LIBRARY() calls
25+
-if( NOT WIN32 )
26+
+if( NOT MSVC )
27+
find_package(PkgConfig)
28+
pkg_check_modules(HEIF_PKG libheif>=1.7.0 QUIET)
29+
-endif( NOT WIN32 )
30+
+endif( NOT MSVC )
31+
32+
FIND_PATH(HEIF_INCLUDE_DIR NAMES libheif/heif.h
33+
PATHS
34+
diff -ur libgd/cmake/modules/FindWEBP.cmake libgd-patched/cmake/modules/FindWEBP.cmake
35+
--- libgd/cmake/modules/FindWEBP.cmake 2025-07-06 13:20:45.358034790 +0200
36+
+++ libgd-patched/cmake/modules/FindWEBP.cmake 2025-07-06 13:21:19.111383452 +0200
37+
@@ -37,11 +37,10 @@
38+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40+
41+
-include(FindZLIB)
42+
-
43+
-find_path(WEBP_INCLUDE_DIR decode.h
44+
-/usr/local/include/webp
45+
-/usr/include/webp
46+
+find_path(WEBP_INCLUDE_DIR
47+
+ NAMES decode.h
48+
+ PATHS /usr/local/include /usr/include
49+
+ PATH_SUFFIXES webp
50+
)
51+
52+
set(WEBP_NAMES ${WEBP_NAMES} webp)
53+
diff -ur libgd/cmake/modules/FindXPM.cmake libgd-patched/cmake/modules/FindXPM.cmake
54+
--- libgd/cmake/modules/FindXPM.cmake 2025-07-06 13:20:45.358034790 +0200
55+
+++ libgd-patched/cmake/modules/FindXPM.cmake 2025-07-06 13:21:19.111383452 +0200
56+
@@ -40,9 +40,10 @@
57+
58+
SET(XPM_FOUND "NO")
59+
60+
-FIND_PATH(XPM_XPM_INCLUDE_DIR xpm.h
61+
-/usr/local/include/X11
62+
-/usr/include/X11
63+
+FIND_PATH(XPM_XPM_INCLUDE_DIR
64+
+ NAMES xpm.h
65+
+ PATHS /usr/local/include /usr/include
66+
+ PATH_SUFFIXES X11
67+
)
68+
69+
SET(XPM_NAMES ${XPM_NAMES} Xpm libXpm)
70+
diff -ur libgd/CMakeLists.txt libgd-patched/CMakeLists.txt
71+
--- libgd/CMakeLists.txt 2025-07-06 13:20:45.358034790 +0200
72+
+++ libgd-patched/CMakeLists.txt 2025-07-06 13:21:19.111383452 +0200
73+
@@ -86,10 +86,10 @@
74+
else (USE_EXT_GD)
75+
76+
MACRO(GV VER VAR)
77+
- execute_process(
78+
- COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config/getver.sh ${VER}
79+
- OUTPUT_VARIABLE ${VAR}
80+
- )
81+
+ file (STRINGS "src/gd.h" _VERSION_LINE REGEX "define[ ]+GD_${VER}_VERSION")
82+
+ if ( _VERSION_LINE )
83+
+ string ( REGEX REPLACE ".*define[ ]+GD_${VER}_VERSION[ ]+\"?([^ \"]*)\"?[ ]+.*" "\\1" ${VAR} "${_VERSION_LINE}" )
84+
+ endif ()
85+
ENDMACRO(GV)
86+
87+
GV(MAJOR GDLIB_MAJOR)
88+
Binary files libgd/.git/index and libgd-patched/.git/index differ
89+
diff -ur libgd/src/CMakeLists.txt libgd-patched/src/CMakeLists.txt
90+
--- libgd/src/CMakeLists.txt 2025-07-06 13:20:45.359034771 +0200
91+
+++ libgd-patched/src/CMakeLists.txt 2025-07-06 13:21:19.111383452 +0200
92+
@@ -132,9 +132,9 @@
93+
94+
if (PNG_FOUND)
95+
set(GD_PROGRAMS ${GD_PROGRAMS} gdtopng pngtogd)
96+
- if (NOT WIN32)
97+
+ if (NOT MSVC)
98+
set(GD_PROGRAMS ${GD_PROGRAMS} webpng)
99+
- endif (NOT WIN32)
100+
+ endif (NOT MSVC)
101+
if (ZLIB_FOUND)
102+
set(GD_PROGRAMS ${GD_PROGRAMS} gdparttopng gd2topng pngtogd2)
103+
endif()
104+
@@ -152,11 +152,6 @@
105+
106+
foreach(program ${GD_PROGRAMS})
107+
add_executable(${program} ${program}.c)
108+
- if (WIN32)
109+
- list(REMOVE_ITEM program webpng.c annotate.c)
110+
- list(REMOVE_ITEM GD_PROGRAMS webpng)
111+
- list(REMOVE_ITEM GD_PROGRAMS annotate)
112+
- endif (WIN32)
113+
114+
if (BUILD_SHARED_LIBS)
115+
target_link_libraries(${program} ${GD_LIB})
116+
diff -ur libgd/src/gd_topal.c libgd-patched/src/gd_topal.c
117+
--- libgd/src/gd_topal.c 2025-07-06 13:20:45.361034732 +0200
118+
+++ libgd-patched/src/gd_topal.c 2025-07-06 13:21:19.111383452 +0200
119+
@@ -1527,8 +1527,12 @@
120+
/* liq requires 16 byte aligned heap memory */
121+
static void *malloc16(size_t size)
122+
{
123+
+#ifndef _WIN32
124+
void *p;
125+
return posix_memalign(&p, 16, size) == 0 ? p : NULL;
126+
+#else
127+
+ return _aligned_malloc(16, size);
128+
+#endif
129+
}
130+
#endif
131+
132+
diff -ur libgd/tests/gdtest/gdtest.c libgd-patched/tests/gdtest/gdtest.c
133+
--- libgd/tests/gdtest/gdtest.c 2025-07-06 13:20:45.362034713 +0200
134+
+++ libgd-patched/tests/gdtest/gdtest.c 2025-07-06 13:21:19.111383452 +0200
135+
@@ -9,6 +9,7 @@
136+
#include <math.h>
137+
#include <limits.h>
138+
#include <time.h>
139+
+#include <errno.h>
140+
141+
#ifdef HAVE_DIRENT_H
142+
#include <dirent.h>

0 commit comments

Comments
 (0)