DEBUG_CFLAGS=""
#DEBUG_CFLAGS="-g -O0"

CFLAGS="${CFLAGS} -Wno-implicit-function-declaration -Wno-int-conversion ${DEBUG_CFLAGS}"

CFLAGS="${CFLAGS} "
LDFLAGS="${LDFLAGS} "

CXXFLAGS="${CFLAGS}"
CXXFLAGS="${CXXFLAGS} ${DEBUG_CFLAGS}"

#TARGET_ROOT="/data/local/tmp/sysroot"

TARGET_ROOT="/system"

TARGET_SYSROOT="/data/local/tmp/develop/sysroot"


CONFIGURE_OPTIONS="
        --prefix=${TARGET_ROOT} 
        --enable-optimize 
        --enable-symbol-hiding 
        --disable-manual 
        --enable-threaded-resolver 
        --enable-alt-svc 
        --enable-hsts 
        --with-openssl=${TARGET_SYSROOT}/usr 
        --with-brotli=${TARGET_SYSROOT}/usr 
        --with-zstd=${TARGET_SYSROOT}/usr 
        --with-ca-path=${TARGET_ROOT}/etc/security 
        --with-nghttp2={TARGET_SYSROOT}/usr 
        --with-libidn2=${TARGET_SYSROOT}/usr 
        --with-libssh2=${TARGET_SYSROOT}/usr 
        --without-quiche 
        --enable-shared 
        --with-ca-path=${TARGET_ROOT}/etc/security/cacerts 
        --with-ca-bundle=${TARGET_ROOT}/etc/security/ca-certificates.crt 
        -with-ca-fallback 
        -with-ca-embed=$PWD/ca-certificates.crt 
        --with-openssl-quic 
"

${PREFIX}  ./configure  --prefix=${TARGET_ROOT}/usr/ CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" ${CONFIGURE_OPTIONS} $* 

find . -name "*.py" -exec sed -i -e "s#/usr/bin/env#/system/bin/env#g" {} \; 
find . -name "*.pl" -exec sed -i -e "s#/usr/bin/env#/system/bin/env#g" {} \; 
find . -name "*.sh" -exec sed -i -e "s#/usr/bin/env#/system/bin/env#g" {} \;


cd lib && cp ${NDK_DIR}/sysroot/usr/lib/${CPU_TYPE}-linux-android/${API}/crt*.o .'


