Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation #4

Open
unlink2 opened this issue Jul 20, 2021 · 3 comments
Open

Compilation #4

unlink2 opened this issue Jul 20, 2021 · 3 comments

Comments

@unlink2
Copy link

unlink2 commented Jul 20, 2021

Hello,

we're trying to implement a wrapper around SVN using .Net 5 on Linux and we'd love to give this library a try however we are not certain how to set up a build environment. Any help would be greatly appreciated.

@ghost
Copy link

ghost commented Aug 5, 2021

Hi @unlink2 You can find a build script I've been using to build it on a Mac below:

build_mac.sh
#!/usr/bin/env bash

script_dir=$(pwd)
output_dir=${script_dir}/__output__

echo "Script dir is: " $script_dir
echo "Output dir is set to: " $output_dir

macos_min_ver=10.12

export SED=sed


# ----------------------------------------
#              OPENSSL BUILD
# ----------------------------------------

if [ -d "${output_dir}/openssl/" ]; then
    echo "* OpenSSL is already built"
else
    echo "* Downloading OpenSSL"
    curl -OL "https://www.openssl.org/source/openssl-1.1.0k.tar.gz"

    echo "* Unpacking OpenSSL"
    tar xzf ./openssl-1.1.0k.tar.gz

    echo "* Changing directory to OpenSSL"
    pushd ./openssl-1.1.0k/

    echo "* Building OpenSSL"
    perl ./Configure                         \
        darwin64-x86_64-cc                   \
        threads                              \
        no-dso                               \
        no-shared                            \
        no-hw                                \
        no-ssl3                              \
        no-gost                              \
        no-dtls                              \
        no-srp                               \
        no-unit-test                         \
        no-zlib                              \
        no-zlib-dynamic                      \
        enable-static-engine                 \
        -DSSL_FORBID_ENULL                   \
        -mmacos-version-min=${macos_min_ver} \
        --prefix="${output_dir}/openssl"     \
        --openssldir="${output_dir}/openssl"
    #   enable-ec_nistp_64_gcc_128
    #   no-asm
    make depend && make && make install

    echo "* Changing directory back"
    popd
fi

if [ ! -d "${output_dir}/openssl/" ]; then
    echo "OpenSSL build has FAILED!"
    exit
fi


# ----------------------------------------
#               SQLITE BUILD
# ----------------------------------------

if [ -d "${output_dir}/sqlite3/" ]; then
    echo "* SQLite is already built"
else
    echo "* Downloading SQLite"
    curl -OL "https://www.sqlite.org/2019/sqlite-autoconf-3280000.tar.gz"

    echo "* Unpacking SQLite"
    tar xzf ./sqlite-autoconf-3280000.tar.gz

    echo "* Changing directory to SQLite"
    pushd ./sqlite-autoconf-3280000/

    echo "* Building SQLite"
    ./configure --prefix="${output_dir}/sqlite3" \
        CPPFLAGS="-DNDEBUG                       \
        -DSQLITE_TEMP_STORE=2                    \
        -DSQLITE_DEFAULT_PAGE_SIZE=4096          \
        -DSQLITE_DEFAULT_CACHE_SIZE=20000        \
        -DSQLITE_DEFAULT_MEMSTATUS=0             \
        -DSQLITE_DEFAULT_RECURSIVE_TRIGGERS=1    \
        -DSQLITE_POWERSAFE_OVERWRITE=1           \
        -DSQLITE_OMIT_AUTOINIT                   \
        -DSQLITE_OMIT_DEPRECATED                 \
        -DSQLITE_OMIT_LOAD_EXTENSION             \
        -DSQLITE_OMIT_PROGRESS_CALLBACK          \
        -DSQLITE_OMIT_TCL_VARIABLE               \
        -DSQLITE_OMIT_TRACE                      \
        -DSQLITE_OMIT_UTF16                      \
        -DSQLITE_OMIT_DATETIME_FUNCS             \
        -DSQLITE_OMIT_LOCALTIME                  \
        -DSQLITE_OMIT_SHARED_CACHE               \
        -DSQLITE_OMIT_BUILTIN_TEST               \
        -DSQLITE_OMIT_GET_TABLE                  \
        -DSQLITE_OMIT_SCHEMA_PRAGMAS             \
        -DSQLITE_OMIT_INTEGRITY_CHECK            \
        -mmacos-version-min=${macos_min_ver}"
    #   -DSQLITE_OMIT_EXPLAIN
    #   -DSQLITE_OMIT_AUTHORIZATION
    make && make install

    echo "* Changing directory back"
    popd
fi

if [ ! -d "${output_dir}/sqlite3/" ]; then
    echo "SQLite build has FAILED!"
    exit
fi


# ----------------------------------------
#                APR BUILD
# ----------------------------------------

if [ -d "${output_dir}/apr/" ]; then
    echo "* APR is already built"
else
    echo "* Downloading APR"
    curl -OL "https://www.apache.org/dist/apr/apr-1.7.0.tar.bz2"

    echo "* Unpacking APR"
    tar xjf ./apr-1.7.0.tar.bz2

    echo "* Changing directory to APR"
    pushd ./apr-1.7.0/

    echo "* Building APR"
    ./configure --prefix="${output_dir}/apr" \
        CPPFLAGS="-mmacos-version-min=${macos_min_ver}"
    make && make install

    echo "* Changing directory back"
    popd
fi

if [ ! -d "${output_dir}/apr/" ]; then
    echo "APR build has FAILED!"
    exit
fi


# ----------------------------------------
#              APR-UTIL BUILD
# ----------------------------------------

if [ -d "${output_dir}/apr-util/" ]; then
    echo "* APR-Util is already built"
else
    echo "* Downloading APR-Util"
    curl -OL "https://www.apache.org/dist/apr/apr-util-1.6.1.tar.bz2"

    echo "* Unpacking APR-Util"
    tar xjf ./apr-util-1.6.1.tar.bz2

    echo "* Changing directory to APR-Util"
    pushd ./apr-util-1.6.1/

    echo "* Building APR-Util"
    ./configure --prefix="${output_dir}/apr-util" \
        --with-apr="${output_dir}/apr"            \
        --with-openssl="${output_dir}/openssl"    \
        --with-sqlite3="${output_dir}/sqlite3"    \
        --with-ldap=no                            \
        --with-odbc=no                            \
        CPPFLAGS="-mmacos-version-min=${macos_min_ver}"
    #   --with-crypto
    make && make install

    echo "* Changing directory back"
    popd
fi

if [ ! -d "${output_dir}/apr-util/" ]; then
    echo "APR-Util build has FAILED!"
    exit
fi


# ----------------------------------------
#                SERF BUILD
# ----------------------------------------

if [ -d "${output_dir}/serf/" ]; then
    echo "* Serf is already built"
else
    echo "* Downloading Serf"
    curl -OL "https://www.apache.org/dist/serf/serf-1.3.9.tar.bz2"

    echo "* Unpacking Serf"
    tar xjf ./serf-1.3.9.tar.bz2

    echo "* Changing directory to Serf"
    pushd ./serf-1.3.9/

    echo "* Building Serf"
    scons PREFIX="${output_dir}/serf"   \
        OPENSSL="${output_dir}/openssl" \
        APR="${output_dir}/apr"         \
        APU="${output_dir}/apr-util"    \
        SOURCE_LAYOUT=no                \
        APR_STATIC=yes                  \
        install-lib                     \
        install-inc                     \
        CPPFLAGS="-mmacos-version-min=${macos_min_ver}"
    scons install

    echo "* Changing directory back"
    popd
fi

if [ ! -d "${output_dir}/serf/" ]; then
    echo "Serf build has FAILED!"
    exit
fi


# ----------------------------------------
#             SUBVERSION BUILD
# ----------------------------------------

if [ -d "${output_dir}/subversion/" ]; then
    echo "* Subversion is already built"
else
    echo "* Downloading Subversion"
    curl -OL "https://www.apache.org/dist/subversion/subversion-1.10.6.tar.bz2"

    echo "* Unpacking Subversion"
    tar xjf ./subversion-1.10.6.tar.bz2

    echo "* Changing directory to Subversion"
    pushd ./subversion-1.10.6/

    ./configure --prefix="${output_dir}/subversion" \
        --with-apr="${output_dir}/apr"              \
        --with-apr-util="${output_dir}/apr-util"    \
        --with-serf="${output_dir}/serf"            \
        --with-sqlite="${output_dir}/sqlite3"       \
        --with-lz4=internal                         \
        --with-utf8proc=internal                    \
        --without-berkeley-db                       \
        --without-swig                              \
        --disable-shared                            \
        CPPFLAGS="-DSVN_HI_RES_SLEEP_MS=1           \
        -mmacos-version-min=${macos_min_ver}"
    #   --without-apxs
    #   --disable-javahl
    make && make install

    echo "* Changing directory back"
    popd
fi

if [ ! -d "${output_dir}/subversion/" ]; then
    echo "Subversion build has FAILED!"
    exit
fi


# ----------------------------------------
#         DYNAMIC LIBRARY LINKING
# ----------------------------------------

echo "* Ignoring exports from dependent libraries"

nm -gjU "${output_dir}/openssl/lib/libcrypto.a"     \
    | grep -v "libcrypto.a"                         \
    >> "${output_dir}/subversion/lib/ignoresym.txt"

nm -gjU "${output_dir}/openssl/lib/libssl.a"        \
    | grep -v "libssl.a"                            \
    >> "${output_dir}/subversion/lib/ignoresym.txt"

nm -gjU "${output_dir}/serf/lib/libserf-1.a"        \
    | grep -v "libserf-1.a"                         \
    >> "${output_dir}/subversion/lib/ignoresym.txt"

nm -gjU "${output_dir}/sqlite3/lib/libsqlite3.a"    \
    | grep -v "libsqlite3.a"                        \
    >> "${output_dir}/subversion/lib/ignoresym.txt"

echo "* Linking a dynamic library"

/bin/sh "${script_dir}/subversion-1.10.6/libtool"                \
    --tag=CC --silent --mode=link                                \
    gcc -dynamiclib                                              \
    -Werror=unknown-warning-option -g -O2  -g -O2                \
    -unexported_symbols_list                                     \
        "${output_dir}/subversion/lib/ignoresym.txt" -dead_strip \
    -mmacos-version-min=${macos_min_ver}                         \
    -o "${output_dir}/subversion/lib/libSharpSvn.Native.dylib"   \
    -force_load "${output_dir}/subversion/lib/libsvn_client-1.a" \
    "${output_dir}/subversion/lib/libsvn_wc-1.a"                 \
    "${output_dir}/subversion/lib/libsvn_ra-1.a"                 \
    "${output_dir}/subversion/lib/libsvn_ra_local-1.a"           \
    "${output_dir}/subversion/lib/libsvn_repos-1.a"              \
    "${output_dir}/subversion/lib/libsvn_fs-1.a"                 \
    "${output_dir}/subversion/lib/libsvn_fs_fs-1.a"              \
    "${output_dir}/subversion/lib/libsvn_fs_x-1.a"               \
    "${output_dir}/subversion/lib/libsvn_fs_util-1.a"            \
    "${output_dir}/subversion/lib/libsvn_ra_svn-1.a"             \
    "${output_dir}/subversion/lib/libsvn_ra_serf-1.a"            \
    "${output_dir}/serf/lib/libserf-1.a"                         \
    "${output_dir}/subversion/lib/libsvn_delta-1.a"              \
    "${output_dir}/subversion/lib/libsvn_diff-1.a"               \
    "${output_dir}/subversion/lib/libsvn_subr-1.a"               \
    "${output_dir}/openssl/lib/libcrypto.a"                      \
    "${output_dir}/openssl/lib/libssl.a"                         \
    "${output_dir}/apr-util/lib/libaprutil-1.a"                  \
    "${output_dir}/apr/lib/libapr-1.a"                           \
    "${output_dir}/sqlite3/lib/libsqlite3.a"                     \
    -lsasl2 -lexpat -lz -liconv -lpthread                        \
    -framework CoreFoundation                                    \
    -framework Security                                          \
    -framework CoreServices

if [ ! -f "${output_dir}/subversion/lib/libSharpSvn.Native.dylib" ]; then
    echo "Dynamic library build has FAILED!"
    exit
fi

strip -x "${output_dir}/subversion/lib/libSharpSvn.Native.dylib"

echo "The build SUCCEEDED!"

# Maybe we should clean up a bit ...

Feel free to adapt it for Linux 🙂

@unlink2
Copy link
Author

unlink2 commented Aug 6, 2021

Hello! Thank you very much I'll give it a try :)

@ghost
Copy link

ghost commented Aug 29, 2024

Here is the script I used on Ubuntu 24.04

I remember you should manually install scons and zlib-dev pkgs before executing it.

#!/usr/bin/env bash

script_dir=$(pwd)
output_dir=${script_dir}/__output__

echo "Script dir is: " $script_dir
echo "Output dir is set to: " $output_dir

export SED=sed


# ----------------------------------------
#              OPENSSL BUILD
# ----------------------------------------

if [ -d "${output_dir}/openssl/" ]; then
    echo "* OpenSSL is already built"
else
    echo "* Downloading OpenSSL"
    curl -OL "https://www.openssl.org/source/openssl-1.1.0k.tar.gz"

    echo "* Unpacking OpenSSL"
    tar xzf ./openssl-1.1.0k.tar.gz

    echo "* Changing directory to OpenSSL"
    pushd ./openssl-1.1.0k/

    echo "* Building OpenSSL"
    perl ./Configure                         \
    linux-x86_64                 \
        threads                              \
        no-dso                               \
        no-shared                            \
        no-hw                                \
        no-ssl3                              \
        no-gost                              \
        no-dtls                              \
        no-srp                               \
        no-unit-test                         \
        no-zlib                              \
        no-zlib-dynamic                      \
        enable-static-engine                 \
        -DSSL_FORBID_ENULL                   \
        --prefix="${output_dir}/openssl"     \
        --openssldir="/usr/lib/ssl"
    make depend && make && make install

    echo "* Changing directory back"
    popd
fi

if [ ! -d "${output_dir}/openssl/" ]; then
    echo "OpenSSL build has FAILED!"
    exit
fi


# ----------------------------------------
#               SQLITE BUILD
# ----------------------------------------

if [ -d "${output_dir}/sqlite3/" ]; then
    echo "* SQLite is already built"
else
    echo "* Downloading SQLite"
    curl -OL "https://www.sqlite.org/2019/sqlite-autoconf-3280000.tar.gz"

    echo "* Unpacking SQLite"
    tar xzf ./sqlite-autoconf-3280000.tar.gz

    echo "* Changing directory to SQLite"
    pushd ./sqlite-autoconf-3280000/

    echo "* Building SQLite"
    ./configure --prefix="${output_dir}/sqlite3" \
        CPPFLAGS="-fPIC -DNDEBUG                 \
        -DSQLITE_TEMP_STORE=2                    \
        -DSQLITE_DEFAULT_PAGE_SIZE=4096          \
        -DSQLITE_DEFAULT_CACHE_SIZE=20000        \
        -DSQLITE_DEFAULT_MEMSTATUS=0             \
        -DSQLITE_DEFAULT_RECURSIVE_TRIGGERS=1    \
        -DSQLITE_POWERSAFE_OVERWRITE=1           \
        -DSQLITE_OMIT_AUTOINIT                   \
        -DSQLITE_OMIT_DEPRECATED                 \
        -DSQLITE_OMIT_LOAD_EXTENSION             \
        -DSQLITE_OMIT_PROGRESS_CALLBACK          \
        -DSQLITE_OMIT_TCL_VARIABLE               \
        -DSQLITE_OMIT_TRACE                      \
        -DSQLITE_OMIT_UTF16                      \
        -DSQLITE_OMIT_DATETIME_FUNCS             \
        -DSQLITE_OMIT_LOCALTIME                  \
        -DSQLITE_OMIT_SHARED_CACHE               \
        -DSQLITE_OMIT_BUILTIN_TEST               \
        -DSQLITE_OMIT_GET_TABLE                  \
        -DSQLITE_OMIT_SCHEMA_PRAGMAS             \
        -DSQLITE_OMIT_INTEGRITY_CHECK"
    make && make install

    echo "* Changing directory back"
    popd
fi

if [ ! -d "${output_dir}/sqlite3/" ]; then
    echo "SQLite build has FAILED!"
    exit
fi


# ----------------------------------------
#                APR BUILD
# ----------------------------------------

if [ -d "${output_dir}/apr/" ]; then
    echo "* APR is already built"
else
    echo "* Downloading APR"
    curl -OL "https://archive.apache.org/dist/apr/apr-1.7.0.tar.bz2"

    echo "* Unpacking APR"
    tar xjf ./apr-1.7.0.tar.bz2

    echo "* Changing directory to APR"
    pushd ./apr-1.7.0/

    echo "* Building APR"
    ./configure --prefix="${output_dir}/apr" CPPFLAGS="-fPIC"
    make && make install

    echo "* Changing directory back"
    popd
fi

if [ ! -d "${output_dir}/apr/" ]; then
    echo "APR build has FAILED!"
    exit
fi


# ----------------------------------------
#              EXPAT BUILD
# ----------------------------------------

if [ -d "${output_dir}/expat/" ]; then
    echo "* Expat is already built"
else
    echo "* Downloading Expat"
    curl -OL "https://github.com/libexpat/libexpat/releases/download/R_2_6_2/expat-2.6.2.tar.bz2"

    echo "* Unpacking Expat"
    tar xjf ./expat-2.6.2.tar.bz2

    echo "* Changing directory to Expat"
    pushd ./expat-2.6.2/

    echo "* Building Expat"
    ./configure --prefix="${output_dir}/expat" CPPFLAGS="-fPIC"
    make && make install

    echo "* Changing directory back"
    popd
fi

if [ ! -d "${output_dir}/expat/" ]; then
    echo "Expat build has FAILED!"
    exit
fi


# ----------------------------------------
#              APR-UTIL BUILD
# ----------------------------------------

if [ -d "${output_dir}/apr-util/" ]; then
    echo "* APR-Util is already built"
else
    echo "* Downloading APR-Util"
    curl -OL "https://archive.apache.org/dist/apr/apr-util-1.6.1.tar.bz2"

    echo "* Unpacking APR-Util"
    tar xjf ./apr-util-1.6.1.tar.bz2

    echo "* Changing directory to APR-Util"
    pushd ./apr-util-1.6.1/

    echo "* Building APR-Util"
    ./configure --prefix="${output_dir}/apr-util" \
        --with-apr="${output_dir}/apr"            \
        --with-openssl="${output_dir}/openssl"    \
        --with-sqlite3="${output_dir}/sqlite3"    \
    --with-expat="${output_dir}/expat"    \
        --with-ldap=no                            \
        --with-odbc=no                            \
    CPPFLAGS="-fPIC"
    make && make install

    echo "* Changing directory back"
    popd
fi

if [ ! -d "${output_dir}/apr-util/" ]; then
    echo "APR-Util build has FAILED!"
    exit
fi


# ----------------------------------------
#                SERF BUILD
# ----------------------------------------

if [ -d "${output_dir}/serf/" ]; then
    echo "* Serf is already built"
else
    echo "* Downloading Serf"
    curl -OL "https://archive.apache.org/dist/serf/serf-1.3.10.tar.bz2"

    echo "* Unpacking Serf"
    tar xjf ./serf-1.3.10.tar.bz2

    echo "* Changing directory to Serf"
    pushd ./serf-1.3.10/

    echo "* Building Serf"
    scons PREFIX="${output_dir}/serf"   \
        OPENSSL="${output_dir}/openssl" \
        APR="${output_dir}/apr"         \
        APU="${output_dir}/apr-util"    \
        SOURCE_LAYOUT=no                \
        APR_STATIC=yes                  \
    CFLAGS="-fPIC"          \
        install-lib                     \
        install-inc
    scons install

    echo "* Changing directory back"
    popd
fi

if [ ! -d "${output_dir}/serf/" ]; then
    echo "Serf build has FAILED!"
    exit
fi


# ----------------------------------------
#             SUBVERSION BUILD
# ----------------------------------------

if [ -d "${output_dir}/subversion/" ]; then
    echo "* Subversion is already built"
else
    echo "* Downloading Subversion"
    curl -OL "https://archive.apache.org/dist/subversion/subversion-1.10.6.tar.bz2"

    echo "* Unpacking Subversion"
    tar xjf ./subversion-1.10.6.tar.bz2

    echo "* Changing directory to Subversion"
    pushd ./subversion-1.10.6/

    ./configure --prefix="${output_dir}/subversion" \
        --with-apr="${output_dir}/apr"              \
        --with-apr-util="${output_dir}/apr-util"    \
        --with-serf="${output_dir}/serf"            \
        --with-sqlite="${output_dir}/sqlite3"       \
        --with-lz4=internal                         \
        --with-utf8proc=internal                    \
        --without-berkeley-db                       \
        --without-swig                              \
        --disable-shared                            \
        CPPFLAGS="-fPIC -DSVN_HI_RES_SLEEP_MS=1"

    make && make install

    echo "* Changing directory back"
    popd
fi

if [ ! -d "${output_dir}/subversion/" ]; then
    echo "Subversion build has FAILED!"
    exit
fi


# ----------------------------------------
#         DYNAMIC LIBRARY LINKING
# ----------------------------------------

echo "* Linking a dynamic library"


gcc -shared                                                      \
    -Werror=unknown-warning-option -g -O2                        \
    -o "${output_dir}/subversion/lib/libSharpSvn.Native.so"      \
    -Wl,--whole-archive                                          \
    "${output_dir}/subversion/lib/libsvn_client-1.a"             \
    "${output_dir}/subversion/lib/libsvn_wc-1.a"                 \
    "${output_dir}/subversion/lib/libsvn_ra-1.a"                 \
    "${output_dir}/subversion/lib/libsvn_ra_local-1.a"           \
    "${output_dir}/subversion/lib/libsvn_repos-1.a"              \
    "${output_dir}/subversion/lib/libsvn_fs-1.a"                 \
    "${output_dir}/subversion/lib/libsvn_fs_fs-1.a"              \
    "${output_dir}/subversion/lib/libsvn_fs_x-1.a"               \
    "${output_dir}/subversion/lib/libsvn_fs_util-1.a"            \
    "${output_dir}/subversion/lib/libsvn_ra_svn-1.a"             \
    "${output_dir}/subversion/lib/libsvn_ra_serf-1.a"            \
    "${output_dir}/serf/lib/libserf-1.a"                         \
    "${output_dir}/subversion/lib/libsvn_delta-1.a"              \
    "${output_dir}/subversion/lib/libsvn_diff-1.a"               \
    "${output_dir}/subversion/lib/libsvn_subr-1.a"               \
    "${output_dir}/openssl/lib/libcrypto.a"                      \
    "${output_dir}/openssl/lib/libssl.a"                         \
    "${output_dir}/apr-util/lib/libaprutil-1.a"                  \
    "${output_dir}/apr/lib/libapr-1.a"                           \
    "${output_dir}/sqlite3/lib/libsqlite3.a"                     \
    "${output_dir}/expat/lib/libexpat.a"                         \
    -lz -lpthread -ldl -lrt                                      \
    -Wl,--no-whole-archive


if [ ! -f "${output_dir}/subversion/lib/libSharpSvn.Native.so" ]; then
    echo "Dynamic library build has FAILED!"
    exit
fi

strip -x "${output_dir}/subversion/lib/libSharpSvn.Native.so"

echo "The build SUCCEEDED!"

# Maybe we should clean up a bit ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant