Makefile.linux-kmodule (2746B)
1 # 2 # Copyright 2017 Broadcom 3 # 4 # This program is free software; you can redistribute it and/or modify 5 # it under the terms of the GNU General Public License, version 2, as 6 # published by the Free Software Foundation (the "GPL"). 7 # 8 # This program is distributed in the hope that it will be useful, but 9 # WITHOUT ANY WARRANTY; without even the implied warranty of 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 # General Public License version 2 (GPLv2) for more details. 12 # 13 # You should have received a copy of the GNU General Public License 14 # version 2 (GPLv2) along with this source code. 15 # 16 # $Id: Makefile.linux-kmodule-3_6,v 1.2 Broadcom SDK $ 17 # $Copyright: (c) 2006 Broadcom Corp. 18 # All Rights Reserved.$ 19 20 # Due to the extensive use of driver libraries, the SDK usually builds 21 # kernel modules from a precompiled object. To avoid various warnings 22 # and conflicts, the pre-compiled object must be named differently 23 # from the target module, and the object file itself should be 24 # appended with "_shipped". 25 26 # If a module exports any symbols, then the exporting source file must 27 # be compiled within the kernel source tree for correct generation of 28 # module symbol versions. The symbol source file should be passed to 29 # this Makefile via the MODULE_SYM variable. 30 31 MODULE := $(MOD_NAME).o 32 KMODULE := $(MOD_NAME).ko 33 PRE_COMPILED_OBJ := obj_$(MOD_NAME).o 34 35 obj-m := $(MODULE) 36 $(MOD_NAME)-y := $(MODULE_SYM) $(PRE_COMPILED_OBJ) 37 38 39 ifeq (,$(CROSS_COMPILE)) 40 41 export CROSS_COMPILE 42 43 endif 44 45 SAVE_CFLAGS := ${CFLAGS} 46 47 include $(SDK)/make/Make.config 48 49 PWD := $(shell pwd) 50 51 ifneq ($(ARCH),) 52 # ELDK does not seem to `automatically' define ARCH where other gccs may 53 A := ARCH=$(ARCH) 54 export ARCH 55 endif 56 57 # Provide an option in case kernel was built in separate directory 58 KERNBLDDIR ?= $(KERNDIR) 59 60 # Standard SDK include path for building source files that export 61 # kernel symbols. 62 63 override EXTRA_CFLAGS = -I${SDK}/include -I${SDK}/systems/linux/kernel/modules/include -I${SDK}/systems/bde/linux/include 64 65 # The precopiled object needs a dummy command file to avoid warnings 66 # from the Kbuild scripts (modpost stage). 67 # Kernels before 2.6.17 do not support external module symbols files, 68 # so we create a dummy to prevent build failures. 69 70 $(KMODULE): 71 rm -f *.o *.ko .*.cmd 72 rm -fr .tmp_versions 73 ln -s $(LIBDIR)/$(MODULE) $(PRE_COMPILED_OBJ)_shipped 74 if [ ! -f $(KERNBLDDIR)/NO_SUPRESS ]; then echo "# suppress warning" > .$(PRE_COMPILED_OBJ).cmd; fi 75 $(MAKE) -C $(KERNBLDDIR) CROSS_COMPILE=$(CROSS_COMPILE) M=$(PWD) modules 76 if [ ! -f Module.symvers ]; then echo "old kernel (pre-2.6.17)" > Module.symvers; fi 77 cp -f $(KMODULE) $(LIBDIR) 78 rm -f $(PRE_COMPILED_OBJ)_shipped 79 80 EXTRA_CFLAGS = $(CFLAGS) 81 CFLAGS := ${SAVE_CFLAGS}