blob: bbc521f4c0e5c79329fb929ef36fefbb27f1a09e [file] [log] [blame]
Daniel Dunbarafed0992010-06-08 20:34:18 +00001##===- 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 Collingbourne51d77772011-10-06 13:03:08 +000017DIRS := utils/TableGen include lib tools runtime docs unittests
Reid Spencer5f016e22007-07-11 17:01:13 +000018
Daniel Dunbar297b0832009-11-15 00:22:33 +000019PARALLEL_DIRS :=
20
21ifeq ($(BUILD_EXAMPLES),1)
22 PARALLEL_DIRS += examples
23endif
Daniel Dunbarafed0992010-06-08 20:34:18 +000024endif
Daniel Dunbar297b0832009-11-15 00:22:33 +000025
Stephen Hines651f13c2014-04-23 16:59:28 -070026ifeq ($(BUILD_EXAMPLES),1)
27 ENABLE_CLANG_EXAMPLES := 1
28else
29 ENABLE_CLANG_EXAMPLES := 0
30endif
31
Chris Lattnerc56bc312010-06-19 06:35:25 +000032ifeq ($(MAKECMDGOALS),libs-only)
33 DIRS := $(filter-out tools docs, $(DIRS))
34 OPTIONAL_DIRS :=
35endif
Bill Wendlingb7bafa92012-10-02 06:19:15 +000036ifeq ($(BUILD_CLANG_ONLY),YES)
Bill Wendling2bf89802012-10-03 08:39:19 +000037 DIRS := $(filter-out docs unittests, $(DIRS))
Bill Wendling615c3dd2012-09-30 11:23:30 +000038 OPTIONAL_DIRS :=
39endif
Chris Lattnerc56bc312010-06-19 06:35:25 +000040
Daniel Dunbarafed0992010-06-08 20:34:18 +000041###
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.
Reid Spencer5f016e22007-07-11 17:01:13 +000048include $(LEVEL)/Makefile.common
49
NAKAMURA Takumi6c7b42f2010-11-14 03:29:27 +000050ifneq ($(ENABLE_DOCS),1)
51 DIRS := $(filter-out docs, $(DIRS))
52endif
53
Daniel Dunbarc4dec1c2010-06-08 20:44:43 +000054# 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
Daniel Dunbar9a4a9c22011-03-31 00:32:50 +000059ifdef CLANG_REPOSITORY_STRING
60CPP.Flags += -DCLANG_REPOSITORY_STRING='"$(CLANG_REPOSITORY_STRING)"'
61endif
Daniel Dunbarc4dec1c2010-06-08 20:44:43 +000062
Daniel Dunbar61f69d92010-06-08 21:55:02 +000063# Disable -fstrict-aliasing. Darwin disables it by default (and LLVM doesn't
Eric Christopher0574c782011-01-07 22:44:49 +000064# work with it enabled with GCC), Clang/llvm-gcc don't support it yet, and newer
Daniel Dunbar61f69d92010-06-08 21:55:02 +000065# 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
Peter Collingbourne6ee5b932011-10-06 01:52:10 +000073# Set up Clang's tblgen.
74ifndef CLANG_TBLGEN
75 ifeq ($(LLVM_CROSS_COMPILING),1)
Peter Collingbourne51d77772011-10-06 13:03:08 +000076 CLANG_TBLGEN := $(BuildLLVMToolDir)/clang-tblgen$(BUILD_EXEEXT)
Peter Collingbourne6ee5b932011-10-06 01:52:10 +000077 else
Peter Collingbourne51d77772011-10-06 13:03:08 +000078 CLANG_TBLGEN := $(LLVMToolDir)/clang-tblgen$(EXEEXT)
Peter Collingbourne6ee5b932011-10-06 01:52:10 +000079 endif
80endif
81ClangTableGen = $(CLANG_TBLGEN) $(TableGen.Flags)
82
Daniel Dunbarafed0992010-06-08 20:34:18 +000083###
84# Clang Top Level specific stuff.
85
86ifeq ($(IS_TOP_LEVEL),1)
87
Mike Stumpadc981a2009-01-20 21:10:41 +000088ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
Daniel Dunbara9829ae2009-12-21 23:28:06 +000089$(RecursiveTargets)::
Jeffrey Yasskin7a178892011-02-03 04:51:52 +000090 $(Verb) for dir in test unittests; do \
Douglas Gregor1456fec2011-09-27 21:28:10 +000091 if [ -f $(PROJ_SRC_DIR)/$${dir}/Makefile ] && [ ! -f $${dir}/Makefile ]; then \
Jeffrey Yasskin7a178892011-02-03 04:51:52 +000092 $(MKDIR) $${dir}; \
93 $(CP) $(PROJ_SRC_DIR)/$${dir}/Makefile $${dir}/Makefile; \
94 fi \
95 done
Mike Stumpadc981a2009-01-20 21:10:41 +000096endif
97
Reid Spencer5f016e22007-07-11 17:01:13 +000098test::
Kovarththanan Rajaratnam61736b42010-03-18 13:56:20 +000099 @ $(MAKE) -C test
Gabor Greifab72ffe2008-03-18 06:14:16 +0000100
101report::
Chris Lattner9d294b92008-04-06 22:32:01 +0000102 @ $(MAKE) -C test report
Reid Spencer5f016e22007-07-11 17:01:13 +0000103
104clean::
Chris Lattner9d294b92008-04-06 22:32:01 +0000105 @ $(MAKE) -C test clean
Daniel Dunbara5107672010-06-25 17:33:46 +0000106
Chris Lattnerc56bc312010-06-19 06:35:25 +0000107libs-only: all
Gabor Greif5267d7c2008-03-20 14:28:22 +0000108
Mike Stump8ba82b32009-02-12 02:25:47 +0000109tags::
Kovarththanan Rajaratnam61736b42010-03-18 13:56:20 +0000110 $(Verb) etags `find . -type f -name '*.h' -or -name '*.cpp' | \
111 grep -v /lib/Headers | grep -v /test/`
Mike Stump8ba82b32009-02-12 02:25:47 +0000112
Daniel Dunbar432eeec2009-03-18 05:59:14 +0000113cscope.files:
Daniel Dunbar073777f2009-03-24 03:00:12 +0000114 find tools lib include -name '*.cpp' \
Daniel Dunbar432eeec2009-03-18 05:59:14 +0000115 -or -name '*.def' \
116 -or -name '*.td' \
117 -or -name '*.h' > cscope.files
118
119.PHONY: test report clean cscope.files
Daniel Dunbarafed0992010-06-08 20:34:18 +0000120
121endif