blob: bf1a77210b5e655ff4e4c6aefde8188759f6e06b [file] [log] [blame]
Daniel Dunbare6c1daa2010-06-08 20:34:181##===- Makefile --------------------------------------------*- 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# If CLANG_LEVEL is not set, then we are the top-level Makefile. Otherwise, we
11# are being included from a subdirectory makefile.
12
13ifndef CLANG_LEVEL
14
15IS_TOP_LEVEL := 1
16CLANG_LEVEL := .
Peter Collingbournebee583f2011-10-06 13:03:0817DIRS := utils/TableGen include lib tools runtime docs unittests
Chris Lattner22eb9722006-06-18 05:43:1218
Daniel Dunbar9b30eb72009-11-15 00:22:3319PARALLEL_DIRS :=
20
21ifeq ($(BUILD_EXAMPLES),1)
22 PARALLEL_DIRS += examples
23endif
Daniel Dunbare6c1daa2010-06-08 20:34:1824endif
Daniel Dunbar9b30eb72009-11-15 00:22:3325
Chris Lattner40ad0a22010-06-19 06:35:2526ifeq ($(MAKECMDGOALS),libs-only)
27 DIRS := $(filter-out tools docs, $(DIRS))
28 OPTIONAL_DIRS :=
29endif
30
Daniel Dunbare6c1daa2010-06-08 20:34:1831###
32# Common Makefile code, shared by all Clang Makefiles.
33
34# Set LLVM source root level.
35LEVEL := $(CLANG_LEVEL)/../..
36
37# Include LLVM common makefile.
Chris Lattner22eb9722006-06-18 05:43:1238include $(LEVEL)/Makefile.common
Chris Lattner09d58042006-11-21 05:01:5639
NAKAMURA Takumid477fe52010-11-14 03:29:2740ifneq ($(ENABLE_DOCS),1)
41 DIRS := $(filter-out docs, $(DIRS))
42endif
43
Daniel Dunbaree6b6922010-06-08 20:44:4344# Set common Clang build flags.
45CPP.Flags += -I$(PROJ_SRC_DIR)/$(CLANG_LEVEL)/include -I$(PROJ_OBJ_DIR)/$(CLANG_LEVEL)/include
46ifdef CLANG_VENDOR
47CPP.Flags += -DCLANG_VENDOR='"$(CLANG_VENDOR) "'
48endif
Daniel Dunbarb1798f72011-03-31 00:32:5049ifdef CLANG_REPOSITORY_STRING
50CPP.Flags += -DCLANG_REPOSITORY_STRING='"$(CLANG_REPOSITORY_STRING)"'
51endif
Daniel Dunbaree6b6922010-06-08 20:44:4352
Daniel Dunbar40fee632010-06-08 21:55:0253# Disable -fstrict-aliasing. Darwin disables it by default (and LLVM doesn't
Eric Christopher7d5f2ff2011-01-07 22:44:4954# work with it enabled with GCC), Clang/llvm-gcc don't support it yet, and newer
Daniel Dunbar40fee632010-06-08 21:55:0255# GCC's have false positive warnings with it on Linux (which prove a pain to
56# fix). For example:
57# http://gcc.gnu.org/PR41874
58# http://gcc.gnu.org/PR41838
59#
60# We can revisit this when LLVM/Clang support it.
61CXX.Flags += -fno-strict-aliasing
62
Peter Collingbourned937a9942011-10-06 01:52:1063# Set up Clang's tblgen.
64ifndef CLANG_TBLGEN
65 ifeq ($(LLVM_CROSS_COMPILING),1)
Peter Collingbournebee583f2011-10-06 13:03:0866 CLANG_TBLGEN := $(BuildLLVMToolDir)/clang-tblgen$(BUILD_EXEEXT)
Peter Collingbourned937a9942011-10-06 01:52:1067 else
Peter Collingbournebee583f2011-10-06 13:03:0868 CLANG_TBLGEN := $(LLVMToolDir)/clang-tblgen$(EXEEXT)
Peter Collingbourned937a9942011-10-06 01:52:1069 endif
70endif
71ClangTableGen = $(CLANG_TBLGEN) $(TableGen.Flags)
72
Daniel Dunbare6c1daa2010-06-08 20:34:1873###
74# Clang Top Level specific stuff.
75
76ifeq ($(IS_TOP_LEVEL),1)
77
Mike Stumpc9268d82009-01-20 21:10:4178ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
Daniel Dunbar01ba2a72009-12-21 23:28:0679$(RecursiveTargets)::
Jeffrey Yasskinc7da9932011-02-03 04:51:5280 $(Verb) for dir in test unittests; do \
Douglas Gregorcb56faf2011-09-27 21:28:1081 if [ -f $(PROJ_SRC_DIR)/$${dir}/Makefile ] && [ ! -f $${dir}/Makefile ]; then \
Jeffrey Yasskinc7da9932011-02-03 04:51:5282 $(MKDIR) $${dir}; \
83 $(CP) $(PROJ_SRC_DIR)/$${dir}/Makefile $${dir}/Makefile; \
84 fi \
85 done
Mike Stumpc9268d82009-01-20 21:10:4186endif
87
Chris Lattner09d58042006-11-21 05:01:5688test::
Kovarththanan Rajaratnam8fc5a802010-03-18 13:56:2089 @ $(MAKE) -C test
Gabor Greif2d2b401c2008-03-18 06:14:1690
91report::
Chris Lattner56a7bf52008-04-06 22:32:0192 @ $(MAKE) -C test report
Chris Lattner79ff0d42007-01-15 02:06:4793
94clean::
Chris Lattner56a7bf52008-04-06 22:32:0195 @ $(MAKE) -C test clean
Daniel Dunbarc3275c52010-06-25 17:33:4696
Chris Lattner40ad0a22010-06-19 06:35:2597libs-only: all
Gabor Greiff5eb2862008-03-20 14:28:2298
Mike Stump3f6c6312009-02-12 02:25:4799tags::
Kovarththanan Rajaratnam8fc5a802010-03-18 13:56:20100 $(Verb) etags `find . -type f -name '*.h' -or -name '*.cpp' | \
101 grep -v /lib/Headers | grep -v /test/`
Mike Stump3f6c6312009-02-12 02:25:47102
Daniel Dunbar0f62e982009-03-18 05:59:14103cscope.files:
Daniel Dunbare5a7ecc2009-03-24 03:00:12104 find tools lib include -name '*.cpp' \
Daniel Dunbar0f62e982009-03-18 05:59:14105 -or -name '*.def' \
106 -or -name '*.td' \
107 -or -name '*.h' > cscope.files
108
109.PHONY: test report clean cscope.files
Daniel Dunbare6c1daa2010-06-08 20:34:18110
111endif