Commit b53f3835 authored by Miguel Jimenez Lopez's avatar Miguel Jimenez Lopez

kernel: Update Makefile and create Kbuild for kernel compilation.

parent e51e1d42
KBUILD_EXTRA_SYMBOLS := $(FMC_BUS_ABS)/kernel/Module.symvers
# add versions of supermodule. It is useful when spec-sw is included as sub-module
# of a bigger project that we want to track
ifdef CONFIG_SUPER_REPO
ifdef CONFIG_SUPER_REPO_VERSION
SUBMODULE_VERSIONS += MODULE_INFO(version_$(CONFIG_SUPER_REPO),\"$(CONFIG_SUPER_REPO_VERSION)\");
endif
endif
# add versions of used submodules
SUBMODULE_VERSIONS += MODULE_INFO(version_fmc_bus,\"$(FMC_BUS_VERSION)\");
ccflags-y += -DADDITIONAL_VERSIONS="$(SUBMODULE_VERSIONS)"
# The library includes <sdb.h>, so point -I directtly there
# include our header before to avoid conflicts with the kernel
LINUXINCLUDE := -I$(FMC_BUS_ABS)/kernel/include -I$(src)/include/linux $(LINUXINCLUDE)
ccflags-y += -I$(src)/include
ccflags-y += $(WR_NIC_CFLAGS)
ccflags-y += -DGIT_VERSION=\"$(GIT_VERSION)\"
# FIXME: Node or switch?
ccflags-y += -DWR_NODE
#ccflags-y += -DWR_SWITCH
obj-m += wr-nic.o
wr-nic-y = module.o
wr-nic-y += device.o
wr-nic-y += nic-core.o
wr-nic-y += endpoint.o
wr-nic-y += ethtool.o
wr-nic-y += pps.o
wr-nic-y += timestamp.o
# This Makefile is meant to be used by the wr-switch. When built for wr-node
# the relevant Makefile lived in the parent directory.
# include parent_common.mk for buildsystem's defines
#use absolute path for REPO_PARENT
REPO_PARENT=$(shell /bin/pwd)/../..
-include $(REPO_PARENT)/parent_common.mk
ccflags-y += -DWR_SWITCH
LINUX ?= /lib/modules/$(shell uname -r)/build
obj-m := wr-nic.o
wr-nic-objs := module.o device.o nic-core.o endpoint.o ethtool.o \
pps.o timestamp.o
# by default use the fmc-bus within the repository
FMC_BUS ?= ../fmc-bus/
# FMC_BUS_ABS has to be absolut path, due to beeing passed to the Kbuild
FMC_BUS_ABS ?= $(abspath $(FMC_BUS) )
# accept WRN_DEBUG from the environment. It turns pr_debug() into printk.
ifdef WRN_DEBUG
ccflags-y += -DDEBUG
endif
GIT_VERSION ?= $(shell git describe --dirty --long --tags)
export GIT_VERSION
ccflags-y += -I$(src)/../wr_pstats
# What follows is standard stuff
export ARCH ?= arm
export CROSS_COMPILE ?= $(CROSS_COMPILE_ARM)
FMC_BUS_VERSION ?= $(shell cd $(FMC_BUS_ABS); git describe --always --dirty --long --tags)
export FMC_BUS_VERSION
all modules:
$(MAKE) CONFIG_DEBUG_SECTION_MISMATCH=y \
-C $(LINUX) SUBDIRS=$(shell /bin/pwd) modules
$(MAKE) -C $(LINUX) M=$(shell /bin/pwd) FMC_BUS_ABS=$(FMC_BUS_ABS) modules
# looking at preprocessed output is helpful for bug hunting
preprocess:
$(MAKE) CONFIG_DEBUG_SECTION_MISMATCH=y \
-C $(LINUX) SUBDIRS=$(shell /bin/pwd) $(wr-nic-objs:.o=.i)
install modules_install:
$(MAKE) -C $(LINUX) M=$(shell /bin/pwd) modules_install
# We might "$(MAKE) -C $(LINUX)" but "make clean" with no LINUX defined
# is sometimes useful to have
# be able to run the "clean" rule even if $(LINUX) is not valid
clean:
rm -f *.mod.c *.o *.ko *.i .*cmd Module.symvers modules.order *~
rm -rf .tmp_versions
rm -rf *.o *~ .*.cmd *.ko *.mod.c .tmp_versions Module.symvers \
Module.markers modules.order
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment