summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Kundiman <erik@megapahit.org>2024-08-14 17:54:36 +0800
committerErik Kundiman <erik@megapahit.org>2024-08-14 18:52:01 +0800
commitf2e44f5ab0d57eea0e145f5da094527f0e39dae3 (patch)
treede4b9d0017b31c6b2c99dfc4a45413252ffbf02d
parent712b4d935dad7cab52a482994b9e999cc3675d40 (diff)
Automatic libcurl download, build & install
The MacPorts openssl11 port is not needed any more for building our libcurl.
-rw-r--r--README.md29
-rw-r--r--indra/cmake/CURL.cmake98
2 files changed, 97 insertions, 30 deletions
diff --git a/README.md b/README.md
index a5c6a3a656..a9bb45dca0 100644
--- a/README.md
+++ b/README.md
@@ -34,27 +34,7 @@ $ cd viewer
### macOS
```
-$ sudo port install cmake pkgconfig autoconf automake libtool apr-util +universal boost +universal collada-dom +universal hunspell +universal freetype +universal jsoncpp +universal openjpeg +universal openssl11 +universal uriparser +universal libvorbis +universal xxhashlib
-$ mkdir -p build/universal-apple-darwin`uname -r`/packages
-$ cd ~/Downloads
-$ curl -OL https://github.com/secondlife/3p-curl/releases/download/v7.54.1-513145c/curl-7.54.1-513145c-darwin64-513145c.tar.zst
-$ cd -
-$ cd ..
-$ git clone https://github.com/secondlife/3p-curl
-$ cd 3p-curl/curl
-$ mkdir -p build/aarch64-apple-darwin`uname -r`
-$ cd build/aarch64-apple-darwin`uname -r`
-$ export CFLAGS="-arch arm64 -mmacosx-version-min=11.0 -std=c90"
-$ sudo port deactivate openssl3
-$ ../../configure --host=aarch64-apple-darwin`uname -r` --disable-alt-svc --disable-dict --disable-doh --disable-file --disable-gopher --disable-headers-api --disable-hsts --disable-imap --disable-ldap --disable-ldaps --disable-libcurl-option --disable-manual --disable-mqtt --disable-ntlm --disable-ntlm-wb --disable-pop3 --disable-rtsp --disable-shared --disable-smb --disable-smtp --disable-sspi --disable-telnet --disable-tftp --disable-tls-srp --disable-unix-sockets --disable-verbose --disable-versioned-symbols --enable-threaded-resolver --with-ssl=/opt/local/libexec/openssl11 --without-libidn2 --without-libpsl
-$ make -j`sysctl -n hw.ncpu`
-$ sudo port activate openssl3
-$ unset CFLAGS
-$ cd ../../../../viewer/build/universal-apple-darwin`uname -r`/packages
-$ tar xf ~/Downloads/curl-7.54.1-513145c-darwin64-513145c.tar.zst
-$ cd lib/release
-$ lipo ../../../../../../3p-curl/curl/build/aarch64-apple-darwin`uname -r`/lib/.libs/libcurl.a libcurl.a -create -output libcurl.a
-$ cd ../../..
+$ sudo port install cmake pkgconfig autoconf automake libtool apr-util +universal boost +universal collada-dom +universal hunspell +universal freetype +universal jsoncpp +universal openjpeg +universal uriparser +universal libvorbis +universal xxhashlib
$ export LL_BUILD="-O3 -gdwarf-2 -stdlib=libc++ -mmacosx-version-min=10.15 -iwithsysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -std=c++17 -fPIC -DLL_RELEASE=1 -DLL_RELEASE_FOR_DOWNLOAD=1 -DNDEBUG -DPIC -DLL_DARWIN=1"
$ cmake -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=newview/Megapahit.app/Contents/Resources -DCMAKE_OSX_ARCHITECTURES:STRING="arm64;x86_64" -DADDRESS_SIZE:INTERNAL=64 -DUSESYSTEMLIBS:BOOL=ON -DUSE_OPENAL:BOOL=OFF -DUSE_FMODSTUDIO:BOOL=ON -DLL_TESTS:BOOL=OFF -DNDOF:BOOL=ON -DVIEWER_CHANNEL:STRING=Megapahit -DVIEWER_BINARY_NAME:STRING=megapahit -DBUILD_SHARED_LIBS:BOOL=OFF -DINSTALL:BOOL=ON -DPACKAGE:BOOL=OFF ../../indra
$ make -j`sysctl -n hw.ncpu`
@@ -65,13 +45,6 @@ $ open newview/Megapahit.app
### GNU/Linux
```
-$ mkdir -p build/`uname -m`-linux-gnu/packages
-$ cd ~/Downloads
-$ curl -OL https://github.com/secondlife/3p-curl/releases/download/v7.54.1-513145c/curl-7.54.1-513145c-linux64-513145c.tar.zst
-$ cd -
-$ cd build/`uname -m`-linux-gnu/packages
-$ tar xf ~/Downloads/curl-7.54.1-513145c-linux64-513145c.tar.zst
-$ cd ..
$ export LL_BUILD="-O3 -std=c++17 -fPIC -DLL_LINUX=1"
```
diff --git a/indra/cmake/CURL.cmake b/indra/cmake/CURL.cmake
index d47e2a765c..5efa9b61b0 100644
--- a/indra/cmake/CURL.cmake
+++ b/indra/cmake/CURL.cmake
@@ -4,8 +4,102 @@ include(Prebuilt)
include_guard()
add_library( ll::libcurl INTERFACE IMPORTED )
-#use_system_binary(libcurl)
-#use_prebuilt_binary(curl)
+if (NOT USESYSTEMLIBS)
+use_system_binary(libcurl)
+endif (NOT USESYSTEMLIBS)
+if (LINUX OR NOT USESYSTEMLIBS)
+use_prebuilt_binary(curl)
+elseif (${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRACKING_DIR}/curl_installed OR NOT ${curl_installed} EQUAL 0)
+ if (NOT EXISTS ${CMAKE_BINARY_DIR}/3p-curl-7.54.1-r1.tar.gz)
+ file(DOWNLOAD
+ https://github.com/secondlife/3p-curl/archive/refs/tags/v7.54.1-r1.tar.gz
+ ${CMAKE_BINARY_DIR}/3p-curl-7.54.1-r1.tar.gz
+ )
+ endif (NOT EXISTS ${CMAKE_BINARY_DIR}/3p-curl-7.54.1-r1.tar.gz)
+ file(ARCHIVE_EXTRACT
+ INPUT ${CMAKE_BINARY_DIR}/3p-curl-7.54.1-r1.tar.gz
+ DESTINATION ${CMAKE_BINARY_DIR}
+ )
+ file(
+ COPY
+ ${CMAKE_BINARY_DIR}/3p-curl-7.54.1-r1/curl/include/curl/curl.h
+ ${CMAKE_BINARY_DIR}/3p-curl-7.54.1-r1/curl/include/curl/curlbuild.h
+ ${CMAKE_BINARY_DIR}/3p-curl-7.54.1-r1/curl/include/curl/curlrules.h
+ ${CMAKE_BINARY_DIR}/3p-curl-7.54.1-r1/curl/include/curl/curlver.h
+ ${CMAKE_BINARY_DIR}/3p-curl-7.54.1-r1/curl/include/curl/easy.h
+ ${CMAKE_BINARY_DIR}/3p-curl-7.54.1-r1/curl/include/curl/mprintf.h
+ ${CMAKE_BINARY_DIR}/3p-curl-7.54.1-r1/curl/include/curl/multi.h
+ ${CMAKE_BINARY_DIR}/3p-curl-7.54.1-r1/curl/include/curl/stdcheaders.h
+ ${CMAKE_BINARY_DIR}/3p-curl-7.54.1-r1/curl/include/curl/system.h
+ ${CMAKE_BINARY_DIR}/3p-curl-7.54.1-r1/curl/include/curl/typecheck-gcc.h
+ DESTINATION ${LIBS_PREBUILT_DIR}/include/curl
+ )
+ file(
+ COPY
+ ${LIBS_PREBUILT_DIR}/lib/release/libcrypto.a
+ ${LIBS_PREBUILT_DIR}/lib/release/libssl.a
+ DESTINATION ${LIBS_PREBUILT_DIR}/lib
+ )
+ message("We need to temporarily have OpenSSL3 header directory and libraries renamed just until the libcurl building process with OpenSSL1.1 now is finished.")
+ if (DARWIN)
+ set(ENV{CFLAGS} "-arch ${CMAKE_OSX_ARCHITECTURES} -mmacosx-version-min=10.15 -std=c90")
+ execute_process(COMMAND sudo mv /opt/local/include/openssl /opt/local/include/openssl3)
+ execute_process(COMMAND sudo mv /opt/local/lib/libcrypto.a /opt/local/lib/libcrypto.a.3)
+ execute_process(COMMAND sudo mv /opt/local/lib/libcrypto.dylib /opt/local/lib/libcrypto.dylib.3)
+ execute_process(COMMAND sudo mv /opt/local/lib/libssl.a /opt/local/lib/libssl.a.3)
+ execute_process(COMMAND sudo mv /opt/local/lib/libssl.dylib /opt/local/lib/libssl.dylib.3)
+ if (CMAKE_OSX_ARCHITECTURES MATCHES arm64)
+ execute_process(
+ COMMAND ./configure --host=aarch64-apple-darwin --disable-alt-svc --disable-dict --disable-doh --disable-file --disable-gopher --disable-headers-api --disable-hsts --disable-imap --disable-ldap --disable-ldaps --disable-libcurl-option --disable-manual --disable-mqtt --disable-ntlm --disable-ntlm-wb --disable-pop3 --disable-rtsp --disable-shared --disable-smb --disable-smtp --disable-sspi --disable-telnet --disable-tftp --disable-tls-srp --disable-unix-sockets --disable-verbose --disable-versioned-symbols --enable-threaded-resolver --with-ssl=${LIBS_PREBUILT_DIR} --without-libidn2 --without-libpsl
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/3p-curl-7.54.1-r1/curl
+ )
+ else (CMAKE_OSX_ARCHITECTURES MATCHES arm64)
+ execute_process(
+ COMMAND ./configure --host=${CMAKE_OSX_ARCHITECTURES}-apple-darwin --disable-alt-svc --disable-dict --disable-doh --disable-file --disable-gopher --disable-headers-api --disable-hsts --disable-imap --disable-ldap --disable-ldaps --disable-libcurl-option --disable-manual --disable-mqtt --disable-ntlm --disable-ntlm-wb --disable-pop3 --disable-rtsp --disable-shared --disable-smb --disable-smtp --disable-sspi --disable-telnet --disable-tftp --disable-tls-srp --disable-unix-sockets --disable-verbose --disable-versioned-symbols --enable-threaded-resolver --with-ssl=${LIBS_PREBUILT_DIR} --without-libidn2 --without-libpsl
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/3p-curl-7.54.1-r1/curl
+ )
+ endif (CMAKE_OSX_ARCHITECTURES MATCHES arm64)
+ else (DARWIN)
+ execute_process(COMMAND sudo mv /usr/include/openssl /usr/include/openssl3)
+ execute_process(COMMAND sudo mv /usr/lib/libcrypto.a /usr/lib/libcrypto.a.3)
+ execute_process(COMMAND sudo mv /usr/lib/libcrypto.so /usr/lib/libcrypto.so.3)
+ execute_process(COMMAND sudo mv /usr/lib/libssl.a /usr/lib/libssl.a.3)
+ execute_process(COMMAND sudo mv /usr/lib/libssl.so /usr/lib/libssl.so.3)
+ execute_process(
+ COMMAND ./configure --disable-alt-svc --disable-dict --disable-doh --disable-file --disable-gopher --disable-headers-api --disable-hsts --disable-imap --disable-ldap --disable-ldaps --disable-libcurl-option --disable-manual --disable-mqtt --disable-ntlm --disable-ntlm-wb --disable-pop3 --disable-rtsp --disable-shared --disable-smb --disable-smtp --disable-sspi --disable-telnet --disable-tftp --disable-tls-srp --disable-unix-sockets --disable-verbose --disable-versioned-symbols --enable-threaded-resolver --with-ssl=${LIBS_PREBUILT_DIR} --without-libidn2 --without-libpsl
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/3p-curl-7.54.1-r1/curl
+ )
+ endif (DARWIN)
+ execute_process(
+ COMMAND make -j${MAKE_JOBS}
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/3p-curl-7.54.1-r1/curl
+ RESULT_VARIABLE curl_installed
+ )
+ file(
+ COPY ${CMAKE_BINARY_DIR}/3p-curl-7.54.1-r1/curl/lib/.libs/libcurl.a
+ DESTINATION ${LIBS_PREBUILT_DIR}/lib/release
+ )
+ if (DARWIN)
+ unset(ENV{CFLAGS})
+ execute_process(COMMAND sudo mv /opt/local/include/openssl3 /opt/local/include/openssl)
+ execute_process(COMMAND sudo mv /opt/local/lib/libcrypto.a.3 /opt/local/lib/libcrypto.a)
+ execute_process(COMMAND sudo mv /opt/local/lib/libcrypto.dylib.3 /opt/local/lib/libcrypto.dylib)
+ execute_process(COMMAND sudo mv /opt/local/lib/libssl.a.3 /opt/local/lib/libssl.a)
+ execute_process(COMMAND sudo mv /opt/local/lib/libssl.dylib.3 /opt/local/lib/libssl.dylib)
+ else (DARWIN)
+ execute_process(COMMAND sudo mv /usr/include/openssl3 /usr/include/openssl)
+ execute_process(COMMAND sudo mv /usr/lib/libcrypto.a.3 /usr/lib/libcrypto.a)
+ execute_process(COMMAND sudo mv /usr/lib/libcrypto.so.3 /usr/lib/libcrypto.so)
+ execute_process(COMMAND sudo mv /usr/lib/libssl.a.3 /usr/lib/libssl.a)
+ execute_process(COMMAND sudo mv /usr/lib/libssl.so.3 /usr/lib/libssl.so)
+ endif (DARWIN)
+ message("OpenSSL3 header directory and library names have been restored.")
+ file(REMOVE
+ ${LIBS_PREBUILT_DIR}/lib/libcrypto.a
+ ${LIBS_PREBUILT_DIR}/lib/libssl.a
+ )
+ file(WRITE ${PREBUILD_TRACKING_DIR}/curl_installed "${curl_installed}")
+endif (LINUX OR NOT USESYSTEMLIBS)
if (WINDOWS)
target_link_libraries(ll::libcurl INTERFACE libcurl.lib)
else (WINDOWS)