Home | History | Annotate | Download | only in src
      1 # Copyright 2017 The Chromium OS Authors. All rights reserved.
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 fortify-test-src := clang-fortify-tests.cpp
      6 # -U_FORTIFY_SOURCE: Clang gets unhappy being passed `-D_FORTIFY_SOURCE=2
      7 #  -D_FORTIFY_SOURCE=1` (the first of which comes from our wrapper).
      8 fortify-cxx := $(CXX) $(fortify-test-src) $(CPPFLAGS) $(CXXFLAGS) -std=c++11 \
      9 	-D_GNU_SOURCE -fno-exceptions -O2 -U_FORTIFY_SOURCE
     10 fortify-diag-flags := -o /dev/null -Xclang -verify -DCOMPILATION_TESTS -c
     11 fortify-runtime-flags := -Wno-user-defined-warnings -Wno-unused-result
     12 
     13 all: fortify-runtime-tests
     14 
     15 fortify-runtime-tests: clang-fortify-driver.o clang-fortify-tests-1.o \
     16                        clang-fortify-tests-2.o
     17 	$(CXX) $(LDFLAGS) -o $@ $+
     18 
     19 clang-fortify-tests-1.o: $(fortify-test-src)
     20 	$(fortify-cxx) $(fortify-runtime-flags) -c -D_FORTIFY_SOURCE=1 -o $@
     21 
     22 clang-fortify-tests-2.o: $(fortify-test-src)
     23 	$(fortify-cxx) $(fortify-runtime-flags) -c -D_FORTIFY_SOURCE=2 -o $@
     24 
     25 clean:
     26 	rm -f clang-fortify-*.o fortify-runtime-tests
     27 
     28 install:
     29 	install -m 0755 -d $(DESTDIR)/usr/local/bin
     30 	install -m 0755 toolchain-tests $(DESTDIR)/usr/local/bin
     31 	install -m 0755 fortify-runtime-tests $(DESTDIR)/usr/local/bin
     32 
     33 .PHONY: check
     34 check:
     35 	$(fortify-cxx) $(fortify-diag-flags) -D_FORTIFY_SOURCE=1
     36 	$(fortify-cxx) $(fortify-diag-flags) -D_FORTIFY_SOURCE=2
     37