VirtualBox

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

Last change on this file since 100191 was 100191, checked in by vboxsync, 18 months ago

*: Some of the easy build fixes for linux.arm64 not warranting their own commit, bugref:10457

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 5.1 KB
Line 
1# $Id: Makefile-footer.gmk 100191 2023-06-16 08:04:11Z 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 ifeq ($(VBOX_KBUILD_TARGET_ARCH),x86)
42VBOXMOD_0_KFLAGS += -DRT_ARCH_X86
43else ifeq ($(VBOX_KBUILD_TARGET_ARCH),arm64)
44VBOXMOD_0_KFLAGS += -DRT_ARCH_ARM64
45else ifeq ($(VBOX_KBUILD_TARGET_ARCH),arm32)
46VBOXMOD_0_KFLAGS += -DRT_ARCH_ARM32
47else
48$(error The variable VBOX_KBUILD_TARGET_ARCH doesn't contain any of the following: amd64, x86, arm64, arm32)
49endif
50
51ifeq ($(VBOX_KBUILD_TYPE),debug)
52# The -Wno-array-bounds is because of a bug in gcc 4.something, see
53# https://sourceware.org/bugzilla/show_bug.cgi?id=10001
54 VBOXMOD_0_KFLAGS += -DDEBUG -DDEBUG_$(subst $(subst _, ,_),_,$(USERNAME)) -DDEBUG_USERNAME=$(subst $(subst _, ,_),_,$(USERNAME))
55 ifeq ($(shell expr $(KERN_VER) : '[23]\.'),0)
56 VBOXMOD_0_KFLAGS += -Werror -Wall -Wno-array-bounds
57# clang objects to calls to __builtin_frame_address with a non-zero argument
58# on general principles in -Wall mode. The x86 linux kernel has two such calls
59# in the thread_info.h / arch_within_stack_frames(), though probably safe.
60 ifndef ($(LLVM),) # (This is how the Linux root Makefile (since 5.7) does the test.)
61 VBOXMOD_0_KFLAGS += -Wno-frame-address
62 endif
63 endif
64endif
65
66ifeq ($(VBOX_KERN_GROKS_EXTMOD),)
67#
68# Pre 2.6.6
69#
70# Note: While pre 2.6.6 kernels could also do "proper" builds from kbuild, the
71# make script needed to support it was somewhat different from 2.6. Since this
72# script works and pre-2.6.6 is not a moving target we will not try do do things
73# the "proper" way.
74#
75VBOXMOD_EXT := o
76
77 ifeq ($(VBOX_KBUILD_TARGET_ARCH),amd64)
78VBOXMOD_0_KFLAGS += -mcmodel=kernel
79 endif
80 ifeq ($(KERN_VERSION),24)
81VBOXMOD_0_KFLAGS += -DVBOX_LINUX_2_4
82 endif
83
84CFLAGS := -O2 $(VBOXMOD_CFLAGS) $(addprefix -I,$(KERN_INCL) $(VBOXMOD_INCL)) $(VBOXMOD_0_KFLAGS) $(KDEBUG)
85
86# 2.4 Module linking
87$(VBOXMOD_0_TARGET).$(VBOXMOD_EXT): $(VBOXMOD_OBJS)
88 $(LD) -o $@ -r $(VBOXMOD_OBJS)
89
90all: $(VBOXMOD_0_TARGET)
91$(VBOXMOD_0_TARGET): $(VBOXMOD_0_TARGET).$(VBOXMOD_EXT)
92
93install: $(VBOXMOD_0_TARGET)
94 @mkdir -p $(MODULE_DIR); \
95 install -m 0644 -o root -g root $(VBOXMOD_0_TARGET).$(VBOXMOD_EXT) $(MODULE_DIR); \
96 PATH="$(PATH):/bin:/sbin" depmod -a; sync
97
98clean:
99 for f in $(sort $(dir $(VBOXMOD_OBJS))); do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
100 rm -rf .$(VBOXMOD_NAME)* .tmp_ver* $(VBOXMOD_NAME).* Modules.symvers modules.order
101
102.PHONY: all $(VBOXMOD_0_TARGET) install clean
103
104else # VBOX_KERN_GROKS_EXTMOD
105#
106# 2.6.6 and later
107#
108VBOXMOD_EXT := ko
109
110# build defs
111EXTRA_CFLAGS += $(VBOXMOD_CFLAGS) $(addprefix -I,$(KERN_INCL) $(VBOXMOD_INCL)) $(VBOXMOD_0_KFLAGS) $(KDEBUG)
112$(VBOXMOD_0_TARGET)-y := $(VBOXMOD_OBJS)
113obj-m += $(VBOXMOD_0_TARGET).o
114
115# Trigger parallel make job.
116 ifndef VBOX_NOJOBS
117JOBS := $(shell (getconf _NPROCESSORS_ONLN || grep -Ec '^processor|^CPU[0-9]' /proc/cpuinfo) 2>/dev/null)
118 ifeq ($(JOBS),0)
119 override JOBS := 1
120 endif
121 else
122JOBS :=
123 endif
124
125VBOX_SUBDIR_VAR=$(if $(VBOX_KERN_GROKS_SUBDIRS),SUBDIRS,M)
126
127# OL/UEK: CONFIG_MODULE_SIG= disables module signing for external modules.
128# Ubuntu 18.04.3: CONFIG_MODULE_SIG_ALL= disables signing of all modules.
129# We disable signing because we don't have any private key and want to leave
130# the key handling and secure boot config to the user.
131 ifndef VBOX_ALLOW_MODULE_SIGNING
132VBOX_DISABLE_SIGN=CONFIG_MODULE_SIG= CONFIG_MODULE_SIG_ALL=
133 endif
134
135# rules:
136all: $(VBOXMOD_0_TARGET)
137
138$(VBOXMOD_0_TARGET):
139 $(MAKE) V=$(VBOX_LNX_VERBOSE) $(VBOX_DISABLE_SIGN) -C $(KERN_DIR) $(VBOX_SUBDIR_VAR)=$(CURDIR) SRCROOT=$(CURDIR) $(if $(JOBS),-j$(JOBS),) modules
140
141install: $(VBOXMOD_0_TARGET)
142 $(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
143
144modules_install: install
145
146clean:
147 $(MAKE) V=$(VBOX_LNX_VERBOSE) $(VBOX_DISABLE_SIGN) -C $(KERN_DIR) $(VBOX_SUBDIR_VAR)=$(CURDIR) SRCROOT=$(CURDIR) clean
148
149.PHONY: all $(VBOXMOD_0_TARGET) install modules_install clean
150endif # VBOX_KERN_GROKS_EXTMOD
151
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