Include ARM v7s (iPhone 5, iPad 4) support in the universal libjpeg/libturbojpeg libraries distributed with our official binary package for OS X.


git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@923 632fc199-4ca6-4c93-a231-07263d6284db
diff --git a/BUILDING.txt b/BUILDING.txt
index 3207d24..1528fce 100644
--- a/BUILDING.txt
+++ b/BUILDING.txt
@@ -322,16 +322,27 @@
 
 Set the following shell variables for simplicity:
 
+  Xcode 3.2.x / iOS 4.3 SDK:
   IOS_PLATFORMDIR="/Developer/Platforms/iPhoneOS.platform"
   IOS_SYSROOT="$IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS4.3.sdk"
   IOS_GCC="$IOS_PLATFORMDIR/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2"
 
+  Xcode 4.5.x / iOS 6.0 SDK:
+  IOS_PLATFORMDIR="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform"
+  IOS_SYSROOT="$IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS6.0.sdk"
+  IOS_GCC="$IOS_PLATFORMDIR/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2"
+
   ARM v6 only (up to and including iPhone 3G):
+  [NOTE: Requires Xcode 4.4.x or earlier]
   IOS_CFLAGS="-march=armv6 -mcpu=arm1176jzf-s -mfpu=vfp"
 
   ARM v7 only (iPhone 3GS-4S, iPad 1st-3rd Generation):
   IOS_CFLAGS="-march=armv7 -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon"
 
+  ARM v7s only (iPhone 5, iPad 4th Generation):
+  [NOTE: Requires Xcode 4.5 or later]
+  IOS_CFLAGS="-march=armv7s -mcpu=swift -mtune=swift -mfpu=neon"
+
 Follow the procedure under "Building libjpeg-turbo" above, adding
 
   --host arm-apple-darwin10 --enable-static --disable-shared \
@@ -341,21 +352,8 @@
 
 to the configure command line.
 
-Once built, lipo can be used to combine the ARM v6 and v7 variants into a
-universal library.
-
-An ARM v7s version of libjpeg-turbo, for iPhone 5 and iPad 4th Generation
-devices, can be built by using the iPhone 5 SDK in XCode 4.5.  You will have to
-adjust IOS_PLATFORMDIR, IOS_SYSROOT, and IOS_GCC accordingly, and use the
-following compiler flags:
-
-IOS_CFLAGS="-march=armv7s -mcpu=swift -mtune=swift -mfpu=neon"
-
-Unfortunately, XCode 4.5 also dropped support for ARM v6, so it will not be
-possible to use a single version of XCode to build a universal binary that
-supports both the iPhone 3G and earlier and the iPhone 5/iPad 4 and later.
-Even more unfortunately, XCode 4.5 requires OS X 10.7, which means that we
-cannot currently install and test it.
+Once built, lipo can be used to combine the ARM v6, v7, and/or v7s variants
+into a universal library.
 
 
 *******************************************************************************
@@ -691,21 +689,24 @@
 make iosdmg [BUILDDIR32={32-bit build directory}] \
   [BUILDDIRARMV6={ARM v6 build directory}] \
   [BUILDDIRARMV7={ARM v7 build directory}] \
+  [BUILDDIRARMV7S={ARM v7s build directory}]
 
   On OS X systems, this creates a Macintosh package and disk image in which the
   libjpeg-turbo static libraries contain ARM architectures necessary to build
   iOS applications.  If building on an x86-64 system, the binaries will also
   contain the i386 architecture, as with 'make udmg' above.  You should first
-  configure ARM v6 and ARM v7 out-of-tree builds of libjpeg-turbo (see
-  "Building libjpeg-turbo for iOS" above.)  If you are building an x86-64
+  configure ARM v6, ARM v7, and/or ARM v7s out-of-tree builds of libjpeg-turbo
+  (see "Building libjpeg-turbo for iOS" above.)  If you are building an x86-64
   version of libjpeg-turbo, you should configure a 32-bit out-of-tree build as
   well.  Next, build libjpeg-turbo as you would normally, using an out-of-tree
   build.  When it is built, run 'make iosdmg' from the build directory.  The
   build system will look for the ARM v6 build under {source_directory}/iosarmv6
   by default, the ARM v7 build under {source_directory}/iosarmv7 by default,
-  and (if applicable) the 32-bit build under {source_directory}/osxx86 by
-  default, but you can override this by setting the BUILDDIR32, BUILDDIRARMV6,
-  and/or BUILDDIRARMV7 variables on the make command line as shown above.
+  the ARM v7s build under {source_directory}/iosarmv7s by default, and (if
+  applicable) the 32-bit build under {source_directory}/osxx86 by default, but
+  you can override this by setting the BUILDDIR32, BUILDDIRARMV6,
+  BUILDDIRARMV7, and/or BUILDDIRARMV7S variables on the make command line as
+  shown above.
 
 make cygwinpkg
 
diff --git a/ChangeLog.txt b/ChangeLog.txt
index 56a858f..7eee85d 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -57,6 +57,10 @@
 libjpeg v6b or v7 API/ABI (or with previous versions of libjpeg-turbo.)  See
 README-turbo.txt for more details.
 
+[13] Added ARM v7s architecture to libjpeg.a and libturbojpeg.a in the official
+libjpeg-turbo binary package for OS X, so that those libraries can be used to
+build applications that leverage the faster CPUs in the iPhone 5 and iPad 4.
+
 
 1.2.1
 =====
@@ -137,8 +141,8 @@
 correctly.
 
 [7] Added ARM v6 and ARM v7 architectures to libjpeg.a and libturbojpeg.a in
-the official OS X distribution package, so that those libraries can be used to
-build both OS X and iOS applications.
+the official libjpeg-turbo binary package for OS X, so that those libraries can
+be used to build both OS X and iOS applications.
 
 
 1.1.90 (1.2 beta1)
diff --git a/Makefile.am b/Makefile.am
index c010092..eefccba 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -371,12 +371,12 @@
 	sh pkgscripts/makemacpkg -build32 ${BUILDDIR32}
 
 iosdmg: all
-	sh pkgscripts/makemacpkg -build32 ${BUILDDIR32} -buildarmv6 ${BUILDDIRARMV6} -buildarmv7 ${BUILDDIRARMV7}
+	sh pkgscripts/makemacpkg -build32 ${BUILDDIR32} -buildarmv6 ${BUILDDIRARMV6} -buildarmv7 ${BUILDDIRARMV7} -buildarmv7s ${BUILDDIRARMV7S}
 
 else
 
 iosdmg: all
-	sh pkgscripts/makemacpkg -buildarmv6 ${BUILDDIRARMV6} -buildarmv7 ${BUILDDIRARMV7}
+	sh pkgscripts/makemacpkg -buildarmv6 ${BUILDDIRARMV6} -buildarmv7 ${BUILDDIRARMV7} -buildarmv7s ${BUILDDIRARMV7S}
 
 endif
 
diff --git a/release/makemacpkg.in b/release/makemacpkg.in
index d53699d..fb8d692 100644
--- a/release/makemacpkg.in
+++ b/release/makemacpkg.in
@@ -17,7 +17,7 @@
 
 usage()
 {
-	echo "$0 [-build32 [32-bit build dir]] [-buildarmv6 [ARM v6 build dir]] [-buildarmv7 [ARM v7 build dir]]"
+	echo "$0 [-build32 [32-bit build dir]] [-buildarmv6 [ARM v6 build dir]] [-buildarmv7 [ARM v7 build dir]] [-buildarmv7s [ARM v7s build dir]]"
 	exit 1
 }
 
@@ -31,6 +31,8 @@
 BUILDARMV6=0
 BUILDDIRARMV7=@abs_top_srcdir@/iosarmv7
 BUILDARMV7=0
+BUILDDIRARMV7S=@abs_top_srcdir@/iosarmv7s
+BUILDARMV7S=0
 WITH_JAVA=@WITH_JAVA@
 while [ $# -gt 0 ]; do
 	case $1 in
@@ -59,6 +61,14 @@
 			fi
 		fi
 		;;
+	-buildarmv7s)
+		BUILDARMV7S=1
+		if [ $# -gt 1 ]; then
+			if [[ ! "$2" =~ -.* ]]; then
+				BUILDDIRARMV7S=$2;  shift
+			fi
+		fi
+		;;
 	esac
 	shift
 done
@@ -193,6 +203,29 @@
 		-output $PKGROOT/usr/lib/libturbojpeg.a
 fi
 
+if [ $BUILDARMV7S = 1 ]; then
+	if [ ! -d $BUILDDIRARMV7S ]; then
+		echo ERROR: ARM v7s build directory $BUILDDIRARMV7S does not exist
+		exit 1
+	fi
+	if [ ! -f $BUILDDIRARMV7S/Makefile ]; then
+		echo ERROR: ARM v7s build directory $BUILDDIRARMV7S is not configured
+		exit 1
+	fi
+	mkdir -p $TMPDIR/dist.armv7s
+	pushd $BUILDDIRARMV7S
+	make install DESTDIR=$TMPDIR/dist.armv7s
+	popd
+	lipo -create \
+		$PKGROOT/opt/$PACKAGE_NAME/lib/libjpeg.a \
+		-arch arm $TMPDIR/dist.armv7s/opt/$PACKAGE_NAME/lib/libjpeg.a \
+		-output $PKGROOT/opt/$PACKAGE_NAME/lib/libjpeg.a
+	lipo -create \
+		$PKGROOT/usr/lib/libturbojpeg.a \
+		-arch arm $TMPDIR/dist.armv7s/opt/$PACKAGE_NAME/lib/libturbojpeg.a \
+		-output $PKGROOT/usr/lib/libturbojpeg.a
+fi
+
 install_name_tool -id /opt/$PACKAGE_NAME/lib/libjpeg.@SO_MAJOR_VERSION@.dylib $PKGROOT/opt/$PACKAGE_NAME/lib/libjpeg.@SO_MAJOR_VERSION@.dylib
 install_name_tool -id libturbojpeg.0.dylib $PKGROOT/usr/lib/libturbojpeg.0.dylib