www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Simple makefile problem - implicit rule

reply "deed" <none none.none> writes:


OBJS    = main.obj othermodule.obj
DC      = dmd
DCFLAGS = -c

all : $(OBJS)

%.obj : %.d
       $(DC) $< $(DCFLAGS)



Error on line 9: expecting target : dependencies

* main.d, othermodule.d and makefile are in the same folder.
* make is executed in this folder from the command line

Anyone cares to explain what's wrong/missing?
Jan 09 2013
next sibling parent reply =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 01/09/2013 09:51 AM, deed wrote:

 $(DC) $< $(DCFLAGS)
Your post has spaces at the beginning on that line. (Thunderbird removes those when I reply. Curse!) Target rules must start with a tab character. Ali
Jan 09 2013
parent reply "deed" <none none.none> writes:
On Wednesday, 9 January 2013 at 17:57:28 UTC, Ali Çehreli wrote:
 On 01/09/2013 09:51 AM, deed wrote:

 $(DC) $< $(DCFLAGS)
Your post has spaces at the beginning on that line. (Thunderbird removes those when I reply. Curse!) Target rules must start with a tab character. Ali
Yeah, that's not the problem. Replacing %.obj and %.d with main.obj and main.d works.
Jan 09 2013
parent reply "deed" <none none.none> writes:
 Yeah, that's not the problem. Replacing %.obj and %.d with 
 main.obj and main.d works.
And $< with main.d
Jan 09 2013
parent reply Matthew Caron <matt.caron redlion.net> writes:
On 01/09/2013 01:13 PM, deed wrote:
 Yeah, that's not the problem. Replacing %.obj and %.d with main.obj
 and main.d works.
And $< with main.d
don't know what make you're using, but this works for me: OBJS = hello.obj hello_loop.obj DC = gdc DCFLAGS = all : $(OBJS) %.obj : %.d $(DC) $< $(DCFLAGS) -o $ Output: gdc hello.d -o hello.obj gdc hello_loop.d -o hello_loop.obj and hello.obj and hello_loop.obj both exist Note that there is a tab before $(DC). make --version says: GNU Make 3.81 Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. This program built for x86_64-pc-linux-gnu -- Matthew Caron, Software Build Engineer Sixnet, a Red Lion business | www.sixnet.com +1 (518) 877-5173 x138 office
Jan 09 2013
parent "deed" <none none.none> writes:
  don't know what make you're using, [...]
I'am using the make.exe coming with the DMD 2.061 distro in D/dmd2/windows/bin/ Thought/hoped the GNU spec was applicable, but if it works with GNU make and not Digital Mars make, well.. make -man leads to http://digitalmars.com/ctg/make.html, which says: Implicit Definition lines Does this give a clue?
Jan 09 2013
prev sibling parent reply =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 01/09/2013 09:51 AM, deed wrote:


 OBJS = main.obj othermodule.obj
 DC = dmd
 DCFLAGS = -c

 all : $(OBJS)

 %.obj : %.d
 $(DC) $< $(DCFLAGS)



 Error on line 9: expecting target : dependencies

 * main.d, othermodule.d and makefile are in the same folder.
 * make is executed in this folder from the command line

 Anyone cares to explain what's wrong/missing?
Assuming that this is for GNU make, ensuring that the rule starts with a tab characters, that file works with GNU Make 3.81. Ali
Jan 09 2013
parent reply "deed" <none none.none> writes:
 Assuming that this is for GNU make, ensuring that the rule 
 starts with a tab characters, that file works with GNU Make 
 3.81.

 Ali
It is Digital Mars Make Version 5.06 and it's on Windows 7.
Jan 09 2013
parent reply =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 01/09/2013 10:19 AM, deed wrote:
 Assuming that this is for GNU make, ensuring that the rule starts with
 a tab characters, that file works with GNU Make 3.81.

 Ali
It is Digital Mars Make Version 5.06 and it's on Windows 7.
That's why you didn't mark the subject with [OT]. ;) It looks like the syntax is different: .d.obj: $(DC) $(DFLAGS) -c $< I got that by clicking "makefile example" here: http://www.prowiki.org/wiki4d/wiki.cgi?DigitalMarsTools#DigitalMarsLinkerandUtilities Ali
Jan 09 2013
next sibling parent "deed" <none none.none> writes:
 .d.obj:
    $(DC) $(DFLAGS) -c $<
 Ali
Works like a charm! Case solved. Thank you very much!
Jan 09 2013
prev sibling parent "deed" <none none.none> writes:
 .d.obj:
    $(DC) $(DFLAGS) -c $<
 Ali
from http://digitalmars.com/ctg/make.html: Implicit Definition lines Isn't targ_ext .obj and dep_ext .d? If so, either the example or the documentation seems incorrect. The example provided works. The .obj is updated when .d is modified. Using .obj.d: dmd $*.d -c or .obj.d: dmd $< -c don't work. My conclusion is that the documentation at http://digitalmars.com/ctg/make.html is incorrect. It should be: Implicit Definition lines
Jan 09 2013