For Programmers: Free Programming Magazines  


Home > Archive > Fortran > June 2005 > make: *** No rule to make target `inc/myProgram.inc'









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author make: *** No rule to make target `inc/myProgram.inc'
Al

2005-06-08, 4:00 pm

I get the following error, using the makefile at the bottom of this
message:

make -k all
make: *** No rule to make target `inc/myProgram.inc', needed by
`obj/myfile1.o'.
make: Target `all' not remade because of errors.

Directory structure looks like this:
--MyProject
--source
myFile1.f
myFile2.f
mainsw.f
--include
myProgram.inc

So it can't find myProgram.inc because its not on a path or something.
but i have specified MyProject/source/inc to be on the include path
(using Eclipse IDE with photran plugin)


Can anyone tell me what is wrong?

Thanks!

-------------------------------

O = obj
SRC = source
OBJ = ${O}/myfile1.o\
${O}/myfile2.o\
${O}/mainsw.o\

FOPT = -c -O
FDEBUG = -g -c -C
#FFLAGS = $(FDEBUG)
FFLAGS = $(FOPT)
INCLUDE = inc/myProgram.inc

all : myProgram

clean :
rm myProgram obj/*.o

myProgram : $(OBJ) $(INCLUDE)
f77 $(OBJ) -o myProgram
# f77 $(OBJ) -o myProgram -C -lm

${O}/myfile1.o : ${SRC}/myfile1.f $(INCLUDE)
f77 $(FFLAGS) ${SRC}/myfile1.f
mv myfile1.o ${O}/myfile1.o
${O}/myfile2.o : ${SRC}/myfile2.f $(INCLUDE)
f77 $(FFLAGS) ${SRC}/myfile2.f
mv myfile2.o ${O}/myfile2.o
${O}/dailysum.o : ${SRC}/mainsw.f $(INCLUDE)
f77 $(FFLAGS) ${SRC}/mainsw.f
mv mainsw.o ${O}/main.o

Michel OLAGNON

2005-06-08, 4:00 pm



Al wrote:
> I get the following error, using the makefile at the bottom of this
> message:
>
> make -k all
> make: *** No rule to make target `inc/myProgram.inc', needed by
> `obj/myfile1.o'.
> make: Target `all' not remade because of errors.
>
> Directory structure looks like this:
> --MyProject
> --source
> myFile1.f
> myFile2.f
> mainsw.f
> --include
> myProgram.inc


May be you should try renaming that directory "inc", in order
to be consistent with target `inc/myProgram.inc'

Ron Shepard

2005-06-08, 4:00 pm

In article <1118236049.278653.68670@g47g2000cwa.googlegroups.com>,
"Al" <allelopath@hotmail.com> wrote:

I see two possible problems. This may have been just a typo, but
your directory structure:

> Directory structure looks like this:
> --MyProject
> --source
> myFile1.f
> myFile2.f
> mainsw.f
> --include
> myProgram.inc


is not consistent with your include file specification

> INCLUDE = inc/myProgram.inc


One has the directory "include" and the other has the directory
"inc". If this really is the situation, then you would need to
change either the directory name or the makefile.

Second, a compile line such as

> ${O}/myfile1.o : ${SRC}/myfile1.f $(INCLUDE)
> f77 $(FFLAGS) ${SRC}/myfile1.f


does not tell the compiler where to find the include file, only that
the object file needs one as a prerequisite. You usually need
something like

<tab> f77 $(FFLAGS) ${SRC}/myfile1.f -I $(INCLUDE)

$.02 -Ron Shepard
Al

2005-06-08, 4:00 pm

Sorry, that was a typo, that directory is really named inc, not include

I added the -I $(INCLUDE) to the line as follows:
${O}/myfile1.o : ${SRC}/myfile1.f $(INCLUDE)
f77 $(FFLAGS) ${SRC}/myfile1.f -I $(INCLUDE)

(with a tab where it should be, as you indicated)
but i get the same error.
Did i do this corrrectly?

Richard E Maine

2005-06-08, 8:58 pm

In article <1118251054.996700.190440@g14g2000cwa.googlegroups.com>,
"Al" <allelopath@hotmail.com> wrote:

> Sorry, that was a typo, that directory is really named inc, not include
>
> I added the -I $(INCLUDE) to the line as follows:
> ${O}/myfile1.o : ${SRC}/myfile1.f $(INCLUDE)
> f77 $(FFLAGS) ${SRC}/myfile1.f -I $(INCLUDE)
>
> (with a tab where it should be, as you indicated)
> but i get the same error.
> Did i do this corrrectly?


Nope, but closer. :-)

The -I switch takes a directory name (which might have multiple include
files in it), not a file name. Your INCLUDE macro (definition elided)
has the file name. Since inc is the directory name, you need something
more like

-I inc

(or maybe -I ./inc might be better - that's arguable)

You could make an appropriate macro; in fact, I'd probably do that, but
your INCLUDE macro is not defined appropriately for this. One
alternative would be to change your INCLUDE macro definition to specify
the directory, but then you'd have to do something else to tack on the
file name part where you need that.

--
Richard Maine | Good judgment comes from experience;
email: my first.last at org.domain | experience comes from bad judgment.
org: nasa, domain: gov | -- Mark Twain
Ron Shepard

2005-06-09, 3:58 am

In article <nospam-0C1277.12284508062005@news.supernews.com>,
Richard E Maine <nospam@see.signature> wrote:

> Since inc is the directory name, you need something
> more like
>
> -I inc
>
> (or maybe -I ./inc might be better - that's arguable)


Yes, that looks better, I didn't catch that in my posting. The
other gotcha to watch for might be to put the include directory
before the filename, rather than after it as I did in my earlier
posting. I forget how g77 works, but I'm pretty sure I've used
other compilers where the order made a difference. For example,

f77 -I ./inc1 file1.f -I ./inc2 file2.f

would compile both file1.f and file2.f and attempt to link them
together. The compilation of file1.f would search only in the
../inc1 directory for include files, while file2.f would search in
both ./inc1 and ./inc2 for include files.

$.02 -Ron Shepard
Michel OLAGNON

2005-06-09, 8:57 am



Ron Shepard wrote:
> In article <nospam-0C1277.12284508062005@news.supernews.com>,
> Richard E Maine <nospam@see.signature> wrote:
>
>
>
>
> Yes, that looks better, I didn't catch that in my posting. The
> other gotcha to watch for might be to put the include directory
> before the filename, rather than after it as I did in my earlier
> posting. I forget how g77 works, but I'm pretty sure I've used
> other compilers where the order made a difference. For example,
>
> f77 -I ./inc1 file1.f -I ./inc2 file2.f
>
> would compile both file1.f and file2.f and attempt to link them
> together. The compilation of file1.f would search only in the
> ./inc1 directory for include files, while file2.f would search in
> both ./inc1 and ./inc2 for include files.
>
> $.02 -Ron Shepard


As far as I can see, the problem is not in f77 but in make.
I just had another idea: try adding the lines
..SUFFIXES:
..SUFFIXES: .inc $(SUFFIXES)

at the beginning of your Makefile. Otherwise, ".inc" may not be
correctly taken into account as it is not a common suffix.

Al

2005-06-09, 3:58 pm

I've tried your various suggestions, but nothing works.
i get the same error message.
(Current state below)
....and then, depression, set in...
------------------------------

O = obj
SRC = source
..SUFFIXES:
..SUFFIXES: .inc $(SUFFIXES)

OBJ = ${O}/myfile1.o\
${O}/myfile2.o\
${O}/mainsw.o

FOPT = -c -O
FDEBUG = -g -c -C
#FFLAGS = $(FDEBUG)
FFLAGS = $(FOPT)
INCLUDE = inc/myProgram.inc
INCLUDEDIR = ./inc

all : myProgram

clean :
rm myProgram obj/*.o

myProgram : $(OBJ) $(INCLUDE)
f77 $(OBJ) -o myProgram
# f77 $(OBJ) -o myProgram -C -lm

${O}/myfile1.o : ${SRC}/myfile1.f $(INCLUDE)
f77 $(FFLAGS) -I INCLUDEDIR ${SRC}/myfile1.f
mv myfile1.o ${O}/myfile1.o
${O}/myfile2.o : ${SRC}/myfile2.f $(INCLUDE)
f77 $(FFLAGS) -I INCLUDEDIR ${SRC}/myfile2.f
mv myfile2.o ${O}/myfile2.o
${O}/dailysum.o : ${SRC}/mainsw.f $(INCLUDE)
f77 $(FFLAGS) -I INCLUDEDIR ${SRC}/mainsw.f
mv mainsw.o ${O}/main.o

Erik Edelmann

2005-06-09, 3:58 pm

On 2005-06-09, Al <allelopath@hotmail.com> wrote:
> I've tried your various suggestions, but nothing works.
> i get the same error message.
> (Current state below)
> ...and then, depression, set in...
> ------------------------------
>
> O = obj
> SRC = source
> .SUFFIXES:
> .SUFFIXES: .inc $(SUFFIXES)
>
> OBJ = ${O}/myfile1.o\
> ${O}/myfile2.o\
> ${O}/mainsw.o
>
> FOPT = -c -O
> FDEBUG = -g -c -C
> #FFLAGS = $(FDEBUG)
> FFLAGS = $(FOPT)
> INCLUDE = inc/myProgram.inc
> INCLUDEDIR = ./inc
>
> all : myProgram
>
> clean :
> rm myProgram obj/*.o
>
> myProgram : $(OBJ) $(INCLUDE)
> f77 $(OBJ) -o myProgram
> # f77 $(OBJ) -o myProgram -C -lm
>
> ${O}/myfile1.o : ${SRC}/myfile1.f $(INCLUDE)
> f77 $(FFLAGS) -I INCLUDEDIR ${SRC}/myfile1.f
> mv myfile1.o ${O}/myfile1.o
> ${O}/myfile2.o : ${SRC}/myfile2.f $(INCLUDE)
> f77 $(FFLAGS) -I INCLUDEDIR ${SRC}/myfile2.f
> mv myfile2.o ${O}/myfile2.o
> ${O}/dailysum.o : ${SRC}/mainsw.f $(INCLUDE)
> f77 $(FFLAGS) -I INCLUDEDIR ${SRC}/mainsw.f
> mv mainsw.o ${O}/main.o


Earlier you wrote:
>Directory structure looks like this:
>--MyProject
> --source
> myFile1.f
> myFile2.f
> mainsw.f
> --include
> myProgram.inc


Where is your Makefile located? From the contents of the Makefile it seems
as if it was in MyProject. In that case, try to change

INCLUDE = inc/myProgram.inc

to

INCLUDE = ${SRC}/inc/myProgram.inc


Erik
Erik Edelmann

2005-06-09, 3:58 pm

On 2005-06-09, Erik Edelmann <eedelman@acclab.helsinki.fi> wrote:
> INCLUDE = inc/myProgram.inc
>
> to
>
> INCLUDE = ${SRC}/inc/myProgram.inc


And, to kepp the compiler happy, change

INCLUDEDIR = ./inc

to

INCLUDEDIR = {SRC}/inc


Erik
Al

2005-06-09, 3:58 pm

makefile is indeed in the MyProject directory, like so:
--MyProject
makefile
--source
myFile1.f
myFile2.f
mainsw.f
--incl
myProgram.inc

Changing to
INCLUDE = ${SRC}/inc/myProgram.inc
INCLUDEDIR = ${SRC}/inc

causes the error to be:
make: *** No rule to make target `source/inc/myProgram.inc', needed by
`obj/myfile1.o'.
(it just added 'source' to the path in the message)

Al

2005-06-09, 3:58 pm

sorry, that directory should be:
--inc (not incl)

Al

2005-06-09, 3:58 pm

given:
WHATEVER = /whatever
Is:
$(WHATEVER) the same as ${WHATEVER}
?

Also,
f77 $(FFLAGS) -I INCLUDEDIR ${SRC}/myfile1.f
probably should be:
f77 $(FFLAGS) -I $(INCLUDEDIR) ${SRC}/myfile1.f

Al

2005-06-09, 3:58 pm

if i change th e line of code:
include 'myProgram.inc'
to:
include 'inc/myProgram.inc'
this seems to help.
Is this a kludge?

Also, i guess there can be no space between the -I and the directory
name:
-Iinc
no
-I inc

Janne Blomqvist

2005-06-09, 3:58 pm

In article <1118332045.006138.89620@f14g2000cwb.googlegroups.com>, Al wrote:
> makefile is indeed in the MyProject directory, like so:
> --MyProject
> makefile
> --source
> myFile1.f
> myFile2.f
> mainsw.f
> --incl
> myProgram.inc
>
> Changing to
> INCLUDE = ${SRC}/inc/myProgram.inc
> INCLUDEDIR = ${SRC}/inc
>
> causes the error to be:
> make: *** No rule to make target `source/inc/myProgram.inc', needed by
> `obj/myfile1.o'.
> (it just added 'source' to the path in the message)


Another thing which for some unexplainable reason the other people who
have contributed to the thread haven't commented on is:

Makefile rules are of the form:

targetname: dependencylist
<tab> commands to do for 'targetname'

where "dependencylist" is a list of other targets that must be
completed before the target in question can be "executed" (made).

Now, in your case your make files contained rules of the form

sometarget: something $(INCLUDE)
<tab> .....

Now, as make is instructed to make 'sometarget' it first checks that
the dependencylist is completed, and as you don't have a target named
$(INCLUDE), which gets expanded to $(SRC)/inc/myProgram.inc, make gets
and decides to bail out with a helpful message which is the
subject of this thread.

--
Janne Blomqvist
Al

2005-06-10, 4:00 am

Its working. Whether changing the code to "inc/myProgram.inc" is the
right thing to do, I can't say. Thanks to Richard, Ron, Michael, Erik,
and Janne for your help.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com