2013-01-14 15:51:39 +08:00
|
|
|
CXXFLAGS = -fPIE -g -Wall -Werror -fno-builtin -DTSAN_DEBUG=$(DEBUG) -DSANITIZER_DEBUG=$(DEBUG)
|
2012-05-10 22:04:19 +08:00
|
|
|
ifeq ($(DEBUG), 0)
|
2012-12-19 14:59:45 +08:00
|
|
|
CXXFLAGS += -O3
|
|
|
|
endif
|
|
|
|
ifeq ($(CXX), clang++)
|
|
|
|
CXXFLAGS+= -Wgnu
|
2012-05-10 22:04:19 +08:00
|
|
|
endif
|
|
|
|
|
|
|
|
# For interception. FIXME: move interception one level higher.
|
2012-05-29 20:18:18 +08:00
|
|
|
INTERCEPTION=../../interception
|
|
|
|
COMMON=../../sanitizer_common
|
2012-08-29 16:21:09 +08:00
|
|
|
INCLUDES= -I../.. -I../../../include
|
2013-03-18 15:00:36 +08:00
|
|
|
EXTRA_CXXFLAGS=-fno-exceptions -fno-rtti
|
2012-05-10 22:04:19 +08:00
|
|
|
NO_SYSROOT=--sysroot=.
|
|
|
|
CXXFLAGS+=$(EXTRA_CXXFLAGS)
|
2012-05-23 00:46:05 +08:00
|
|
|
CXXFLAGS+=$(CFLAGS)
|
2012-05-10 22:04:19 +08:00
|
|
|
ifeq ($(DEBUG), 0)
|
|
|
|
CXXFLAGS+=-fomit-frame-pointer
|
2012-05-11 22:42:24 +08:00
|
|
|
ifeq ($(CXX), g++)
|
|
|
|
CXXFLAGS+=-Wframe-larger-than=512
|
|
|
|
endif # CXX=g++
|
|
|
|
endif # DEBUG=0
|
|
|
|
|
2012-05-10 22:04:19 +08:00
|
|
|
ifeq ($(CXX), clang++)
|
|
|
|
# Global constructors are banned.
|
|
|
|
CXXFLAGS+=-Wglobal-constructors
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
2012-05-11 22:42:24 +08:00
|
|
|
|
2012-05-10 22:04:19 +08:00
|
|
|
all: libtsan.a
|
|
|
|
|
2012-05-29 20:18:18 +08:00
|
|
|
LIBTSAN_HEADERS=$(wildcard *.h) \
|
|
|
|
$(wildcard $(INTERCEPTION)/*.h) \
|
|
|
|
$(wildcard $(COMMON)/*.h)
|
|
|
|
LIBTSAN_SRC=$(wildcard *.cc)
|
|
|
|
LIBTSAN_ASM_SRC=$(wildcard *.S)
|
|
|
|
INTERCEPTION_SRC=$(wildcard $(INTERCEPTION)/*.cc)
|
|
|
|
COMMON_SRC=$(wildcard $(COMMON)/*.cc)
|
2012-05-10 22:04:19 +08:00
|
|
|
|
2012-05-29 20:18:18 +08:00
|
|
|
LIBTSAN_OBJ=$(patsubst %.cc,%.o,$(LIBTSAN_SRC)) \
|
|
|
|
$(patsubst %.S,%.o,$(LIBTSAN_ASM_SRC)) \
|
|
|
|
$(patsubst $(INTERCEPTION)/%.cc,%.o,$(INTERCEPTION_SRC)) \
|
|
|
|
$(patsubst $(COMMON)/%.cc,%.o,$(COMMON_SRC))
|
2012-05-10 22:04:19 +08:00
|
|
|
|
|
|
|
%_linux.o: %_linux.cc Makefile.old $(LIBTSAN_HEADERS)
|
|
|
|
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $<
|
|
|
|
%.o: %.cc Makefile.old $(LIBTSAN_HEADERS)
|
|
|
|
$(CXX) $(CXXFLAGS) $(INCLUDES) $(NO_SYSROOT) -c $<
|
2012-05-29 20:18:18 +08:00
|
|
|
%.o: $(INTERCEPTION)/%.cc Makefile.old $(LIBTSAN_HEADERS)
|
|
|
|
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
|
|
|
|
%.o: $(COMMON)/%.cc Makefile.old $(LIBTSAN_HEADERS)
|
|
|
|
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
|
2012-05-10 22:04:19 +08:00
|
|
|
|
|
|
|
libtsan.a: $(LIBTSAN_OBJ)
|
|
|
|
ar ru $@ $(LIBTSAN_OBJ)
|
|
|
|
|
|
|
|
libtsan_dummy.a: tsan_dummy_rtl.o
|
|
|
|
ar ru $@ $<
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -f *.o *.a
|