cross-prereqs-build.sh (3550B)
1 #!/bin/bash 2 3 set -e 4 set -o xtrace 5 6 HOST=$1 7 8 # Debian's cross-pkg-config wrappers are broken for MinGW targets, since 9 # dpkg-architecture doesn't know about MinGW target triplets. 10 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=930492 11 cat >/usr/local/bin/${HOST}-pkg-config <<EOF 12 #!/bin/sh 13 14 PKG_CONFIG_SYSROOT_DIR=/usr/${HOST} PKG_CONFIG_LIBDIR=/usr/${HOST}/lib/pkgconfig:/usr/share/pkgconfig pkg-config \$@ 15 EOF 16 chmod +x /usr/local/bin/${HOST}-pkg-config 17 18 # when cross-compiling, some autoconf tests cannot be run: 19 20 # --enable-malloc0returnsnull 21 export xorg_cv_malloc0_returns_null=yes 22 23 build() { 24 url=$1 25 commit=$2 26 config=$3 27 28 name=$(basename ${url} .git) 29 30 if [[ $commit =~ ^[[:xdigit:]]{1,}$ ]] 31 then 32 git clone ${url} ${name} 33 git -C ${name} checkout ${commit} 34 else 35 git clone --depth 1 --branch ${commit:-master} --recurse-submodules -c advice.detachedHead=false ${url} ${name} 36 fi 37 38 pushd ${name} 39 NOCONFIGURE=1 ./autogen.sh || ./.bootstrap 40 ./configure ${config} --host=${HOST} --prefix= --with-sysroot=/usr/${HOST}/ 41 make -j$(nproc) 42 DESTDIR=/usr/${HOST} make install 43 44 popd 45 rm -rf ${OLDPWD} 46 } 47 48 build 'https://gitlab.freedesktop.org/pixman/pixman.git' 'pixman-0.38.4' 49 build 'https://gitlab.freedesktop.org/xorg/lib/pthread-stubs.git' '0.4' 50 # we can't use the xorgproto pkgconfig files from /usr/share/pkgconfig, because 51 # these would add -I/usr/include to CFLAGS, which breaks cross-compilation 52 build 'https://gitlab.freedesktop.org/xorg/proto/xorgproto.git' 'xorgproto-2021.4.99.2' '--datadir=/lib' 53 build 'https://gitlab.freedesktop.org/xorg/lib/libXau.git' 'libXau-1.0.9' 54 build 'https://gitlab.freedesktop.org/xorg/proto/xcbproto.git' 'xcb-proto-1.14' 55 build 'https://gitlab.freedesktop.org/xorg/lib/libxcb.git' 'libxcb-1.14' 56 build 'https://gitlab.freedesktop.org/xorg/lib/libxtrans.git' 'xtrans-1.4.0' 57 # the default value of keysymdefdir is taken from the includedir variable for 58 # xproto, which isn't adjusted by pkg-config for the sysroot 59 build 'https://gitlab.freedesktop.org/xorg/lib/libX11.git' 'libX11-1.6.9' "--with-keysymdefdir=/usr/${HOST}/include/X11" 60 build 'https://gitlab.freedesktop.org/xorg/lib/libxkbfile.git' 'libxkbfile-1.1.0' 61 # freetype needs an explicit --build to know it's cross-compiling 62 # disable png as freetype tries to use libpng-config, even when cross-compiling 63 build 'git://git.savannah.gnu.org/freetype/freetype2.git' 'VER-2-10-1' "--build=$(cc -dumpmachine) --with-png=no" 64 build 'https://gitlab.freedesktop.org/xorg//font/util.git' 'font-util-1.3.2' 65 build 'https://gitlab.freedesktop.org/xorg/lib/libfontenc.git' 'libfontenc-1.1.4' 66 build 'https://gitlab.freedesktop.org/xorg/lib/libXfont.git' 'libXfont2-2.0.3' 67 build 'https://gitlab.freedesktop.org/xorg/lib/libXdmcp.git' 'libXdmcp-1.1.3' 68 build 'https://gitlab.freedesktop.org/xorg/lib/libXfixes.git' 'libXfixes-5.0.3' 69 build 'https://gitlab.freedesktop.org/xorg/lib/libxcb-util.git' '0.4.0' 70 build 'https://gitlab.freedesktop.org/xorg/lib/libxcb-image.git' '0.4.0' 71 build 'https://gitlab.freedesktop.org/xorg/lib/libxcb-wm.git' '0.4.1' 72 73 # workaround xcb_windefs.h leaking all Windows API types into X server build 74 # (some of which clash which types defined by Xmd.h) XXX: This is a bit of a 75 # hack, as it makes this header depend on xorgproto. Maybe an upstreamable 76 # fix would involve a macro defined in the X server (XFree86Server? 77 # XCB_NO_WINAPI?), which makes xcb_windefs.h wrap things like XWinsock.h 78 # does??? 79 sed -i s#winsock2#X11/Xwinsock# /usr/${HOST}/include/xcb/xcb_windefs.h