-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
141 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/bin/sh | ||
|
||
set -ue | ||
|
||
LINK_MODE="$1" | ||
OS="$2" | ||
FLAGS= | ||
CCLIB= | ||
|
||
case "$LINK_MODE" in | ||
dynamic) | ||
;; # No extra flags needed | ||
static) | ||
case "$OS" in | ||
linux) | ||
CCLIB="-static -no-pie";; | ||
*) | ||
echo "No known static compilation flags for '$OS'" >&2 | ||
exit 1 | ||
esac;; | ||
mixed) | ||
FLAGS="-noautolink" | ||
# Note: for OCaml 5, use -lcamlstrnat and -lunixnat and mind zlib | ||
# https://github.com/ocaml/ocaml/issues/12562 | ||
CCLIB="-lnums -lzarith -lunix" | ||
LIBS="gmp" | ||
case "$OS" in | ||
linux) | ||
for lib in $LIBS; do | ||
CCLIB="$CCLIB -l$lib" | ||
done | ||
CCLIB="-Wl,-Bstatic $CCLIB -Wl,-Bdynamic";; | ||
macosx) | ||
for lib in $LIBS; do | ||
if [[ $lib == lib* ]]; then | ||
archive="$lib.a" | ||
else | ||
archive="lib$lib.a" | ||
fi | ||
CCLIB="$CCLIB $(pkg-config $lib --variable libdir)/$archive" | ||
done;; | ||
*) | ||
echo "No known mixed compilation flags for '$OS'" >&2 | ||
exit 1 | ||
esac;; | ||
|
||
*) | ||
echo "Invalid link mode '$LINK_MODE'" >&2 | ||
exit 2 | ||
esac | ||
|
||
echo '(' | ||
echo ' -linkall' | ||
for f in $FLAGS; do echo " $f"; done | ||
for f in $CCLIB; do echo " -cclib $f"; done | ||
echo ')' |