@@ -53,28 +53,34 @@ if [ -f "$DLL_TARGET_DIR/libzbar-0.dll" ]; then
5353 info " libzbar already built, skipping"
5454else
5555 (
56- # As debian bullseye doesn't provide win-iconv-mingw-w64-dev, we need to build it:
57- WIN_ICONV_COMMIT=" 9f98392dfecadffd62572e73e9aba878e03496c4"
58- # ^ tag "v0.0.8"
59- info " Building win-iconv..."
60- cd " $CACHEDIR "
61- if [ ! -d win-iconv ]; then
62- git clone https://github.com/win-iconv/win-iconv.git
63- fi
64- cd win-iconv
65- if ! $( git cat-file -e ${WIN_ICONV_COMMIT} ) ; then
66- info " Could not find requested version $WIN_ICONV_COMMIT in local clone; fetching..."
67- git fetch --all
68- fi
69- git reset --hard
70- git clean -dfxq
71- git checkout " ${WIN_ICONV_COMMIT} ^{commit}"
72-
73- # note: "-j1" as parallel jobs lead to non-reproducibility seemingly due to ordering issues
74- # see https://github.com/win-iconv/win-iconv/issues/42
75- CC=" ${GCC_TRIPLET_HOST} -gcc" make -j1 || fail " Could not build win-iconv"
56+ # iconv is needed for zbar. see https://github.com/mchehab/zbar/blob/a549566ea11eb03622bd4458a1728ffe3f589163/README-windows.md
57+ # (previously were using win-iconv, but changed to GNU libiconv due to compilation errors with modern gcc)
58+ LIBICONV_VER=" 1.18"
59+ download_if_not_exist " $CACHEDIR /libiconv-${LIBICONV_VER} .tar.gz" " https://ftp.gnu.org/pub/gnu/libiconv/libiconv-${LIBICONV_VER} .tar.gz"
60+ verify_hash " $CACHEDIR /libiconv-${LIBICONV_VER} .tar.gz" " 3b08f5f4f9b4eb82f151a7040bfd6fe6c6fb922efe4b1659c66ea933276965e8"
61+ tar xf " $CACHEDIR /libiconv-${LIBICONV_VER} .tar.gz" -C " $CACHEDIR "
62+ # ref https://github.com/msys2/MINGW-packages/blob/7f68e9f2488737bbe03888ade094eaee8021d1c5/mingw-w64-libiconv/PKGBUILD
63+ info " Building libiconv..."
64+ cd " $CACHEDIR /libiconv-${LIBICONV_VER} "
65+ # Patches taken from msys2/MINGW-packages
66+ patch -p1 < " $here /patches/libiconv-fix-pointer-buf.patch"
67+ ./configure \
68+ $AUTOCONF_FLAGS \
69+ --prefix=" /usr/${GCC_TRIPLET_HOST} " \
70+ --disable-static \
71+ --enable-shared \
72+ --enable-extra-encodings \
73+ --enable-relocatable \
74+ --disable-rpath \
75+ --enable-silent-rules \
76+ --enable-nls
77+ CC=" ${GCC_TRIPLET_HOST} -gcc" make " -j$CPU_COUNT " || fail " Could not build libiconv"
78+ cp -fpv " libcharset/lib/.libs/libcharset-1.dll" " $DLL_TARGET_DIR /" || fail " Could not copy the libcharset binary to DLL_TARGET_DIR"
79+ cp -fpv " lib/.libs/libiconv-2.dll" " $DLL_TARGET_DIR /" || fail " Could not copy the libiconv binary to DLL_TARGET_DIR"
7680 # FIXME avoid using sudo
77- sudo make install prefix=" /usr/${GCC_TRIPLET_HOST} " || fail " Could not install win-iconv"
81+ sudo make install || fail " Could not install libiconv"
82+ # workaround to delete files owned by root, created by "make install":
83+ make clean
7884 )
7985 " $CONTRIB " /make_zbar.sh || fail " Could not build zbar"
8086fi
0 commit comments