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