2016-11-22 4 views
0

Ich habe folgendes Makefile:Befehl ausführen eins nach dem anderen

CC := clang++ 
CFLAGS := -std=c++1z 
BINARY := -g -Wall -Wextra -Wformat -Werror -pedantic 
OPTIMIZE := -Ofast -march=native -ffast-math 
CPPCOREGUIDELINES := clang-tidy 

SRC := $(wildcard *.cpp) 
BIN := $(patsubst %.cpp,bin/%,$(SRC)) 

all: clean cpp 

clean: 
    mkdir -p ./bin 
    rm -f bin/* 

cpp: $(BIN) 
$(BIN): bin/%: %.cpp 
    $(CC) $(CFLAGS) $(BINARY) $(OPTIMIZE) $^ -o [email protected] 

checks: $(SRC) 
    $(CPPCOREGUIDELINES) $^ -- $(CFLAGS) $(BINARY) $(OPTIMIZE) 

Welche Ausführung checks wie folgt aus: wie diese

$ make checks 
clang-tidy 007-pointer.cpp 008-arrays-introduction-smarter.cpp -- -std=c++1z -g -Wall -Wextra -Wformat -Werror -pedantic -Ofast -march=native -ffast-math 
81 warnings generated. 
393 warnings generated. 
C:\www\cpp\hackerrank\007-pointer.cpp:16:3: warning: do not call c-style vararg functions [cppcoreguidelines-pro-type-vararg] 
    scanf("%d %d", &a, &b); 
^
C:\www\cpp\hackerrank\007-pointer.cpp:18:3: warning: do not call c-style vararg functions [cppcoreguidelines-pro-type-vararg] 
    printf("%d\n%d", a, b); 
^
C:\www\cpp\hackerrank\008-arrays-introduction-smarter.cpp:19:12: warning: do not use pointer arithmetic [cppcoreguidelines-pro-bounds-pointer-arithmetic] 
    cin >> t[i]; 
     ^
C:\www\cpp\hackerrank\008-arrays-introduction-smarter.cpp:22:13: warning: do not use pointer arithmetic [cppcoreguidelines-pro-bounds-pointer-arithmetic] 
    cout << t[i] << " "; 
      ^
... 

I checks nacheinander nach jeder Datei ausgeführt werden soll:

$ make checks 
clang-tidy 007-pointer.cpp -- -std=c++1z -g -Wall -Wextra -Wformat -Werror -pedantic -Ofast -march=native -ffast-math 
81 warnings generated. 
C:\www\cpp\hackerrank\007-pointer.cpp:16:3: warning: do not call c-style vararg functions [cppcoreguidelines-pro-type-vararg] 
    scanf("%d %d", &a, &b); 
^
C:\www\cpp\hackerrank\007-pointer.cpp:18:3: warning: do not call c-style vararg functions [cppcoreguidelines-pro-type-vararg] 
    printf("%d\n%d", a, b); 
^
clang-tidy 008-arrays-introduction-smarter.cpp -- -std=c++1z -g -Wall -Wextra -Wformat -Werror -pedantic -Ofast -march=native -ffast-math 
312 warnings generated. 
C:\www\cpp\hackerrank\008-arrays-introduction-smarter.cpp:19:12: warning: do not use pointer arithmetic [cppcoreguidelines-pro-bounds-pointer-arithmetic] 
    cin >> t[i]; 
     ^
C:\www\cpp\hackerrank\008-arrays-introduction-smarter.cpp:22:13: warning: do not use pointer arithmetic [cppcoreguidelines-pro-bounds-pointer-arithmetic] 
    cout << t[i] << " "; 
      ^
... 

Wie kann ich das tun?

Antwort

1

Sie sie eins nach dem anderen dann:

checks: $(patsubst %.cpp,%.check,${SRC}) 
%.check : %.cpp 
    $(CPPCOREGUIDELINES) $< -- $(CFLAGS) $(BINARY) $(OPTIMIZE) 
.PHONY: %.check checks 
+0

Danke! Funktioniert einwandfrei. – Lanti

+1

@Lanti Es ist auch parallel mit '-j'. –

Verwandte Themen