我目前正在尝试针对版本 2.6.27.7 中的旧 Linux 内核交叉编译网络驱动程序,但编译失败并打印:
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 »
我运行的命令取自自述文件,其中包含以下来源:
make KSRC=<source> KDIR=<build>
它看起来是这样的:
#
# 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 ************************
例如,我没有看到任何在使用之前声明的 $(CONFIG_BE2NET) 变量。
答案1
一种可能的解决方法是更换 obj-$(CONFIG_BE2NET) += be2net.o 和 obj-m += be2net.o
答案2
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
我需要知道司机的姓名以及您从哪里得到的信息才能准确回答。