LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-18-2011, 05:30 AM   #1
freeindy
Member
 
Registered: Nov 2002
Posts: 207

Rep: Reputation: 32
Recursive Makefile


Hi,

I'm having problems with compiling recursive Makefiles in my directory structure:

My folder layout is:
top/
|- one/
|- one.c (With main function)
|- zero.c
|- two/
|- two.c
in my top folder the make file looks like:
Code:
MAKE_DIRECTORIES = one two

.PHONY: all
all: $(MAKE_DIRECTORIES)

.PHONY: $(MAKE_DIRECTORIES)
$(MAKE_DIRECTORIES):
        @echo $@
    $(MAKE) --directory=$@
in my one and two folder I have the following Makefile:
Code:
.PHONE: all

all:
        @echo $@
        $(CC) $(CFLAGS) *.c
But when I compile it from top folder: make

I get following output:
Code:
one
two
Which states that directory statement by echo in main Makefile is ok but the files are not compiled in one and two. Does anyone know why?

Thanks,
Indy
 
Old 05-18-2011, 06:07 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,999

Rep: Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190
Quote:
.PHONE: all
Firstly, is the red item a typo?
 
Old 05-18-2011, 06:50 AM   #3
freeindy
Member
 
Registered: Nov 2002
Posts: 207

Original Poster
Rep: Reputation: 32
Indeed, There was this error. Silly. However, it's changed to .PHONY but the result is still the same. I double checked it...
 
Old 05-18-2011, 07:41 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,999

Rep: Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190
Maybe this can help
 
Old 05-18-2011, 09:34 AM   #5
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,774

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Quote:
Originally Posted by freeindy View Post
Code:
$(MAKE_DIRECTORIES):
        @echo $@
    $(MAKE) --directory=$@
It looks like the second line is indented differently from the first. Remember that Makefiles require every command to be prefixed with a TAB, spaces won't work.
 
Old 05-25-2011, 08:19 AM   #6
freeindy
Member
 
Registered: Nov 2002
Posts: 207

Original Poster
Rep: Reputation: 32
Ah thanks!

Indentation was the problem... should be more careful :-)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to write non recursive makefile tushs Programming 5 01-07-2012 11:04 AM
Is it mandatory to have the name of the makefile as 'Makefile' for kernal module comp narender.d Linux - Kernel 3 05-29-2009 06:26 AM
how to get (makefile -f makefile )output into the textview widget in Pygtk sailu_mvn Programming 3 02-28-2005 03:57 AM
generate Makefile from Makefile.in without calling ./configure ? chris78 Programming 2 05-02-2004 12:23 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration