blob: 9dfb965d38fb0ea457a956d403b6f1e4b992fd74 [file] [log] [blame]
Misha Brukman8fb520e2009-01-01 02:24:48 +00001##===- unittests/Makefile.unittest -------------------------*- Makefile -*-===##
2#
3# The LLVM Compiler Infrastructure
4#
5# This file is distributed under the University of Illinois Open Source
6# License. See LICENSE.TXT for details.
7#
8##===----------------------------------------------------------------------===##
9#
10# This file is included by all of the unit test makefiles.
11#
12##===----------------------------------------------------------------------===##
13
14# Set up variables for building a unit test.
15ifdef TESTNAME
16
Jeffrey Yasskin98155822010-01-26 23:30:46 +000017CPP.Flags += -DGTEST_HAS_RTTI=0
18# gcc's TR1 <tuple> header depends on RTTI, so force googletest to use
19# its own tuple implementation. When we import googletest >=1.4.0, we
20# can drop this line.
21CPP.Flags += -DGTEST_HAS_TR1_TUPLE=0
Chris Lattner43b5f932010-01-24 20:43:08 +000022
Misha Brukman8fb520e2009-01-01 02:24:48 +000023include $(LEVEL)/Makefile.common
24
Misha Brukmanb0426e82009-04-01 00:35:00 +000025LLVMUnitTestExe = $(BuildMode)/$(TESTNAME)Tests$(EXEEXT)
26
Misha Brukman8fb520e2009-01-01 02:24:48 +000027CPP.Flags += -I$(LLVM_SRC_ROOT)/utils/unittest/googletest/include/
Julien Lerougecadd4b92009-10-26 20:01:35 +000028CPP.Flags += $(NO_VARIADIC_MACROS)
Benjamin Kramere2b208a2009-10-02 19:52:33 +000029TESTLIBS = -lGoogleTest -lUnitTestMain
Misha Brukman8fb520e2009-01-01 02:24:48 +000030
Jeffrey Yasskinea6c39d2010-02-23 18:10:07 +000031ifeq ($(ENABLE_SHARED), 1)
32 # Add the absolute path to the dynamic library. This is ok because
33 # we'll never install unittests.
34 LD.Flags += $(RPATH) -Wl,$(LibDir)
35endif
36ifeq ($(ENABLE_SHARED), 1)
37 # Also set {DYLD,LD}_LIBRARY_PATH because OSX ignores the rpath most
38 # of the time.
39 Run.Shared := $(SHLIBPATH_VAR)="$(LibDir)$${$(SHLIBPATH_VAR):+:}$$$(SHLIBPATH_VAR)"
40endif
41
Misha Brukman8fb520e2009-01-01 02:24:48 +000042$(LLVMUnitTestExe): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths)
43 $(Echo) Linking $(BuildMode) unit test $(TESTNAME) $(StripWarnMsg)
Nick Lewyckya15dc032009-02-26 07:44:16 +000044 $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \
Benjamin Kramere2b208a2009-10-02 19:52:33 +000045 $(TESTLIBS) $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) $(LIBS)
Misha Brukman8fb520e2009-01-01 02:24:48 +000046 $(Echo) ======= Finished Linking $(BuildMode) Unit test $(TESTNAME) \
47 $(StripWarnMsg)
48
49all:: $(LLVMUnitTestExe)
Daniel Dunbar7f068f42009-09-13 22:39:27 +000050
51unitcheck:: $(LLVMUnitTestExe)
Jeffrey Yasskinea6c39d2010-02-23 18:10:07 +000052 $(Run.Shared) $(LLVMUnitTestExe)
Misha Brukman8fb520e2009-01-01 02:24:48 +000053
54endif