--- /dev/null
+From edd3d4347cc73a99c7cf59aceeb1e8ad4d4dd303 Mon Sep 17 00:00:00 2001
+From: crao <quic_crao@quicinc.com>
+Date: Tue, 15 Nov 2022 18:50:01 +0800
+Subject: [PATCH] [qca-ssdk]: Support Linux-Style Makefile for SSDK
+
+Change-Id: I8c4399433b6422ef6192f70bf08b0d3023cc94b6
+Signed-off-by: crao <quic_crao@quicinc.com>
+---
+ Makefile | 15 +++++++++++++
+ Makefile.modules | 16 ++++++++++++++
+ make/defs.mk | 1 +
+ make/linux_opt.mk | 54 ++++++++++++++++++++++++++++-------------------
+ make/target.mk | 12 +++++++++++
+ src/api/Makefile | 2 +-
+ 6 files changed, 77 insertions(+), 23 deletions(-)
+ mode change 100755 => 100644 Makefile
+ create mode 100644 Makefile.modules
+ mode change 100755 => 100644 make/defs.mk
+ mode change 100755 => 100644 make/linux_opt.mk
+ mode change 100755 => 100644 make/target.mk
+ mode change 100755 => 100644 src/api/Makefile
+
+--- a/Makefile
++++ b/Makefile
+@@ -12,6 +12,9 @@ include ./make/$(OS)_opt.mk
+ SUB_DIR=$(patsubst %/, %, $(dir $(wildcard src/*/Makefile)))
+ SUB_LIB=$(subst src/, , $(SUB_DIR))
+
++####################################################################
++# SSDK-Style Makefile
++####################################################################
+ all: $(BIN_DIR) kslib
+ mkdir -p ./temp/;cd ./temp;cp ../build/bin/ssdk_ks_km.a ./;ar -x ssdk_ks_km.a; cp ../ko_Makefile ./Makefile;
+ make -C $(SYS_PATH) M=$(PRJ_PATH)/temp/ CROSS_COMPILE=$(TOOLPREFIX) modules
+@@ -20,6 +23,18 @@ all: $(BIN_DIR) kslib
+ rm -Rf ./temp/*.o ./temp/*.ko ./temp/*.a
+ @echo "---Build [SSDK-$(VERSION)] at $(BUILD_DATE) finished."
+
++####################################################################
++# LNX Modules-Style Makefile
++####################################################################
++modules: $(BIN_DIR) kslib_c
++ cp Makefile.modules ./Makefile;
++ make -C $(SYS_PATH) M=$(PRJ_PATH)/ $(LNX_MAKEOPTS) modules
++ cp *.ko build/bin;
++ @echo "---Build [SSDK-$(VERSION)] at $(BUILD_DATE) finished."
++
++kslib_c:
++ $(foreach i, $(SUB_LIB), $(MAKE) MODULE_TYPE=KSLIB -C src/$i src_list_loop || exit 1;)
++
+ kslib:kslib_o
+ $(AR) -r $(BIN_DIR)/$(KS_MOD)_$(RUNMODE).a $(wildcard $(BLD_DIR)/KSLIB/*.o)
+
+--- /dev/null
++++ b/Makefile.modules
+@@ -0,0 +1,16 @@
++####################################################################
++# Add All Local Flags
++####################################################################
++ccflags-y += $(LNX_LOCAL_CFLAGS) -Wno-error
++
++####################################################################
++# Build Object List
++####################################################################
++SRC_LIST := $(shell cat $(PRJ_PATH)/src_list.dep)
++OBJ_LIST := $(patsubst %.c,%.o,$(SRC_LIST))
++
++####################################################################
++# Linux Kernel Module
++####################################################################
++obj-m := qca-ssdk.o
++qca-ssdk-objs := $(OBJ_LIST)
+--- a/make/defs.mk
++++ b/make/defs.mk
+@@ -7,6 +7,7 @@ ifeq (,$(findstring $(LIB), $(COMPONENTS
+ endif
+
+ SRC_FILE=$(addprefix $(PRJ_PATH)/$(LOC_DIR)/, $(SRC_LIST))
++LOC_SRC_FILE=$(addprefix $(LOC_DIR)/, $(SRC_LIST))
+
+ OBJ_LIST=$(SRC_LIST:.c=.o)
+ OBJ_FILE=$(addprefix $(DST_DIR)/, $(OBJ_LIST))
+--- a/make/linux_opt.mk
++++ b/make/linux_opt.mk
+@@ -295,7 +295,7 @@ ifeq (TRUE, $(DEBUG_ON))
+ MODULE_CFLAG += -g
+ endif
+
+-MODULE_CFLAG += $(OPT_FLAG) -Wall -DVERSION=\"$(VERSION)\" -DBUILD_DATE=\"$(BUILD_DATE)\" -DOS=\"$(OS)\" -D"KBUILD_STR(s)=\#s" -D"KBUILD_MODNAME=KBUILD_STR(qca-ssdk)"
++MODULE_CFLAG += $(OPT_FLAG) -Wall -DVERSION=\"$(VERSION)\" -DBUILD_DATE=\"$(BUILD_DATE)\" -DOS=\"$(OS)\" -D"KBUILD_STR(s)=\#s"
+
+ MODULE_INC += -I$(PRJ_PATH)/include \
+ -I$(PRJ_PATH)/include/common \
+@@ -450,7 +450,7 @@ ifeq (KSLIB, $(MODULE_TYPE))
+ MODULE_CFLAG += -DKVER34
+ MODULE_CFLAG += -DKVER32
+ MODULE_CFLAG += -DLNX26_22
+- MODULE_INC += -I$(SYS_PATH) \
++ SYS_INC += -I$(SYS_PATH) \
+ -I$(TOOL_PATH)/../lib/gcc/$(TARGET_NAME)/$(GCC_VERSION)/include/ \
+ -I$(SYS_PATH)/include \
+ -I$(SYS_PATH)/source/include \
+@@ -473,7 +473,7 @@ ifeq (KSLIB, $(MODULE_TYPE))
+ MODULE_CFLAG += -DKVER32
+ MODULE_CFLAG += -DLNX26_22
+ ifeq ($(ARCH), arm64)
+- MODULE_INC += -I$(SYS_PATH) \
++ SYS_INC += -I$(SYS_PATH) \
+ -I$(TOOL_PATH)/../lib/gcc/$(TARGET_NAME)/$(GCC_VERSION)/include/ \
+ -I$(SYS_PATH)/include \
+ -I$(SYS_PATH)/source \
+@@ -492,13 +492,13 @@ ifeq (KSLIB, $(MODULE_TYPE))
+ -I$(SYS_PATH)/source/include/uapi
+
+ ifneq ($(wildcard $(SYS_PATH)/include/linux/kconfig.h),)
+- MODULE_INC += -include $(SYS_PATH)/include/linux/kconfig.h
++ SYS_INC += -include $(SYS_PATH)/include/linux/kconfig.h
+ else
+- MODULE_INC += -include $(KERNEL_SRC)/include/linux/kconfig.h
++ SYS_INC += -include $(KERNEL_SRC)/include/linux/kconfig.h
+ endif
+
+ else ifeq ($(ARCH), arm)
+- MODULE_INC += -I$(SYS_PATH) \
++ SYS_INC += -I$(SYS_PATH) \
+ -I$(TOOL_PATH)/../lib/gcc/$(TARGET_NAME)/$(GCC_VERSION)/include/ \
+ -I$(TOOL_PATH)/../lib/gcc/$(TARGET_NAME)/7.5.0/include/ \
+ -I$(TOOL_PATH)/../../lib/armv7a-vfp-neon-rdk-linux-gnueabi/gcc/arm-rdk-linux-gnueabi/4.8.4/include/ \
+@@ -522,13 +522,13 @@ ifeq (KSLIB, $(MODULE_TYPE))
+ -I$(TOOL_PATH)/../../lib/arm-rdk-linux-gnueabi/gcc/arm-rdk-linux-gnueabi/9.3.0/include/
+
+ ifneq ($(wildcard $(SYS_PATH)/include/linux/kconfig.h),)
+- MODULE_INC += -include $(SYS_PATH)/include/linux/kconfig.h
++ SYS_INC += -include $(SYS_PATH)/include/linux/kconfig.h
+ else
+- MODULE_INC += -include $(KERNEL_SRC)/include/linux/kconfig.h
++ SYS_INC += -include $(KERNEL_SRC)/include/linux/kconfig.h
+ endif
+
+ else
+- MODULE_INC += -I$(SYS_PATH) \
++ SYS_INC += -I$(SYS_PATH) \
+ -I$(TOOL_PATH)/../lib/gcc/$(TARGET_NAME)/$(GCC_VERSION)/include/ \
+ -I$(SYS_PATH)/include \
+ -I$(SYS_PATH)/source \
+@@ -564,7 +564,7 @@ ifeq (KSLIB, $(MODULE_TYPE))
+ MODULE_CFLAG += -DLNX26_22
+ ifeq ($(ARCH), arm64)
+ KCONF_FILE = $(SYS_PATH)/source/include/linux/kconfig.h
+- MODULE_INC += -I$(SYS_PATH) \
++ SYS_INC += -I$(SYS_PATH) \
+ -I$(TOOL_PATH)/../lib/gcc/$(TARGET_NAME)/$(GCC_VERSION)/include/ \
+ -I$(SYS_PATH)/include \
+ -I$(SYS_PATH)/source/include \
+@@ -581,7 +581,7 @@ ifeq (KSLIB, $(MODULE_TYPE))
+ -I$(SYS_PATH)/source/arch/arm64/include/asm/mach \
+ -include $(KCONF_FILE)
+ else ifeq ($(ARCH), arm)
+- MODULE_INC += -I$(SYS_PATH) \
++ SYS_INC += -I$(SYS_PATH) \
+ -I$(TOOL_PATH)/../lib/gcc/$(TARGET_NAME)/$(GCC_VERSION)/include/ \
+ -I$(TOOL_PATH)/../../lib/armv7a-vfp-neon-rdk-linux-gnueabi/gcc/arm-rdk-linux-gnueabi/4.8.4/include/ \
+ -I$(SYS_PATH)/include \
+@@ -604,7 +604,7 @@ ifeq (KSLIB, $(MODULE_TYPE))
+ MODULE_CFLAG += -DKVER34
+ MODULE_CFLAG += -DKVER32
+ MODULE_CFLAG += -DLNX26_22
+- MODULE_INC += -I$(SYS_PATH) \
++ SYS_INC += -I$(SYS_PATH) \
+ -I$(TOOL_PATH)/../lib/gcc/$(TARGET_NAME)/$(GCC_VERSION)/include/ \
+ -I$(TOOL_PATH)/../../lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/5.3.0/include/ \
+ -I$(TOOL_PATH)/../../lib/armv7a-vfp-neon-rdk-linux-gnueabi/gcc/arm-rdk-linux-gnueabi/4.8.4/include/ \
+@@ -627,10 +627,10 @@ ifeq (KSLIB, $(MODULE_TYPE))
+ -I$(EXT_PATH) \
+ -I$(SYS_PATH)/source/arch/arm/include/asm/mach
+ ifneq ($(wildcard $(SYS_PATH)/include/linux/kconfig.h),)
+- MODULE_INC += \
++ SYS_INC += \
+ -include $(SYS_PATH)/include/linux/kconfig.h
+ else
+- MODULE_INC += \
++ SYS_INC += \
+ -include $(SYS_PATH)/source/include/linux/kconfig.h
+ endif
+
+@@ -641,7 +641,7 @@ ifeq (KSLIB, $(MODULE_TYPE))
+ MODULE_CFLAG += -DKVER32
+ MODULE_CFLAG += -DLNX26_22
+ MODULE_CFLAG += -Werror
+- MODULE_INC += -I$(SYS_PATH) \
++ SYS_INC += -I$(SYS_PATH) \
+ -I$(SYS_PATH)/include \
+ -I$(SYS_PATH)/source/include \
+ -I$(SYS_PATH)/source/arch/arm/mach-msm/include \
+@@ -657,7 +657,7 @@ ifeq (KSLIB, $(MODULE_TYPE))
+ MODULE_CFLAG += -DKVER32
+ MODULE_CFLAG += -DLNX26_22
+ ifeq (mips, $(CPU))
+- MODULE_INC += -I$(SYS_PATH) \
++ SYS_INC += -I$(SYS_PATH) \
+ -I$(SYS_PATH)/include \
+ -I$(SYS_PATH)/arch/mips/include \
+ -I$(SYS_PATH)/arch/mips/include/asm/mach-ar7240 \
+@@ -678,7 +678,7 @@ ifeq (KSLIB, $(MODULE_TYPE))
+ -O2 -fno-pic -pipe -mabi=32 -march=mips32r2 -DMODULE -mlong-calls -DEXPORT_SYMTAB
+ endif
+ else
+- MODULE_INC += -I$(SYS_PATH) \
++ SYS_INC += -I$(SYS_PATH) \
+ -I$(SYS_PATH)/include \
+ -I$(SYS_PATH)/arch/arm/include \
+ -I$(SYS_PATH)/arch/arm/include/asm \
+@@ -695,7 +695,7 @@ ifeq (KSLIB, $(MODULE_TYPE))
+ MODULE_CFLAG += -DKVER26
+ MODULE_CFLAG += -DLNX26_22
+ ifeq (mips, $(CPU))
+- MODULE_INC += -I$(SYS_PATH) \
++ SYS_INC += -I$(SYS_PATH) \
+ -I$(SYS_PATH)/include \
+ -I$(SYS_PATH)/arch/mips/include \
+ -I$(SYS_PATH)/arch/mips/include/asm/mach-ar7240 \
+@@ -708,7 +708,7 @@ ifeq (KSLIB, $(MODULE_TYPE))
+ -O2 -fno-pic -pipe -mabi=32 -march=mips32r2 -DMODULE -mlong-calls -DEXPORT_SYMTAB
+ endif
+ else
+- MODULE_INC += -I$(SYS_PATH) \
++ SYS_INC += -I$(SYS_PATH) \
+ -I$(SYS_PATH)/include \
+ -I$(SYS_PATH)/arch/arm/include \
+ -I$(SYS_PATH)/arch/arm/include/asm \
+@@ -721,8 +721,7 @@ ifeq (KSLIB, $(MODULE_TYPE))
+
+ endif
+
+- MODULE_CFLAG += -D__KERNEL__ -DKERNEL_MODULE $(CPU_CFLAG)
+-
++ MODULE_CFLAG += -D__KERNEL__ -DKERNEL_MODULE
+
+ endif
+
+@@ -748,4 +747,15 @@ ifneq (TRUE, $(KERNEL_MODE))
+ endif
+ endif
+
+-LOCAL_CFLAGS += $(MODULE_INC) $(MODULE_CFLAG) $(EXTRA_CFLAGS)
++LOCAL_CFLAGS += $(MODULE_INC) $(SYS_INC) $(MODULE_CFLAG) $(EXTRA_CFLAGS)
++
++####################################################################
++# cflags for SSDK-Style Makefile
++####################################################################
++LOCAL_CFLAGS += $(CPU_CFLAG) -D"KBUILD_MODNAME=KBUILD_STR(qca-ssdk)"
++
++####################################################################
++# cflags for LNX Modules-Style Makefile
++####################################################################
++LNX_LOCAL_CFLAGS += $(MODULE_INC) $(MODULE_CFLAG) ${EXTRA_INC}
++export LNX_LOCAL_CFLAGS
+--- a/make/target.mk
++++ b/make/target.mk
+@@ -3,6 +3,18 @@ include $(PRJ_PATH)/make/$(OS)_opt.mk
+
+ include $(PRJ_PATH)/make/tools.mk
+
++####################################################################
++# LNX Modules-Style Makefile
++####################################################################
++src_list_loop: src_list
++ $(foreach i, $(SUB_DIR), $(MAKE) -C $(i) src_list_loop || exit 1;)
++
++src_list:
++ echo -n "$(LOC_SRC_FILE) " >> $(PRJ_PATH)/src_list.dep
++
++####################################################################
++# SSDK-Style Makefile
++####################################################################
+ obj: $(OBJ_LIST)
+ $(OBJ_LOOP)
+
+--- a/src/api/Makefile
++++ b/src/api/Makefile
+@@ -1,4 +1,4 @@
+-LOC_DIR=src/sal
++LOC_DIR=src/api
+ LIB=API
+
+ include $(PRJ_PATH)/make/config.mk