Fix minizip compile on Haiku (#16301)
[mono-project.git] / sdks / builds / create-shared-library.sh
blobcadc86f662054b68bd2750be3b4aee0eb5c44c70
1 #!/bin/bash -e
3 # This script takes a static library (.a) as input and creates a dylib or framework from it:
4 # 1) First all the object files are extracted from the static library.
5 # 2) Then all the object files are relinked into a dynamic library / framework).
7 # Arguments
8 # 1: the input static library
9 # 2: the output framework library
10 # 3+: any custom linker arguments.
12 STATIC_LIBRARY=$1
13 FRAMEWORK=$2
15 if test -z $STATIC_LIBRARY; then
16 echo "The first argument must be the input (static) library."
17 exit 1
18 elif ! test -f $STATIC_LIBRARY; then
19 echo "Could not find the input library: $STATIC_LIBRARY"
20 exit 1
23 if test -z $FRAMEWORK; then
24 echo "The second argument must be the output (shared) library."
25 exit 1
28 shift 2
29 LINKER_FLAGS="$@"
31 mkdir -p $(dirname $FRAMEWORK)
32 TMPDIR=$FRAMEWORK.tmpdir
33 rm -Rf $TMPDIR
34 mkdir -p $TMPDIR
35 cd $TMPDIR
36 ar -x $STATIC_LIBRARY
37 cd ..
39 $CC $LINKER_FLAGS -dynamiclib -O2 -Wl,-application_extension -compatibility_version 2 -current_version 2.0 -framework CoreFoundation -lobjc -liconv -lz -o $FRAMEWORK $TMPDIR/*.o