VirtualBox

Changeset 77404 in vbox


Ignore:
Timestamp:
Feb 20, 2019 7:57:07 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
128958
Message:

More linux kernel module Makefile cleanups: Try make 2.6.0 thru 2.6.5 build using the 2.4.x approach. Tweaked the version detection code. Check that the compiler supports -fno-pie and -Wno-declaration-after-statement before using them (additions only). Eliminated VBOX_INCL (formerly know n as INCL).

Location:
trunk/src/VBox
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuest/linux/Makefile

    r77403 r77404  
    152152        $(VBOXGUEST_DIR)r0drv/linux
    153153
    154 ifeq ($(KERN_VERSION),24)
    155 VBOXMOD_CFLAGS =
    156 else
    157 VBOXMOD_CFLAGS = -Wno-declaration-after-statement -include $(VBOXGUEST_DIR)include/VBox/VBoxGuestMangling.h -fno-pie
     154VBOXMOD_CFLAGS := $(call VBOX_GCC_CHECK_CC,-Wno-declaration-after-statement,-Wno-declaration-after-statement,,)
     155VBOXMOD_CFLAGS += $(call VBOX_GCC_CHECK_CC,-fno-pie,-fno-pie,,)
     156ifneq ($(KERN_VERSION),24)
     157VBOXMOD_CFLAGS += -include $(VBOXGUEST_DIR)include/VBox/VBoxGuestMangling.h
    158158endif
    159159
  • trunk/src/VBox/Additions/linux/sharedfolders/Makefile.module

    r77403 r77404  
    6666VBOXMOD_DEFS += VBOX_WITH_64_BITS_GUESTS
    6767endif
    68 ifeq ($(KERN_VERSION),24)
    69 VBOXMOD_CFLAGS =
    70 else
    71 VBOXMOD_CFLAGS = -Wno-declaration-after-statement -fshort-wchar -include $(VBOXSF_DIR)/include/VBox/VBoxGuestMangling.h -fno-pie
     68VBOXMOD_CFLAGS := $(call VBOX_GCC_CHECK_CC,-Wno-declaration-after-statement,-Wno-declaration-after-statement,,)
     69VBOXMOD_CFLAGS += $(call VBOX_GCC_CHECK_CC,-fno-pie,-fno-pie,,)
     70ifneq ($(KERN_VERSION),24)
     71VBOXMOD_CFLAGS += -include $(VBOXSF_DIR)/include/VBox/VBoxGuestMangling.h
     72## @todo r-bird: What's with -fshort-wchar here?? We either need that or we dont, right? It should be 2.6+ only.
     73VBOXMOD_CFLAGS += -fshort-wchar
    7274endif
    7375ifdef VBOX_NO_OMIT_FRAME_POINTER
  • trunk/src/VBox/Installer/linux/Makefile-footer.gmk

    r77403 r77404  
    2626# Compiler options
    2727#
    28 VBOX_INCL := $(addprefix -I,$(KERN_INCL) $(VBOXMOD_INCL))
    29 
    3028VBOXMOD_0_KFLAGS := -D__KERNEL__ -DMODULE -DRT_WITHOUT_PRAGMA_ONCE $(addprefix -D,$(VBOXMOD_DEFS))
    3129ifeq ($(BUILD_TARGET_ARCH),amd64)
     
    4442endif
    4543
    46 ifeq ($(KERN_VERSION),24)
     44ifeq ($(VBOX_KERN_GROKS_EXTMOD),)
    4745#
    48 # 2.4
     46# Pre 2.6.6
    4947#
    50 # Note: while 2.4 kernels could also do "proper" builds from kbuild, the make
    51 # script needed to support it was somewhat different from 2.6.  Since this
    52 # script works and 2.4 is not a moving target we will not try do do things the
    53 # "proper" way.
     48# Note: While pre 2.6.6 kernels could also do "proper" builds from kbuild, the
     49# make script needed to support it was somewhat different from 2.6.  Since this
     50# script works and pre-2.6.6 is not a moving target we will not try do do things
     51# the "proper" way.
    5452#
    5553VBOXMOD_EXT := o
    5654
    57 ifeq ($(BUILD_TARGET_ARCH),amd64)
    58  VBOXMOD_0_KFLAGS += -mcmodel=kernel
    59 endif
     55 ifeq ($(BUILD_TARGET_ARCH),amd64)
     56VBOXMOD_0_KFLAGS += -mcmodel=kernel
     57 endif
     58 ifeq ($(KERN_VERSION),24)
     59$(error KERN_VERSION=$(KERN_VERSION))
     60VBOXMOD_0_KFLAGS += -DVBOX_LINUX_2_4
     61 endif
    6062
    61 CFLAGS := -O2 -DVBOX_LINUX_2_4 $(VBOXMOD_CFLAGS) $(VBOX_INCL) $(VBOXMOD_0_KFLAGS) $(KDEBUG)
     63CFLAGS := -O2 $(VBOXMOD_CFLAGS) $(addprefix -I,$(KERN_INCL) $(VBOXMOD_INCL)) $(VBOXMOD_0_KFLAGS) $(KDEBUG)
    6264
    6365# 2.4 Module linking
     
    6567        $(LD) -o $@ -r $(VBOXMOD_OBJS)
    6668
    67 .PHONY: $(VBOXMOD_0_TARGET)
    6869all: $(VBOXMOD_0_TARGET)
    6970$(VBOXMOD_0_TARGET): $(VBOXMOD_0_TARGET).$(VBOXMOD_EXT)
     
    7879        rm -rf .$(VBOXMOD_NAME)* .tmp_ver* $(VBOXMOD_NAME).* Modules.symvers modules.order
    7980
    80 else  # ! $(KERN_VERSION), 24
     81.PHONY: all $(VBOXMOD_0_TARGET) install clean
     82
     83else  # VBOX_KERN_GROKS_EXTMOD
    8184#
    82 # 2.6 and later
    83 #
    84 ## @todo XXX does not work for 2.6.5 and earlier (see KBUILD_EXTMOD in header).
     85# 2.6.6 and later
    8586#
    8687VBOXMOD_EXT := ko
    8788
    8889# build defs
    89 EXTRA_CFLAGS += $(VBOXMOD_CFLAGS) $(VBOX_INCL) $(VBOXMOD_0_KFLAGS) $(KDEBUG)
     90EXTRA_CFLAGS += $(VBOXMOD_CFLAGS) $(addprefix -I,$(KERN_INCL) $(VBOXMOD_INCL)) $(VBOXMOD_0_KFLAGS) $(KDEBUG)
    9091$(VBOXMOD_0_TARGET)-y := $(VBOXMOD_OBJS)
    9192obj-m += $(VBOXMOD_0_TARGET).o
     
    9394# Trigger parallel make job.
    9495JOBS := $(shell (getconf _NPROCESSORS_ONLN || grep -Ec '^processor|^CPU[0-9]' /proc/cpuinfo) 2>/dev/null)
    95 ifeq ($(JOBS),0)
    96  override JOBS := 1
    97 endif
     96 ifeq ($(JOBS),0)
     97  override JOBS := 1
     98 endif
    9899
    99100# rules:
    100 .PHONY: $(VBOXMOD_0_TARGET)
    101101all: $(VBOXMOD_0_TARGET)
    102102
     
    114114
    115115.PHONY: all $(VBOXMOD_0_TARGET) install modules_install clean
    116 endif
     116endif # VBOX_KERN_GROKS_EXTMOD
     117
  • trunk/src/VBox/Installer/linux/Makefile-header.gmk

    r77399 r77404  
    113113 endif
    114114
    115  # guess kernel major version (24 or later)
    116  ifeq ($(shell if grep '"2\.4\.' /lib/modules/$(KERN_VER)/build/include/linux/version.h > /dev/null 2>&1; then echo yes; fi),yes)
     115 ifeq ($(KERN_DIR),)
     116  KERN_DIR := /lib/modules/$(KERN_VER)/build
     117 endif
     118
     119 # Is this 2.4 or < 2.6.6? The UTS_RELEASE "2.x.y.z" define is present in the header until 2.6.1x something.
     120 ifeq ($(shell if grep '"2\.4\.' $(KERN_DIR)/include/linux/version.h > /dev/null 2>&1; then echo yes; fi),yes)
    117121  KERN_VERSION := 24
     122  VBOX_KERN_GROKS_EXTMOD :=
    118123 else
    119124  KERN_VERSION := 26
     125  VBOX_KERN_GROKS_EXTMOD := yes
     126  ifeq ($(shell if grep '"2\.6\.[012345][."]' $(KERN_DIR)/include/linux/version.h > /dev/null 2>&1; then echo yes; fi),yes)
     127   VBOX_KERN_GROKS_EXTMOD :=
     128  else
     129  endif
    120130 endif
    121131
     
    127137
    128138 # guess kernel version (24 or 26)
    129  ifeq ($(shell if echo "$(VERSION).$(PATCHLEVEL)." | grep '2\.4\.' > /dev/null; then echo yes; fi),yes)
     139 ifeq ($(VERSION).$(PATCHLEVEL),2.4)
    130140  KERN_VERSION := 24
     141  VBOX_KERN_GROKS_EXTMOD :=
    131142 else
    132143  KERN_VERSION := 26
     144  VBOX_KERN_GROKS_EXTMOD := yes
     145  ifeq ($(VERSION).$(PATCHLEVEL),2.6)
     146   ifeq ($(findstring @$(SUBLEVEL)@,@0@1@2@3@4@5@),@$(SUBLEVEL)@)
     147    VBOX_KERN_GROKS_EXTMOD :=
     148   endif
     149  endif
    133150 endif
    134151
    135152 KERN_VER := $(KERNELRELEASE)
    136153
     154 ifeq ($(KERN_DIR),)
     155  KERN_DIR := /lib/modules/$(KERN_VER)/build
     156 endif
    137157endif # neq($(KERNELRELEASE),)
    138158
    139159# Kernel build folder
    140 ifeq ($(KERN_DIR),)
    141  KERN_DIR := /lib/modules/$(KERN_VER)/build
    142 endif
    143160ifneq ($(shell if test -d $(KERN_DIR); then echo yes; fi),yes)
    144161 $(error Error: unable to find the headers of the Linux kernel to build against. \
     
    163180 KBUILD_EXTMOD := $(CURDIR)
    164181endif
     182
     183
     184# For VBOX_GCC_CHECK_CC
     185VBOX_CLOSEPAR := )
     186VBOX_DOLLAR   := $$
     187## Modified VBOX_GCC_CHECK_EX_CC_CXX macro from /Config.kmk.
     188# @param 1 The option to test for.
     189# @param 2 The return value when supported.
     190# @param 3 The return value when NOT supported.
     191VBOX_GCC_CHECK_CC = $(shell \
     192    > /tmp/$(VBOX_DOLLAR)$(VBOX_DOLLAR).check.c; \
     193    if $(CC) $(subst -Wno-,-W,$(1)) -Werror -c -o /dev/null /tmp/$(VBOX_DOLLAR)$(VBOX_DOLLAR).check.c > /dev/null 2>&1; then \
     194        case "`LC_ALL=C $(CC) $(subst -Wno-,-W,$(1)) -Werror -c -o /dev/null /tmp/$(VBOX_DOLLAR)$(VBOX_DOLLAR).check.c 2>&1`" in \
     195            "error: unknown warning option"*$(VBOX_CLOSEPAR) echo "$(3)";; \
     196            *$(VBOX_CLOSEPAR) echo "$(2)";; \
     197         esac; \
     198    else echo "$(3)"; fi; \
     199    rm -f /tmp/$(VBOX_DOLLAR)$(VBOX_DOLLAR).check.c; )
     200
    165201
    166202# debug - show guesses.
Note: See TracChangeset for help on using the changeset viewer.

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