Skip to content
This repository has been archived by the owner on Sep 29, 2022. It is now read-only.

Commit

Permalink
xar: Hacked to be as static as possible
Browse files Browse the repository at this point in the history
  • Loading branch information
mingwandroid committed Aug 13, 2017
1 parent f8d794d commit a0c1ac6
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
43 changes: 40 additions & 3 deletions xar/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,48 @@

pushd xar
./autogen.sh --noconfigure
# Because --disable-shared happily links to shared libs
rm -f "${PREFIX}"/lib/lib{xml2,bz2,z,lzma,iconv}*.dylib*
# Because --disable-shared happily links to shared libs:
# (here the xar executable dynamically links them, while
# the shared library just contains undefined references)
rm -f "${PREFIX}"/lib/lib{xml2,bz2,z,lzma,iconv}*.dylib
./configure --prefix=${PREFIX} \
--with-lzma=${PREFIX} \
--disable-shared
--disable-shared \
--enable-static
make
make install
# Since libxar is linked to ld64 it's imperative that we
# do not have any transitive static library dependencies.
# The reason being that these can end up as dynamic libs
# at the point of consumption. If this library generated
# .pc files and if my port of ld64 read those this would
# not be necessary; still it should be safe. One thing to
# take care about is that libcrypto.dylib is needed and
# we want that to come from a 10.9 sysroot and not from
# a conda openssl package. The way to ensure this happens
# is by linking to '/usr/lib/libcrypto.dylib' directly,
# instead of using '-L/usr/lib -lcrypto'
declare -a _statics
_statics+=(libxar.a)
_statics+=(libxml2.a)
_statics+=(libz.a)
_statics+=(liblzma.a)
_statics+=(libiconv.a)
_statics+=(libbz2.a)
mkdir -p tmp_reform
pushd tmp_reform
for _static in "${_statics[@]}"; do
_full_a=${PREFIX}/lib/${_static}
if [[ ! -e ${_full_a} ]]; then
echo "${_full_a} does not exist"
ls $(dirname ${_full_a})/*.a
exit 1
fi
ar -x ${_full_a}
done
[[ -f ../libxar.a ]] && rm -rf ../libxar.a
ar crv ../libxar.a *.o
popd
ranlib libxar.a
cp -f libxar.a ${PREFIX}/lib
popd
7 changes: 6 additions & 1 deletion xar/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# of it, not this fork. Still, it should work OK. We do not need lzma and
# may not even need bzip2 nor libxml2 however the build system ignores
# --without-lzma (and probably the others too) and finds system libraries.
# Also, I link the transitive static libraries into libxar.

package:
name: xar
Expand Down Expand Up @@ -31,7 +32,11 @@ about:
A fork/clone of the subversion xar repository from
http://xar.googlecode.com/svn/ that includes several
enhancements and bug fixes including very basic command
line signature support (master branch).
line signature support. This is not a general purpose
package and exists only as a dependency for ld64. As
such, on Darwin, it is entirely statically linked, except
for libcrypto, which you must ensure gets resolved to
/usr/lib/libcrypto.dylib when this library is consumed.
doc_url: http://mackyle.github.io/xar/xar.html
doc_source_url: https://raw.githubusercontent.com/mackyle/xar/master/xar/xar.spec.in
dev_url: https://github.com/mackyle/xar

0 comments on commit a0c1ac6

Please sign in to comment.