Solved

Recursive Make

Posted on 2004-10-03
5
244 Views
Last Modified: 2010-05-18
How to create a recursive make?
I read from my lecture notes that Make can be recursive.
If possible, can also code out some .c or .h files to illustrate that?
A very simple one will do.

FYI, I am using Solaris Unix and GNU make.

I also read this on my lecture notes. What does the below mean? Can illustrate?
        Advise: call ${MAKE} instead of make


Thanks a lot
0
Comment
Question by:ee_guest
5 Comments
 
LVL 33

Assisted Solution

by:hongjun
hongjun earned 20 total points
Comment Utility
0
 
LVL 22

Expert Comment

by:grg99
Comment Utility
"make" is intrinsically recursive.  that is, if you tell it to make "foo", and there's a rule saying "foo" depends on "goo", then make has to do an internal "make goo", which can lead to yet more makes for things that goo depends on.


Example:

foo:  goo


goo:   zoo bloo

zoo:   zoo.c   zoo.h

bloo:  bloo.c  bloo.h


0
 

Author Comment

by:ee_guest
Comment Utility
then can anyone explain this?
    Advise: call ${MAKE} instead of make
0
 
LVL 22

Expert Comment

by:grg99
Comment Utility
On many systems there's more than one copy or version of "make".  There may be Solaris Make, dgpp make, Gnu make, watcom make, Microsoft Make, Borland make, etc...   All with slightly different or sometimes wildly different syntax and semantics and options and bugs.

So to select one particular make you can define a system environment variable somewhere  in your .login or autoexec.bat file:

SET MAKE=C:\\sr\local\bin\watcom\nt\make.exe

... then when you use the "CALL ${MAKE}" line, it expands to calling the make program defined above.

0
 
LVL 1

Accepted Solution

by:
rghome earned 25 total points
Comment Utility
Your lecturer might have been refering to the fact that you can call make from within a makefile. Often, you will use this if you want to make something in a different directory that has its own makefile. Although you can include makefiles within makefiles, this is not really recursive. The rules iin make are recursively applied, but if you want to run another makefile, you have to re-inovke make.

For example:

tests:
    $(MAKE) -f tests/makefile

The Macro $(MAKE) is used because you might want to change the make program that you use.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now