VirtualBox

source: vbox/trunk/src/VBox/Installer/linux/Makefile.include.footer@ 76747

Last change on this file since 76747 was 76712, checked in by vboxsync, 6 years ago

Do not use pragma once when building Linux kernel modules.
bugref:4567: Linux kernel driver maintenance
CentOS 3 does not like this pragma, and it is intended for building non-driver
code anyway.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 3.3 KB
Line 
1# $Id: Makefile.include.footer 76712 2019-01-08 16:15:38Z vboxsync $
2## @file
3# VirtualBox Guest Additions kernel module Makefile, common parts.
4#
5# See Makefile.include.header for details of how to use this.
6#
7
8#
9# Copyright (C) 2006-2019 Oracle Corporation
10#
11# This file is part of VirtualBox Open Source Edition (OSE), as
12# available from http://www.virtualbox.org. This file is free software;
13# you can redistribute it and/or modify it under the terms of the GNU
14# General Public License (GPL) as published by the Free Software
15# Foundation, in version 2 as it comes in the "COPYING" file of the
16# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18#
19
20# override is required by the Debian guys
21override MODULE = $(MOD_NAME)
22OBJS = $(MOD_OBJS)
23
24KBUILD_VERBOSE ?= 1
25LINUX_VERBOSE = $(if $(KBUILD_VERBOSE),1,)
26
27#
28# Compiler options
29#
30ifndef INCL
31 INCL := $(addprefix -I,$(KERN_INCL) $(EXTRA_INCL))
32 ifndef KBUILD_EXTMOD
33 KBUILD_EXTMOD := $(shell pwd)
34 endif
35 INCL += $(MOD_INCL)
36 export INCL
37endif
38KFLAGS := -D__KERNEL__ -DMODULE -DRT_WITHOUT_PRAGMA_ONCE $(MOD_DEFS)
39ifeq ($(BUILD_TYPE),debug)
40# The -Wno-array-bounds is because of a bug in gcc 4.something, see
41# https://sourceware.org/bugzilla/show_bug.cgi?id=10001
42 KFLAGS += -DDEBUG -DDEBUG_$(subst $(subst _, ,_),_,$(USERNAME)) -DDEBUG_USERNAME=$(subst $(subst _, ,_),_,$(USERNAME))
43 ifeq ($(shell expr $(KERN_VER) : '[23]\.'),0)
44 KFLAGS += -Werror -Wall -Wno-array-bounds
45 endif
46endif
47
48ifeq ($(KERN_VERSION), 24)
49#
50# 2.4
51#
52
53# Note: while 2.4 kernels could also do "proper" builds from kbuild, the make
54# script needed to support it was somewhat different from 2.6. Since this
55# script works and 2.4 is not a moving target we will not try do do things the
56# "proper" way.
57
58ifeq ($(BUILD_TARGET_ARCH),amd64)
59 KFLAGS += -mcmodel=kernel
60endif
61
62CFLAGS := -O2 -DVBOX_LINUX_2_4 $(MOD_CFLAGS) $(INCL) $(KFLAGS) $(MOD_EXTRA) $(KDEBUG)
63MODULE_EXT := o
64
65# 2.4 Module linking
66$(MODULE).o: $(OBJS)
67 $(LD) -o $@ -r $(OBJS)
68
69.PHONY: $(MODULE)
70all: $(MODULE)
71$(MODULE): $(MODULE).o
72
73install: $(MODULE)
74 @mkdir -p $(MODULE_DIR); \
75 install -m 0644 -o root -g root $(MODULE).$(MODULE_EXT) $(MODULE_DIR); \
76 PATH="$(PATH):/bin:/sbin" depmod -a; sync
77
78clean:
79 for f in $(sort $(dir $(OBJS))); do rm -f $$f/*.o $$f/.*.cmd $$f/.*.flags; done
80 rm -rf .$(MOD_NAME)* .tmp_ver* $(MOD_NAME).* Modules.symvers modules.order
81
82else # ! $(KERN_VERSION), 24
83#
84# 2.6 and later
85#
86
87MODULE_EXT := ko
88
89$(MODULE)-y := $(OBJS)
90
91# build defs
92EXTRA_CFLAGS += $(MOD_CFLAGS) $(INCL) $(KFLAGS) $(MOD_EXTRA) $(KDEBUG)
93
94.PHONY: $(MODULE)
95all: $(MODULE)
96
97obj-m += $(MODULE).o
98
99JOBS := $(shell (getconf _NPROCESSORS_ONLN || grep -Ec '^processor|^CPU[0-9]' /proc/cpuinfo) 2>/dev/null)
100ifeq ($(JOBS),0)
101 override JOBS := 1
102endif
103
104# OL/UEK: disable module signing for external modules -- we don't have any private key
105$(MODULE):
106 $(MAKE) V=$(LINUX_VERBOSE) CONFIG_MODULE_SIG= -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) $(if $(JOBS),-j$(JOBS),) modules
107
108install: $(MODULE)
109 $(MAKE) V=$(LINUX_VERBOSE) CONFIG_MODULE_SIG= -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) INSTALL_MOD_PATH=$(INSTALL_MOD_PATH) INSTALL_MOD_DIR=$(INSTALL_MOD_DIR) modules_install
110
111modules_install: install
112
113clean:
114 $(MAKE) V=$(LINUX_VERBOSE) CONFIG_MODULE_SIG= -C $(KERN_DIR) SUBDIRS=$(CURDIR) SRCROOT=$(CURDIR) clean
115
116.PHONY: $(MODULE) install modules_install clean
117endif
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