美文网首页
Cross-Compile APR (Apache Portab

Cross-Compile APR (Apache Portab

作者: 避雷殝 | 来源:发表于2022-08-10 10:33 被阅读0次
    1. Add additional config options to build script:
    # http://stackoverflow.com/questions/1604470/cross-compile-apache-portable-runtime-to-the-iphone
    my $config_opts = "ac_cv_file__dev_zero=\"yes\" " .
            "ac_cv_func_setpgrp_void=\"yes\" " .
            "apr_cv_process_shared_works=\"yes\" " .
            "apr_cv_mutex_robust_shared=\"no\" " .
            "apr_cv_tcp_nodelay_with_cork=\"yes\" " .
            "ac_cv_sizeof_struct_iovec=\"8\" " .
            "apr_cv_mutex_recursive=\"yes\" " .
            "ac_cv_func_fdatasync=\"no\"";
    
    ./iphone.configure --$arch $config_opts
    

    Note that if were to enable bitcode, please add flags -O3 -fembed-bitcode to CFLAGS, else just -O3.

    1. Create a iphone.configure file for autotools:
    #! /bin/bash
    
    #
    # Program  : iphone3.1-configure
    # Authors  : Michael Aaron Safyan (michaelsafyan@gmail.com)
    # Synopsis :
    #            This program runs the "configure" script generated by the
    #            GNU Autotools in order to cross-compile thirdparty libraries
    #            for the iPhone 3.1 SDK. Run this script while in a directory
    #            containing an autotools "configure" script. Once you run this,
    #            you can use "make" and "sudo make install" to build the library.
    #            An install prefix of "/opt/iphone-3.1/" is used.
    #
    
    unset CPATH
    unset C_INCLUDE_PATH
    unset CPLUS_INCLUDE_PATH
    unset OBJC_INCLUDE_PATH
    unset LIBS
    unset DYLD_FALLBACK_LIBRARY_PATH
    unset DYLD_FALLBACK_FRAMEWORK_PATH
    
    export BUILD_DARWIN_VER=`uname -r`
    export SDKVER="3.1"
    export DEVROOT="/Developer/Platforms/iPhoneOS.platform/Developer"
    export SDKROOT="$DEVROOT/SDKs/iPhoneOS$SDKVER.sdk"
    export PKG_CONFIG_PATH=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS$SDKVER.sdk/usr/lib/pkgconfig:/Developer/Platforms/iPhoneOS.platform/Developer/usr/lib/pkgconfig:/opt/iphone-$SDKVER/lib/pkgconfig:/usr/local/iphone-$SDKVER/lib/pkgconfig
    export PREFIX="/opt/iphone-$SDKVER"
    export AS="$DEVROOT/usr/bin/as"
    export ASCPP="$DEVROOT/usr/bin/as"
    export AR="$DEVROOT/usr/bin/ar"
    export RANLIB="$DEVROOT/usr/bin/ranlib"
    export CPPFLAGS="-pipe -no-cpp-precomp -I$SDKROOT/usr/lib/gcc/arm-apple-darwin9/4.2.1/include/ -I$SDKROOT/usr/include -I$DEVROOT/usr/include -I/opt/iphone-$SDKVER/include -I/usr/local/iphone-$SDKVER/include"
    export CFLAGS="-std=c99 -arch armv6 -pipe -no-cpp-precomp --sysroot='$SDKROOT' -isystem $SDKROOT/usr/lib/gcc/arm-apple-darwin9/4.2.1/include/ -isystem $SDKROOT/usr/include -isystem $DEVROOT/usr/include -isystem /opt/iphone-$SDKVER/include -isystem /usr/local/iphone-$SDKVER/include"
    export CXXFLAGS="-std=c99 -arch armv6 -pipe -no-cpp-precomp --sysroot='$SDKROOT' -isystem $SDKROOT/usr/lib/gcc/arm-apple-darwin9/4.2.1/include/ -isystem $SDKROOT/usr/include -isystem $DEVROOT/usr/include -isystem /opt/iphone-$SDKVER/include -isystem /usr/local/iphone-$SDKVER/include"
    export LDFLAGS="-arch armv6 --sysroot='$SDKROOT' -L$SDKROOT/usr/lib -L$DEVROOT/usr/lib -L/opt/iphone-$SDKVER/lib -L/usr/local/iphone-$SDKVER/lib"
    export CPP="$DEVROOT/usr/bin/cpp"
    export CXXCPP="$DEVROOT/usr/bin/cpp"
    export CC="$DEVROOT/usr/bin/gcc-4.2"
    export CXX="$DEVROOT/usr/bin/g++-4.2"
    export LD="$DEVROOT/usr/bin/ld"
    export STRIP="$DEVROOT/usr/bin/strip"
    
    if [ ! \( -d "$DEVROOT" \) ] ; then
       echo "The iPhone SDK could not be found. Folder \"$DEVROOT\" does not exist."
       exit 1
    fi
    
    if [ ! \( -d "$SDKROOT" \) ] ; then
       echo "The iPhone SDK could not be found. Folder \"$SDKROOT\" does not exist."
       exit 1
    fi
    
    ./configure --prefix="$PREFIX" --build="i386-apple-darwin$BUILD_DARWIN_VER" --host="arm-apple-darwin9" --enable-static --disable-shared ac_cv_file__dev_zero=no ac_cv_func_setpgrp_void=yes $@
    
    1. Patch the header file, in apr/include/apr_general.h, add the following line to line 35:
    #include <stddef.h>
    

    Or you could apply the following patch file:

    --- a/source/apr/include/apr_general.h
    +++ b/source/apr/include/apr_general.h
    @@ -33,6 +33,8 @@
     #include <signal.h>
     #endif
     
    +#include <stddef.h>
    +
     #ifdef __cplusplus
     extern "C" {
     #endif /* __cplusplus */
    
    1. If run into Bad CPU type in executable error, do the following steps to manually compile gen_test_char (refer to https://stackoverflow.com/questions/18408400/apache-cross-compilation-error-gen-test-char-cannot-execute-binary-file):
      a. cd $APR/tools
      b. gcc -Wall -O2 -DCROSS_COMPILE gen_test_char.c -s -o gen_test_char
      c. cd ..
      d. make install

    相关文章

      网友评论

          本文标题:Cross-Compile APR (Apache Portab

          本文链接:https://www.haomeiwen.com/subject/asoowrtx.html