- # elf.h is taken from glibc since the elf.h in the NDK is lacking.
- # sysexits.h is header-only and used by a few programs.
- cp "$TERMUX_SCRIPTDIR"/ndk_patches/{elf.h,sysexits.h} $_TERMUX_TOOLCHAIN_TMPDIR/sysroot/usr/include
+ # elf.h: Taken from glibc since the elf.h in the NDK is lacking.
+ # sysexits.h: Header-only and used by a few programs.
+ # ifaddrs.h: Added in android-24 unified headers, use a inline implementation for now.
+ cp "$TERMUX_SCRIPTDIR"/ndk-patches/{elf.h,sysexits.h,ifaddrs.h} usr/include
+
+ # Remove <sys/shm.h> from the NDK in favour of that from the libandroid-shmem.
+ # Also remove <sys/sem.h> as it doesn't work for non-root.
+ rm usr/include/sys/{shm.h,sem.h}
+
+ sed -i "s/define __ANDROID_API__ __ANDROID_API_FUTURE__/define __ANDROID_API__ $TERMUX_API_LEVEL/" \
+ usr/include/android/api-level.h