blob: cb2566a0a17d2fa6b30b90d89d79bd9f3915c510 [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
Chris Lattnerc56bc312010-06-19 06:35:25 +000026ifeq ($(MAKECMDGOALS),libs-only)
27 DIRS := $(filter-out tools docs, $(DIRS))
28 OPTIONAL_DIRS :=
29endif
Bill Wendlingb7bafa92012-10-02 06:19:15 +000030ifeq ($(BUILD_CLANG_ONLY),YES)
Bill Wendling2bf89802012-10-03 08:39:19 +000031 DIRS := $(filter-out docs unittests, $(DIRS))
Bill Wendling615c3dd2012-09-30 11:23:30 +000032 OPTIONAL_DIRS :=
33endif
Chris Lattnerc56bc312010-06-19 06:35:25 +000034
Daniel Dunbarafed0992010-06-08 20:34:18 +000035###
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.
Reid Spencer5f016e22007-07-11 17:01:13 +000042include $(LEVEL)/Makefile.common
43
NAKAMURA Takumi6c7b42f2010-11-14 03:29:27 +000044ifneq ($(ENABLE_DOCS),1)
45 DIRS := $(filter-out docs, $(DIRS))
46endif
47
Daniel Dunbarc4dec1c2010-06-08 20:44:43 +000048# 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
Daniel Dunbar9a4a9c22011-03-31 00:32:50 +000053ifdef CLANG_REPOSITORY_STRING
54CPP.Flags += -DCLANG_REPOSITORY_STRING='"$(CLANG_REPOSITORY_STRING)"'
55endif
Daniel Dunbarc4dec1c2010-06-08 20:44:43 +000056
Daniel Dunbar61f69d92010-06-08 21:55:02 +000057# Disable -fstrict-aliasing. Darwin disables it by default (and LLVM doesn't
Eric Christopher0574c782011-01-07 22:44:49 +000058# work with it enabled with GCC), Clang/llvm-gcc don't support it yet, and newer
Daniel Dunbar61f69d92010-06-08 21:55:02 +000059# 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
Peter Collingbourne6ee5b932011-10-06 01:52:10 +000067# Set up Clang's tblgen.
68ifndef CLANG_TBLGEN
69 ifeq ($(LLVM_CROSS_COMPILING),1)
Peter Collingbourne51d77772011-10-06 13:03:08 +000070 CLANG_TBLGEN := $(BuildLLVMToolDir)/clang-tblgen$(BUILD_EXEEXT)
Peter Collingbourne6ee5b932011-10-06 01:52:10 +000071 else
Peter Collingbourne51d77772011-10-06 13:03:08 +000072 CLANG_TBLGEN := $(LLVMToolDir)/clang-tblgen$(EXEEXT)
Peter Collingbourne6ee5b932011-10-06 01:52:10 +000073 endif
74endif
75ClangTableGen = $(CLANG_TBLGEN) $(TableGen.Flags)
76
Daniel Dunbarafed0992010-06-08 20:34:18 +000077###
78# Clang Top Level specific stuff.
79
80ifeq ($(IS_TOP_LEVEL),1)
81
Mike Stumpadc981a2009-01-20 21:10:41 +000082ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT))
Daniel Dunbara9829ae2009-12-21 23:28:06 +000083$(RecursiveTargets)::
Jeffrey Yasskin7a178892011-02-03 04:51:52 +000084 $(Verb) for dir in test unittests; do \
Douglas Gregor1456fec2011-09-27 21:28:10 +000085 if [ -f $(PROJ_SRC_DIR)/$${dir}/Makefile ] && [ ! -f $${dir}/Makefile ]; then \
Jeffrey Yasskin7a178892011-02-03 04:51:52 +000086 $(MKDIR) $${dir}; \
87 $(CP) $(PROJ_SRC_DIR)/$${dir}/Makefile $${dir}/Makefile; \
88 fi \
89 done
Mike Stumpadc981a2009-01-20 21:10:41 +000090endif
91
Reid Spencer5f016e22007-07-11 17:01:13 +000092test::
Kovarththanan Rajaratnam61736b42010-03-18 13:56:20 +000093 @ $(MAKE) -C test
Gabor Greifab72ffe2008-03-18 06:14:16 +000094
95report::
Chris Lattner9d294b92008-04-06 22:32:01 +000096 @ $(MAKE) -C test report
Reid Spencer5f016e22007-07-11 17:01:13 +000097
98clean::
Chris Lattner9d294b92008-04-06 22:32:01 +000099 @ $(MAKE) -C test clean
Daniel Dunbara5107672010-06-25 17:33:46 +0000100
Chris Lattnerc56bc312010-06-19 06:35:25 +0000101libs-only: all
Gabor Greif5267d7c2008-03-20 14:28:22 +0000102
Mike Stump8ba82b32009-02-12 02:25:47 +0000103tags::
Kovarththanan Rajaratnam61736b42010-03-18 13:56:20 +0000104 $(Verb) etags `find . -type f -name '*.h' -or -name '*.cpp' | \
105 grep -v /lib/Headers | grep -v /test/`
Mike Stump8ba82b32009-02-12 02:25:47 +0000106
Daniel Dunbar432eeec2009-03-18 05:59:14 +0000107cscope.files:
Daniel Dunbar073777f2009-03-24 03:00:12 +0000108 find tools lib include -name '*.cpp' \
Daniel Dunbar432eeec2009-03-18 05:59:14 +0000109 -or -name '*.def' \
110 -or -name '*.td' \
111 -or -name '*.h' > cscope.files
112
113.PHONY: test report clean cscope.files
Daniel Dunbarafed0992010-06-08 20:34:18 +0000114
115endif