1 CXXFLAGS = -std=c++11 -fPIE -g -Wall -Werror -fno-builtin -msse3 -DSANITIZER_DEBUG=$(DEBUG) 2 CLANG=clang 3 ifeq ($(DEBUG), 0) 4 CXXFLAGS += -O3 5 endif 6 7 # For interception. FIXME: move interception one level higher. 8 INTERCEPTION=../../interception 9 COMMON=../../sanitizer_common 10 INCLUDES= -I../.. -I../../../include 11 EXTRA_CXXFLAGS=-fno-exceptions -fno-rtti 12 NO_SYSROOT=--sysroot=. 13 CXXFLAGS+=$(EXTRA_CXXFLAGS) 14 CXXFLAGS+=$(CFLAGS) 15 ifeq ($(DEBUG), 0) 16 CXXFLAGS+=-fomit-frame-pointer 17 ifeq ($(CXX), g++) 18 CXXFLAGS+=-Wno-maybe-uninitialized 19 CXXFLAGS+=-Wframe-larger-than=512 20 endif # CXX=g++ 21 endif # DEBUG=0 22 23 ifeq ($(CXX), $(CLANG)++) 24 # Global constructors are banned. 25 CXXFLAGS+=-Wglobal-constructors 26 endif 27 28 29 30 all: libtsan.a 31 32 LIBTSAN_HEADERS=$(wildcard *.h) \ 33 $(wildcard $(INTERCEPTION)/*.h) \ 34 $(wildcard $(COMMON)/*.h) 35 LIBTSAN_SRC=$(wildcard *.cc) 36 LIBTSAN_ASM_SRC=$(wildcard *.S) 37 INTERCEPTION_SRC=$(wildcard $(INTERCEPTION)/*.cc) 38 COMMON_SRC=$(wildcard $(COMMON)/*.cc) 39 40 LIBTSAN_OBJ=$(patsubst %.cc,%.o,$(LIBTSAN_SRC)) \ 41 $(patsubst %.S,%.o,$(LIBTSAN_ASM_SRC)) \ 42 $(patsubst $(INTERCEPTION)/%.cc,%.o,$(INTERCEPTION_SRC)) \ 43 $(patsubst $(COMMON)/%.cc,%.o,$(COMMON_SRC)) 44 45 %_linux.o: %_linux.cc Makefile.old $(LIBTSAN_HEADERS) 46 $(CXX) $(CXXFLAGS) $(INCLUDES) -c $< 47 %.o: %.cc Makefile.old $(LIBTSAN_HEADERS) 48 $(CXX) $(CXXFLAGS) $(INCLUDES) $(NO_SYSROOT) -c $< 49 %.o: $(INTERCEPTION)/%.cc Makefile.old $(LIBTSAN_HEADERS) 50 $(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@ 51 %.o: $(COMMON)/%.cc Makefile.old $(LIBTSAN_HEADERS) 52 $(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@ 53 %.o: %.S 54 $(CXX) $(INCLUDES) -o $@ -c $< 55 56 libtsan.a: $(LIBTSAN_OBJ) 57 ar ru $@ $(LIBTSAN_OBJ) 58 59 libtsan_dummy.a: tsan_dummy_rtl.o 60 ar ru $@ $< 61 62 clean: 63 rm -f *.o *.a 64