1 SVN_ROOT=.. 2 include ../common.mk 3 4 ifeq ($(OS), darwin) 5 DEFINES=-DOS_$(OS) -DARCH_$(ARCH) -DOS_$(DARWIN_VERSION) 6 else 7 DEFINES=-DOS_$(OS) -DARCH_$(ARCH) 8 endif 9 10 CFLAGS+=$(OPTFLAGS) $(ARCHFLAGS) $(OS_CFLAGS) $(DEFINES) $(EXTRA_CFLAGS) 11 CXXFLAGS+=$(OPTFLAGS) $(ARCHFLAGS) $(OS_CXXFLAGS) $(DEFINES) $(EXTRA_CXXFLAGS) 12 OPT_CXXFLAGS=$(CXXFLAGS) -O2 -g $(ARCHFLAGS) $(OS_CXXFLAGS) $(DEFINES) $(EXTRA_CXXFLAGS) -foptimize-sibling-calls 13 ifeq ($(OS), darwin) 14 LDFLAGS=$(LDOPT) $(ARCHFLAGS) $(STATICFLAGS) -framework Foundation 15 else 16 LDFLAGS=$(LDOPT) $(ARCHFLAGS) $(STATICFLAGS) 17 endif 18 19 # OS = linux, darwin, windows 20 # ARCH= x86, amd64 21 # OX = O0, O1, ... 22 # S= <empty>, -static 23 BUILD=${OS}-${ARCH}-${OX}${S}${EXTRA_BUILD_SUFFIX} 24 BIN=bin/ 25 26 ifeq ($(OS), linux) 27 OS_CXXFLAGS=-Wall -Werror -Wno-sign-compare -Wshadow -Wno-unused-function -std=c++0x 28 OS_CFLAGS=-Wall -Werror -Wno-sign-compare -Wshadow -Wno-unused-function -std=c89 29 LIBS=-lpthread -lrt 30 else ifeq ($(OS), darwin) 31 OS_CXXFLAGS=-Wall -Werror -Wno-sign-compare -Wshadow -Wno-unused-function 32 OS_CFLAGS=-Wall -Werror -Wno-sign-compare -Wshadow -Wno-unused-function -std=c89 33 LIBS=-lpthread 34 else ifeq ($(OS), windows) 35 OS_CXXFLAGS=/EHs- /EHa- /wd4530 /D_CRT_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /nologo /Gy /D "WIN32" 36 OS_CFLAGS=/EHs- /EHa- /wd4530 /D_CRT_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /nologo /Gy /D "WIN32" 37 else 38 OS=UNKNOWN_OS 39 endif 40 41 OUTPUT_TESTS_LIST=$(patsubst output_tests/%.cc,%,$(wildcard output_tests/*.cc)) 42 OUTPUT_TESTS_OBJS=$(patsubst %,$(BIN)output_tests/%-$(BUILD)$(EXE),$(OUTPUT_TESTS_LIST)) 43 44 all: $(BIN)racecheck_unittest-$(BUILD)$(EXE) $(BIN)demo_tests-$(BUILD)$(EXE) \ 45 $(BIN)bigtest-$(BUILD)$(EXE) output_tests \ 46 $(BIN)memory_unittest-$(BUILD)$(EXE) 47 ifeq ($(OS), linux) 48 all: $(BIN)deadlock_unittest-$(BUILD)$(EXE) 49 endif 50 51 output_tests: bin/output_tests $(OUTPUT_TESTS_OBJS) 52 53 run_output_tests: output_tests 54 BUILD=$(BUILD) BIN=$(BIN) ./run_output_tests.sh $(OUTPUT_TESTS_LIST) 55 56 w: 57 $(MAKE) all OS=windows ARCH=x86 58 m: m32 m64 59 m32: 60 $(MAKE) all OS=darwin ARCH=x86 61 m64: 62 $(MAKE) all OS=darwin ARCH=amd64 63 l: l32 l64 64 l32: 65 $(MAKE) all OS=linux ARCH=x86 66 l64: 67 $(MAKE) all OS=linux ARCH=amd64 68 69 bin: 70 mkdir -p bin 71 bin/output_tests: 72 mkdir -p bin/output_tests 73 74 DYNAMIC_ANNOTATIONS_DIR=../dynamic_annotations 75 DYNAMIC_ANNOTATIONS_H=${DYNAMIC_ANNOTATIONS_DIR}/dynamic_annotations.h 76 DYNAMIC_ANNOTATIONS_C=${DYNAMIC_ANNOTATIONS_DIR}/dynamic_annotations.c 77 ifndef OMIT_DYNAMIC_ANNOTATIONS_IMPL 78 DYNAMIC_ANNOTATIONS_O=$(BIN)dynamic_annotations-$(BUILD).$(OBJ) 79 else 80 DYNAMIC_ANNOTATIONS_O= 81 endif 82 DYNAMIC_ANNOTATIONS=${DYNAMIC_ANNOTATIONS_C} ${DYNAMIC_ANNOTATIONS_H} 83 84 TEST_UTILS_O=$(BIN)test_utils-$(BUILD).$(OBJ) 85 86 $(BIN)racecheck_unittest-$(BUILD)$(EXE): $(BIN)racecheck_unittest-$(BUILD).$(OBJ) \ 87 $(BIN)old_test_suite-$(BUILD).$(OBJ) \ 88 $(BIN)opt_tests-$(BUILD).$(OBJ) \ 89 $(BIN)atomicity_tests-$(BUILD).$(OBJ) \ 90 $(TEST_UTILS_O) $(GTEST_LIB) ${DYNAMIC_ANNOTATIONS_O} | bin 91 ${LD} ${LDFLAGS} $^ $(LIBS) $(LINKO)$@ 92 93 ifeq ($(OS), windows) 94 $(BIN)racecheck_unittest-$(BUILD)$(EXE): $(BIN)windows_tests-$(BUILD).$(OBJ) 95 else 96 $(BIN)racecheck_unittest-$(BUILD)$(EXE): $(BIN)posix_tests-$(BUILD).$(OBJ) 97 endif 98 99 ifeq ($(OS), linux) 100 ifndef OMIT_CPP0X 101 $(BIN)racecheck_unittest-$(BUILD)$(EXE): $(BIN)libstdc++_tests-$(BUILD).$(OBJ) 102 endif 103 endif 104 105 ifeq ($(OS), darwin) 106 $(BIN)racecheck_unittest-$(BUILD)$(EXE): $(BIN)mac_tests-$(BUILD).$(OBJ) 107 endif 108 109 $(BIN)deadlock_unittest-$(BUILD)$(EXE): $(BIN)deadlock_unittest-$(BUILD).$(OBJ) $(BIN)old_test_suite-$(BUILD).$(OBJ) \ 110 $(TEST_UTILS_O) $(GTEST_LIB) ${DYNAMIC_ANNOTATIONS_O} | bin 111 ${LD} ${LDFLAGS} $^ $(LIBS) $(LINKO)$@ 112 113 $(BIN)demo_tests-$(BUILD)$(EXE): $(BIN)demo_tests-$(BUILD).$(OBJ) \ 114 $(TEST_UTILS_O) $(GTEST_LIB) ${DYNAMIC_ANNOTATIONS_O} | bin 115 ${LD} $(LDFLAGS) $^ $(LIBS) $(LINKO)$@ 116 117 $(BIN)output_tests/%-$(BUILD)$(EXE): $(BIN)output_tests/%-$(BUILD).$(OBJ) \ 118 ${TEST_UTILS_O} ${DYNAMIC_ANNOTATIONS_O} | bin 119 ${LD} $(LDFLAGS) $^ $(LIBS) $(LINKO)$@ 120 121 $(BIN)bigtest-$(BUILD)$(EXE): $(BIN)bigtest-$(BUILD).$(OBJ) ${DYNAMIC_ANNOTATIONS_O} | bin 122 ${LD} $(LDFLAGS) $^ $(LIBS) $(LINKO)$@ 123 124 $(BIN)memory_unittest-$(BUILD)$(EXE): $(BIN)memory_unittest-$(BUILD).$(OBJ) $(BIN)old_test_suite-$(BUILD).$(OBJ) \ 125 $(TEST_UTILS_O) $(GTEST_LIB) ${DYNAMIC_ANNOTATIONS_O} | bin 126 ${LD} $(LDFLAGS) $^ $(LIBS) $(LINKO)$@ 127 128 $(BIN)%-$(BUILD).$(OBJ): %.cc ${DYNAMIC_ANNOTATIONS} thread_wrappers.h \ 129 thread_wrappers_win.h thread_wrappers_pthread.h old_test_suite.h \ 130 test_utils.h gtest_fixture_injection.h | bin 131 ${CXX} ${CXXFLAGS} \ 132 -I${DYNAMIC_ANNOTATIONS_DIR} -I${GTEST_ROOT}/include -I. \ 133 -DDYNAMIC_ANNOTATIONS_ENABLED=1 -c $< $(O)$@ 134 135 $(BIN)opt_tests-$(BUILD).$(OBJ): opt_tests.cc ${DYNAMIC_ANNOTATIONS} thread_wrappers.h thread_wrappers_win.h thread_wrappers_pthread.h old_test_suite.h test_utils.h | bin 136 ${CXX} ${OPT_CXXFLAGS} \ 137 -I${DYNAMIC_ANNOTATIONS_DIR} -I${GTEST_ROOT}/include -I. \ 138 -DDYNAMIC_ANNOTATIONS_ENABLED=1 -c $< $(O)$@ 139 140 $(BIN)%-$(BUILD).$(OBJ): %.mm ${DYNAMIC_ANNOTATIONS} thread_wrappers.h thread_wrappers_win.h thread_wrappers_pthread.h old_test_suite.h test_utils.h | bin 141 ${CXX} ${CXXFLAGS} \ 142 -I${DYNAMIC_ANNOTATIONS_DIR} -I${GTEST_ROOT}/include -I. \ 143 -DDYNAMIC_ANNOTATIONS_ENABLED=1 -c $< $(O)$@ 144 145 146 ${DYNAMIC_ANNOTATIONS_O}: ${DYNAMIC_ANNOTATIONS_C} 147 ${CC} ${CFLAGS} $< \ 148 -I${DYNAMIC_ANNOTATIONS_DIR} -DDYNAMIC_ANNOTATIONS_ENABLED=1 \ 149 -c $(O)$@ 150 151 clean: GTEST_CLEAN 152 rm -rf bin racecheck_unittest demo_tests bigtest *.o *.O1 *.O2 *.obj *.dSYM *.exe *.pdb *.ilk *.idb *.manifest 153