diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2020-05-07 05:59:37 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2020-05-07 05:59:37 -0400 |
commit | cd85778597a709c5d589c9f984d039e5b96bafca (patch) | |
tree | 4a0e4cecb2ff216cc270a2fac5716a54175e7c15 /bzip2 | |
parent | 041601b591742fa071f50f25ee8ef9f5b1008bd4 (diff) | |
download | spm_packages-cd85778597a709c5d589c9f984d039e5b96bafca.tar.gz |
Initial Darwin compat sweep
Diffstat (limited to 'bzip2')
-rw-r--r-- | bzip2/build.sh | 87 |
1 files changed, 72 insertions, 15 deletions
diff --git a/bzip2/build.sh b/bzip2/build.sh index ab59efd..4ddf384 100644 --- a/bzip2/build.sh +++ b/bzip2/build.sh @@ -3,35 +3,92 @@ name=bzip2 version=1.0.8 revision=0 sources=( - https://sourceware.org/pub/bzip2/${name}-${version}.tar.gz + https://sourceware.org/pub/${name}/${name}-${version}.tar.gz ) depends=() +lib_type=so function prepare() { tar xf ${name}-${version}.tar.gz cd ${name}-${version} + + if [[ $(uname -s) == Darwin ]]; then + # Rotate the elder signs 14.8 degrees counter-clockwise + lib_type=dylib + cp Makefile Makefile.orig + cp Makefile-libbz2_so Makefile-libbz2_so.orig + sed -e 's|$(PREFIX)|$(DESTDIR)$(PREFIX)|g' -e 's|2\.so|2.dylib|g' < Makefile.orig > Makefile + sed -e 's|-soname|-install_name|g' -e 's|2\.so|2.dylib|g' < Makefile-libbz2_so.orig > Makefile-libbz2_so + fi } function build() { - make -f Makefile-libbz2_so CC="gcc $CFLAGS $LDFLAGS" make bzip2 bzip2recover CC="gcc $CFLAGS $LDFLAGS" + make -f Makefile-libbz2_so CC="gcc $CFLAGS $LDFLAGS" } function package() { - install -dm755 "${_pkgdir}/${_prefix}"/{bin,lib,include,share/man/man1} - install -m755 bzip2-shared "${_pkgdir}/${_prefix}"/bin/bzip2 - install -m755 bzip2recover bzdiff bzgrep bzmore "${_pkgdir}/${_prefix}"/bin - ln -sf bzip2 "${_pkgdir}/${_prefix}"/bin/bunzip2 - ln -sf bzip2 "${_pkgdir}/${_prefix}"/bin/bzcat - cp -a libbz2.so* "${_pkgdir}/${_prefix}"/lib - ln -s libbz2.so.${version} "${_pkgdir}/${_prefix}"/lib/libbz2.so - ln -s libbz2.so.${version} "${_pkgdir}/${_prefix}"/lib/libbz2.so.1 - install -m644 bzlib.h "${_pkgdir}/${_prefix}"/include - install -m644 bzip2.1 "${_pkgdir}/${_prefix}"/share/man/man1 - ln -sf bzip2.1 "${_pkgdir}/${_prefix}"/share/man/man1/bunzip2.1 - ln -sf bzip2.1 "${_pkgdir}/${_prefix}"/share/man/man1/bzcat.1 - ln -sf bzip2.1 "${_pkgdir}/${_prefix}"/share/man/man1/bzip2recover.1 + # Wow, this makefile is horrible. Fix shared library names. + lib_format=${lib_type}.${version} + lib_format_short=${lib_type}.${version%.*} + if [[ $(uname -s) == Darwin ]]; then + lib_format_darwin=${version}.${lib_type} + lib_format_darwin_short=${version%.*}.${lib_type} + + mv libbz2.${lib_format} libbz2.${lib_format_darwin} + # Remove remaining Linux-style shared libraries + rm -f libbz2.${lib_type}* + + # Reconstruct symlinks + ln -s libbz2.${lib_format_darwin} libbz2.${lib_format_darwin_short} + ln -s libbz2.${lib_format_darwin} libbz2.${lib_type} + + # Reset LC_ID_DYLIB to use expected naming conventions + install_name_tool -id libbz2.${lib_format_darwin_short} \ + libbz2.${lib_format_darwin} + + lib_format=${lib_format_darwin} + lib_format_short=${lib_format_darwin_short} + fi + + # Install bzip2, for what its worth + make install PREFIX=${_prefix} DESTDIR=${_pkgdir} + + # Install binaries + cp -a bzip2-shared "${_pkgdir}${_prefix}"/bin/bzip2 + cp -a libbz2.${lib_format} "${_pkgdir}${_prefix}"/lib + cp -a libbz2.${lib_format_short} "${_pkgdir}${_prefix}"/lib + cp -a libbz2.${lib_type} "${_pkgdir}${_prefix}"/lib + + # Wow, this makefile is horrible. Destroy symlinks it created. + for f in "${_pkgdir}${_prefix}"/bin/*; do + if [[ -L "$f" ]]; then + rm -f "${f}" + fi + done + + # Fix botched copy operation in makefile + cp -a bzdiff "${_pkgdir}${_prefix}"/bin + cp -a bzgrep "${_pkgdir}${_prefix}"/bin + chmod +x bzmore + cp -a bzmore "${_pkgdir}${_prefix}"/bin + + # Recreate symlinks with relative paths + ln -sf bzip2 "${_pkgdir}${_prefix}"/bin/bunzip2 + ln -sf bzip2 "${_pkgdir}${_prefix}"/bin/bzcat + ln -sf bzgrep "${_pkgdir}${_prefix}"/bin/bzfgrep + ln -sf bzgrep "${_pkgdir}${_prefix}"/bin/bzegrep + ln -sf bzdiff "${_pkgdir}${_prefix}"/bin/bzcmp + ln -sf bzmore "${_pkgdir}${_prefix}"/bin/bzless + + # Fix man directory location + mkdir -p "${_pkgdir}${_prefix}"/share + mv "${_pkgdir}${_prefix}"/man "${_pkgdir}${_prefix}"/share + + ln -sf bzip2.1 "${_pkgdir}${_prefix}"/share/man/man1/bunzip2.1 + ln -sf bzip2.1 "${_pkgdir}${_prefix}"/share/man/man1/bzcat.1 + ln -sf bzip2.1 "${_pkgdir}${_prefix}"/share/man/man1/bzip2recover.1 } |