Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9166753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:13:29+00:00 2026-06-17T15:13:29+00:00

The kernel Makefile init the variables like KBUILD_OUTPUT outside any target’s make process. The

  • 0

The kernel Makefile init the variables like KBUILD_OUTPUT outside any target’s make process. The code is like this:

ifeq ("$(origin O)", "command line")
  KBUILD_OUTPUT := $(O)
endif

But when I try to output KBUILD_OUTPUT in the target’s make process, for example, the target help, I find it is not defined. The code I modified is like this:

help:
    @echo 'KBUILD_OUTPUT: ${KBUILD_OUTPUT}'

When I execute make O=../build help, the KBUILD_OUTPUT variable is empty. I want to know when will it init?

Thanks a lot.

Update

However, when I just write a Makefile with this:

ifeq ("$(origin O)", "command line")
  KBUILD_OUTPUT := $(O)
endif

help:
    @echo 'KBUILD_OUTPUT: ${KBUILD_OUTPUT}'

Then I run make O=../build help, I will see KBUILD_OUTPUT: ../build.

Is there anything special in kernel’s Makefile?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T15:13:30+00:00Added an answer on June 17, 2026 at 3:13 pm

    The kernel make process is a bit more complicated than most makes. The main kernel makefile will recursively call itself (that is, it calls make specifying itself as the makefile, but giving different target sets). Because of this, large portions of the main kernel Makefile has conditionals around them, some parts meant to be executed when the Make is first invoked, and others which are meant to be executed when the makefile is invoked as a child of itself. The code you are quoting, is actually:

    ifeq ($(KBUILD_SRC),)
    
    # OK, Make called in directory where kernel src resides
    # Do we want to locate output files in a separate directory?
    ifeq ("$(origin O)", "command line")
      KBUILD_OUTPUT := $(O)
    endif
    

    When you create the help target, the Makefile will run only that rule, and thus not recursively call itself, and therefore, KBUILD_SRC will not be set, and thus KBUILD_OUTPUT will remain unset.

    John

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone explain what the target oldconfig does exactly in the Linux kernel makefile?
in kernel Makefile # Modules / %/: prepare scripts FORCE $(cmd_crmodverdir) $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1)
ifeq ($(KBUILD_SRC),) I saw the above in Makefile of linux kernel. It doesn't look
Kernel threads do context switch at kernel level instead of process level. I am
in Linux kernel source code, I find below code: h++; pending >>= 1; It
I have a third party makefile, and I'd like one of the targets (T1)
I am trying to cross-compile a Linux kernel for an ARM-target ( Freescale i.Mx28
I'm trying to write a makefile for a kernel module and cannot get it
I'm trying to compile a linux kernel module using a Makefile: obj-m += main.o
In Linux kernel source code, there are many memory barrier(smp_mb() and so on). But

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.