summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2026-11-22 19:28:20 +0100
committerSébastien Dailly <sebastien@dailly.me>2026-11-22 19:28:20 +0100
commitb3e549a2dbf1b74c3ea7b1e4321c20953fc2ce11 (patch)
tree7fa8dd3cdf49109260690a7467fc7e1942da7139
parentad4d82c5d728f87fc1bc04cce9ed2c17dbfdbd6d (diff)
Patch for irssi with perl support
-rw-r--r--package/irssi/irssi.mk45
-rw-r--r--patches/irssi/0001-perl-cross-compilation-use-staging-dir.patch86
2 files changed, 131 insertions, 0 deletions
diff --git a/package/irssi/irssi.mk b/package/irssi/irssi.mk
new file mode 100644
index 0000000..1a76be0
--- /dev/null
+++ b/package/irssi/irssi.mk
@@ -0,0 +1,45 @@
+################################################################################
+#
+# irssi
+#
+################################################################################
+
+# Cross-compilation of the perl plugin is handled by
+# patches/irssi/0001-perl-cross-compilation-use-staging-dir.patch:
+# when $cross_compiling=yes, configure derives the perl CFLAGS/LDFLAGS from
+# the *target* perl installation found in $STAGING_DIR (instead of the host
+# perl paths reported by ExtUtils::Embed, which the cross compiler rejects)
+# and overrides the MakeMaker variables (PERL_LIB/PERL_ARCHLIB/PERL_INC,
+# LD/LDDLFLAGS and the INSTALL* dirs) of the perl XS subdirectories.
+#
+# The patch modifies configure.ac, so configure must be regenerated: run
+# autoreconf ourselves in a PRE_CONFIGURE hook (IRSSI_AUTORECONF cannot be
+# used here: buildroot evaluates it when parsing its own package/irssi
+# .mk, which happens before this external file is included).
+#
+# host-perl (same version as the target perl) is used to run Makefile.PL and
+# xsubpp during the build, so point configure at it explicitly.
+
+IRSSI_DEPENDENCIES += host-perl host-autoconf host-automake host-libtool host-pkgconf perl
+
+define IRSSI_RUN_AUTORECONF
+ cd $(@D) && PATH=$(HOST_DIR)/bin:$$PATH autoreconf --force --install
+endef
+IRSSI_PRE_CONFIGURE_HOOKS += IRSSI_RUN_AUTORECONF
+
+IRSSI_CONF_ENV += \
+ PATH=$(HOST_DIR)/bin:$$PATH \
+ ac_cv_path_perlpath=$(HOST_DIR)/bin/perl
+
+# V=1: irssi's Makefile_silent.pm injects $(PL_AM_V_BLIB) in the middle of
+# the multi-line pm_to_blib perl command; with V=0 this expands to
+# `@echo " BLIB " $@;` and breaks the command ("Failed to find -- in
+# @echo| BLIB |pm_to_blib", Error 127). With V=1 it expands to nothing.
+IRSSI_MAKE_ENV += \
+ PATH=$(HOST_DIR)/bin:$$PATH \
+ V=1
+
+IRSSI_CONF_OPTS += \
+ --with-perl=module \
+ --with-perl-lib=site
+
diff --git a/patches/irssi/0001-perl-cross-compilation-use-staging-dir.patch b/patches/irssi/0001-perl-cross-compilation-use-staging-dir.patch
new file mode 100644
index 0000000..765233d
--- /dev/null
+++ b/patches/irssi/0001-perl-cross-compilation-use-staging-dir.patch
@@ -0,0 +1,86 @@
+Use the target perl from $STAGING_DIR when cross-compiling the perl plugin
+
+When cross-compiling (e.g. from Buildroot), the perl found by configure is a
+host perl and ExtUtils::Embed reports host paths (/usr/lib/<host>/perl/...),
+which the cross compiler rejects as "unsafe header/library path", so perl
+support was silently disabled.
+
+When $cross_compiling = yes and $STAGING_DIR is set (Buildroot exports it),
+derive the perl flags from the target perl installation found in
+$STAGING_DIR/usr/lib/perl5/*/*/CORE (ccflags/ldflags/lddlflags/libs and the
+INSTALL* dirs are read from its Config_heavy.pl), and pass staging-rooted
+PERL_LIB/PERL_ARCHLIB/PERL_INC plus LD/LDDLFLAGS and target-rooted INSTALL*
+to the MakeMaker-generated Makefiles of the perl XS subdirectories, so that
+both the build and "make install DESTDIR=..." use the right paths.
+
+--- a/configure.ac
++++ b/configure.ac
+@@ -442,6 +442,40 @@
+ ;;
+ esac
+
++ dnl * When cross-compiling (e.g. from Buildroot), $perlpath is a host
++ dnl * perl and ExtUtils::Embed reports paths of the *host* perl
++ dnl * installation, which the cross compiler rejects as "unsafe
++ dnl * header/library path". Buildroot exports STAGING_DIR pointing at
++ dnl * the target sysroot: use the target perl installation found there
++ dnl * instead, and override the MakeMaker variables of the perl XS
++ dnl * subdirectories with staging-rooted paths (and target-rooted
++ dnl * INSTALL* dirs, so that "make install DESTDIR=..." lands in the
++ dnl * target rootfs).
++ if test "x$cross_compiling" = "xyes" && test -n "$STAGING_DIR"; then
++ perl_core=
++ for d in "$STAGING_DIR"/usr/lib/perl5/*/*/CORE; do
++ if test -d "$d"; then perl_core="$d"; fi
++ done
++ if test -n "$perl_core"; then
++ perl_archlib=`dirname "$perl_core"`
++ perl_privlib=`dirname "$perl_archlib"`
++ perl_ccflags=`grep "^ccflags=" "$perl_archlib/Config_heavy.pl" | cut -d= -f2- | tr -d "\\047"`
++ perl_ldflags=`grep "^ldflags=" "$perl_archlib/Config_heavy.pl" | cut -d= -f2- | tr -d "\\047"`
++ perl_lddlflags=`grep "^lddlflags=" "$perl_archlib/Config_heavy.pl" | cut -d= -f2- | tr -d "\\047"`
++ perl_libs=`grep "^libs=" "$perl_archlib/Config_heavy.pl" | cut -d= -f2- | tr -d "\\047"`
++ perl_installprivlib=`grep "^installprivlib=" "$perl_archlib/Config_heavy.pl" | cut -d= -f2- | tr -d "\\047"`
++ perl_installarchlib=`grep "^installarchlib=" "$perl_archlib/Config_heavy.pl" | cut -d= -f2- | tr -d "\\047"`
++ perl_installsitelib=`grep "^installsitelib=" "$perl_archlib/Config_heavy.pl" | cut -d= -f2- | tr -d "\\047"`
++ perl_installsitearch=`grep "^installsitearch=" "$perl_archlib/Config_heavy.pl" | cut -d= -f2- | tr -d "\\047"`
++ PERL_CFLAGS="$perl_ccflags -I$perl_core"
++ PERL_LDFLAGS="-Wl,-E $perl_ldflags -L$perl_core -lperl $perl_libs"
++ PERL_CROSS_MAKE_PARAMS="LD=\"$CC\" LDDLFLAGS=\"$perl_lddlflags -fPIC\" PERL_LIB=$perl_privlib PERL_ARCHLIB=$perl_archlib PERL_INC=$perl_core INSTALLPRIVLIB=$perl_installprivlib INSTALLARCHLIB=$perl_installarchlib INSTALLSITELIB=$perl_installsitelib INSTALLSITEARCH=$perl_installsitearch"
++ AC_MSG_NOTICE([cross-compiling: using target perl from $perl_core])
++ else
++ perl_check_error="target perl not found in \$STAGING_DIR/usr/lib/perl5"
++ fi
++ fi
++
+ dnl * check that perl's ldflags actually work
+ echo "#include <EXTERN.h>" > conftest.c
+ echo "#include <perl.h>" >> conftest.c
+@@ -538,6 +572,7 @@
+ AC_SUBST(PERL_MM_OPT)
+ AC_SUBST(PERL_MM_PARAMS)
+ AC_SUBST(PERL_STATIC_LIBS)
++ AC_SUBST(PERL_CROSS_MAKE_PARAMS)
+ fi
+ fi
+
+--- a/src/perl/Makefile.am
++++ b/src/perl/Makefile.am
+@@ -143,14 +143,14 @@
+ if [ ! -f Makefile ]; then \
+ $(am_v_pl__show_gen)$(perlpath) Makefile.PL $(PERL_MM_PARAMS) $(am_v_pl__hide_gen); \
+ fi && \
+- ($(MAKE) CC="$(CC)" CCFLAGS="$(PERL_CFLAGS) $(CFLAGS)" $(PERL_EXTRA_OPTS) || \
+- $(MAKE) CC="$(CC)" CCFLAGS="$(PERL_CFLAGS) $(CFLAGS)" $(PERL_EXTRA_OPTS)) && \
++ ($(MAKE) CC="$(CC)" $(PERL_CROSS_MAKE_PARAMS) CCFLAGS="$(PERL_CFLAGS) $(CFLAGS)" $(PERL_EXTRA_OPTS) || \
++ $(MAKE) CC="$(CC)" $(PERL_CROSS_MAKE_PARAMS) CCFLAGS="$(PERL_CFLAGS) $(CFLAGS)" $(PERL_EXTRA_OPTS)) && \
+ cd ..; \
+ done
+
+ install-exec-local:
+ for dir in $(perl_dirs); do \
+- cd $$dir && $(MAKE) install && cd ..; \
++ cd $$dir && $(MAKE) $(PERL_CROSS_MAKE_PARAMS) install && cd ..; \
+ done
+
+ clean-generic: