2018-08-07 02:14:37 -05:00
|
|
|
#
|
2018-08-23 14:05:14 -05:00
|
|
|
# Copyright 2017 Broadcom
|
2018-08-07 02:14:37 -05:00
|
|
|
#
|
2018-08-23 14:05:14 -05:00
|
|
|
# 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.
|
2018-08-07 02:14:37 -05:00
|
|
|
#
|
|
|
|
# $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
|
|
|
|
PRE_COMPILED_OBJ := obj_$(MOD_NAME).o
|
|
|
|
|
|
|
|
obj-m := $(MODULE)
|
|
|
|
$(MOD_NAME)-y := $(MODULE_SYM) $(PRE_COMPILED_OBJ)
|
|
|
|
|
|
|
|
|
|
|
|
ifeq (,$(CROSS_COMPILE))
|
|
|
|
|
|
|
|
export CROSS_COMPILE
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
SAVE_CFLAGS := ${CFLAGS}
|
|
|
|
|
|
|
|
include $(SDK)/make/Make.config
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
# 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
|
|
|
|
echo "suppress warning" > .$(PRE_COMPILED_OBJ).cmd
|
|
|
|
$(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
|
|
|
|
|
|
|
|
EXTRA_CFLAGS = $(CFLAGS)
|
|
|
|
CFLAGS := ${SAVE_CFLAGS}
|