Makefile.linux-kmodule (2199B)
1 # 2 # This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 3 # 4 # Copyright 2007-2019 Broadcom Inc. All rights reserved. 5 6 # Due to the extensive use of driver libraries, the SDK usually builds 7 # kernel modules from a precompiled object. To avoid various warnings 8 # and conflicts, the pre-compiled object must be named differently 9 # from the target module, and the object file itself should be 10 # appended with "_shipped". 11 12 # If a module exports any symbols, then the exporting source file must 13 # be compiled within the kernel source tree for correct generation of 14 # module symbol versions. The symbol source file should be passed to 15 # this Makefile via the MODULE_SYM variable. 16 17 MODULE := $(MOD_NAME).o 18 KMODULE := $(MOD_NAME).ko 19 PRE_COMPILED_OBJ := obj_$(MOD_NAME).o 20 21 obj-m := $(MODULE) 22 $(MOD_NAME)-y := $(MODULE_SYM) $(PRE_COMPILED_OBJ) 23 24 25 ifeq (,$(CROSS_COMPILE)) 26 27 export CROSS_COMPILE 28 29 endif 30 31 SAVE_CFLAGS := ${CFLAGS} 32 33 include $(SDK)/make/Make.config 34 35 PWD := $(shell pwd) 36 37 ifneq ($(ARCH),) 38 # ELDK does not seem to `automatically' define ARCH where other gccs may 39 A := ARCH=$(ARCH) 40 export ARCH 41 endif 42 43 # Provide an option in case kernel was built in separate directory 44 KERNBLDDIR ?= $(KERNDIR) 45 46 # Standard SDK include path for building source files that export 47 # kernel symbols. 48 49 override EXTRA_CFLAGS = -I${SDK}/include -I${SDK}/systems/linux/kernel/modules/include -I${SDK}/systems/bde/linux/include 50 51 # The precopiled object needs a dummy command file to avoid warnings 52 # from the Kbuild scripts (modpost stage). 53 # Kernels before 2.6.17 do not support external module symbols files, 54 # so we create a dummy to prevent build failures. 55 56 $(KMODULE): 57 rm -f *.o *.ko .*.cmd 58 rm -fr .tmp_versions 59 ln -s $(LIBDIR)/$(MODULE) $(PRE_COMPILED_OBJ)_shipped 60 if [ ! -f $(KERNBLDDIR)/NO_SUPRESS ]; then echo "# suppress warning" > .$(PRE_COMPILED_OBJ).cmd; fi 61 $(MAKE) -C $(KERNBLDDIR) CROSS_COMPILE=$(CROSS_COMPILE) M=$(PWD) modules 62 if [ ! -f Module.symvers ]; then echo "old kernel (pre-2.6.17)" > Module.symvers; fi 63 cp -f $(KMODULE) $(LIBDIR) 64 rm -f $(PRE_COMPILED_OBJ)_shipped 65 66 EXTRA_CFLAGS = $(CFLAGS) 67 CFLAGS := ${SAVE_CFLAGS}