VirtualBox

source: vbox/trunk/src/VBox/Installer/linux/Makefile.include.header@ 68706

Last change on this file since 68706 was 68706, checked in by vboxsync, 7 years ago

Linux driver Make files: fix Linux 2.4 module installation.
bugref:4567: Linux kernel driver maintenance

The Guest Additions installer was no longer installing kernel modules on
Linux 2.4-based systems due to a path specification problem which was a
regression from recent clean-ups. Fix this and switch to taking a kernel
version rather than a kernel header path as a parameter for allowing builds
for different kernels.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 KB
Line 
1#
2# VirtualBox Guest Additions kernel module Makefile, common parts.
3#
4# (For 2.6.x, the main file must be called 'Makefile'!)
5#
6# Copyright (C) 2006-2015 Oracle Corporation
7#
8# This file is part of VirtualBox Open Source Edition (OSE), as
9# available from http://www.virtualbox.org. This file is free software;
10# you can redistribute it and/or modify it under the terms of the GNU
11# General Public License (GPL) as published by the Free Software
12# Foundation, in version 2 as it comes in the "COPYING" file of the
13# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15#
16
17# Testing:
18# * Building with KERN_DIR set uses the value specified and
19# the default value for the unspecified one if any.
20
21#
22# These file should be included by the Makefiles for any kernel modules we
23# build as part of the Guest Additions. The intended way of doing this is as
24# follows:
25#
26# # Linux kbuild sets this to our source directory if we are called from
27# # there
28# obj ?= $(CURDIR)
29# include $(obj)/Makefile.include.header
30# MOD_NAME = <name of the module to be built, without extension>
31# MOD_OBJS = <list of object files which should be included>
32# MOD_DEFS = <any additional defines which this module needs>
33# MOD_INCL = <any additional include paths which this module needs>
34# MOD_CFLAGS = <any additional CFLAGS which this module needs>
35# include $(obj)/Makefile.include.footer
36#
37# The kmk kBuild define KBUILD_TARGET_ARCH is available.
38#
39
40
41#
42# First, figure out which architecture we're targeting and the build type.
43# (We have to support basic cross building (ARCH=i386|x86_64).)
44# While at it, warn about BUILD_* vars found to help with user problems.
45#
46ifeq ($(filter-out x86_64 amd64 AMD64,$(shell uname -m)),)
47 BUILD_TARGET_ARCH_DEF := amd64
48else
49 BUILD_TARGET_ARCH_DEF := x86
50endif
51ifneq ($(filter-out amd64 x86,$(BUILD_TARGET_ARCH)),)
52 $(warning Ignoring unknown BUILD_TARGET_ARCH value '$(BUILD_TARGET_ARCH)'.)
53 BUILD_TARGET_ARCH :=
54endif
55ifeq ($(BUILD_TARGET_ARCH),)
56 ifeq ($(ARCH),x86_64)
57 BUILD_TARGET_ARCH := amd64
58 else
59 ifeq ($(ARCH),i386)
60 BUILD_TARGET_ARCH := x86
61 else
62 BUILD_TARGET_ARCH := $(BUILD_TARGET_ARCH_DEF)
63 endif
64 endif
65else
66 ifneq ($(BUILD_TARGET_ARCH),$(BUILD_TARGET_ARCH_DEF))
67 $(warning Using BUILD_TARGET_ARCH='$(BUILD_TARGET_ARCH)' from the $(origin BUILD_TARGET_ARCH).)
68 endif
69endif
70
71ifneq ($(filter-out release profile debug strict,$(BUILD_TYPE)),)
72 $(warning Ignoring unknown BUILD_TYPE value '$(BUILD_TYPE)'.)
73 BUILD_TYPE :=
74endif
75ifeq ($(BUILD_TYPE),)
76 BUILD_TYPE := release
77else
78 ifneq ($(BUILD_TYPE),release)
79 $(warning Using BUILD_TYPE='$(BUILD_TYPE)' from the $(origin BUILD_TYPE).)
80 endif
81endif
82ifeq ($(USERNAME),)
83 USERNAME := noname
84endif
85
86ifeq ($(KERNELRELEASE),)
87
88 #
89 # building from this directory
90 #
91
92 # kernel base directory
93 KERN_VER ?= $(shell uname -r)
94
95 # guess kernel major version (24 or later)
96 ifeq ($(shell if grep '"2\.4\.' /lib/modules/$(KERN_VER)/build/include/linux/version.h > /dev/null 2>&1; then echo yes; fi),yes)
97 KERN_VERSION := 24
98 else
99 KERN_VERSION := 26
100 endif
101
102else # neq($(KERNELRELEASE),)
103
104 #
105 # building from kbuild (make -C <kernel_directory> M=`pwd`)
106 #
107
108 # guess kernel version (24 or 26)
109 ifeq ($(shell if echo "$(VERSION).$(PATCHLEVEL)." | grep '2\.4\.' > /dev/null; then echo yes; fi),yes)
110 KERN_VERSION := 24
111 else
112 KERN_VERSION := 26
113 endif
114
115 KERN_VER := $(KERNELRELEASE)
116
117endif # neq($(KERNELRELEASE),)
118
119# Kernel build folder
120KERN_DIR := /lib/modules/$(KERN_VER)/build
121ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
122 $(error Error: unable to find the headers of the Linux kernel to build against. \
123 Specify KERN_VER=<version> and run Make again)
124endif
125# Kernel include folder
126KERN_INCL := $(KERN_DIR)/include
127# module install folder
128INSTALL_MOD_DIR ?= misc
129MODULE_DIR := $(INSTALL_MOD_PATH)/lib/modules/$(KERN_VER)/$(INSTALL_MOD_DIR)
130
131# debug - show guesses.
132ifdef DEBUG
133$(warning dbg: INSTALL_MOD_PATH = $(INSTALL_MOD_PATH))
134$(warning dbg: INSTALL_MOD_DIR = $(INSTALL_MOD_DIR))
135$(warning dbg: KERN_DIR = $(KERN_DIR))
136$(warning dbg: KERN_INCL = $(KERN_INCL))
137$(warning dbg: KERN_VERSION = $(KERN_VERSION))
138$(warning dbg: MODULE_DIR = $(MODULE_DIR))
139endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette