Skip to content

Commit

Permalink
[Glib] Add patch to fix missing xattr.h on FreeBSD
Browse files Browse the repository at this point in the history
  • Loading branch information
giordano committed May 20, 2021
1 parent f8d611a commit 5059ec6
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 11 deletions.
27 changes: 16 additions & 11 deletions G/Glib/build_tarballs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,41 @@ version = v"2.68.1"
sources = [
ArchiveSource("https://ftp.gnome.org/pub/gnome/sources/glib/$(version.major).$(version.minor)/glib-$(version).tar.xz",
"241654b96bd36b88aaa12814efc4843b578e55d47440103727959ac346944333"),
DirectorySource("./bundled"),
]

# Bash recipe for building across all platforms
script = raw"""
cd $WORKSPACE/srcdir/glib-*/
mkdir build_glib && cd build_glib
SED_SCRIPT=()
# Tell meson where to find libintl.h
SED_SCRIPT=(-e "s?c_args = \[]?c_args = ['-I${includedir}']?")
# We need to link to iconv, but ninja doesn't know how to do that as libiconv
# doesn't have a pkgconfig file. Let's give meson a tip. Note: on PowerPC the
# cross-file has already entries for `c_link_args`, so we have to append.
if [[ "${target}" == powerpc64le-* ]]; then
SED_SCRIPT+=(-e "s?c_link_args = \[\(.*\)]?c_link_args = [\1, '-liconv']?")
elif [[ "${target}" == *-freebsd* ]]; then
SED_SCRIPT+=(-e "s?c_link_args = \[]?c_link_args = ['-L${libdir}', '-liconv']?")
# Our FreeBSD libc has `environ` as undefined symbol, so the linker will
# complain if this symbol is used in the built library, even if this won't
# be a problem at runtim. This flag allows having undefined symbols.
MESON_FLAGS=(-Db_lundef=false)
# Adapt patch relative to `xattr` from
# http://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/devel/glib2/patches/patch-meson.build?rev=1.2&content-type=text/x-cvsweb-markup.
# Quoting the comment:
# Don't fail if getxattr is not available. The code is already ready
# for this case with some small configure changes.
atomic_patch -p1 ../patches/freebsd-have_xattr.patch
else
SED_SCRIPT+=(-e "s?c_link_args = \[]?c_link_args = ['-liconv']?")
fi
if [[ "${target}" == i686-linux-musl ]]; then
# We can't run executables for i686-linux-musl in the BB environment
SED_SCRIPT+=(-e "s?needs_exe_wrapper = false?needs_exe_wrapper = true?" "${MESON_TARGET_TOOLCHAIN}")
elif [[ "${target}" == *-apple-* ]] || [[ "${target}" == *-mingw* ]]; then
# Tell meson where to find libintl.h
SED_SCRIPT+=(-e "s?c_args = \[]?c_args = ['-I${prefix}/include']?")
fi
sed -i "${SED_SCRIPT[@]}" \
"${MESON_TARGET_TOOLCHAIN}"
meson .. -Dman=false --cross-file="${MESON_TARGET_TOOLCHAIN}"
mkdir build_glib && cd build_glib
meson .. -Dman=false --cross-file="${MESON_TARGET_TOOLCHAIN}" "${MESON_FLAGS[@]}"
ninja -j${nproc}
ninja install
"""
Expand Down
21 changes: 21 additions & 0 deletions G/Glib/bundled/patches/freebsd-have_xattr.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--- a/meson.build
+++ b/meson.build
@@ -2111,16 +2111,15 @@
if cc.has_function('getxattr') and cc.has_header('sys/xattr.h')
glib_conf.set('HAVE_SYS_XATTR_H', 1)
glib_conf_prefix = glib_conf_prefix + '#define @0@ 1\n'.format('HAVE_SYS_XATTR_H')
+ glib_conf.set('HAVE_XATTR', 1)
#failure. try libattr
elif cc.has_header_symbol('attr/xattr.h', 'getxattr')
glib_conf.set('HAVE_ATTR_XATTR_H', 1)
glib_conf_prefix = glib_conf_prefix + '#define @0@ 1\n'.format('HAVE_ATTR_XATTR_H')
xattr_dep = [cc.find_library('xattr')]
- else
- error('No getxattr implementation found in C library or libxattr')
+ glib_conf.set('HAVE_XATTR', 1)
endif

- glib_conf.set('HAVE_XATTR', 1)
if cc.compiles(glib_conf_prefix + '''
#include <stdio.h>
#ifdef HAVE_SYS_TYPES_H

0 comments on commit 5059ec6

Please sign in to comment.