help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Implicit rule ignored


From: Noel David Torres Taño
Subject: Implicit rule ignored
Date: Tue, 16 Feb 2010 14:18:06 +0100
User-agent: KMail/1.9.9

Hello all:

I'm working in Fortran 95, with modules, and I need to build tests for the 
modules.

Thus, I need to express the following:

#modules depend on module sources and are rebuilt compiling source to objects
#module times are not updated by FC so best is to delete the module and force 
compilation
#compilation of *_m.F95 generates the appropiate module
modules/%.mod : %.F95
        @-rm $@ 2>/dev/null
        $(MAKE) -B --no-print-directory $*.o

#object files whose name ends in _m are module sources
#module sources may depend not only on sources with the same name but on 
non-module sources with the same name via #include
%_m.o : %_m.F95 %.F95
        $(FC) $(FFLAGS) -Jmodules -o $@ -c $<

#objects for module test programs depends on their source and the module being 
tested
################################
### THIS RULE IS THE PROBLEM ###
################################
%_test.o : %_test.F95 modules/%_m.mod
        @echo "***** Regla: %_test.o : modules/%_m.mod %_test.F95"
        $(FC) $(FFLAGS) -Jmodules -o $@ -c $<

#objects whose name does not end in _m or _test are compiled normally
%.o : %.F95
        @echo "***** Regla: %.o : %.F95"
        $(FC) $(FFLAGS) -Jmodules -o $@ -c $<

But the rule for test programs seems to be ignored:

$ LANG=C make -dr do_newton_test.o
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 i486-pc-linux-gnu
Reading makefiles...
Reading makefile `Makefile'...
Updating makefiles....
 Considering target file `Makefile'.
  Looking for an implicit rule for `Makefile'.
  No implicit rule found for `Makefile'.
  Finished prerequisites of target file `Makefile'.
 No need to remake target `Makefile'.
Updating goal targets....
Considering target file `do_newton_test.o'.
 File `do_newton_test.o' does not exist.
 Looking for an implicit rule for `do_newton_test.o'.
 Trying pattern rule with stem `do_newton'. <----------------- Rule is tested 
here
 Trying implicit prerequisite `do_newton_test.F95'.
 Trying implicit prerequisite `modules/do_newton_m.mod'.
 Trying pattern rule with stem `do_newton_test'. <------------ What happened to 
the other rule?
 Trying implicit prerequisite `do_newton_test.F95'.
 Found an implicit rule for `do_newton_test.o'.
  Considering target file `do_newton_test.F95'.
   Looking for an implicit rule for `do_newton_test.F95'.
   No implicit rule found for `do_newton_test.F95'.
   Finished prerequisites of target file `do_newton_test.F95'.
  No need to remake target `do_newton_test.F95'.
 Finished prerequisites of target file `do_newton_test.o'.
Must remake target `do_newton_test.o'.
***** Regla: %.o : %.F95 <------------------------------------ It is using the 
wrong implicit rule!
Putting child 0x08d2c7b0 (do_newton_test.o) PID 22469 on the chain.
Live child 0x08d2c7b0 (do_newton_test.o) PID 22469
Reaping winning child 0x08d2c7b0 PID 22469
gfortran -Wall -ggdb -pedantic -O0 -Jmodules -o do_newton_test.o -c 
do_newton_test.F95
Live child 0x08d2c7b0 (do_newton_test.o) PID 22470
do_newton_test.F95:13.17:

  use do_newton_m
                1
Fatal Error: Can't open module file 'do_newton_m.mod' for reading at (1): No 
such file or directory
Reaping losing child 0x08d2c7b0 PID 22470
make: *** [do_newton_test.o] Error 1
Removing child 0x08d2c7b0 PID 22470 from chain.
$

But, if I include a rule like (having one of these for each test is what I 
tried to avoid):

do_newton_test.o : modules/do_newton_m.mod

compilation success:

$ LANG=C make -dr do_newton_test.o
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 i486-pc-linux-gnu
Reading makefiles...
Reading makefile `Makefile'...
Updating makefiles....
 Considering target file `Makefile'.
  Looking for an implicit rule for `Makefile'.
  No implicit rule found for `Makefile'.
  Finished prerequisites of target file `Makefile'.
 No need to remake target `Makefile'.
Updating goal targets....
Considering target file `do_newton_test.o'.
 File `do_newton_test.o' does not exist.
 Looking for an implicit rule for `do_newton_test.o'.
 Trying pattern rule with stem `do_newton'.
 Trying implicit prerequisite `do_newton_test.F95'.
 Trying implicit prerequisite `modules/do_newton_m.mod'.
 Found an implicit rule for `do_newton_test.o'. <------------- Here now it uses 
the rule!
...blah blah blah
make -B --no-print-directory do_newton_m.o
...blah blah blah
 Finished prerequisites of target file `do_newton_m.o'.
Must remake target `do_newton_m.o'.
gfortran -Wall -ggdb -pedantic -O0 -Jmodules -o do_newton_m.o -c do_newton_m.F95
...blah blah blah
  Successfully remade target file `modules/do_newton_m.mod'.
  Pruning file `modules/do_newton_m.mod'.
 Finished prerequisites of target file `do_newton_test.o'.
Must remake target `do_newton_test.o'.
***** Regla: %_test.o : modules/%_m.mod %_test.F95 <---------- Here it is using 
the right rule
Putting child 0x09875ce0 (do_newton_test.o) PID 22820 on the chain.
Live child 0x09875ce0 (do_newton_test.o) PID 22820
Reaping winning child 0x09875ce0 PID 22820
gfortran -Wall -ggdb -pedantic -O0 -Jmodules -o do_newton_test.o -c 
do_newton_test.F95
Live child 0x09875ce0 (do_newton_test.o) PID 22821
Reaping winning child 0x09875ce0 PID 22821
Removing child 0x09875ce0 PID 22821 from chain.
Successfully remade target file `do_newton_test.o'.
$


Can somebody explain me? I've looked through the doc and found nothing.

Thanks

Noel
er Envite

Attachment: signature.asc
Description: This is a digitally signed message part.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]