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