1##===- 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 := .
17DIRS := utils/TableGen include lib tools runtime docs unittests
18
19PARALLEL_DIRS :=
20
21ifeq ($(BUILD_EXAMPLES),1)
22  PARALLEL_DIRS += examples
23endif
24endif
25
26ifeq ($(BUILD_EXAMPLES),1)
27  ENABLE_CLANG_EXAMPLES := 1
28else
29  ENABLE_CLANG_EXAMPLES := 0
30endif
31
32ifeq ($(MAKECMDGOALS),libs-only)
33  DIRS := $(filter-out tools docs, $(DIRS))
34  OPTIONAL_DIRS :=
35endif
36ifeq ($(BUILD_CLANG_ONLY),YES)
37  DIRS := $(filter-out docs unittests, $(DIRS))
38  OPTIONAL_DIRS :=
39endif
40
41###
42# Common Makefile code, shared by all Clang Makefiles.
43
44# Set LLVM source root level.
45LEVEL := $(CLANG_LEVEL)/../..
46
47# Include LLVM common makefile.
48include $(LEVEL)/Makefile.common
49
50ifneq ($(ENABLE_DOCS),1)
51  DIRS := $(filter-out docs, $(DIRS))
52endif
53
54# Set common Clang build flags.
55CPP.Flags += -I$(PROJ_SRC_DIR)/$(CLANG_LEVEL)/include -I$(PROJ_OBJ_DIR)/$(CLANG_LEVEL)/include
56ifdef CLANG_VENDOR
57CPP.Flags += -DCLANG_VENDOR='"$(CLANG_VENDOR) "'
58endif
59ifdef CLANG_REPOSITORY_STRING
60CPP.Flags += -DCLANG_REPOSITORY_STRING='"$(CLANG_REPOSITORY_STRING)"'
61endif
62
63# Disable -fstrict-aliasing. Darwin disables it by default (and LLVM doesn't
64# work with it enabled with GCC), Clang/llvm-gcc don't support it yet, and newer
65# GCC's have false positive warnings with it on Linux (which prove a pain to
66# fix). For example:
67#   http://gcc.gnu.org/PR41874
68#   http://gcc.gnu.org/PR41838
69#
70# We can revisit this when LLVM/Clang support it.
71CXX.Flags += -fno-strict-aliasing
72
73# Set up Clang's tblgen.
74ifndef CLANG_TBLGEN
75  ifeq ($(LLVM_CROSS_COMPILING),1)
76    CLANG_TBLGEN := $(BuildLLVMToolDir)/clang-tblgen$(BUILD_EXEEXT)
77  else
78    CLANG_TBLGEN := $(LLVMToolDir)/clang-tblgen$(EXEEXT)
79  endif
80endif
81ClangTableGen = $(CLANG_TBLGEN) $(TableGen.Flags)
82
83###
84# Clang Top Level specific stuff.
85
86ifeq ($(IS_TOP_LEVEL),1)
87
88ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
89$(RecursiveTargets)::
90	$(Verb) for dir in test unittests; do \
91	  if [ -f $(PROJ_SRC_DIR)/$${dir}/Makefile ] && [ ! -f $${dir}/Makefile ]; then \
92	    $(MKDIR) $${dir}; \
93	    $(CP) $(PROJ_SRC_DIR)/$${dir}/Makefile $${dir}/Makefile; \
94	  fi \
95	done
96endif
97
98test::
99	@ $(MAKE) -C test
100
101report::
102	@ $(MAKE) -C test report
103
104clean::
105	@ $(MAKE) -C test clean
106
107libs-only: all
108
109tags::
110	$(Verb) etags `find . -type f -name '*.h' -or -name '*.cpp' | \
111	  grep -v /lib/Headers | grep -v /test/`
112
113cscope.files:
114	find tools lib include -name '*.cpp' \
115	                    -or -name '*.def' \
116	                    -or -name '*.td' \
117	                    -or -name '*.h' > cscope.files
118
119.PHONY: test report clean cscope.files
120
121endif
122