Changeset 16701 in niluje


Ignore:
Timestamp:
Nov 19, 2019, 10:29:25 PM (3 weeks ago)
Author:
NiLuJe
Message:

Kindle Hacks:

  • X-TC:
    • Update to libfuse 3 That implies a lot of meson nonsense, so, here be dragons.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Configs/trunk/Kindle/Misc/x-compile.sh

    r16700 r16701  
    870870        return 0
    871871fi
     872
     873## Some helper functions for extremely unfriendly build-systems (hi, meson!).
     874meson_setup() {
     875        # NOTE: Let's deal with Meson and its lack of support for env vars...
     876        #       c.f., https://github.com/gentoo/gentoo/blob/39008f571c7693e1bd34109614e02a39e6805a96/eclass/meson.eclass#L123
     877        cp -f ${SCRIPTS_BASE_DIR}/MesonCross.tpl MesonCross.txt
     878        sed -e "s#%CC%#$(command -v ${CROSS_TC}-gcc)#g" -i MesonCross.txt
     879        sed -e "s#%CXX%#$(command -v ${CROSS_TC}-g++)#g" -i MesonCross.txt
     880        sed -e "s#%AR%#$(command -v ${CROSS_TC}-gcc-ar)#g" -i MesonCross.txt
     881        sed -e "s#%STRIP%#$(command -v ${CROSS_TC}-strip)#g" -i MesonCross.txt
     882        sed -e "s#%PKGCONFIG%#${TC_BUILD_DIR}/bin/pkg-config#g" -i MesonCross.txt
     883        sed -e "s#%SYSROOT%#${HOME}/x-tools/${CROSS_TC}/${CROSS_TC}/sysroot#g" -i MesonCross.txt
     884        sed -e "s#%MARCH%#$(echo ${CFLAGS} | tr ' ' '\n' | grep mtune | cut -d'=' -f 2)#g" -i MesonCross.txt
     885        sed -e "s#%PREFIX%#${TC_BUILD_DIR}#g" -i MesonCross.txt
     886
     887        # Deal with the *FLAGS insanity (see below)
     888        meson_flags=""
     889        for my_flag in $(echo ${CPPFLAGS} ${CFLAGS} | tr ' ' '\n') ; do
     890                meson_flags+="'${my_flag}', "
     891        done
     892        sed -e "s#%CFLAGS%#${meson_flags%,*}#" -i MesonCross.txt
     893        meson_flags=""
     894        for my_flag in $(echo ${CPPFLAGS} ${CXXFLAGS} | tr ' ' '\n') ; do
     895                meson_flags+="'${my_flag}', "
     896        done
     897        sed -e "s#%CXXFLAGS%#${meson_flags%,*}#" -i MesonCross.txt
     898        meson_flags=""
     899        for my_flag in $(echo ${LDFLAGS} | tr ' ' '\n') ; do
     900                meson_flags+="'${my_flag}', "
     901        done
     902        sed -e "s#%LDFLAGS%#${meson_flags%,*}#g" -i MesonCross.txt
     903        unset meson_flags
     904
     905        # NOTE: This is in case we ever need an pkg-config wrapper again,
     906        #       if meson decides to enforce PKG_CONFIG_SYSROOT_DIR in another stupid way...
     907        # NOTE: Plus, we honor PKG_CONFIG from the env, so we can easily pass --static...
     908        if [[ "${MESON_NEEDS_PKGCFG_WRAPPER}" == "true" ]] ; then
     909                cat <<-EOF > "${TC_BUILD_DIR}/bin/pkg-config"
     910                        #!/bin/sh
     911                        exec ${PKG_CONFIG} --define-variable=prefix=/ "\$@"
     912                EOF
     913                chmod -cvR a+x "${TC_BUILD_DIR}/bin/pkg-config"
     914        fi
     915}
    872916
    873917## Get to our build dir
     
    38853929export CXXFLAGS="${BASE_CFLAGS} -DG_DISABLE_CAST_CHECKS"
    38863930
    3887 # NOTE: Let's deal with Meson and its lack of support for env vars...
    3888 cp -f ${SCRIPTS_BASE_DIR}/MesonCross.tpl MesonCross.txt
    3889 sed -e "s#%CC%#$(command -v ${CROSS_TC}-gcc)#g" -i MesonCross.txt
    3890 sed -e "s#%CXX%#$(command -v ${CROSS_TC}-g++)#g" -i MesonCross.txt
    3891 sed -e "s#%AR%#$(command -v ${CROSS_TC}-gcc-ar)#g" -i MesonCross.txt
    3892 sed -e "s#%STRIP%#$(command -v ${CROSS_TC}-strip)#g" -i MesonCross.txt
    3893 sed -e "s#%PKGCONFIG%#${TC_BUILD_DIR}/bin/pkg-config#g" -i MesonCross.txt
    3894 sed -e "s#%SYSROOT%#${HOME}/x-tools/${CROSS_TC}/${CROSS_TC}/sysroot#g" -i MesonCross.txt
    3895 sed -e "s#%MARCH%#$(echo ${CFLAGS} | tr ' ' '\n' | grep mtune | cut -d'=' -f 2)#g" -i MesonCross.txt
    3896 sed -e "s#%PREFIX%#${TC_BUILD_DIR}#g" -i MesonCross.txt
    3897 
    3898 # Cf. https://developer.gnome.org/glib/stable/glib-cross-compiling.html
     3931# NOTE: Let's deal with Meson and generate our cross file...
     3932meson_setup
     3933
     3934# c.f., https://developer.gnome.org/glib/stable/glib-cross-compiling.html
    38993935my_meson_props=( "growing_stack=false" "have_c99_vsnprintf=true" "have_c99_snprintf=true" "have_unix98_printf=true" "have_strlcpy=false" )
    39003936if [[ "${KINDLE_TC}" == "K3" ]] ; then
     
    39193955unset my_meson_props
    39203956
    3921 # Deal with the *FLAGS insanity (see below)
    3922 meson_flags=""
    3923 for my_flag in $(echo ${CPPFLAGS} ${CFLAGS} | tr ' ' '\n') ; do
    3924         meson_flags+="'${my_flag}', "
    3925 done
    3926 sed -e "s#%CFLAGS%#${meson_flags%,*}#" -i MesonCross.txt
    3927 meson_flags=""
    3928 for my_flag in $(echo ${CPPFLAGS} ${CXXFLAGS} | tr ' ' '\n') ; do
    3929         meson_flags+="'${my_flag}', "
    3930 done
    3931 sed -e "s#%CXXFLAGS%#${meson_flags%,*}#" -i MesonCross.txt
    3932 meson_flags=""
    3933 for my_flag in $(echo ${LDFLAGS} | tr ' ' '\n') ; do
    3934         meson_flags+="'${my_flag}', "
    3935 done
    3936 sed -e "s#%LDFLAGS%#${meson_flags%,*}#g" -i MesonCross.txt
    3937 unset meson_flags
    3938 
    3939 # And with the pkg-config insanity this causes...
    3940 cat <<-EOF > "${TC_BUILD_DIR}/bin/pkg-config"
    3941         #!/bin/sh
    3942         exec /usr/bin/pkg-config --define-variable=prefix=/ "\$@"
    3943 EOF
    3944 chmod -cvR a+x "${TC_BUILD_DIR}/bin/pkg-config"
    3945 
    39463957# NOTE: Meson sanity checks the *native* compiler with the CFLAGS from the env, which of course contain target-specific flags.
    39473958#       This is extremely stupid. Deal with that nonsense.
     
    39583969echo ""
    39593970cd ..
    3960 tar -I pigz -xvf /usr/portage/distfiles/fuse-2.9.9.tar.gz
    3961 cd fuse-2.9.9
    3962 update_title_info
    3963 patch -p1 < /usr/portage/sys-fs/fuse/files/fuse-2.9.3-kernel-types.patch
    3964 ./configure --prefix=${TC_BUILD_DIR} --host=${CROSS_TC} INIT_D_PATH=${TC_BUILD_DIR}/etc/init.d MOUNT_FUSE_PATH=${TC_BUILD_DIR}/sbin UDEV_RULES_PATH=${TC_BUILD_DIR}/etc/udev/rules.d --enable-shared=no --enable-static=yes --disable-example
    3965 make ${JOBSFLAGS} V=1
    3966 make install
     3971tar -xvJf /usr/portage/distfiles/fuse-3.8.0.tar.xz
     3972cd fuse-3.8.0
     3973update_title_info
     3974# NOTE: Can't use LTO (https://github.com/libfuse/libfuse/issues/198)
     3975export CFLAGS="${NOLTO_CFLAGS}"
     3976
     3977# NOTE: Let's deal with Meson...
     3978meson_setup
     3979env -u CPPFLAGS -u CFLAGS -u CXXFLAGS -u LDFLAGS meson . builddir --cross-file MesonCross.txt --buildtype plain -Ddefault_library=static -Dudevrulesdir=${TC_BUILD_DIR}/etc/udev/rules.d -Dexamples=false
     3980ninja -v -C builddir
     3981ninja -v -C builddir install
     3982
     3983export CFLAGS="${BASE_CFLAGS}"
    39673984
    39683985# And finally sshfs
     
    39713988cd ..
    39723989rm -rf sshfs
    3973 until git clone -b sshfs_2.x --single-branch --depth 1 https://github.com/libfuse/sshfs.git ; do
     3990until git clone --depth 1 https://github.com/libfuse/sshfs.git ; do
    39743991        rm -rf sshfs
    39753992        sleep 15
     
    39773994cd sshfs
    39783995update_title_info
     3996
    39793997# We don't have ssh in $PATH, call our own
    39803998sed -e "s#ssh_add_arg(\"ssh\");#ssh_add_arg(\"${DEVICE_USERSTORE}/usbnet/bin/ssh\");#" -i ./sshfs.c
    39813999# Same for sftp-server
    39824000sed -e "s#\"/usr/lib/sftp-server\"#\"${DEVICE_USERSTORE}/usbnet/libexec/sftp-server\"#" -i ./sshfs.c
    3983 autoreconf -fi
    3984 # Static libfuse...
    3985 env PKG_CONFIG="pkg-config --static" ./configure --prefix=${TC_BUILD_DIR} --host=${CROSS_TC} --disable-sshnodelay
    3986 make ${JOBSFLAGS}
    3987 make install
     4001
     4002# NOTE: Let's deal with Meson...
     4003meson_setup
     4004env -u CPPFLAGS -u CFLAGS -u CXXFLAGS -u LDFLAGS meson . builddir --cross-file MesonCross.txt --buildtype plain -Ddefault_library=static
     4005ninja -v -C builddir
     4006ninja -v -C builddir install
     4007
    39884008${CROSS_TC}-strip --strip-unneeded ../bin/sshfs
    39894009cp ../bin/sshfs ${BASE_HACKDIR}/USBNetwork/src/usbnet/bin/sshfs
Note: See TracChangeset for help on using the changeset viewer.