mrtazz / checkmake

experimental linter/analyzer for Makefiles
MIT License
1.04k stars 45 forks source link

Support make check (the GNU conventions) #72

Open rurban opened 2 years ago

rurban commented 2 years ago

Expected behaviour

Instead of warning a missing .PHONY test, check if a check target exists instead.

Actual behaviour

With GNU Makefiles it warns about a missing make test target. minphony Missing required phony target 1222
"test"

Output of checkmake --version

checkmake 0.2.1 built at 2022-08-15T10:00:27Z by Reinhard Urban reinhard.urban@nubix.de with go version go1.18.1 linux/amd64

Output of checkmake --debug <your makefile>

...
      RULE                 DESCRIPTION             LINE NUMBER  

  maxbodylength   Target body for "Makefile"               578  
                  exceeds allowed length of 5                   
                  (8).                                          
  maxbodylength   Target body for "distcheck"              988  
                  exceeds allowed length of 5                   
                  (57).                                         
  maxbodylength   Target body for                         1046  
                  "distcleancheck" exceeds                      
                  allowed length of 5 (8).                      
  maxbodylength   Target body for "unknown"               1230  
                  exceeds allowed length of 5                   
                  (14).                                         
  minphony        Missing required phony target           1222  
                  "clean"                                       
  minphony        Missing required phony target           1222  
                  "test"                                        
  phonydeclared   Target "tags" should be                  711  
                  declared PHONY.                               
  phonydeclared   Target "ctags" should be                 742  
                  declared PHONY.                               
  phonydeclared   Target "cscopelist" should be            761  
                  declared PHONY.                               
  phonydeclared   Target "installdirs" should be          1060  
                  declared PHONY.                               
  phonydeclared   Target "uninstall" should be            1070  
                  declared PHONY.                               
  phonydeclared   Target "installcheck" should            1075  
                  be declared PHONY.                            
  phonydeclared   Target "clean" should be                1121  
                  declared PHONY.                               
  phonydeclared   Target "dvi" should be                  1131  
                  declared PHONY.                               
  phonydeclared   Target "html" should be                 1135  
                  declared PHONY.                               
  phonydeclared   Target "info" should be                 1139  
                  declared PHONY.                               
  phonydeclared   Target "mostlyclean" should be          1178  
                  declared PHONY.                               
  phonydeclared   Target "pdf" should be                  1182  
                  declared PHONY.                               
  phonydeclared   Target "ps" should be declared          1186  
                  PHONY.                                        

Output of make --version

GNU Make 4.3

Sample Makefile to reproduce issue

Any autotools generated GNU Makefile

(some of these things might not apply but the more you can provide the easier it will be to fix this bug. Thanks!)

crazybolillo commented 1 year ago

This not only happens on autotools Makefiles, but as far as I can see on any file that does not have .test under .PHONY

For example this Makefile also generates the warning:

.PHONY: all

all:
    printf "Hello\n"

The error goes away if you add the targets to PHONY, even if they do not exist:

.PHONY: all test clean

all:
    printf "Hello\n"
cooljeanius commented 12 months ago

dup of #15 I think (bugs #86 and #87 are also related, as is PR #88)