|
6 | 6 | return function (Preprocessor $p) { |
7 | 7 |
|
8 | 8 | // gettext 包含 libintl 库 |
9 | | - |
| 9 | + // 在常见的 Linux 发行版里,libintl 是由 libc 提供的,此时 gettext 编译的时候就不会附带 libintl; |
| 10 | + // 而如果在 macOS 上,由于 macOS 的 libc 没有 libintl 的 API,所以 gettext 编译的时候就要附带 libintl |
| 11 | + // 详情: https://jia.je/devops/2023/07/08/gentoo-prefix-m1/#libintl |
10 | 12 | $gettext_prefix = GETTEXT_PREFIX; |
11 | 13 | $libunistring_prefix = LIBUNISTRING_PREFIX; |
12 | 14 | $iconv_prefix = ICONV_PREFIX; |
13 | 15 | $libxml2_prefix = LIBXML2_PREFIX; |
14 | 16 | $ncurses_prefix = NCURSES_PREFIX; |
| 17 | + $options = ''; |
| 18 | + if ($p->isMacos()) { |
| 19 | + $options .= ' --with-included-gettext '; |
| 20 | + } |
| 21 | + |
15 | 22 | $p->addLibrary( |
16 | 23 | (new Library('gettext')) |
17 | 24 | ->withHomePage('https://www.gnu.org/software/gettext/') |
18 | 25 | ->withLicense('https://www.gnu.org/licenses/licenses.html', Library::LICENSE_GPL) |
19 | 26 | ->withManual('https://www.gnu.org/software/gettext/') |
20 | | - //->withUrl('https://ftp.gnu.org/gnu/gettext/gettext-0.22.tar.xz') |
21 | | - ->withUrl('https://ftpmirror.gnu.org/gnu/gettext/gettext-0.22.tar.xz') |
| 27 | + ->withUrl('https://ftpmirror.gnu.org/gettext/gettext-0.22.5.tar.gz') |
| 28 | + ->withFileHash('sha256', "ec1705b1e969b83a9f073144ec806151db88127f5e40fe5a94cb6c8fa48996a0") |
22 | 29 | ->withPrefix($gettext_prefix) |
23 | 30 | ->withConfigure( |
24 | 31 | <<<EOF |
25 | 32 |
|
26 | 33 | ./configure --help |
27 | 34 |
|
| 35 | + PACKAGES='zlib ' |
| 36 | + PACKAGES="\$PACKAGES libxml-2.0" |
| 37 | + PACKAGES="\$PACKAGES ncursesw" |
| 38 | +
|
| 39 | + CPPFLAGS="$(pkg-config --cflags-only-I --static \$PACKAGES) " |
| 40 | + LDFLAGS="$(pkg-config --libs-only-L --static \$PACKAGES) " |
| 41 | + LIBS="$(pkg-config --libs-only-l --static \$PACKAGES) " |
| 42 | +
|
| 43 | + CPPFLAGS="\${CPPFLAGS} -I{$libunistring_prefix}/include/ -I{$iconv_prefix}/include/" \ |
| 44 | + LDFLAGS="\${LDFLAGS} -L{$libunistring_prefix}/lib/ -L{$iconv_prefix}/lib/" \ |
| 45 | + LIBS="\${LIBS} -liconv -lunistring " \ |
28 | 46 | ./configure \ |
29 | 47 | --prefix={$gettext_prefix} \ |
30 | 48 | --enable-shared=no \ |
31 | 49 | --enable-static=yes \ |
32 | 50 | --enable-relocatable \ |
33 | 51 | --enable-year2038 \ |
| 52 | + --with-pic \ |
34 | 53 | --with-libiconv-prefix={$iconv_prefix} \ |
35 | 54 | --with-libncurses-prefix={$ncurses_prefix} \ |
36 | 55 | --with-libxml2-prefix={$libxml2_prefix} \ |
37 | 56 | --with-libunistring-prefix={$libunistring_prefix} \ |
38 | 57 | --without-emacs \ |
39 | 58 | --without-lispdir \ |
40 | | - --without-cvs \ |
41 | 59 | --disable-acl \ |
42 | 60 | --disable-java \ |
43 | 61 | --disable-csharp \ |
44 | | - --without-git |
45 | | -
|
| 62 | + --without-cvs \ |
| 63 | + --without-git \ |
| 64 | + --without-xz \ |
| 65 | + {$options} \ |
46 | 66 |
|
47 | 67 | EOF |
48 | 68 | ) |
49 | | - ->withDependentLibraries('libunistring', 'libiconv', 'ncurses', 'libxml2') |
| 69 | + ->withDependentLibraries('libunistring', 'libiconv', 'ncurses', 'libxml2', 'zlib') |
50 | 70 | ); |
51 | 71 |
|
52 | 72 | $p->withVariable('CPPFLAGS', '$CPPFLAGS -I' . $gettext_prefix . '/include'); |
53 | 73 | $p->withVariable('LDFLAGS', '$LDFLAGS -L' . $gettext_prefix . '/lib'); |
54 | 74 | $p->withVariable('LIBS', '$LIBS -lintl '); |
| 75 | + if ($p->isMacos()) { |
| 76 | + $p->withFramework('LDFLAGS', '-framework CoreFoundation'); |
| 77 | + } |
55 | 78 | }; |
0 commit comments