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

  • SEARCH
  • Home
  • 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 6675645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:52:59+00:00 2026-05-26T03:52:59+00:00

I am trying to create a Makefile in the root directory that creates an

  • 0

I am trying to create a Makefile in the root directory that creates an output (/bin) directory and then recursively goes into subdirectories, looking for a Makefile, calling it with the files in that directory, and outputing everything in /bin.

The Makefile in the root is the following:

DIR=bin
OUT_DIR=/bin
MAKE=make
CURRENT_DIR=./Server
ROOT=.

all: compile

compile: dir
    export ROOT;
    export OUT_DIR;
    export CURRENT_DIR;
    export;
    $(MAKE) -C $(CURRENT_DIR)

dir:
        mkdir -p $(DIR);

clean:
        rm -rf $(OUT_DIR)/*

The bin directory gets created, and it seems like the Makefile in the server directory also gets called (I don’t have a loop to go into subdirectories yet).

In my Makefile in Server, where two .java files are, I have the following:

JC=javac

all: server

server:
    echo $(OUT_DIR);
    echo $(CURRENT_DIR);
    $(JC) -d $(OUT_DIR) $(CURRENT_DIR)/*.java

What is happening is when I call “export” in the initial Makefile, the variables I am trying to export are not exported and I do not understand why.

I would really appreciate if someone could please point me towards my question and also point me towards an elegant solution to solve my overall problem please.

Makefiles are a bit tricky for me at this point: There seem to be multiple ways to achieve a similar solution, and I am not sure which one is more appropriate and elegant.

  • 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-05-26T03:53:00+00:00Added an answer on May 26, 2026 at 3:53 am

    Your exports are on multiple lines and therefore in different shell invocations. Put a \ at the end of a line to join them.

    It is a little more elegant at this point to export the variables directly in the Makefile, e.g. state

    ROOT=.
    export ROOT
    

    It is even more elegant to use automake and have it generate the makefile for you.

    It is even even more elegant to use non-recursive makefiles.

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

Sidebar

Related Questions

I'm trying to create a Makefile that uses information from the path to create
I'm trying to create a Makefile that will download and process file a file
I'm trying to create a Makefile that will compile and run 3 different implementations
I am new to python and I'm trying to create a program that creates
I'm trying to create a makefile that has rule something like: ~/$ cat >
I'm trying to create a library that I can load into Lua with require
I am trying create a WCF service that leverages the WPF MediaPlayer on the
Trying to create my first iPhone app that would play back audio. When I
I've been trying to create an executable file from a Makefile to run a
I'm trying to create an application bundle for a game that uses some libraries

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.