bug-make
[Top][All Lists]
Advanced

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

make doesn't complain if target cannot be built


From: Christian Eggers
Subject: make doesn't complain if target cannot be built
Date: Mon, 13 Jan 2014 22:23:24 +0100
User-agent: KMail/4.8.5 (Linux/3.8.0-rc6-2.20-desktop; KDE/4.8.5; x86_64; ; )

Hint: There's no file present from which foo.o can be built with implicit 
rules.

Makefile 1:
--snip---
all: foo.o
--EOF---
# make foo.o
make: *** No rule to make target `foo.o'.  Stop.
# echo $?
2

Makefile 2:
--snip---
all: foo.o
foo.o: generated.h
--EOF---
# touch generated.h
# make foo.o
make: Nothing to be done for `foo.o'
# echo $?
0

In Makefile 2 my intention was to state that foo.o depends on some generated 
header which must be generated first (might be in another rule). But I didn't 
want to change the be behaviour if foo.o cannot be built because e.g. there's 
no foo.c.

The example in make's manual, chapter "4.11 Multiple Rules for One Target", 
suffers from the identical problem.



Regarding to the make source code, foo.o ..
- has no cmds.
- is not "phony"
- is a target

remake.c
---snip---
remake_file (struct file *file)
{
  if (file->cmds == 0)
    {
      if (file->phony)                                                          
                                                                    
        /* Phony target.  Pretend it succeeded.  */                             
                                                                    
        file->update_status = us_success;                                       
                                                                    
      else if (file->is_target)                                                 
                                                                    
        /* This is a nonexistent target file we cannot make.                    
                                                                    
           Pretend it was successfully remade.  */                              
                                                                    
--->                                                                            
                                                                    
---> foo.o matches this case                                                    
                                                                    
--->                                                                            
                                                                    
        file->update_status = us_success;                                       
                                                                    
      else                                                                      
                                                                    
        {                                                                       
                                                                    
          /* This is a dependency file we cannot remake.  Fail.  */             
                                                                    
          if (!rebuilding_makefiles || !file->dontcare)                         
                                                                    
            complain (file);
          file->update_status = us_failed;
        }
    }
  else
---snap---

regards
Christian




reply via email to

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