VirtualBox

source: vbox/trunk/src/VBox/Installer/linux/Makefile-footer.gmk@ 98715

Last change on this file since 98715 was 98103, checked in by vboxsync, 23 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 4.8 KB
Line 
1# $Id: Makefile-footer.gmk 98103 2023-01-17 14:15:46Z vboxsync $
2## @file
3# VirtualBox Guest Additions kernel module Makefile, common parts.
4#
5# See Makefile-header.gmk for details of how to use this.
6#
7
8#
9# Copyright (C) 2006-2023 Oracle and/or its affiliates.
10#
11# This file is part of VirtualBox base platform packages, as
12# available from https://www.virtualbox.org.
13#
14# This program is free software; you can redistribute it and/or
15# modify it under the terms of the GNU General Public License
16# as published by the Free Software Foundation, in version 3 of the
17# License.
18#
19# This program is distributed in the hope that it will be useful, but
20# WITHOUT ANY WARRANTY; without even the implied warranty of
21# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22# General Public License for more details.
23#
24# You should have received a copy of the GNU General Public License
25# along with this program; if not, see <https://www.gnu.org/licenses>.
26#
27# SPDX-License-Identifier: GPL-3.0-only
28#
29
30VBOXMOD_0_TARGET = $(VBOXMOD_NAME)
31
32KBUILD_VERBOSE ?= 1 # Variable belongs to our kBuild, not the linux one.
33VBOX_LNX_VERBOSE = $(if $(KBUILD_VERBOSE),1,)
34
35#
36# Compiler options
37#
38VBOXMOD_0_KFLAGS := -D__KERNEL__ -DMODULE -DRT_WITHOUT_PRAGMA_ONCE $(addprefix -D,$(VBOXMOD_DEFS))
39ifeq ($(VBOX_KBUILD_TARGET_ARCH),amd64)
40VBOXMOD_0_KFLAGS += -DRT_ARCH_AMD64
41else
42VBOXMOD_0_KFLAGS += -DRT_ARCH_X86
43endif
44
45ifeq ($(VBOX_KBUILD_TYPE),debug)
46# The -Wno-array-bounds is because of a bug in gcc 4.something, see
47# https://sourceware.org/bugzilla/show_bug.cgi?id=10001
48 VBOXMOD_0_KFLAGS += -DDEBUG -DDEBUG_$(subst $(subst _, ,_),_,$(USERNAME)) -DDEBUG_USERNAME=$(subst $(subst _, ,_),_,$(USERNAME))
49 ifeq ($(shell expr $(KERN_VER) : '[23]\.'),0)
50 VBOXMOD_0_KFLAGS += -Werror -Wall -Wno-array-bounds
51# clang objects to calls to __builtin_frame_address with a non-zero argument
52# on general principles in -Wall mode. The x86 linux kernel has two such calls
53# in the thread_info.h / arch_within_stack_frames(), though probably safe.
54 ifndef ($(LLVM),) # (This is how the Linux root Makefile (since 5.7) does the test.)
55 VBOXMOD_0_KFLAGS += -Wno-frame-address
56 endif
57 endif
58endif
59
60ifeq ($(VBOX_KERN_GROKS_EXTMOD),)
61#
62# Pre 2.6.6
63#
64# Note: While pre 2.6.6 kernels could also do "proper" builds from kbuild, the
65# make script needed to support it was somewhat different from 2.6. Since this
66# script works and pre-2.6.6 is not a moving target we will not try do do things
67# the "proper" way.
68#
69VBOXMOD_EXT := o
70
71 ifeq ($(VBOX_KBUILD_TARGET_ARCH),amd64)
72VBOXMOD_0_KFLAGS += -mcmodel=kernel
73 endif
74 ifeq ($(KERN_VERSION),24)
75VBOXMOD_0_KFLAGS += -DVBOX_LINUX_2_4
76 endif
77
78CFLAGS := -O2 $(VBOXMOD_CFLAGS) $(addprefix -I,$(KERN_INCL) $(VBOXMOD_INCL)) $(VBOXMOD_0_KFLAGS) $(KDEBUG)
79
80# 2.4 Module linking
81$(VBOXMOD_0_TARGET).$(VBOXMOD_EXT): $(VBOXMOD_OBJS)
82 $(LD) -o $@ -r $(VBOXMOD_OBJS)
83
84all: $(VBOXMOD_0_TARGET)
85$(VBOXMOD_0_TARGET): $(VBOXMOD_0_TARGET).$(VBOXMOD_EXT)
86
87install: $(VBOXMOD_0_TARGET)
88 @mkdir -p $(MODULE_DIR); \
89 install -m 0644 -o root -g root $(VBOXMOD_0_TARGET).$(VBOXMOD_EXT) $(MODULE_DIR); \
90 PATH="$(PATH):/bin:/sbin" depmod -a; sync
91
92clean:
93 for f in $(sort $(dir $(VBOXMOD_OBJS))); do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
94 rm -rf .$(VBOXMOD_NAME)* .tmp_ver* $(VBOXMOD_NAME).* Modules.symvers modules.order
95
96.PHONY: all $(VBOXMOD_0_TARGET) install clean
97
98else # VBOX_KERN_GROKS_EXTMOD
99#
100# 2.6.6 and later
101#
102VBOXMOD_EXT := ko
103
104# build defs
105EXTRA_CFLAGS += $(VBOXMOD_CFLAGS) $(addprefix -I,$(KERN_INCL) $(VBOXMOD_INCL)) $(VBOXMOD_0_KFLAGS) $(KDEBUG)
106$(VBOXMOD_0_TARGET)-y := $(VBOXMOD_OBJS)
107obj-m += $(VBOXMOD_0_TARGET).o
108
109# Trigger parallel make job.
110 ifndef VBOX_NOJOBS
111JOBS := $(shell (getconf _NPROCESSORS_ONLN || grep -Ec '^processor|^CPU[0-9]' /proc/cpuinfo) 2>/dev/null)
112 ifeq ($(JOBS),0)
113 override JOBS := 1
114 endif
115 else
116JOBS :=
117 endif
118
119VBOX_SUBDIR_VAR=$(if $(VBOX_KERN_GROKS_SUBDIRS),SUBDIRS,M)
120
121# OL/UEK: CONFIG_MODULE_SIG= disables module signing for external modules.
122# Ubuntu 18.04.3: CONFIG_MODULE_SIG_ALL= disables signing of all modules.
123# We disable signing because we don't have any private key and want to leave
124# the key handling and secure boot config to the user.
125 ifndef VBOX_ALLOW_MODULE_SIGNING
126VBOX_DISABLE_SIGN=CONFIG_MODULE_SIG= CONFIG_MODULE_SIG_ALL=
127 endif
128
129# rules:
130all: $(VBOXMOD_0_TARGET)
131
132$(VBOXMOD_0_TARGET):
133 $(MAKE) V=$(VBOX_LNX_VERBOSE) $(VBOX_DISABLE_SIGN) -C $(KERN_DIR) $(VBOX_SUBDIR_VAR)=$(CURDIR) SRCROOT=$(CURDIR) $(if $(JOBS),-j$(JOBS),) modules
134
135install: $(VBOXMOD_0_TARGET)
136 $(MAKE) V=$(VBOX_LNX_VERBOSE) $(VBOX_DISABLE_SIGN) -C $(KERN_DIR) $(VBOX_SUBDIR_VAR)=$(CURDIR) SRCROOT=$(CURDIR) INSTALL_MOD_PATH=$(INSTALL_MOD_PATH) INSTALL_MOD_DIR=$(INSTALL_MOD_DIR) modules_install
137
138modules_install: install
139
140clean:
141 $(MAKE) V=$(VBOX_LNX_VERBOSE) $(VBOX_DISABLE_SIGN) -C $(KERN_DIR) $(VBOX_SUBDIR_VAR)=$(CURDIR) SRCROOT=$(CURDIR) clean
142
143.PHONY: all $(VBOXMOD_0_TARGET) install modules_install clean
144endif # VBOX_KERN_GROKS_EXTMOD
145
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