|
| 1 | +#!/bin/bash -xe |
| 2 | + |
| 3 | +# Extract tar.gz to temp folder |
| 4 | +tarname=$(find . -maxdepth 1 -name '*.tar.gz') |
| 5 | +if [ -z "${tarname}" ]; then |
| 6 | + echo "tar.gz not found" |
| 7 | + exit 1 |
| 8 | +fi |
| 9 | +# Remove .tar.gz from filename |
| 10 | +subfoldername=$(echo "${tarname}" | rev | cut -b 8- | rev) |
| 11 | + |
| 12 | +mkdir -p temp_tar |
| 13 | +tar -xzf "${tarname}" -C temp_tar |
| 14 | +mv "temp_tar/${subfoldername}" temp |
| 15 | +cd temp |
| 16 | + |
| 17 | +# Update rpath of library and tools |
| 18 | +libusb_loc=$(find $(brew --cellar) -name libusb-1.0.dylib) |
| 19 | +libxml_loc=$(find $(brew --cellar) -name libxml2.dylib) |
| 20 | +libserialport_loc=$(find $(brew --cellar) -name libserialport.dylib) |
| 21 | +libiio_loc=$(find . -name iio | grep Versions) |
| 22 | +libiioheader_loc=$(find . -name iio.h) |
| 23 | + |
| 24 | +if [ ! -f "${libusb_loc}" ]; then |
| 25 | + echo "libusb library not found" |
| 26 | + exit 1 |
| 27 | +fi |
| 28 | +if [ ! -f "${libxml_loc}" ]; then |
| 29 | + echo "libxml library not found" |
| 30 | + exit 1 |
| 31 | +fi |
| 32 | +if [ ! -f "${libserialport_loc}" ]; then |
| 33 | + echo "libserialport library not found" |
| 34 | + exit 1 |
| 35 | +fi |
| 36 | + |
| 37 | +# Create links to framework files |
| 38 | +mkdir -p usr/local/{lib,include} |
| 39 | +ln -fs "${libiio_loc}" usr/local/lib/libiio.dylib |
| 40 | +ln -fs "${libiioheader_loc}" usr/local/include/iio.h |
| 41 | + |
| 42 | +# Copy dependent libs to local libs |
| 43 | +cp "${libusb_loc}" usr/local/lib/ |
| 44 | +cp "${libxml_loc}" usr/local/lib/ |
| 45 | +cp "${libserialport_loc}" usr/local/lib/ |
| 46 | +chmod +w usr/local/lib/libusb-1.0.dylib |
| 47 | +chmod +w usr/local/lib/libxml2.dylib |
| 48 | +chmod +w usr/local/lib/libserialport.dylib |
| 49 | +install_name_tool -id @rpath/libusb-1.0.dylib usr/local/lib/libusb-1.0.dylib |
| 50 | +install_name_tool -id @rpath/libxml2.dylib usr/local/lib/libxml2.dylib |
| 51 | +install_name_tool -id @rpath/libserialport.dylib usr/local/lib/libserialport.dylib |
| 52 | + |
| 53 | +# Update rpath of library |
| 54 | +install_name_tool -change "${libusb_loc}" "@rpath/libusb-1.0.dylib" "${libiio_loc}" |
| 55 | +install_name_tool -change "${libxml_loc}" "@rpath/libxml2.dylib" "${libiio_loc}" |
| 56 | +install_name_tool -change "${libserialport_loc}" "@rpath/libserialport.dylib" "${libiio_loc}" |
| 57 | +install_name_tool -add_rpath @loader_path/. "${libiio_loc}" |
| 58 | + |
| 59 | +# Update tools |
| 60 | +cd Library/Frameworks/iio.framework/Tools |
| 61 | +for tool in *; |
| 62 | +do |
| 63 | + install_name_tool -add_rpath @loader_path/../.. "${tool}" |
| 64 | +done |
| 65 | +cd ../../../../ |
| 66 | + |
| 67 | +# Remove old tar and create new one |
| 68 | +rm "../${tarname}" |
| 69 | +tar -czf "../${tarname}" . |
| 70 | +cd .. |
| 71 | +rm -rf temp |
0 commit comments