Please note that it is not possible to create a universal library that will work for both iOS Simulator and macOS. iOS / Intel and macOS / Intel are not compatible with ABI over the C runtime library (Libc). This answer serves to show you how to cross-compile autoconf-based projects for iOS purposes, and you can easily merge the resulting static archives together.
You need to do something like this:
#!/bin/bash -e -x OPT_FLAGS="-Os -g3" MAKE_JOBS=16 dobuild() { export CC="$(xcrun -find -sdk ${SDK} cc)" export CXX="$(xcrun -find -sdk ${SDK} cxx)" export CPP="$(xcrun -find -sdk ${SDK} cpp)" export CFLAGS="${HOST_FLAGS} ${OPT_FLAGS}" export CXXFLAGS="${HOST_FLAGS} ${OPT_FLAGS}" export LDFLAGS="${HOST_FLAGS}" ./configure --host=${CHOST} --prefix=${PREFIX} --enable-static --disable-shared make clean make -j${MAKE_JOBS} make install } SDK="iphoneos" ARCH_FLAGS="-arch armv7" HOST_FLAGS="${ARCH_FLAGS} -miphoneos-version-min=8.0 -isysroot $(xcrun -sdk ${SDK} --show-sdk-path)" CHOST="arm-apple-darwin" PREFIX="${HOME}/DEVICE_ARM" dobuild SDK="iphoneos" ARCH_FLAGS="-arch arm64" HOST_FLAGS="${ARCH_FLAGS} -miphoneos-version-min=8.0 -isysroot $(xcrun -sdk ${SDK} --show-sdk-path)" CHOST="arm-apple-darwin" PREFIX="${HOME}/DEVICE_ARM64" dobuild SDK="iphonesimulator" ARCH_FLAGS="-arch i386" HOST_FLAGS="${ARCH_FLAGS} -mios-simulator-version-min=8.0 -isysroot $(xcrun -sdk ${SDK} --show-sdk-path)" CHOST="i386-apple-darwin" PREFIX="${HOME}/SIM_i386" dobuild SDK="iphonesimulator" ARCH_FLAGS="-arch x86_64" HOST_FLAGS="${ARCH_FLAGS} -mios-simulator-version-min=8.0 -isysroot $(xcrun -sdk ${SDK} --show-sdk-path)" CHOST="x86_64-apple-darwin" PREFIX="${HOME}/SIM_x86_64" dobuild
I just threw this script together and checked that it works (with the addition of --disable-libpng and skipped tests) for pixman. You may have to configure it for libgcrypt, but it serves to display a common template for creating projects based on autoconf / automake / glibtool for iOS.
After creation, you will have content in ~ / {DEVICE_ARM {, 64}, SIM_ {i386, x86_64}}, and you can either lipo-static libraries together or just use them all in your project (the linker will emit warnings about missing slices for "other" archives that you can ignore).
lipo -create -output lib.a DEVICE_ARM/lib/lib.a DEVICE_ARM64/lib/lib.a SIM_i386/lib/lib.a SIM_x86_64/lib/lib.a
source share