sonic-buildimage/platform/broadcom/saibcm-modules/make/Makefile.linux-kmodule
zitingguo-ms 2c0f4e57d7
Upgrade XGS saibcm-modules to 8.4 (#16246)
Why I did it
XGS saibcm-modules 8.4 is needed. #14471

Work item tracking
Microsoft ADO (number only): 24917414
How I did it
Copy files from xgs SDK 8.4 repo and modify makefiles to build the image.
Upgrade version to 8.4.0.2 in saibcm-modules.mk.

How to verify it
Build a private image and run full qualification with it: https://elastictest.org/scheduler/testplan/650419cb71f60aa92c456a2b
2023-10-26 18:58:34 +08:00

164 lines
5.5 KiB
Makefile

#
# Copyright 2007-2020 Broadcom Inc. All rights reserved.
#
# Permission is granted to use, copy, modify and/or distribute this
# software under either one of the licenses below.
#
# License Option 1: GPL
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2, as
# published by the Free Software Foundation (the "GPL").
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License version 2 (GPLv2) for more details.
#
# You should have received a copy of the GNU General Public License
# version 2 (GPLv2) along with this source code.
#
#
# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license
#
# This software is governed by the Broadcom Open Network Switch APIs license:
# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa
#
# $Id: Makefile.linux-kmodule-3_6,v 1.2 Broadcom SDK $
# $Copyright: (c) 2006 Broadcom Corp.
# All Rights Reserved.$
# Due to the extensive use of driver libraries, the SDK usually builds
# kernel modules from a precompiled object. To avoid various warnings
# and conflicts, the pre-compiled object must be named differently
# from the target module, and the object file itself should be
# appended with "_shipped".
# If a module exports any symbols, then the exporting source file must
# be compiled within the kernel source tree for correct generation of
# module symbol versions. The symbol source file should be passed to
# this Makefile via the MODULE_SYM variable.
MODULE := $(MOD_NAME).o
KMODULE := $(MOD_NAME).ko
obj-m := $(MODULE)
SAVE_CFLAGS := ${CFLAGS}
ifeq (1,$(NO_PRECOMPILED_MODULE))
# {
#
# When compiling the module within the kernel environment, we get plenty of warnings
# of pointer-to-int and the other way round. So, we need to silence them.
# Apart from that, we need a search path on the kernel's 'include' and the various
# SDK 'include' directories.
# It is not clear why they need to be repeated in EXTRA_CFLAGS (probably because
# of the compilation cycle which is done within the SDK environment).
#
ccflags-y := \
-Wno-pointer-to-int-cast \
-Wno-int-to-pointer-cast \
-I$(KERNDIR)/include \
-I$(SDK)/include \
-I$(SDK)/systems/bde/linux/include \
-I$(SDK)/systems/bde/shared/include \
-I$(SDK)/systems/linux/kernel/modules/include
include $(SDK)/make/Make.config
#
# For compilation of all module files on linux environment, make sure
# all CFLAGS are passed to the module. This was not required when a
# 'precompiled' object was used since it automatically got all these flags.
#
ccflags-y += $(KFLAGS)
ccflags-y += $(CFLAGS)
#
# Reach here if this makefile is invoked
# from systems\bde\linux\kernel (module name: linux-kernel-bde.ko).
# from systems\bde\linux\user\kernel (module name: linux-user.ko)
# from systems/linux/kernel/modules/bcm-knet (module name: linux-bcm-knet)
# from systems/linux/kernel/modules/knet-cb (module name: linux-knet-cb)
$(MOD_NAME)-y := $(MOD_OBJS)
#
# If, for any reason, the definition of CROSS_COMPILE was erased, then
# set it, again.
#
ifeq ($(CROSS_COMPILE),)
CROSS_COMPILE = /tools/bin/
endif
export CROSS_COMPILE
# }
else
# {
PRE_COMPILED_OBJ := obj_$(MOD_NAME).o
$(MOD_NAME)-y := $(MODULE_SYM) $(PRE_COMPILED_OBJ)
ifeq (,$(CROSS_COMPILE))
export CROSS_COMPILE
endif
include $(SDK)/make/Make.config
# }
endif
#
# Note that PWD will get two values, in the process of making the module,
# one for the current directory within 'build' and one for the 'base' of the kernel.
#
PWD := $(shell pwd)
ifneq ($(ARCH),)
# ELDK does not seem to `automatically' define ARCH where other gccs may
A := ARCH=$(ARCH)
export ARCH
endif
# Provide an option in case kernel was built in separate directory
KERNBLDDIR ?= $(KERNDIR)
#
# Standard SDK include path for building source files that export
# kernel symbols.
#
override EXTRA_CFLAGS = -I${SDK}/include -I${SDK}/systems/linux/kernel/modules/include -I${SDK}/systems/bde/linux/include
#
# If, for any reason, the definition of LD was erased, then
# set it, again.
#
ifeq ($(LD),)
LD = $(CROSS_COMPILE)ld
endif
ifeq (1,$(NO_PRECOMPILED_MODULE))
# {
$(KMODULE):
rm -f *.o *.ko .*.cmd *.sig *.P
rm -fr .tmp_versions
if [ ! -f $(KERNBLDDIR)/NO_SUPRESS ]; then echo "# suppress warning" > .$(PRE_COMPILED_OBJ).cmd; fi
#
# This make creates the module's object. It, somehow, runs two cycls, one in SDK environment
# and one in the kernel's directory.
#
$(MAKE) -C $(KERNBLDDIR) CROSS_COMPILE=$(CROSS_COMPILE) LD=$(LD) M=$(PWD) modules
if [ ! -f Module.symvers ]; then echo "old kernel (pre-2.6.17)" > Module.symvers; fi
cp -f $(KMODULE) $(LIBDIR)
# }
else
# {
# The precopiled object needs a dummy command file to avoid warnings
# from the Kbuild scripts (modpost stage).
# Kernels before 2.6.17 do not support external module symbols files,
# so we create a dummy to prevent build failures.
#
$(KMODULE):
rm -f *.o *.ko .*.cmd
rm -fr .tmp_versions
ln -s $(LIBDIR)/$(MODULE) $(PRE_COMPILED_OBJ)_shipped
if [ ! -f $(KERNBLDDIR)/NO_SUPRESS ]; then echo "# suppress warning" > .$(PRE_COMPILED_OBJ).cmd; fi
$(MAKE) -C $(KERNBLDDIR) CROSS_COMPILE=$(CROSS_COMPILE) M=$(PWD) modules
if [ ! -f Module.symvers ]; then echo "old kernel (pre-2.6.17)" > Module.symvers; fi
cp -f $(KMODULE) $(LIBDIR)
rm -f $(PRE_COMPILED_OBJ)_shipped
# }
endif
EXTRA_CFLAGS = $(CFLAGS)
CFLAGS := ${SAVE_CFLAGS}