mirror of
https://github.com/proski/madwifi
synced 2024-11-21 14:01:54 +03:00
Port elements of the build system from ndiswrapper
This eliminates compilation to find the kernel version. The new Makefile provides more sanity checks and more verbose reporting.
This commit is contained in:
parent
19e85c5f13
commit
e1a1d8f94f
73
Makefile.inc
73
Makefile.inc
@ -49,47 +49,50 @@ endif
|
|||||||
# DESTDIR is used as path prefix during installation.
|
# DESTDIR is used as path prefix during installation.
|
||||||
DESTDIR ?=
|
DESTDIR ?=
|
||||||
|
|
||||||
# KERNELPATH is the path to the Linux kernel build tree. Unless a
|
# By default, we try to compile the modules for the currently running
|
||||||
# separate build directory was used for the kernel build, it's the same
|
# kernel. But it's the first approximation, as we will re-read the
|
||||||
# as the kernel source tree. KERNELPATH is used to access the kernel
|
# version from the kernel sources.
|
||||||
# configuration, include files and the build system. To build for
|
KVERS_UNAME ?= $(shell uname -r)
|
||||||
# another kernel, set KERNELPATH manually, for example with:
|
|
||||||
# make KERNELPATH=/path/to/kernel/source
|
|
||||||
|
|
||||||
# The default KERNELPATH points to the directory where the currently
|
# KERNELPATH is the path to the Linux kernel build tree. It is usually the
|
||||||
# running kernel was compiled. Note that the configuration and the
|
# same as the kernel source tree, except when the kernel was compiled in
|
||||||
# version of the kernel tree might have changed since then.
|
# a separate directory.
|
||||||
ifeq ($(wildcard $(KERNELPATH)),)
|
KERNELPATH ?= $(shell readlink -f /lib/modules/$(KVERS_UNAME)/build)
|
||||||
KERNELPATH = /lib/modules/$(shell uname -r)/build
|
|
||||||
# sanity check: does KERNELPATH exist?
|
ifeq (,$(KERNELPATH))
|
||||||
ifeq ($(shell cd $(KERNELPATH) && pwd),)
|
$(error Kernel build tree not found - please set KERNELPATH to configured kernel)
|
||||||
$(error $(KERNELPATH) is missing, please set KERNELPATH)
|
|
||||||
endif
|
|
||||||
export KERNELPATH
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# KERNELRELEASE is the target kernel's version. It's always taken from
|
KERNELCONF := $(KERNELPATH)/.config
|
||||||
# the kernel build tree. Kernel Makefile doesn't always know the exact
|
ifeq (,$(wildcard $(KERNELCONF)))
|
||||||
# kernel version (especially for vendor stock kernels), so we get it
|
$(error No .config found in $(KERNELPATH), please set KERNELPATH to configured kernel)
|
||||||
# from <linux/version.h> instead. But simply grepping it from version.h
|
endif
|
||||||
# doesn't work, since some distributions have multiple UTS_RELEASE
|
|
||||||
# in that file.
|
ifneq (,$(wildcard $(KERNELPATH)/include/linux/version.h))
|
||||||
# This trick has been inspired by the lm_sensors project.
|
ifneq (,$(wildcard $(KERNELPATH)/include/generated/uapi/linux/version.h))
|
||||||
ifndef KERNELRELEASE
|
$(error Multiple copies of version.h found, please clean your build tree)
|
||||||
KERNELRELEASE := $(shell $(CC) -I $(KERNELPATH)/include -E $(TOP)/kernelversion.c | grep uts_release | cut -f2 -d'"')
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Kernel Makefile doesn't always know the exact kernel version, so we
|
||||||
|
# get it from the kernel headers instead and pass it to make.
|
||||||
|
VERSION_H := $(KERNELPATH)/include/generated/utsrelease.h
|
||||||
|
ifeq (,$(wildcard $(VERSION_H)))
|
||||||
|
VERSION_H := $(KERNELPATH)/include/linux/utsrelease.h
|
||||||
|
endif
|
||||||
|
ifeq (,$(wildcard $(VERSION_H)))
|
||||||
|
VERSION_H := $(KERNELPATH)/include/linux/version.h
|
||||||
|
endif
|
||||||
|
ifeq (,$(wildcard $(VERSION_H)))
|
||||||
|
$(error Please run 'make modules_prepare' in $(KERNELPATH))
|
||||||
|
endif
|
||||||
|
|
||||||
|
KERNELRELEASE := $(shell sed -ne 's/"//g;s/^\#define UTS_RELEASE //p' $(VERSION_H))
|
||||||
|
|
||||||
ifeq (,$(KERNELRELEASE))
|
ifeq (,$(KERNELRELEASE))
|
||||||
$(error Cannot detect kernel version - please check compiler and KERNELPATH)
|
$(error Cannot find UTS_RELEASE in $(VERSION_H), please report)
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# KERNELCONF is the name of the file that holds the configuration
|
|
||||||
# of the target kernel.
|
|
||||||
KERNELCONF ?= $(KERNELPATH)/.config
|
|
||||||
|
|
||||||
# sanity check: does KERNELCONF exist?
|
|
||||||
ifeq ($(wildcard $(KERNELCONF)),)
|
|
||||||
$(error KERNELCONF: $(KERNELCONF) does not exist.)
|
|
||||||
endif
|
|
||||||
include $(KERNELCONF)
|
include $(KERNELCONF)
|
||||||
|
|
||||||
# KMODPATH nominates the directory where the modules will be
|
# KMODPATH nominates the directory where the modules will be
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
/* This file is used for a trick to determine the version of the kernel
|
|
||||||
* build tree. Simply grepping <linux/version.h> doesn't work, since
|
|
||||||
* some distributions have multiple UTS_RELEASE definitions in that
|
|
||||||
* file.
|
|
||||||
* Taken from the lm_sensors project.
|
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*/
|
|
||||||
#include <linux/version.h>
|
|
||||||
|
|
||||||
#ifndef UTS_RELEASE
|
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
|
|
||||||
/* Linux 2.6.33+ uses <generated/utsrelease.h> */
|
|
||||||
#include <generated/utsrelease.h>
|
|
||||||
#else
|
|
||||||
/* Linux 2.6.18 - 2.6.32 uses <linux/utsrelease.h> */
|
|
||||||
#include <linux/utsrelease.h>
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
char *uts_release = UTS_RELEASE;
|
|
Loading…
Reference in New Issue
Block a user