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 8657325
In Process

The Archive Base Latest Questions

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

I need some help with my Makefile for a project. The source directory looks

  • 0

I need some help with my Makefile for a project. The source directory looks something like this.

|-- Makefile
|-- drivers
|   |-- Makefile
|   |-- tty
|       |-- Makefile
|       |-- console.c
|       |-- keyboard.c
|-- kernel
|   |-- Makefile
|   |-- kmain.c

In the top Makefile, I have exported a variable OBJECTS that I want to populate with object files so I can build and link them together in the top Makefile.

I want to update OBJECTS in, say, drivers/tty/Makefile by doing something like this:

OBJECTS += $(CURDIR)console.o
OBJECTS += $(CURDIR)keyboard.o

But the change to OBJECTS does not bubble up to the top Makefile. I’ve been looking at the Makefiles in the Linux source tree, and they seem to be doing something similar. However, I can’t get it to work. Am I missing something here?

  • 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-12T15:29:41+00:00Added an answer on June 12, 2026 at 3:29 pm

    You appear to be using Make recursively, something like

    # Makefile:
    
    export OBJECTS :=
    all:
        $(MAKE) -C drivers/tty
        @echo OBJECTS is $(OBJECTS)
    
    # drivers/tty/Makefile:
    
    OBJECTS += $(CURDIR)console.o
    all:
        whatever
    

    This doesn’t work, because each Make has its own OBJECTS; the child Make can’t modify variables in the parent Make. It’s export, not import/export or share (there’s no such thing as import/export or share, I’m just trying to illustrate).

    You can get the effect you want by including the other makefiles instead of invoking them:

    # Makefile:
    
    OBJECTS :=
    all: DRIVERS_TTY
        @echo OBJECTS is $(OBJECTS)
    
    include drivers/tty/Makefile
    
    # drivers/tty/Makefile:
    
    OBJECTS += drivers/tty/console.o
    
    DRIVERS_TTY:
        whatever
    

    You’ll notice there is some unpleasant location-dependency there; drivers/tty/Makefile has “drivers/tty” spelled out inside it, which makes maintenance a pain. There are ways to fix that, once you have this basic include trick working.

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

Sidebar

Related Questions

Need some help finishing up this program, everything works and runs like I want
Need some help to solve this. I have a gridview and inside the gridview
Need some help with this problem in implementing with XSLT, I had already implemented
Need some help gathering thoughts on this issue. Our team is moving ahead with
Need some help with a query.. I have three tables. Source id name 1
Need some help with this error. Fresh wordpress 2.9 install... Fatal error: Cannot instantiate
Need some help on understanding how to do this; I'm going to be running
Need some help in Notepad++ Example how it looks at the moment http://www.test.com/doc/rat.rar>rat.rar http://www.test.com/down/ung.rar>ung.rar
I would like some help in setting up a project in SVN with regards
Need some help refactoring this if/else block that builds the conditions for a find

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.