I'm trying to create make targets for flawfinder and cppcheck that will recursively search the current directory, but ignore directories named "Test". However, I have run into some issues with formatting.

My user written and script commands look identical when displayed on the terminal

Terminal display of my user input:

cppcheck --quiet --force !(Tests) 

Vs terminal display of makefile output when I run make .securityCheck:

=================== cppcheck ======================
Tue Aug 29 13:32:00 PDT 2017
===================================================
cppcheck --quiet --force !(Tests)

When executed the makefile script creates the error:

syntax error near unexpected token `('

while my user input evaluates correctly

Makefile:

CPPCHECK ?= cppcheck
CPPCHECK_FLAGS += --quiet --force

FLAWFINDER ?= flawfinder
FLAWFINDER_FLAGS += --quiet --dataonly --minlevel 4

SOURCES ?= !(Tests)

.securityCheck:
  @$(ECHO) =================== cppcheck ======================
  @$(DATE)
  @$(TIME)
  @$(ECHO) ===================================================
  $(CPPCHECK) $(CPPCHECK_FLAGS) $(SOURCES)

  @$(ECHO) ================== flawfinder =====================
  @$(DATE)
  @$(TIME)
  @$(ECHO) ===================================================
  $(FLAWFINDER) $(FLAWFINDER_FLAGS) $(SOURCES)

Currently using kubuntu 16.04 LTS. uname -a gives the linux version as 4.10.0-33-generic. make --version gives GNU Make 4.1. Also using bash.

  • 3
  • @Wildcard thanks, edited formatting for readability – Aidan Grimshaw Aug 30 '17 at 17:01
  • @Kusalananda I'm using kubuntu 16.04 LTS. uname -a gives the linux version as 4.10.0-33-generic. make --version gives GNU Make 4.1. I am also using bash. – Aidan Grimshaw Aug 30 '17 at 17:09
  • @Aidan please include those version details in the Question itself; comments can be deleted or skipped over. Thank you! – Jeff Schaller Aug 30 '17 at 18:27
  • @JeffSchaller Fixed – Aidan Grimshaw Aug 30 '17 at 18:37
up vote 0 down vote accepted

I believe that the error that you see may be cppcheck running with Makefile (or some other non-C or non-C++ source code file in the current directory) as input file.

I suggest that you instead of setting SOURCES to !(Tests), set it to the actual source code files of the program that you'd like to run cppcheck on.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.