Improve build portability with pkg-config
Use pkg-config if available to get the proper build flags for the user's environment, falling back to hardcoded defaults if necessary.
This avoids situations like the following, on macOS Sonoma with the required Command Line Tools:
# Without pkg-config
% echo "int main(){}" | gcc -xc - -lssl -lcrypto -o /dev/null && echo YES
ld: library 'ssl' not found
clang: error: linker command failed with exit code 1 (use -v to see invocation)
# With pkg-config
% echo "int main(){}" | gcc -xc - $(pkg-config --libs libssl) $(pkg-config --libs libcrypto) -o /dev/null && echo YES
YES
There are no changes to the user-facing build process, and the new shell functions in this PR should make specifying further dependencies quite painless:
% ./compile.sh
Building fry:
OpenSSL lib: found
dependencies done ✔
sdk......... done ✔
front-end... done ✔
runtime..... done ✔
tools....... done ✔
linking..... done ✔
stripping... done ✔
% otool -L bin/*
bin/fry:
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1345.100.2)
/usr/lib/libcurl.4.dylib (compatibility version 7.0.0, current version 9.0.0)
/opt/homebrew/opt/openssl@3/lib/libssl.3.dylib (compatibility version 3.0.0, current version 3.0.0)
/opt/homebrew/opt/openssl@3/lib/libcrypto.3.dylib (compatibility version 3.0.0, current version 3.0.0)
/usr/lib/libedit.3.dylib (compatibility version 2.0.0, current version 3.0.0)
bin/unit:
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1345.100.2)
/usr/lib/libcurl.4.dylib (compatibility version 7.0.0, current version 9.0.0)
/opt/homebrew/opt/openssl@3/lib/libssl.3.dylib (compatibility version 3.0.0, current version 3.0.0)
/opt/homebrew/opt/openssl@3/lib/libcrypto.3.dylib (compatibility version 3.0.0, current version 3.0.0)
/usr/lib/libedit.3.dylib (compatibility version 2.0.0, current version 3.0.0)
Closes #11 (closed).
Edited by Adrian Ho