LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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-08-2013, 08:30 AM   #1
j3ski
LQ Newbie
 
Registered: Sep 2012
Location: Orlando, FL
Posts: 7

Rep: Reputation: Disabled
Makefile question?


I have a Makefile with:
.PHONY: all clean distclean

all: $(LEXFILE) $(BINDIR)/$(APP)
where:
LEXFILE := lex.yy.c
APP = bridge
BINDIR = bin
If I redefine:
all: $(LEXFILE) $(OBJDIR)/%.o
where:
OBJDIR = obj
I get: make: *** No rule to make target `obj/%.o', needed by `all'. Stop.

Why?
 
Old 05-08-2013, 08:56 AM   #2
pan64
Senior Member
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 4,926

Rep: Reputation: 1305Reputation: 1305Reputation: 1305Reputation: 1305Reputation: 1305Reputation: 1305Reputation: 1305Reputation: 1305Reputation: 1305Reputation: 1305
the line all: $(LEXFILE) $(OBJDIR)/%.o is syntactically correct, but will not do what you want, you would need to check the documentation about how to use %.
In your case make is looking for a file named %.o in the dir obj.
Usually you need something like that:
%.ext1: %.ext2 where % can be replaced with a filename using ext1 and ext2 as target(result) and source.
 
Old 05-09-2013, 02:14 AM   #3
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 1,810

Rep: Reputation: 501Reputation: 501Reputation: 501Reputation: 501Reputation: 501Reputation: 501
Well, what did you mean by $(OBJDIR)/%.o? What should make have substitute with?
 
  


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
makefile question ryande Linux - General 5 04-30-2010 12:11 AM
Makefile question silentray Linux - Newbie 1 12-18-2009 04:51 AM
g++ makefile question zahadumy Programming 4 03-25-2007 04:18 PM
Makefile.in question lucky6969b Programming 4 12-08-2005 03:32 AM
Question about makefile taureanyang Programming 1 03-25-2005 11:57 PM


All times are GMT -5. The time now is 12:08 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration