#!/bin/bash
#
# syntax: smart_lipo_thin file
#
# extracts the native architecture part of the fat input file, or does nothing if input is thin
#

INPUT=$1
ARCH=`arch`

REPORT=`lipo -info $INPUT 2>&1 | cut -d\  -f1-5`
if [ "$REPORT" == "Architectures in the fat file:" ]
then
  echo thinning `basename $INPUT`
  lipo -thin $ARCH $INPUT -output $INPUT.tmp
  rm -f $INPUT
  mv $INPUT.tmp $INPUT
fi

