Skip to content

Commit af18530

Browse files
Build gettext. Gives us libintl.a. Will prevent glib from building libintl.so
1 parent ab37c15 commit af18530

5 files changed

Lines changed: 78 additions & 1 deletion

File tree

3rdparty/EPHelpers.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ function(FilterDependsList DEPENDS_LIST)
2525
endif()
2626
endif()
2727

28+
elseif("${DEPENDENCY}" STREQUAL "gettext")
29+
# gettext does not have pkg-config.pc. Just check if the it exists.
30+
# libintl.a is the interesting part.
31+
if (NOT EXISTS ${THIRDPARTY_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}intl${CMAKE_STATIC_LIBRARY_SUFFIX})
32+
message(FATAL_ERROR "Missing dependency ${DEPENDENCY}!")
33+
endif()
34+
2835
else()
2936
pkg_check_modules(LIBNAME REQUIRED ${DEPENDENCY})
3037
endif()
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
GETTEXT_SRC=$1
4+
5+
#libcroco/cr-statement.c:2661:32: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]
6+
#fprintf (a_fp, str) ;
7+
8+
# gettext wtf? Why U doing this???
9+
10+
sed -i 's/fprintf (a_fp, str)/fprintf (a_fp, "%s", str)/g' $GETTEXT_SRC/libtextstyle/gnulib-local/lib/libcroco/cr-statement.c
11+
sed -i 's/fprintf (a_fp, str)/fprintf (a_fp, "%s", str)/g' $GETTEXT_SRC/libtextstyle/lib/libcroco/cr-statement.c
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
THIRDPARTY_PREFIX=$1
5+
PC_FILE=${THIRDPARTY_PREFIX}/lib/pkgconfig/glib-2.0.pc
6+
7+
8+
echo "Before patching"
9+
cat $PC_FILE
10+
11+
# glib uses libintl
12+
# Currently, pkg-config.pc tells linker to first link libintl.a and only then libglib.a
13+
# That is bad, because libintl.a is a static lib, and whatever symbols it provides will not
14+
# be included when requested by the the libglib.a
15+
16+
sed -i 's/Libs: -lintl/Libs:/g' $PC_FILE
17+
sed -i '/Libs:/s/$/ -lintl/' $PC_FILE
18+
19+
echo ""
20+
21+
echo "After patching"
22+
cat $PC_FILE

3rdparty/packages/gettext.cmake

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
include_guard(GLOBAL)
2+
3+
# gettext doesn't provide pkg-config .pc
4+
# Check if build is needed, before calling to EPAutotools
5+
6+
# We only building gettext for libintl.a, so that is what we are checking
7+
if (EXISTS ${THIRDPARTY_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}intl${CMAKE_STATIC_LIBRARY_SUFFIX})
8+
return()
9+
endif ()
10+
11+
ExternalProjectAutotools(gettext
12+
DEPENDS iconv libxml-2.0
13+
URL https://ftp.gnu.org/pub/gnu/gettext/gettext-0.20.1.tar.gz
14+
URL_HASH SHA256=66415634c6e8c3fa8b71362879ec7575e27da43da562c798a8a2f223e6e47f5c
15+
CONFIGURE_ARGUMENTS
16+
--disable-java
17+
--disable-libasprintf
18+
--disable-curses
19+
--disable-namespacing
20+
--disable-openmp
21+
--disable-acl
22+
EXTRA_ARGUMENTS
23+
UPDATE_COMMAND
24+
# libcroco/cr-statement.c:2661:32: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]
25+
#fprintf (a_fp, str) ;
26+
# gettext wtf? Why U doing this???
27+
${CMAKE_CURRENT_SOURCE_DIR}/packages/FixGettextSource.sh
28+
${CMAKE_CURRENT_BINARY_DIR}/gettext-prefix/src/gettext/
29+
30+
LOG_UPDATE 1
31+
)

3rdparty/packages/glib-2.0.cmake

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
include_guard(GLOBAL)
22

33
ExternalProjectMeson(glib-2.0
4-
DEPENDS libffi iconv
4+
DEPENDS libffi iconv gettext
55
URL https://ftp.gnome.org/pub/gnome/sources/glib/2.61/glib-2.61.1.tar.xz
66
URL_HASH SHA256=f8d827955f0d8e197ff5c2105dd6ac4f6b63d15cd021eb1de66534c92a762161
77
CONFIGURE_ARGUMENTS -Dlibmount=false
8+
9+
EXTRA_ARGUMENTS
10+
# glib uses libintl (from gettext), but the glib-2.0.pc is wrong
11+
# libintl.a needs to be included after libglib-2.0
12+
TEST_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/packages/FixGlibInstall.sh ${THIRDPARTY_PREFIX}
13+
LOG_TEST 1
814
)

0 commit comments

Comments
 (0)