From 4304ad645017fe372308885704cbe10160a50d02 Mon Sep 17 00:00:00 2001
From: Zhipeng Wang <zhipeng.wang_1@nxp.com>
Date: Fri, 16 Sep 2022 16:24:18 +0800
Subject: [PATCH] MA-20666-1 Kleaf: Add wlan as an external module.

Test: tools/bazel run --lto=thin  //common:imx_abi_update_symbol_list

Change-Id: I3ed918514ee08dbd376b9a737b47a21badceed77
Signed-off-by: Zhipeng Wang <zhipeng.wang_1@nxp.com>
---
 mxm_wifiex/wlan_src/BUILD.bazel | 21 +++++++++++++++++++++
 mxm_wifiex/wlan_src/Makefile    |  7 +++----
 2 files changed, 24 insertions(+), 4 deletions(-)
 create mode 100644 mxm_wifiex/wlan_src/BUILD.bazel

diff --git a/mxm_wifiex/wlan_src/BUILD.bazel b/mxm_wifiex/wlan_src/BUILD.bazel
new file mode 100644
index 0000000..0aed636
--- /dev/null
+++ b/mxm_wifiex/wlan_src/BUILD.bazel
@@ -0,0 +1,21 @@
+# NOTE: THIS FILE IS EXPERIMENTAL FOR THE BAZEL MIGRATION AND NOT USED FOR
+# YOUR BUILDS CURRENTLY.
+#
+# It is not yet the source of truth for your build. If you're looking to modify
+# the build file, modify the Android.bp file instead. Do *not* modify this file
+# unless you have coordinated with the team managing the Soong to Bazel
+# migration.
+
+load("//build/kernel/kleaf:kernel.bzl", "kernel_module")
+
+kernel_module(
+    name = "wlan.imx",
+    outs = [
+         "mlan.ko",
+         "moal.ko",
+    ],
+    kernel_build = "//common:imx",
+    visibility = [
+        "//common:__pkg__",
+    ],
+)
diff --git a/mxm_wifiex/wlan_src/Makefile b/mxm_wifiex/wlan_src/Makefile
index 353a2bb..376d747 100644
--- a/mxm_wifiex/wlan_src/Makefile
+++ b/mxm_wifiex/wlan_src/Makefile
@@ -28,6 +28,7 @@ LD ?=		$(CROSS_COMPILE)ld
 BACKUP=		/root/backup
 YMD=		`date +%Y%m%d%H%M`
 PWD := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
+M ?= $(shell pwd)
 
 #############################################################################
 # Configuration Options
@@ -639,12 +640,10 @@ moal-objs := $(MOALOBJS)
 else
 
 default:
-	$(MAKE) -C $(KERNELDIR) M=$(PWD) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) modules
+	$(MAKE) -C $(KERNELDIR) M=$(M) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) modules
 
 modules_install:
-	$(MAKE) -C $(KERNELDIR) M=$(PWD) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) modules_install
-
-
+	$(MAKE) -C $(KERNELDIR) M=$(M) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) modules_install
 endif
 
 ###############################################################