iOS

In order to build targeting iOS you have to cross compile for a specific architecture targetting a specific sysroot. In order to build targetting arm or aarch64 (iphone) the gas-preprocessor is required.

Make sure to use a gas-preprocessor as recent as the Libav sources. New assembly code can uncover unsupported asm constructs.

You can leverage xcodebuild and xcrun to pick the sysroot you want to cross compile to.

# xcodebuild -showsdks
# xcrun --sdk iphoneos7.1 --show-sdk-path

The clang compiler is inherently a cross-compiler, you should set the target architecture using --extra-cflags and --extra-ldflags to pass the appropriate -arch,

iphoneos target

The iphoneos is available for arm and arm64 targets.

arm

Commonly targeting armv7a

--cc=`xcrun -f --sdk iphoneos7.1 clang`
--arch=armv7
--cpu=cortex-a8
--sysroot=`xcrun --sdk iphoneos7.1 --show-sdk-path`
--target-os=darwin
--extra-cflags='-arch armv7 -Wno-asm-operand-widths -integrated-as'
--extra-ldflags='-arch armv7 -miphoneos-version-min=5.1'
--enable-cross-compile --enable-pic

arm64

Commonly known as aarch64, it is a 64bit architecture, it is available since iOS 7.0.

--cc=`xcrun -f --sdk iphoneos7.1 clang`
--arch=aarch64
--cpu=generic
--sysroot=`xcrun --sdk iphoneos7.1 --show-sdk-path`
--target-os=darwin
--extra-cflags='-arch arm64'
--extra-ldflags='-arch arm64 -miphoneos-version-min=7.0'
--enable-cross-compile

iphonesimulator target

The iphone simulator architecture are x86 and x86_64.

x86

--cc=`xcrun -f --sdk iphonesimulator7.1 clang`
--arch=x86
--cpu=generic
--sysroot=`xcrun --sdk iphonesimulator7.1 --show-sdk-path`
--target-os=darwin
--extra-cflags='-arch i386'
--extra-ldflags='-arch i386 -miphoneos-version-min=7.0'
--enable-cross-compile

x86_64

--cc=`xcrun --sdk iphonesimulator7.1 clang`
--arch=x86_64
--cpu=generic
--sysroot=`xcrun --sdk iphonesimulator7.1 --show-sdk-path`
--target-os=darwin
--extra-cflags='-arch x86_64'
--extra-ldflags='-arch x86_64 -miphoneos-version-min=7.0'
--enable-cross-compile

Creating frameworks

MacOSX peculiar way to bundle libraries and headers is named framework. The basic structure is the following

name.framework/
name.framework/Headers/
name.framework/name

Is possible to use configure to not add prefixes at all

./configure --includedir=/ --libdir=/ --prefix=/ --disable-programs
make install DESTDIR=tmpdir
for lib in lib*; do
    mkdir -p ${lib}.framework/Headers;
    cp tmpdir/${lib}.a ${lib}.framework/${lib}
    cp -a tmpdir/${lib}/* ${lib}/Headers/

This way you create a framework for each library and is the suggested way. The alternative of merging all the libraries in a single libav.a archive and prepare a single libav.framework bundle is sometimes metioned, but then the include paths would be non-standard.

If you plan to develop for iOS comes handy joining the different builds in a single one leveraging lipo.

lipo -create -arch arm arm/libavformat.a -arch arm64 arm64/libavformat.a -arch i383 x86/libavformat.a -arch x86_64 x86_64/libavformat.a libavformat.framework/libavformat
cp -a arm/libavformat libavformat.framework/Headers/