| Daniel Dunbar | afed099 | 2010-06-08 20:34:18 +0000 | [diff] [blame] | 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 := . | 
| Peter Collingbourne | 51d7777 | 2011-10-06 13:03:08 +0000 | [diff] [blame] | 17 | DIRS := utils/TableGen include lib tools runtime docs unittests | 
| Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 18 |  | 
| Daniel Dunbar | 297b083 | 2009-11-15 00:22:33 +0000 | [diff] [blame] | 19 | PARALLEL_DIRS := | 
 | 20 |  | 
 | 21 | ifeq ($(BUILD_EXAMPLES),1) | 
 | 22 |   PARALLEL_DIRS += examples | 
 | 23 | endif | 
| Daniel Dunbar | afed099 | 2010-06-08 20:34:18 +0000 | [diff] [blame] | 24 | endif | 
| Daniel Dunbar | 297b083 | 2009-11-15 00:22:33 +0000 | [diff] [blame] | 25 |  | 
| Chris Lattner | c56bc31 | 2010-06-19 06:35:25 +0000 | [diff] [blame] | 26 | ifeq ($(MAKECMDGOALS),libs-only) | 
 | 27 |   DIRS := $(filter-out tools docs, $(DIRS)) | 
 | 28 |   OPTIONAL_DIRS := | 
 | 29 | endif | 
 | 30 |  | 
| Daniel Dunbar | afed099 | 2010-06-08 20:34:18 +0000 | [diff] [blame] | 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. | 
| Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 38 | include $(LEVEL)/Makefile.common | 
 | 39 |  | 
| NAKAMURA Takumi | 6c7b42f | 2010-11-14 03:29:27 +0000 | [diff] [blame] | 40 | ifneq ($(ENABLE_DOCS),1) | 
 | 41 |   DIRS := $(filter-out docs, $(DIRS)) | 
 | 42 | endif | 
 | 43 |  | 
| Daniel Dunbar | c4dec1c | 2010-06-08 20:44:43 +0000 | [diff] [blame] | 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 | 
| Daniel Dunbar | 9a4a9c2 | 2011-03-31 00:32:50 +0000 | [diff] [blame] | 49 | ifdef CLANG_REPOSITORY_STRING | 
 | 50 | CPP.Flags += -DCLANG_REPOSITORY_STRING='"$(CLANG_REPOSITORY_STRING)"' | 
 | 51 | endif | 
| Daniel Dunbar | c4dec1c | 2010-06-08 20:44:43 +0000 | [diff] [blame] | 52 |  | 
| Daniel Dunbar | 61f69d9 | 2010-06-08 21:55:02 +0000 | [diff] [blame] | 53 | # Disable -fstrict-aliasing. Darwin disables it by default (and LLVM doesn't | 
| Eric Christopher | 0574c78 | 2011-01-07 22:44:49 +0000 | [diff] [blame] | 54 | # work with it enabled with GCC), Clang/llvm-gcc don't support it yet, and newer | 
| Daniel Dunbar | 61f69d9 | 2010-06-08 21:55:02 +0000 | [diff] [blame] | 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 |  | 
| Peter Collingbourne | 6ee5b93 | 2011-10-06 01:52:10 +0000 | [diff] [blame] | 63 | # Set up Clang's tblgen. | 
 | 64 | ifndef CLANG_TBLGEN | 
 | 65 |   ifeq ($(LLVM_CROSS_COMPILING),1) | 
| Peter Collingbourne | 51d7777 | 2011-10-06 13:03:08 +0000 | [diff] [blame] | 66 |     CLANG_TBLGEN := $(BuildLLVMToolDir)/clang-tblgen$(BUILD_EXEEXT) | 
| Peter Collingbourne | 6ee5b93 | 2011-10-06 01:52:10 +0000 | [diff] [blame] | 67 |   else | 
| Peter Collingbourne | 51d7777 | 2011-10-06 13:03:08 +0000 | [diff] [blame] | 68 |     CLANG_TBLGEN := $(LLVMToolDir)/clang-tblgen$(EXEEXT) | 
| Peter Collingbourne | 6ee5b93 | 2011-10-06 01:52:10 +0000 | [diff] [blame] | 69 |   endif | 
 | 70 | endif | 
 | 71 | ClangTableGen = $(CLANG_TBLGEN) $(TableGen.Flags) | 
 | 72 |  | 
| Daniel Dunbar | afed099 | 2010-06-08 20:34:18 +0000 | [diff] [blame] | 73 | ### | 
 | 74 | # Clang Top Level specific stuff. | 
 | 75 |  | 
 | 76 | ifeq ($(IS_TOP_LEVEL),1) | 
 | 77 |  | 
| Mike Stump | adc981a | 2009-01-20 21:10:41 +0000 | [diff] [blame] | 78 | ifneq ($(PROJ_SRC_ROOT),$(PROJ_OBJ_ROOT)) | 
| Daniel Dunbar | a9829ae | 2009-12-21 23:28:06 +0000 | [diff] [blame] | 79 | $(RecursiveTargets):: | 
| Jeffrey Yasskin | 7a17889 | 2011-02-03 04:51:52 +0000 | [diff] [blame] | 80 | 	$(Verb) for dir in test unittests; do \ | 
| Douglas Gregor | 1456fec | 2011-09-27 21:28:10 +0000 | [diff] [blame] | 81 | 	  if [ -f $(PROJ_SRC_DIR)/$${dir}/Makefile ] && [ ! -f $${dir}/Makefile ]; then \ | 
| Jeffrey Yasskin | 7a17889 | 2011-02-03 04:51:52 +0000 | [diff] [blame] | 82 | 	    $(MKDIR) $${dir}; \ | 
 | 83 | 	    $(CP) $(PROJ_SRC_DIR)/$${dir}/Makefile $${dir}/Makefile; \ | 
 | 84 | 	  fi \ | 
 | 85 | 	done | 
| Mike Stump | adc981a | 2009-01-20 21:10:41 +0000 | [diff] [blame] | 86 | endif | 
 | 87 |  | 
| Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 88 | test:: | 
| Kovarththanan Rajaratnam | 61736b4 | 2010-03-18 13:56:20 +0000 | [diff] [blame] | 89 | 	@ $(MAKE) -C test | 
| Gabor Greif | ab72ffe | 2008-03-18 06:14:16 +0000 | [diff] [blame] | 90 |  | 
 | 91 | report:: | 
| Chris Lattner | 9d294b9 | 2008-04-06 22:32:01 +0000 | [diff] [blame] | 92 | 	@ $(MAKE) -C test report | 
| Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 93 |  | 
 | 94 | clean:: | 
| Chris Lattner | 9d294b9 | 2008-04-06 22:32:01 +0000 | [diff] [blame] | 95 | 	@ $(MAKE) -C test clean | 
| Daniel Dunbar | a510767 | 2010-06-25 17:33:46 +0000 | [diff] [blame] | 96 |  | 
| Chris Lattner | c56bc31 | 2010-06-19 06:35:25 +0000 | [diff] [blame] | 97 | libs-only: all | 
| Gabor Greif | 5267d7c | 2008-03-20 14:28:22 +0000 | [diff] [blame] | 98 |  | 
| Mike Stump | 8ba82b3 | 2009-02-12 02:25:47 +0000 | [diff] [blame] | 99 | tags:: | 
| Kovarththanan Rajaratnam | 61736b4 | 2010-03-18 13:56:20 +0000 | [diff] [blame] | 100 | 	$(Verb) etags `find . -type f -name '*.h' -or -name '*.cpp' | \ | 
 | 101 | 	  grep -v /lib/Headers | grep -v /test/` | 
| Mike Stump | 8ba82b3 | 2009-02-12 02:25:47 +0000 | [diff] [blame] | 102 |  | 
| Daniel Dunbar | 432eeec | 2009-03-18 05:59:14 +0000 | [diff] [blame] | 103 | cscope.files: | 
| Daniel Dunbar | 073777f | 2009-03-24 03:00:12 +0000 | [diff] [blame] | 104 | 	find tools lib include -name '*.cpp' \ | 
| Daniel Dunbar | 432eeec | 2009-03-18 05:59:14 +0000 | [diff] [blame] | 105 | 	                    -or -name '*.def' \ | 
 | 106 | 	                    -or -name '*.td' \ | 
 | 107 | 	                    -or -name '*.h' > cscope.files | 
 | 108 |  | 
 | 109 | .PHONY: test report clean cscope.files | 
| Daniel Dunbar | afed099 | 2010-06-08 20:34:18 +0000 | [diff] [blame] | 110 |  | 
 | 111 | endif |