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