openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

Makefile.linux-kmodule-3_13 (2054B)


      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 # Standard SDK include path for building source files that export
     44 # kernel symbols.
     45 
     46 override EXTRA_CFLAGS = -I${SDK}/include -I${SDK}/systems/linux/kernel/modules/include -I${SDK}/systems/bde/linux/include
     47 
     48 # The precopiled object needs a dummy command file to avoid warnings
     49 # from the Kbuild scripts (modpost stage).
     50 # Kernels before 2.6.17 do not support external module symbols files,
     51 # so we create a dummy to prevent build failures.
     52 	
     53 $(KMODULE):
     54 	rm -f *.o *.ko .*.cmd
     55 	rm -fr .tmp_versions
     56 	ln -s $(LIBDIR)/$(MODULE) $(PRE_COMPILED_OBJ)_shipped
     57 	echo "suppress warning" > .$(PRE_COMPILED_OBJ).cmd
     58 	$(MAKE) -C $(KERNDIR) CROSS_COMPILE=$(CROSS_COMPILE) M=$(PWD) modules
     59 	if [ ! -f Module.symvers ]; then echo "old kernel (pre-2.6.17)" > Module.symvers; fi
     60 	cp -f $(KMODULE) $(LIBDIR)
     61 	rm -f $(PRE_COMPILED_OBJ)_shipped
     62 
     63 EXTRA_CFLAGS = $(CFLAGS)
     64 CFLAGS := ${SAVE_CFLAGS}