Search code examples
c++makefilelintpc-lint

How can I run an incremental PC-Lint using make


I would like to apply Gimpel PC-Lint to my source code in an incremental manner using Make. I want it to only run lint against the source file if the source file has changed since the last time lint was run. Is anyone doing this? How are you approaching it?


Solution

  • The common pattern is to create output (or create artificial output if there is none).

    Edit note that $(LINT) $< > $@ will expand to something like lint test.cpp > test.lint (redirecting output into that file)

    E.g.

     %.o: %.cpp | %.lint
          S(CC) -o $@ $(CPPFLAGS) $<
    
     %.lint: %.cpp
          $(LINT) $< > $@
    

    or for a process without output:

     %.o: %.cpp | %.emailsent
          S(CC) -o $@ $(CPPFLAGS) $<
    
     %.emailsent: %.cpp
          $(DOEMAIL) $^   # no output from mail sender
          touch $@        # won't be reached DOEMAIL returned error