From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: syphyr <syphyr@gmail.com>
Date: Mon, 13 Jun 2022 20:18:46 +0200
Subject: [PATCH] Backport Makefile for Nougat

Change-Id: Ie0cdd00be6f73a0b39a43eb67c95a0a628a11923
---
 Android.bp | 54 ------------------------------------
 Android.mk | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 81 insertions(+), 54 deletions(-)
 delete mode 100644 Android.bp
 create mode 100644 Android.mk

diff --git a/Android.bp b/Android.bp
deleted file mode 100644
index 80a0347..0000000
--- a/Android.bp
+++ /dev/null
@@ -1,54 +0,0 @@
-cc_library_static {
-    name: "libFraunhoferAAC",
-    vendor_available: true,
-    srcs: [
-        "libAACdec/src/*.cpp",
-        "libAACenc/src/*.cpp",
-        "libPCMutils/src/*.cpp",
-        "libFDK/src/*.cpp",
-        "libSYS/src/*.cpp",
-        "libMpegTPDec/src/*.cpp",
-        "libMpegTPEnc/src/*.cpp",
-        "libSBRdec/src/*.cpp",
-        "libSBRenc/src/*.cpp",
-        "libArithCoding/src/*.cpp",
-        "libDRCdec/src/*.cpp",
-        "libSACdec/src/*.cpp",
-        "libSACenc/src/*.cpp",
-    ],
-    cflags: [
-        "-Werror",
-        "-Wno-unused-parameter",
-        "-Wno-#warnings",
-        "-Wuninitialized",
-        "-Wno-self-assign",
-        "-Wno-implicit-fallthrough",
-    ],
-    sanitize: {
-        misc_undefined:[
-           "unsigned-integer-overflow",
-           "signed-integer-overflow",
-           "bounds",
-        ],
-        // Enable CFI if this becomes a shared library.
-        // cfi: true,
-    },
-    shared_libs: [
-        "liblog",
-    ],
-    export_include_dirs: [
-        "libAACdec/include",
-        "libAACenc/include",
-        "libPCMutils/include",
-        "libFDK/include",
-        "libSYS/include",
-        "libMpegTPDec/include",
-        "libMpegTPEnc/include",
-        "libSBRdec/include",
-        "libSBRenc/include",
-        "libArithCoding/include",
-        "libDRCdec/include",
-        "libSACdec/include",
-        "libSACenc/include",
-    ],
-}
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..fc89fa6
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,81 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+aacdec_sources := $(sort $(wildcard $(LOCAL_PATH)/libAACdec/src/*.cpp))
+aacdec_sources := $(aacdec_sources:$(LOCAL_PATH)/libAACdec/src/%=%)
+
+aacenc_sources := $(sort $(wildcard $(LOCAL_PATH)/libAACenc/src/*.cpp))
+aacenc_sources := $(aacenc_sources:$(LOCAL_PATH)/libAACenc/src/%=%)
+
+pcmutils_sources := $(sort $(wildcard $(LOCAL_PATH)/libPCMutils/src/*.cpp))
+pcmutils_sources := $(pcmutils_sources:$(LOCAL_PATH)/libPCMutils/src/%=%)
+
+fdk_sources := $(sort $(wildcard $(LOCAL_PATH)/libFDK/src/*.cpp))
+fdk_sources := $(fdk_sources:$(LOCAL_PATH)/libFDK/src/%=%)
+
+sys_sources := $(sort $(wildcard $(LOCAL_PATH)/libSYS/src/*.cpp))
+sys_sources := $(sys_sources:$(LOCAL_PATH)/libSYS/src/%=%)
+
+mpegtpdec_sources := $(sort $(wildcard $(LOCAL_PATH)/libMpegTPDec/src/*.cpp))
+mpegtpdec_sources := $(mpegtpdec_sources:$(LOCAL_PATH)/libMpegTPDec/src/%=%)
+
+mpegtpenc_sources := $(sort $(wildcard $(LOCAL_PATH)/libMpegTPEnc/src/*.cpp))
+mpegtpenc_sources := $(mpegtpenc_sources:$(LOCAL_PATH)/libMpegTPEnc/src/%=%)
+
+sbrdec_sources := $(sort $(wildcard $(LOCAL_PATH)/libSBRdec/src/*.cpp))
+sbrdec_sources := $(sbrdec_sources:$(LOCAL_PATH)/libSBRdec/src/%=%)
+
+sbrenc_sources := $(sort $(wildcard $(LOCAL_PATH)/libSBRenc/src/*.cpp))
+sbrenc_sources := $(sbrenc_sources:$(LOCAL_PATH)/libSBRenc/src/%=%)
+
+arithcoding_sources := $(sort $(wildcard $(LOCAL_PATH)/libArithCoding/src/*.cpp))
+arithcoding_sources := $(arithcoding_sources:$(LOCAL_PATH)/libArithCoding/src/%=%)
+
+drcdec_sources := $(sort $(wildcard $(LOCAL_PATH)/libDRCdec/src/*.cpp))
+drcdec_sources := $(drcdec_sources:$(LOCAL_PATH)/libDRCdec/src/%=%)
+
+sacdec_sources := $(sort $(wildcard $(LOCAL_PATH)/libSACdec/src/*.cpp))
+sacdec_sources := $(sacdec_sources:$(LOCAL_PATH)/libSACdec/src/%=%)
+
+sacenc_sources := $(sort $(wildcard $(LOCAL_PATH)/libSACenc/src/*.cpp))
+sacenc_sources := $(sacenc_sources:$(LOCAL_PATH)/libSACenc/src/%=%)
+
+LOCAL_SRC_FILES := \
+        $(aacdec_sources:%=libAACdec/src/%) \
+        $(aacenc_sources:%=libAACenc/src/%) \
+        $(pcmutils_sources:%=libPCMutils/src/%) \
+        $(fdk_sources:%=libFDK/src/%) \
+        $(sys_sources:%=libSYS/src/%) \
+        $(mpegtpdec_sources:%=libMpegTPDec/src/%) \
+        $(mpegtpenc_sources:%=libMpegTPEnc/src/%) \
+        $(sbrdec_sources:%=libSBRdec/src/%) \
+        $(sbrenc_sources:%=libSBRenc/src/%) \
+        $(arithcoding_sources:%=libArithCoding/src/%) \
+        $(drcdec_sources:%=libDRCdec/src/%) \
+        $(sacdec_sources:%=libSACdec/src/%) \
+        $(sacenc_sources:%=libSACenc/src/%)
+
+LOCAL_CFLAGS += -Werror -Wno-unused-parameter -Wno-#warnings -Wuninitialized \
+                -Wno-self-assign -Wno-implicit-fallthrough
+
+LOCAL_C_INCLUDES := \
+        $(LOCAL_PATH)/libAACdec/include \
+        $(LOCAL_PATH)/libAACenc/include \
+        $(LOCAL_PATH)/libPCMutils/include \
+        $(LOCAL_PATH)/libFDK/include \
+        $(LOCAL_PATH)/libSYS/include \
+        $(LOCAL_PATH)/libMpegTPDec/include \
+        $(LOCAL_PATH)/libMpegTPEnc/include \
+        $(LOCAL_PATH)/libSBRdec/include \
+        $(LOCAL_PATH)/libSBRenc/include \
+        $(LOCAL_PATH)/libArithCoding/include \
+        $(LOCAL_PATH)/libDRCdec/include \
+        $(LOCAL_PATH)/libSACdec/include \
+        $(LOCAL_PATH)/libSACenc/include
+
+LOCAL_SHARED_LIBRARIES := \
+        liblog
+
+LOCAL_MODULE:= libFraunhoferAAC
+
+include $(BUILD_STATIC_LIBRARY)
