Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm currently trying to cross-compile a network driver against an old Linux kernel, in version 2.6.27.7 but the compilation fails and prints:

make[1]: entering directory « /home/johann/Desktop/linux-2.6.27.7 »
Building modules, stage 2.
MODPOST 0 modules
make[1]: leaving directory « /home/johann/Desktop/linux-2.6.27.7 »

The command I ran to get this was taken from the readme found with the sources:

make KSRC=<source> KDIR=<build>

I'm no expert with makefiles, yet I think there's something wrong with the one provided by the driver source.

Here's how it looks like:

#
# Makefile to build the be2net network driver
#

# find a source path that exists among the possible paths
ver = $(shell uname -r)
paths := /lib/modules/$(ver)/source /lib/modules/$(ver)/build
exists = $(shell [ -e $(path)/include/linux ] && echo $(path))
paths := $(foreach path, $(paths), $(exists))
ifeq (,$(KSRC))
    KSRC := $(firstword $(paths))
endif

# ************** Header checks ********************
ifneq (,$(shell grep -o alloc_etherdev_mqs $(KSRC)/include/linux/etherdevice.h))
    EXTRA_CFLAGS += -DALLOC_ETHDEV_MQS_defined
endif

ifneq (,$(shell grep -o alloc_etherdev_mq $(KSRC)/include/linux/etherdevice.h))
    EXTRA_CFLAGS += -DALLOC_ETHDEV_MQ_defined
endif

ifneq (,$(shell grep -o netif_set_real_num_rx_queues $(KSRC)/include/linux/netdevice.h))
    EXTRA_CFLAGS += -DNETIF_SET_REAL_NUM_RX_QS_defined
endif

ifneq (,$(shell grep -o PCI_DEV_FLAGS_ASSIGNED $(KSRC)/include/linux/pci.h))
    EXTRA_CFLAGS += -DPCI_FLAGS_ASSIGNED_defined
endif

ifneq (,$(shell grep -o skb_frag_set_page $(KSRC)/include/linux/skbuff.h))
    EXTRA_CFLAGS += -DSKB_FRAG_API_defined
endif

ifneq (,$(shell grep -o skb_frag_size $(KSRC)/include/linux/skbuff.h))
    EXTRA_CFLAGS += -DSKB_FRAG_SIZE_defined
endif

ifneq (,$(shell grep -o netdev_alloc_skb_ip_align $(KSRC)/include/linux/skbuff.h))
    EXTRA_CFLAGS += -DALLOC_SKB_IP_ALIGN_defined
endif

ifneq (,$(shell grep -o skb_record_rx_queue $(KSRC)/include/linux/skbuff.h))
    EXTRA_CFLAGS += -DSKB_RECORD_RX_QUEUE_defined
endif

ifneq (,$(shell grep -o rxhash $(KSRC)/include/linux/skbuff.h))
    EXTRA_CFLAGS += -DRXHASH_defined
endif

#GRO is usable only when full implementation is available
ifneq (,$(shell grep -o napi_get_frags $(KSRC)/include/linux/netdevice.h))
    EXTRA_CFLAGS += -DGRO_defined
endif

ifneq (,$(shell grep -o netdev_alloc_skb $(KSRC)/include/linux/skbuff.h))
    EXTRA_CFLAGS += -DALLOC_SKB_defined
endif

ifneq (,$(shell grep -o dev_mc_list $(KSRC)/include/linux/netdevice.h))
    EXTRA_CFLAGS += -DDEV_MC_LIST_defined
endif

ifneq (,$(shell grep -o pcie_set_readrq $(KSRC)/include/linux/pci.h))
    EXTRA_CFLAGS += -DPCIE_SET_READRQ_defined
endif

ifneq (,$(shell grep -so vlan_group_set_device $(KSRC)/include/linux/if_vlan.h $(KSRC)/net/8021q/vlan.h))
    EXTRA_CFLAGS += -DVLAN_GRP_SET_DEV_defined
endif

ifneq (,$(shell grep -o "struct vlan_group" $(KSRC)/include/linux/if_vlan.h))
    EXTRA_CFLAGS += -DVLAN_GRP_defined
endif

ifeq (,$(shell grep -o "vlan_hwaccel_receive_skb" $(KSRC)/include/linux/if_vlan.h))
    EXTRA_CFLAGS += -DUSE_NEW_VLAN_MODEL
endif

ifneq (,$(shell grep -o ndo_set_vf_mac $(KSRC)/include/linux/netdevice.h))
    EXTRA_CFLAGS += -DNDO_VF_CFG_defined
endif

ifneq (,$(shell grep -o ndo_set_features $(KSRC)/include/linux/netdevice.h))
    EXTRA_CFLAGS += -DNDO_SET_FEATURES_defined
endif

ifneq (,$(shell grep -so "ethtool_cmd_speed_set" $(KSRC)/include/linux/ethtool.h \
                        $(KSRC)/include/uapi/linux/ethtool.h))
    EXTRA_CFLAGS += -DETHTOOL_CMD_SPEED_SET_defined
endif

ifneq (,$(shell grep -so "ethtool_cmd_speed" $(KSRC)/include/linux/ethtool.h \
                    $(KSRC)/include/uapi/linux/ethtool.h))
    EXTRA_CFLAGS += -DETHTOOL_CMD_SPEED_defined
endif

ifneq (,$(shell grep -o "ethtool_phys_id_state" $(KSRC)/include/linux/ethtool.h))
    EXTRA_CFLAGS += -DPHYS_ID_STATE_defined
endif

ifneq (,$(shell grep -o "flash_device" $(KSRC)/include/linux/ethtool.h))
    EXTRA_CFLAGS += -DETHTOOL_FLASH_defined
endif

ifneq (,$(shell grep -o "get_sset_count" $(KSRC)/include/linux/ethtool.h))
    EXTRA_CFLAGS += -DETHTOOL_SSET_COUNT_defined
endif

ifneq (,$(shell grep -o "set_dump" $(KSRC)/include/linux/ethtool.h))
    EXTRA_CFLAGS += -DETHTOOL_SET_DUMP_defined
endif

ifneq (,$(shell grep -o "ethtool_ops_ext" $(KSRC)/include/linux/ethtool.h))
    EXTRA_CFLAGS += -DETHTOOL_OPS_EXT_defined
endif

ifneq (,$(shell grep -o "pci_enable_pcie_error_reporting" $(KSRC)/include/linux/aer.h))
    EXTRA_CFLAGS += -DAER_REPORTING_defined
endif

ifneq (,$(shell grep -o "pci_physfn" $(KSRC)/include/linux/pci.h))
    EXTRA_CFLAGS += -DPCI_PHYSFN_defined
endif

ifneq (,$(shell grep -o "set_rxnfc" $(KSRC)/include/linux/ethtool.h))
    EXTRA_CFLAGS += -DETHTOOL_RXNFC_OPS_defined
endif

ifneq (,$(shell grep -o ndo_get_stats64 $(KSRC)/include/linux/netdevice.h))
    EXTRA_CFLAGS += -DNDO_GET_STATS64_defined
endif

ifneq (,$(shell grep -o txq_trans_update $(KSRC)/include/linux/netdevice.h))
    EXTRA_CFLAGS += -DTXQ_TRANS_UPDATE_defined
endif
# ************* End header checks *****************

# ************* Targets ***************************
ifeq ($(KERNELRELEASE),)
ifeq ($(KDIR),)
    KDIR ?= /lib/modules/`uname -r`/build
endif   
default:
    @$(MAKE) -C$(KDIR) M=$$PWD
clean:
    @$(MAKE) -C$(KDIR) M=$$PWD clean
else
obj-$(CONFIG_BE2NET) += be2net.o
be2net-y :=  be_main.o be_cmds.o be_ethtool.o be_compat.o be_misc.o inet_lro.o
endif
# ************* End Targets ************************

I didn't see any $(CONFIG_BE2NET) variable declared prior to its usage, for instance.

I'm aware it's a specific issue... I've actually just started to learn how to produce makefile to help me understand this, but any help would be greatly appreciated :)

share|improve this question
    
CONFIG_xxx variables come from the .config file. You can't really hope to understand the Linux kernel makefiles without hours of reading, they're really hairy (and very different from typical makefiles). –  Gilles Oct 10 '13 at 21:51
    
Did you run make KSRC=<source> KDIR=<build> config? –  Gilles Oct 10 '13 at 21:52
    
Yeah I guess it's going to be a long week-end for me! –  blablabla Oct 11 '13 at 9:08
    
I tried make KSRC=<source> KDIR=<build> config but it just says there's no rule to build the target. –  blablabla Oct 11 '13 at 9:10
    
The if/else section is about building in the kernel tree versus outside. But what I don't see is how the module build rules in the Kernel's makefile system are supposed to figure out what to build simply from the M=$$PWD. In the in-kernel case, it spells out what object files are in the module. It's possible that this is deduced from the pathname? I mean, that $PWD should be in a directory whose basename is be2net, and from that we know that there should be a be2net-y variable which lists the object files. –  Kaz Oct 30 '13 at 3:19
add comment

2 Answers

One possible workaround is you replace obj-$(CONFIG_BE2NET) += be2net.o with obj-m += be2net.o

share|improve this answer
add comment
mkdir /usr/src <--This directory may already exists
cd usr/src
wget https://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.27.7.tar.gz 
tar -xvf linux-2.6.27.7.tar.gz 
ln -s /usr/src/linux-2.6.27.7 /usr/src/linux
cd /usr/src/linux
tar -xvf <nameofdriverdownload>.tar.gz <--If all goes well, this should inject the driver you downloaded into the kernel source 
make menuconfig <-- Select Desired options Here
make install
make modules_install
make initrd

I need to know the name of the driver and where you got it to make this answer exact.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.