Vikram S. Adve | d60aede | 2002-07-09 12:04:21 +0000 | [diff] [blame] | 1 | #===-- Makefile.common - Common make rules for LLVM -------*- makefile -*--==== |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2 | # |
| 3 | # This file is included by all of the LLVM makefiles. This file defines common |
| 4 | # rules to do things like compile a .cpp file or generate dependancy info. |
| 5 | # These are platform dependant, so this is the file used to specify these |
| 6 | # system dependant operations. |
| 7 | # |
Vikram S. Adve | c214e71 | 2002-08-29 23:28:46 +0000 | [diff] [blame] | 8 | # The following functionality can be set by setting incoming variables. |
| 9 | # The variable $(LEVEL) *must* be set: |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 10 | # |
| 11 | # 1. LEVEL - The level of the current subdirectory from the top of the |
| 12 | # MagicStats view. This level should be expressed as a path, for |
| 13 | # example, ../.. for two levels deep. |
| 14 | # |
| 15 | # 2. DIRS - A list of subdirectories to be built. Fake targets are set up |
Chris Lattner | a8abc22 | 2002-09-18 03:22:27 +0000 | [diff] [blame] | 16 | # so that each of the targets "all", "install", and "clean" each build |
| 17 | # the subdirectories before the local target. DIRS are guaranteed to be |
| 18 | # built in order. |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 19 | # |
Chris Lattner | a8abc22 | 2002-09-18 03:22:27 +0000 | [diff] [blame] | 20 | # 3. PARALLEL_DIRS - A list of subdirectories to be built, but that may be |
| 21 | # built in any order. All DIRS are built in order before PARALLEL_DIRS are |
| 22 | # built, which are then built in any order. |
| 23 | # |
| 24 | # 4. Source - If specified, this sets the source code filenames. If this |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 25 | # is not set, it defaults to be all of the .cpp, .c, .y, and .l files |
Chris Lattner | e001059 | 2001-10-18 01:48:09 +0000 | [diff] [blame] | 26 | # in the current directory. Also, if you want to build files in addition |
| 27 | # to the local files, you can use the ExtraSource variable |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 28 | # |
Chris Lattner | 694c5df | 2003-05-15 21:28:55 +0000 | [diff] [blame] | 29 | # 5. SourceDir - If specified, this specifies a directory that the source files |
| 30 | # are in, if they are not in the current directory. This should include a |
| 31 | # trailing / character. |
| 32 | # |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 33 | # 6. LLVM_SRC_ROOT - If specified, points to the top of the LLVM source tree. |
Dinakar Dhurjati | 584dd18 | 2003-05-29 21:49:00 +0000 | [diff] [blame] | 34 | # |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 35 | # 7. LLVM_OBJ_ROOT - If specified, points to the top directory where LLVM |
| 36 | # object files are placed. |
| 37 | # |
| 38 | # 8. BUILD_SRC_DIR - The directory which contains the current set of Makefiles |
| 39 | # and usually the source code too (unless SourceDir is set). |
| 40 | # |
| 41 | # 9. BUILD_SRC_ROOT - The root directory of the source code being compiled. |
| 42 | # |
| 43 | # 10. BUILD_OBJ_DIR - The directory where object code should be placed. |
| 44 | # |
| 45 | # 11. BUILD_OBJ_ROOT - The root directory for where object code should be |
| 46 | # placed. |
| 47 | # |
| 48 | # For building, |
| 49 | # LLVM, LLVM_SRC_ROOT = BUILD_SRC_ROOT, and |
| 50 | # LLVM_OBJ_ROOT = BUILD_OBJ_ROOT. |
Vikram S. Adve | d60aede | 2002-07-09 12:04:21 +0000 | [diff] [blame] | 51 | #===-----------------------------------------------------------------------==== |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 52 | |
John Criswell | 2a6530f | 2003-06-27 16:58:44 +0000 | [diff] [blame] | 53 | # |
Vikram S. Adve | c214e71 | 2002-08-29 23:28:46 +0000 | [diff] [blame] | 54 | # Configuration file to set paths specific to local installation of LLVM |
| 55 | # |
| 56 | include $(LEVEL)/Makefile.config |
| 57 | |
John Criswell | 8bff509 | 2003-06-11 13:55:44 +0000 | [diff] [blame] | 58 | ########################################################################### |
| 59 | # Directory Configuration |
| 60 | # This section of the Makefile determines what is where. To be |
| 61 | # specific, there are several locations that need to be defined: |
| 62 | # |
| 63 | # o LLVM_SRC_ROOT : The root directory of the LLVM source code. |
| 64 | # o LLVM_OBJ_ROOT : The root directory containing the built LLVM code. |
| 65 | # |
| 66 | # o BUILD_SRC_DIR : The directory containing the code to build. |
| 67 | # o BUILD_SRC_ROOT : The root directory of the code to build. |
| 68 | # |
| 69 | # o BUILD_OBJ_DIR : The directory in which compiled code will be placed. |
| 70 | # o BUILD_OBJ_ROOT : The root directory in which compiled code is placed. |
| 71 | # |
| 72 | ########################################################################### |
| 73 | |
| 74 | # |
| 75 | # Set the source build directory. That is almost always the current directory. |
| 76 | # |
| 77 | ifndef BUILD_SRC_DIR |
| 78 | BUILD_SRC_DIR = $(shell pwd) |
| 79 | endif |
| 80 | |
| 81 | # |
| 82 | # Set the source root directory. |
| 83 | # |
| 84 | ifndef BUILD_SRC_ROOT |
John Criswell | 890d5bd | 2003-06-16 19:14:31 +0000 | [diff] [blame] | 85 | BUILD_SRC_ROOT = $(shell cd $(BUILD_SRC_DIR)/$(LEVEL); pwd) |
John Criswell | 8bff509 | 2003-06-11 13:55:44 +0000 | [diff] [blame] | 86 | endif |
| 87 | |
| 88 | # |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 89 | # Determine the path of the source tree relative from $HOME (the mythical |
| 90 | # home directory). |
| 91 | # |
| 92 | HOME_OBJ_ROOT := $(OBJ_ROOT)/$(patsubst $(HOME)%,%,$(BUILD_SRC_ROOT)) |
| 93 | |
| 94 | # |
John Criswell | 8bff509 | 2003-06-11 13:55:44 +0000 | [diff] [blame] | 95 | # Set the object build directory. Its location depends upon the source path |
| 96 | # and where object files should go. |
| 97 | # |
| 98 | ifndef BUILD_OBJ_DIR |
| 99 | ifeq ($(OBJ_ROOT),.) |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 100 | BUILD_OBJ_DIR = $(BUILD_SRC_DIR) |
John Criswell | 8bff509 | 2003-06-11 13:55:44 +0000 | [diff] [blame] | 101 | else |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 102 | BUILD_OBJ_DIR := $(HOME_OBJ_ROOT)$(patsubst $(BUILD_SRC_ROOT)%,%,$(BUILD_SRC_DIR)) |
John Criswell | 8bff509 | 2003-06-11 13:55:44 +0000 | [diff] [blame] | 103 | endif |
| 104 | endif |
| 105 | |
| 106 | # |
| 107 | # Set the root of the object directory. |
| 108 | # |
| 109 | ifndef BUILD_OBJ_ROOT |
| 110 | ifeq ($(OBJ_ROOT),.) |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 111 | BUILD_OBJ_ROOT = $(BUILD_SRC_ROOT) |
John Criswell | 8bff509 | 2003-06-11 13:55:44 +0000 | [diff] [blame] | 112 | else |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 113 | BUILD_OBJ_ROOT := $(HOME_OBJ_ROOT) |
John Criswell | 8bff509 | 2003-06-11 13:55:44 +0000 | [diff] [blame] | 114 | endif |
| 115 | endif |
| 116 | |
| 117 | # |
| 118 | # Set the LLVM source directory. |
| 119 | # It is typically the root directory of what we're compiling now. |
| 120 | # |
| 121 | ifndef LLVM_SRC_ROOT |
| 122 | LLVM_SRC_ROOT = $(BUILD_SRC_ROOT) |
| 123 | endif |
| 124 | |
| 125 | # |
| 126 | # Set the LLVM object directory. |
| 127 | # |
| 128 | ifndef LLVM_OBJ_ROOT |
| 129 | LLVM_OBJ_ROOT = $(BUILD_OBJ_ROOT) |
| 130 | endif |
| 131 | |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 132 | ########################################################################### |
| 133 | # Default Targets: |
| 134 | # The following targets are the standard top level targets for |
| 135 | # building. |
| 136 | ########################################################################### |
Chris Lattner | 4bb13b8 | 2002-09-13 22:14:47 +0000 | [diff] [blame] | 137 | |
Chris Lattner | edf1f23 | 2002-07-23 19:21:31 +0000 | [diff] [blame] | 138 | ifdef SHARED_LIBRARY |
| 139 | # if SHARED_LIBRARY is specified, the default is to build the dynamic lib |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 140 | all:: dynamic |
Chris Lattner | edf1f23 | 2002-07-23 19:21:31 +0000 | [diff] [blame] | 141 | endif |
| 142 | |
Chris Lattner | b19e59c | 2001-06-29 05:20:16 +0000 | [diff] [blame] | 143 | # Default Rule: Make sure it's also a :: rule |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 144 | all :: |
| 145 | |
| 146 | # Default for install is to at least build everything... |
| 147 | install :: |
| 148 | |
John Criswell | 8bff509 | 2003-06-11 13:55:44 +0000 | [diff] [blame] | 149 | # Default rule for test. It ensures everything has a test rule |
| 150 | test:: |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame] | 151 | |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 152 | # Print out the directories used for building |
| 153 | prdirs:: |
| 154 | echo "Home Offset : " $(HOME_OBJ_ROOT); |
| 155 | echo "Build Source Root: " $(BUILD_SRC_ROOT); |
| 156 | echo "Build Source Dir : " $(BUILD_SRC_DIR); |
| 157 | echo "Build Object Root: " $(BUILD_OBJ_ROOT); |
| 158 | echo "Build Object Dir : " $(BUILD_OBJ_DIR); |
| 159 | echo "LLVM Source Root: " $(LLVM_SRC_ROOT); |
| 160 | echo "LLVM Object Root: " $(LLVM_OBJ_ROOT); |
| 161 | |
| 162 | ########################################################################### |
| 163 | # Miscellaneous paths and commands: |
| 164 | # This section defines various configuration macros, such as where |
| 165 | # to find burg, tblgen, and libtool. |
| 166 | ########################################################################### |
| 167 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 168 | #-------------------------------------------------------------------- |
Vikram S. Adve | c214e71 | 2002-08-29 23:28:46 +0000 | [diff] [blame] | 169 | # Variables derived from configuration options... |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 170 | #-------------------------------------------------------------------- |
| 171 | |
| 172 | #BinInstDir=/usr/local/bin |
John Criswell | 65aa5934 | 2003-05-29 18:52:10 +0000 | [diff] [blame] | 173 | #LibInstDir=/usr/local/lib/xxx |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 174 | #DocInstDir=/usr/doc/xxx |
| 175 | |
Vikram S. Adve | dba59ef | 2001-08-06 19:01:20 +0000 | [diff] [blame] | 176 | BURG_OPTS = -I |
| 177 | |
John Criswell | 8bff509 | 2003-06-11 13:55:44 +0000 | [diff] [blame] | 178 | PURIFY := $(PURIFY) -cache-dir="$(BUILD_OBJ_ROOT)/../purifycache" -chain-length="30" -messages=all |
Chris Lattner | 6e39070 | 2001-10-30 20:24:08 +0000 | [diff] [blame] | 179 | |
Chris Lattner | 760da06 | 2003-03-14 20:25:22 +0000 | [diff] [blame] | 180 | ifdef ENABLE_PROFILING |
| 181 | ENABLE_OPTIMIZED = 1 |
| 182 | CONFIGURATION := Profile |
| 183 | else |
| 184 | ifdef ENABLE_OPTIMIZED |
| 185 | CONFIGURATION := Release |
| 186 | else |
| 187 | CONFIGURATION := Debug |
| 188 | endif |
| 189 | endif |
| 190 | |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 191 | # |
| 192 | # Enable this for profiling support with 'gprof' |
| 193 | # This automatically enables optimized builds. |
| 194 | # |
| 195 | ifdef ENABLE_PROFILING |
| 196 | PROFILE = -pg |
| 197 | endif |
| 198 | |
| 199 | # |
| 200 | # Suffixes for library compilation rules |
| 201 | # |
| 202 | .SUFFIXES: .so |
| 203 | |
John Criswell | 8bff509 | 2003-06-11 13:55:44 +0000 | [diff] [blame] | 204 | ########################################################################### |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 205 | # Library Locations: |
John Criswell | 8bff509 | 2003-06-11 13:55:44 +0000 | [diff] [blame] | 206 | # These variables describe various library locations: |
| 207 | # |
| 208 | # DEST* = Location of where libraries that are built will be placed. |
| 209 | # LLVM* = Location of LLVM libraries used for linking. |
| 210 | # PROJ* = Location of previously built libraries used for linking. |
| 211 | ########################################################################### |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame] | 212 | |
John Criswell | 8bff509 | 2003-06-11 13:55:44 +0000 | [diff] [blame] | 213 | # Libraries that are being built |
| 214 | DESTLIBDEBUG := $(BUILD_OBJ_ROOT)/lib/Debug |
| 215 | DESTLIBRELEASE := $(BUILD_OBJ_ROOT)/lib/Release |
| 216 | DESTLIBPROFILE := $(BUILD_OBJ_ROOT)/lib/Profile |
| 217 | DESTLIBCURRENT := $(BUILD_OBJ_ROOT)/lib/$(CONFIGURATION) |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame] | 218 | |
John Criswell | 8bff509 | 2003-06-11 13:55:44 +0000 | [diff] [blame] | 219 | # LLVM libraries used for linking |
| 220 | LLVMLIBDEBUGSOURCE := $(LLVM_OBJ_ROOT)/lib/Debug |
| 221 | LLVMLIBRELEASESOURCE := $(LLVM_OBJ_ROOT)/lib/Release |
| 222 | LLVMLIBPROFILESOURCE := $(LLVM_OBJ_ROOT)/lib/Profile |
| 223 | LLVMLIBCURRENTSOURCE := $(LLVM_OBJ_ROOT)/lib/$(CONFIGURATION) |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame] | 224 | |
John Criswell | 8bff509 | 2003-06-11 13:55:44 +0000 | [diff] [blame] | 225 | # Libraries that were built that will now be used for linking |
| 226 | PROJLIBDEBUGSOURCE := $(BUILD_OBJ_ROOT)/lib/Debug |
| 227 | PROJLIBRELEASESOURCE := $(BUILD_OBJ_ROOT)/lib/Release |
| 228 | PROJLIBPROFILESOURCE := $(BUILD_OBJ_ROOT)/lib/Profile |
| 229 | PROJLIBCURRENTSOURCE := $(BUILD_OBJ_ROOT)/lib/$(CONFIGURATION) |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame] | 230 | |
John Criswell | 8bff509 | 2003-06-11 13:55:44 +0000 | [diff] [blame] | 231 | ########################################################################### |
| 232 | # Tool Locations |
| 233 | # These variables describe various tool locations: |
| 234 | # |
| 235 | # DEST* = Location of where tools that are built will be placed. |
| 236 | # LLVM* = Location of LLVM tools used for building. |
| 237 | # PROJ* = Location of previously built tools used for linking. |
| 238 | ########################################################################### |
Chris Lattner | 760da06 | 2003-03-14 20:25:22 +0000 | [diff] [blame] | 239 | |
John Criswell | 8bff509 | 2003-06-11 13:55:44 +0000 | [diff] [blame] | 240 | DESTTOOLDEBUG := $(BUILD_OBJ_ROOT)/tools/Debug |
| 241 | DESTTOOLRELEASE := $(BUILD_OBJ_ROOT)/tools/Release |
| 242 | DESTTOOLPROFILE := $(BUILD_OBJ_ROOT)/tools/Profile |
| 243 | DESTTOOLCURRENT := $(BUILD_OBJ_ROOT)/tools/$(CONFIGURATION) |
| 244 | |
| 245 | LLVMTOOLDEBUG := $(LLVM_OBJ_ROOT)/tools/Debug |
| 246 | LLVMTOOLRELEASE := $(LLVM_OBJ_ROOT)/tools/Release |
| 247 | LLVMTOOLPROFILE := $(LLVM_OBJ_ROOT)/tools/Profile |
| 248 | LLVMTOOLCURRENT := $(LLVM_OBJ_ROOT)/tools/$(CONFIGURATION) |
| 249 | |
| 250 | PROJTOOLDEBUG := $(BUILD_OBJ_ROOT)/tools/Debug |
| 251 | PROJTOOLRELEASE := $(BUILD_OBJ_ROOT)/tools/Release |
| 252 | PROJTOOLPROFILE := $(BUILD_OBJ_ROOT)/tools/Profile |
| 253 | PROJTOOLCURRENT := $(BUILD_OBJ_ROOT)/tools/$(CONFIGURATION) |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 254 | |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 255 | # |
| 256 | # Libtool is found in the current directory. |
| 257 | # |
| 258 | ifdef VERBOSE |
| 259 | LIBTOOL=$(LLVM_SRC_ROOT)/libtool |
| 260 | else |
| 261 | LIBTOOL=$(LLVM_SRC_ROOT)/libtool --silent |
| 262 | endif |
| 263 | |
| 264 | # |
Misha Brukman | b5f096f | 2002-09-12 16:05:39 +0000 | [diff] [blame] | 265 | # Verbosity levels |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 266 | # |
Chris Lattner | 760da06 | 2003-03-14 20:25:22 +0000 | [diff] [blame] | 267 | ifndef VERBOSE |
Misha Brukman | b5f096f | 2002-09-12 16:05:39 +0000 | [diff] [blame] | 268 | VERB := @ |
| 269 | endif |
| 270 | |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 271 | ########################################################################### |
| 272 | # Miscellaneous paths and commands (part deux): |
| 273 | # This section defines various configuration macros, such as where |
| 274 | # to find burg, tblgen, and libtool. |
| 275 | ########################################################################### |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 276 | |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 277 | #-------------------------------------------------------------------------- |
| 278 | # Special tools used while building the LLVM tree. Burg is built as part |
| 279 | # of the utils directory. |
| 280 | #-------------------------------------------------------------------------- |
John Criswell | 8bff509 | 2003-06-11 13:55:44 +0000 | [diff] [blame] | 281 | BURG := $(LLVMTOOLCURRENT)/burg |
Chris Lattner | 9b94701 | 2002-09-19 19:42:24 +0000 | [diff] [blame] | 282 | RunBurg := $(BURG) $(BURG_OPTS) |
| 283 | |
John Criswell | 8bff509 | 2003-06-11 13:55:44 +0000 | [diff] [blame] | 284 | TBLGEN := $(LLVMTOOLCURRENT)/tblgen |
Vikram S. Adve | dba59ef | 2001-08-06 19:01:20 +0000 | [diff] [blame] | 285 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 286 | |
John Criswell | 8bff509 | 2003-06-11 13:55:44 +0000 | [diff] [blame] | 287 | ########################################################################### |
| 288 | # Compile Time Flags |
| 289 | ########################################################################### |
| 290 | |
| 291 | # |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 292 | # Include both the project headers and the LLVM headers for compilation and |
| 293 | # dependency computation. |
John Criswell | 8bff509 | 2003-06-11 13:55:44 +0000 | [diff] [blame] | 294 | # |
| 295 | CPPFLAGS += -I$(BUILD_SRC_ROOT)/include -I$(LLVM_SRC_ROOT)/include |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame] | 296 | |
Vikram S. Adve | feeae58 | 2002-09-18 11:55:13 +0000 | [diff] [blame] | 297 | # By default, strip symbol information from executable |
Chris Lattner | 760da06 | 2003-03-14 20:25:22 +0000 | [diff] [blame] | 298 | ifndef KEEP_SYMBOLS |
Chris Lattner | 527002c | 2003-01-31 19:00:26 +0000 | [diff] [blame] | 299 | STRIP = $(PLATFORMSTRIPOPTS) |
| 300 | STRIP_WARN_MSG = "(without symbols) " |
Vikram S. Adve | feeae58 | 2002-09-18 11:55:13 +0000 | [diff] [blame] | 301 | endif |
| 302 | |
Chris Lattner | 73e1d0f | 2002-09-13 16:02:26 +0000 | [diff] [blame] | 303 | # Allow gnu extensions... |
| 304 | CPPFLAGS += -D_GNU_SOURCE |
| 305 | |
Chris Lattner | c7acf81 | 2002-01-23 05:46:01 +0000 | [diff] [blame] | 306 | # -Wno-unused-parameter |
John Criswell | 8bff509 | 2003-06-11 13:55:44 +0000 | [diff] [blame] | 307 | CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused -I$(LEVEL)/include |
Chris Lattner | 1d1e5b5 | 2003-02-13 16:56:30 +0000 | [diff] [blame] | 308 | CompileOptimizeOpts := -O3 -DNDEBUG -finline-functions -fshort-enums |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 309 | |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 310 | # |
| 311 | # Compile commands with libtool. |
| 312 | # |
| 313 | Compile := $(LIBTOOL) --mode=compile $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(CompileCommonOpts) |
| 314 | CompileC := $(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CCFLAGS) $(CompileCommonOpts) |
| 315 | |
| 316 | # |
| 317 | # Add the LLVM specific "-only-static" option so that we only compile .o files |
| 318 | # once when not building a shared library. |
| 319 | # |
| 320 | # For shared libraries, we will end up building twice, but that doesn't happen |
| 321 | # very often, so we'll let it go. |
| 322 | # |
| 323 | ifndef SHARED_LIBRARY |
| 324 | Compile := $(Compile) -only-static |
| 325 | CompileC := $(CompileC) -only-static |
| 326 | endif |
| 327 | |
Chris Lattner | 172b648 | 2002-09-22 02:47:15 +0000 | [diff] [blame] | 328 | # Compile a cpp file, don't link... |
Chris Lattner | 285af38 | 2002-08-12 21:19:28 +0000 | [diff] [blame] | 329 | CompileG := $(Compile) -g -D_DEBUG |
Chris Lattner | 1d1e5b5 | 2003-02-13 16:56:30 +0000 | [diff] [blame] | 330 | CompileO := $(Compile) $(CompileOptimizeOpts) -felide-constructors -fomit-frame-pointer |
| 331 | CompileP := $(Compile) $(CompileOptimizeOpts) -felide-constructors $(PROFILE) |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 332 | |
Chris Lattner | 172b648 | 2002-09-22 02:47:15 +0000 | [diff] [blame] | 333 | # Compile a c file, don't link... |
Chris Lattner | 172b648 | 2002-09-22 02:47:15 +0000 | [diff] [blame] | 334 | CompileCG := $(CompileC) -g -D_DEBUG |
Chris Lattner | fe95dae | 2003-02-19 22:12:20 +0000 | [diff] [blame] | 335 | CompileCO := $(CompileC) $(CompileOptimizeOpts) -fomit-frame-pointer |
| 336 | CompileCP := $(CompileC) $(CompileOptimizeOpts) $(PROFILE) |
Chris Lattner | 172b648 | 2002-09-22 02:47:15 +0000 | [diff] [blame] | 337 | |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 338 | ########################################################################### |
| 339 | # Link Time Options |
| 340 | ########################################################################### |
Chris Lattner | 172b648 | 2002-09-22 02:47:15 +0000 | [diff] [blame] | 341 | |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 342 | # |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 343 | # Link final executable |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 344 | # (Note that we always link with the C++ compiler). |
| 345 | # |
Chris Lattner | 1917e95 | 2002-07-31 21:32:05 +0000 | [diff] [blame] | 346 | ifdef ENABLE_PURIFY # To enable purify, build with 'gmake ENABLE_PURIFY=1' |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 347 | Link := $(PURIFY) $(LIBTOOL) --mode=link $(CXX) -static |
Chris Lattner | 12604ed | 2002-04-05 18:56:58 +0000 | [diff] [blame] | 348 | else |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 349 | Link := $(LIBTOOL) --mode=link $(CXX) |
Chris Lattner | 12604ed | 2002-04-05 18:56:58 +0000 | [diff] [blame] | 350 | endif |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame] | 351 | |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 352 | # link both projlib and llvmlib libraries |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame] | 353 | LinkG := $(Link) -g -L$(PROJLIBDEBUGSOURCE) -L$(LLVMLIBDEBUGSOURCE) $(STRIP) |
| 354 | LinkO := $(Link) -O3 -L$(PROJLIBRELEASESOURCE) -L$(LLVMLIBRELEASESOURCE) |
| 355 | LinkP := $(Link) -O3 -L$(PROJLIBPROFILESOURCE) -L$(LLVMLIBPROFILESOURCE) $(PROFILE) |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 356 | |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 357 | # Create one .o file from a bunch of .o files... |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 358 | Relink = ${LIBTOOL} --mode=link $(CXX) |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 359 | |
Chris Lattner | 4bb13b8 | 2002-09-13 22:14:47 +0000 | [diff] [blame] | 360 | # MakeSO - Create a .so file from a .o files... |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 361 | #MakeSO := $(LIBTOOL) --mode=link $(CXX) $(MakeSharedObjectOption) |
| 362 | #MakeSOO := $(MakeSO) -O3 |
| 363 | #MakeSOP := $(MakeSOO) $(PROFILE) |
| 364 | |
| 365 | # |
| 366 | # Configure where the item being compiled should go. |
| 367 | # |
| 368 | ifdef SHARED_LIBRARY |
| 369 | Link := $(Link) -rpath $(DESTLIBCURRENT) |
| 370 | endif |
| 371 | |
| 372 | ifdef TOOLNAME |
| 373 | Link := $(Link) -rpath $(DESTTOOLCURRENT) |
| 374 | endif |
Chris Lattner | 4bb13b8 | 2002-09-13 22:14:47 +0000 | [diff] [blame] | 375 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 376 | # Create dependancy file from CPP file, send to stdout. |
John Criswell | 8bff509 | 2003-06-11 13:55:44 +0000 | [diff] [blame] | 377 | Depend := $(CXX) -MM -I$(LEVEL)/include $(CPPFLAGS) |
| 378 | DependC := $(CC) -MM -I$(LEVEL)/include $(CPPFLAGS) |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 379 | |
| 380 | # Archive a bunch of .o files into a .a file... |
John Criswell | 794fcd2 | 2003-05-30 15:50:31 +0000 | [diff] [blame] | 381 | AR = ${AR_PATH} cq |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 382 | |
| 383 | #---------------------------------------------------------- |
| 384 | |
| 385 | # Source includes all of the cpp files, and objects are derived from the |
| 386 | # source files... |
Chris Lattner | e001059 | 2001-10-18 01:48:09 +0000 | [diff] [blame] | 387 | # The local Makefile can list other Source files via ExtraSource = ... |
Vikram S. Adve | c4bed34 | 2001-10-17 12:33:55 +0000 | [diff] [blame] | 388 | # |
Vikram S. Adve | ad9ea7e | 2002-10-14 16:40:04 +0000 | [diff] [blame] | 389 | ifndef Source |
Chris Lattner | e001059 | 2001-10-18 01:48:09 +0000 | [diff] [blame] | 390 | Source := $(ExtraSource) $(wildcard *.cpp *.c *.y *.l) |
Vikram S. Adve | ad9ea7e | 2002-10-14 16:40:04 +0000 | [diff] [blame] | 391 | endif |
Vikram S. Adve | 112a72c | 2001-07-15 13:16:47 +0000 | [diff] [blame] | 392 | |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 393 | LObjs := $(sort $(patsubst Debug/%.lo, %.lo, $(addsuffix .lo,$(notdir $(basename $(Source)))))) |
| 394 | LObjectsO := $(addprefix $(BUILD_OBJ_DIR)/Release/,$(LObjs)) |
| 395 | LObjectsP := $(addprefix $(BUILD_OBJ_DIR)/Profile/,$(LObjs)) |
| 396 | LObjectsG := $(addprefix $(BUILD_OBJ_DIR)/Debug/,$(LObjs)) |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 397 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 398 | #--------------------------------------------------------- |
Chris Lattner | a8abc22 | 2002-09-18 03:22:27 +0000 | [diff] [blame] | 399 | # Handle the DIRS and PARALLEL_DIRS options |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 400 | #--------------------------------------------------------- |
| 401 | |
Anand Shukla | 7c7a07e | 2002-09-18 04:29:30 +0000 | [diff] [blame] | 402 | ifdef DIRS |
Chris Lattner | dc95ade | 2003-01-16 20:02:30 +0000 | [diff] [blame] | 403 | all install clean test :: |
Chris Lattner | 16d1f73 | 2002-09-17 23:45:34 +0000 | [diff] [blame] | 404 | $(VERB) for dir in ${DIRS}; do \ |
Chris Lattner | f1ffd99 | 2002-09-17 23:35:02 +0000 | [diff] [blame] | 405 | (cd $$dir; $(MAKE) $@) || exit 1; \ |
| 406 | done |
Anand Shukla | 7c7a07e | 2002-09-18 04:29:30 +0000 | [diff] [blame] | 407 | endif |
Chris Lattner | a8abc22 | 2002-09-18 03:22:27 +0000 | [diff] [blame] | 408 | |
| 409 | # Handle PARALLEL_DIRS |
| 410 | ifdef PARALLEL_DIRS |
| 411 | all :: $(addsuffix /.makeall , $(PARALLEL_DIRS)) |
| 412 | install :: $(addsuffix /.makeinstall, $(PARALLEL_DIRS)) |
| 413 | clean :: $(addsuffix /.makeclean , $(PARALLEL_DIRS)) |
Chris Lattner | dc95ade | 2003-01-16 20:02:30 +0000 | [diff] [blame] | 414 | test :: $(addsuffix /.maketest , $(PARALLEL_DIRS)) |
Chris Lattner | a8abc22 | 2002-09-18 03:22:27 +0000 | [diff] [blame] | 415 | |
Chris Lattner | dc95ade | 2003-01-16 20:02:30 +0000 | [diff] [blame] | 416 | %/.makeall %/.makeinstall %/.makeclean %/.maketest: |
Chris Lattner | a8abc22 | 2002-09-18 03:22:27 +0000 | [diff] [blame] | 417 | $(VERB) cd $(@D); $(MAKE) $(subst $(@D)/.make,,$@) |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 418 | endif |
| 419 | |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 420 | # Handle directories that may or may not exist |
John Criswell | 2a6530f | 2003-06-27 16:58:44 +0000 | [diff] [blame] | 421 | ifdef OPTIONAL_DIRS |
| 422 | all install clean test :: |
| 423 | $(VERB) for dir in ${OPTIONAL_DIRS}; do \ |
| 424 | if [ -d $$dir ]; \ |
| 425 | then\ |
| 426 | (cd $$dir; $(MAKE) $@) || exit 1; \ |
| 427 | fi \ |
| 428 | done |
| 429 | endif |
| 430 | |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 431 | ########################################################################### |
| 432 | # Library Build Rules: |
| 433 | # |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 434 | #--------------------------------------------------------- |
| 435 | # Handle the LIBRARYNAME option - used when building libs... |
| 436 | #--------------------------------------------------------- |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 437 | # |
| 438 | # When libraries are built, they are allowed to optionally define the |
| 439 | # DONT_BUILD_RELINKED make variable, which, when defined, prevents a .o file |
| 440 | # from being built for the library. This .o files may then be linked to by a |
| 441 | # tool if the tool does not need (or want) the semantics a .a file provides |
| 442 | # (linking in only object files that are "needed"). If a library is never to |
| 443 | # be used in this way, it is better to define DONT_BUILD_RELINKED, and define |
| 444 | # BUILD_ARCHIVE instead. |
| 445 | # |
| 446 | # Some libraries must be built as .a files (libscalar for example) because if |
Chris Lattner | 1917e95 | 2002-07-31 21:32:05 +0000 | [diff] [blame] | 447 | # it's built as a .o file, then all of the constituent .o files in it will be |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 448 | # linked into tools (for example gccas) even if they only use one of the parts |
| 449 | # of it. For this reason, sometimes it's useful to use libraries as .a files. |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 450 | ########################################################################### |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 451 | |
| 452 | ifdef LIBRARYNAME |
Vikram S. Adve | 112a72c | 2001-07-15 13:16:47 +0000 | [diff] [blame] | 453 | |
Chris Lattner | 2a548c5 | 2002-09-16 22:36:42 +0000 | [diff] [blame] | 454 | # Make sure there isn't any extranous whitespace on the LIBRARYNAME option |
Chris Lattner | ccb4ebd | 2002-09-16 22:34:56 +0000 | [diff] [blame] | 455 | LIBRARYNAME := $(strip $(LIBRARYNAME)) |
| 456 | |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame] | 457 | LIBNAME_O := $(DESTLIBRELEASE)/lib$(LIBRARYNAME).so |
| 458 | LIBNAME_P := $(DESTLIBPROFILE)/lib$(LIBRARYNAME).so |
| 459 | LIBNAME_G := $(DESTLIBDEBUG)/lib$(LIBRARYNAME).so |
| 460 | LIBNAME_AO := $(DESTLIBRELEASE)/lib$(LIBRARYNAME).a |
| 461 | LIBNAME_AP := $(DESTLIBPROFILE)/lib$(LIBRARYNAME).a |
| 462 | LIBNAME_AG := $(DESTLIBDEBUG)/lib$(LIBRARYNAME).a |
| 463 | LIBNAME_OBJO := $(DESTLIBRELEASE)/$(LIBRARYNAME).o |
| 464 | LIBNAME_OBJP := $(DESTLIBPROFILE)/$(LIBRARYNAME).o |
| 465 | LIBNAME_OBJG := $(DESTLIBDEBUG)/$(LIBRARYNAME).o |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 466 | |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 467 | #-------------------------------------------------------------------- |
| 468 | # Library Targets |
| 469 | # Modify the top level targets to build the desired libraries. |
| 470 | #-------------------------------------------------------------------- |
| 471 | |
Chris Lattner | 760da06 | 2003-03-14 20:25:22 +0000 | [diff] [blame] | 472 | # dynamic target builds a shared object version of the library... |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame] | 473 | dynamic:: $(DESTLIBCURRENT)/lib$(LIBRARYNAME).so |
Vikram S. Adve | 60f5606 | 2002-08-02 18:34:12 +0000 | [diff] [blame] | 474 | |
Chris Lattner | 760da06 | 2003-03-14 20:25:22 +0000 | [diff] [blame] | 475 | # Does the library want a .o version built? |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 476 | ifndef DONT_BUILD_RELINKED |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame] | 477 | all:: $(DESTLIBCURRENT)/$(LIBRARYNAME).o |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 478 | endif |
Chris Lattner | 760da06 | 2003-03-14 20:25:22 +0000 | [diff] [blame] | 479 | |
| 480 | # Does the library want an archive version built? |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 481 | ifdef BUILD_ARCHIVE |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame] | 482 | all:: $(DESTLIBCURRENT)/lib$(LIBRARYNAME).a |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 483 | endif |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 484 | |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 485 | #-------------------------------------------------------------------- |
| 486 | # Rules for building libraries |
| 487 | #-------------------------------------------------------------------- |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 488 | |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 489 | # |
| 490 | # Rules for building dynamically linked libraries. |
| 491 | # |
| 492 | $(LIBNAME_O): $(LObjectsO) $(LibSubDirs) $(DESTLIBRELEASE)/.dir |
| 493 | @echo ======= Linking $(LIBRARYNAME) dynamic release library ======= |
| 494 | $(VERB) $(Link) -o $*.la $(LObjectsO) $(LibSubDirs) $(LibLinkOpts); |
| 495 | $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $*.la $(DESTLIBCURRENT); |
Vikram S. Adve | 41e7891 | 2002-09-20 14:03:13 +0000 | [diff] [blame] | 496 | |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 497 | $(LIBNAME_P): $(LObjectsP) $(LibSubDirs) $(DESTLIBPROFILE)/.dir |
| 498 | @echo ======= Linking $(LIBRARYNAME) dynamic profile library ======= |
| 499 | $(VERB) $(Link) -o $*.la $(LObjectsP) $(LibSubDirs) $(LibLinkOpts); |
| 500 | $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $*.la $(DESTLIBCURRENT); |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 501 | |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 502 | $(LIBNAME_G): $(LObjectsG) $(LibSubDirs) $(DESTLIBDEBUG)/.dir |
| 503 | @echo ======= Linking $(LIBRARYNAME) dynamic debug library ======= |
| 504 | $(VERB) $(Link) -o $*.la $(LObjectsG) $(LibSubDirs) $(LibLinkOpts); |
| 505 | $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $*.la $(DESTLIBCURRENT); |
Vikram S. Adve | 112a72c | 2001-07-15 13:16:47 +0000 | [diff] [blame] | 506 | |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 507 | # |
| 508 | # Rules for building static archive libraries. |
| 509 | # |
| 510 | $(LIBNAME_AO): $(LObjectsO) $(LibSubDirs) $(DESTLIBRELEASE)/.dir |
| 511 | @echo ======= Linking $(LIBRARYNAME) archive release library ======= |
| 512 | @$(RM) -f $@ |
| 513 | $(VERB) $(Link) -03 -o $@ $(LObjectsO) $(LibSubDirs) -static |
Vikram S. Adve | 41e7891 | 2002-09-20 14:03:13 +0000 | [diff] [blame] | 514 | |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 515 | $(LIBNAME_AP): $(LObjectsP) $(LibSubDirs) $(DESTLIBPROFILE)/.dir |
| 516 | @echo ======= Linking $(LIBRARYNAME) archive profile library ======= |
| 517 | @$(RM) -f $@ |
| 518 | $(VERB) $(Link) -03 $(PROFILE) -o $@ $(LObjectsP) $(LibSubDirs) -static |
Vikram S. Adve | 112a72c | 2001-07-15 13:16:47 +0000 | [diff] [blame] | 519 | |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 520 | $(LIBNAME_AG): $(LObjectsG) $(LibSubDirs) $(DESTLIBDEBUG)/.dir |
| 521 | @echo ======= Linking $(LIBRARYNAME) archive debug library ======= |
| 522 | @$(RM) -f $@ |
| 523 | $(VERB) $(Link) -g $(STRIP) -o $@ $(LObjectsG) $(LibSubDirs) -static |
| 524 | |
| 525 | # |
| 526 | # Rules for building .o libraries. |
| 527 | # |
| 528 | $(LIBNAME_OBJO): $(LObjectsO) $(LibSubDirs) $(DESTLIBRELEASE)/.dir |
Misha Brukman | b5f096f | 2002-09-12 16:05:39 +0000 | [diff] [blame] | 529 | @echo "Linking $@" |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 530 | $(VERB) $(Relink) -o $@ $(LObjectsO) $(LibSubDirs) |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 531 | |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 532 | $(LIBNAME_OBJP): $(LObjectsP) $(LibSubDirs) $(DESTLIBPROFILE)/.dir |
Vikram S. Adve | 41e7891 | 2002-09-20 14:03:13 +0000 | [diff] [blame] | 533 | @echo "Linking $@" |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 534 | $(VERB) $(Relink) -o $@ $(LObjectsP) $(LibSubDirs) |
Vikram S. Adve | 41e7891 | 2002-09-20 14:03:13 +0000 | [diff] [blame] | 535 | |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 536 | $(LIBNAME_OBJG): $(LObjectsG) $(LibSubDirs) $(DESTLIBDEBUG)/.dir |
Chris Lattner | 9e39816 | 2002-09-25 17:15:22 +0000 | [diff] [blame] | 537 | @echo "Linking $@" |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 538 | $(VERB) $(Relink) -o $@ $(LObjectsG) $(LibSubDirs) |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 539 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 540 | endif |
| 541 | |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 542 | #------------------------------------------------------------------------ |
Vikram S. Adve | 0193d5e | 2001-10-10 22:35:00 +0000 | [diff] [blame] | 543 | # Create a TAGS database for emacs |
| 544 | #------------------------------------------------------------------------ |
| 545 | |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 546 | ifdef ETAGS |
Vikram S. Adve | 022d06c | 2001-10-13 12:26:59 +0000 | [diff] [blame] | 547 | ifeq ($(LEVEL), .) |
Vikram S. Adve | 022d06c | 2001-10-13 12:26:59 +0000 | [diff] [blame] | 548 | tags: |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 549 | $(ETAGS) -l c++ `find include lib tools -name '*.cpp' -o -name '*.h'` |
Vikram S. Adve | 022d06c | 2001-10-13 12:26:59 +0000 | [diff] [blame] | 550 | all:: tags |
Vikram S. Adve | 022d06c | 2001-10-13 12:26:59 +0000 | [diff] [blame] | 551 | endif |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 552 | else |
| 553 | tags: |
| 554 | ${ECHO} "Cannot build $@: The program etags is not installed" |
| 555 | endif |
Vikram S. Adve | 0193d5e | 2001-10-10 22:35:00 +0000 | [diff] [blame] | 556 | |
| 557 | #------------------------------------------------------------------------ |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 558 | # Handle the TOOLNAME option - used when building tool executables... |
| 559 | #------------------------------------------------------------------------ |
| 560 | # |
| 561 | # The TOOLNAME option should be used with a USEDLIBS variable that tells the |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 562 | # libraries (and the order of the libs) that should be linked to the |
| 563 | # tool. USEDLIBS should contain a list of library names (some with .a extension) |
| 564 | # that are automatically linked in as .o files unless the .a suffix is added. |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 565 | # |
| 566 | ifdef TOOLNAME |
| 567 | |
| 568 | # TOOLEXENAME* - These compute the output filenames to generate... |
John Criswell | 8bff509 | 2003-06-11 13:55:44 +0000 | [diff] [blame] | 569 | TOOLEXENAME_G := $(DESTTOOLDEBUG)/$(TOOLNAME) |
| 570 | TOOLEXENAME_O := $(DESTTOOLRELEASE)/$(TOOLNAME) |
| 571 | TOOLEXENAME_P := $(DESTTOOLPROFILE)/$(TOOLNAME) |
| 572 | TOOLEXENAMES := $(DESTTOOLCURRENT)/$(TOOLNAME) |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 573 | |
| 574 | # USED_LIBS_OPTIONS - Compute the options line that add -llib1 -llib2, etc. |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame] | 575 | PROJ_LIBS_OPTIONS := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS))) |
| 576 | PROJ_LIBS_OPTIONS_G := $(patsubst %.o, $(PROJLIBDEBUGSOURCE)/%.o, $(PROJ_LIBS_OPTIONS)) |
| 577 | PROJ_LIBS_OPTIONS_O := $(patsubst %.o, $(PROJLIBRELEASESOURCE)/%.o,$(PROJ_LIBS_OPTIONS)) |
| 578 | PROJ_LIBS_OPTIONS_P := $(patsubst %.o, $(PROJLIBPROFILESOURCE)/%.o,$(PROJ_LIBS_OPTIONS)) |
| 579 | |
| 580 | LLVM_LIBS_OPTIONS := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS))) |
| 581 | LLVM_LIBS_OPTIONS_G := $(patsubst %.o, $(LLVMLIBDEBUGSOURCE)/%.o, $(LLVM_LIBS_OPTIONS)) |
| 582 | LLVM_LIBS_OPTIONS_O := $(patsubst %.o, $(LLVMLIBRELEASESOURCE)/%.o,$(LLVM_LIBS_OPTIONS)) |
| 583 | LLVM_LIBS_OPTIONS_P := $(patsubst %.o, $(LLVMLIBPROFILESOURCE)/%.o,$(LLVM_LIBS_OPTIONS)) |
| 584 | |
| 585 | LIB_OPTS_G := $(LLVM_LIBS_OPTIONS_G) $(PROJ_LIBS_OPTIONS_G) |
Chris Lattner | e3ba95e | 2003-06-20 15:41:57 +0000 | [diff] [blame] | 586 | LIB_OPTS_O := $(LLVM_LIBS_OPTIONS_O) $(PROJ_LIBS_OPTIONS_O) |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame] | 587 | LIB_OPTS_P := $(LLVM_LIBS_OPTIONS_P) $(PROJ_LIBS_OPTIONS_P) |
| 588 | |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 589 | # USED_LIB_PATHS - Compute the path of the libraries used so that tools are |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 590 | # rebuilt if libraries change. This has to make sure to handle .a/.so and .o |
| 591 | # files seperately. |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 592 | # |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 593 | STATICUSEDLIBS := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS))) |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame] | 594 | USED_LIB_PATHS_G := $(addprefix $(DESTLIBDEBUG)/, $(STATICUSEDLIBS)) |
| 595 | USED_LIB_PATHS_O := $(addprefix $(DESTLIBRELEASE)/, $(STATICUSEDLIBS)) |
| 596 | USED_LIB_PATHS_P := $(addprefix $(DESTLIBPROFILE)/, $(STATICUSEDLIBS)) |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 597 | #LINK_OPTS := $(TOOLLINKOPTS) $(PLATFORMLINKOPTS) |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 598 | |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 599 | # |
| 600 | # Libtool link options: |
| 601 | # Ensure that all binaries have their symbols exported so that they can |
| 602 | # by dlsym'ed. |
| 603 | # |
| 604 | LINK_OPTS := -export-dynamic $(TOOLLINKOPTS) |
Chris Lattner | 8d7dfb3 | 2003-01-22 16:13:31 +0000 | [diff] [blame] | 605 | |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame] | 606 | |
| 607 | |
| 608 | |
| 609 | |
Chris Lattner | 8d7dfb3 | 2003-01-22 16:13:31 +0000 | [diff] [blame] | 610 | # Tell make that we need to rebuild subdirectories before we can link the tool. |
| 611 | # This affects things like LLI which has library subdirectories. |
| 612 | $(USED_LIB_PATHS_G) $(USED_LIB_PATHS_O) $(USED_LIB_PATHS_P): \ |
| 613 | $(addsuffix /.makeall, $(PARALLEL_DIRS)) |
| 614 | |
Chris Lattner | 669bd7c | 2001-10-13 05:10:29 +0000 | [diff] [blame] | 615 | all:: $(TOOLEXENAMES) |
John Criswell | 2a6530f | 2003-06-27 16:58:44 +0000 | [diff] [blame] | 616 | |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 617 | clean:: |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 618 | $(VERB) $(RM) -f $(TOOLEXENAMES) |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 619 | |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 620 | $(TOOLEXENAME_G): $(LObjectsG) $(USED_LIB_PATHS_G) $(DESTTOOLDEBUG)/.dir |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame] | 621 | @echo ======= Linking $(TOOLNAME) debug executable $(STRIP_WARN_MSG)======= |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 622 | $(VERB) $(LinkG) -o $@ $(LObjectsG) $(LIB_OPTS_G) $(LINK_OPTS) $(LIBS) |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 623 | |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 624 | $(TOOLEXENAME_O): $(LObjectsO) $(USED_LIB_PATHS_O) $(DESTTOOLRELEASE)/.dir |
Chris Lattner | 287d443 | 2002-09-12 17:02:40 +0000 | [diff] [blame] | 625 | @echo ======= Linking $(TOOLNAME) release executable ======= |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 626 | $(VERB) $(LinkO) -o $@ $(LObjectsO) $(LIB_OPTS_O) $(LINK_OPTS) $(LIBS) |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 627 | |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 628 | $(TOOLEXENAME_P): $(LObjectsP) $(USED_LIB_PATHS_P) $(DESTTOOLPROFILE)/.dir |
Vikram S. Adve | 41e7891 | 2002-09-20 14:03:13 +0000 | [diff] [blame] | 629 | @echo ======= Linking $(TOOLNAME) profile executable ======= |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 630 | $(VERB) $(LinkP) -o $@ $(LObjectsP) $(LIB_OPTS_P) $(LINK_OPTS) $(LIBS) |
Vikram S. Adve | 41e7891 | 2002-09-20 14:03:13 +0000 | [diff] [blame] | 631 | |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 632 | endif |
| 633 | |
| 634 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 635 | |
| 636 | #--------------------------------------------------------- |
John Criswell | 8bff509 | 2003-06-11 13:55:44 +0000 | [diff] [blame] | 637 | .PRECIOUS: $(BUILD_OBJ_DIR)/Depend/.dir |
| 638 | .PRECIOUS: $(BUILD_OBJ_DIR)/Debug/.dir $(BUILD_OBJ_DIR)/Release/.dir |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 639 | |
Vikram S. Adve | 112a72c | 2001-07-15 13:16:47 +0000 | [diff] [blame] | 640 | # Create .o files in the ObjectFiles directory from the .cpp and .c files... |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 641 | #$(BUILD_OBJ_DIR)/Release/%.o: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Release/.dir |
| 642 | #@echo "Compiling $<" |
| 643 | #$(VERB) $(CompileO) $< -o $@ |
| 644 | |
| 645 | #$(BUILD_OBJ_DIR)/Release/%.o: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Release/.dir |
| 646 | #$(VERB) $(CompileCO) $< -o $@ |
| 647 | |
| 648 | #$(BUILD_OBJ_DIR)/Profile/%.o: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Profile/.dir |
| 649 | #@echo "Compiling $<" |
| 650 | #$(VERB) $(CompileP) $< -o $@ |
| 651 | |
| 652 | #$(BUILD_OBJ_DIR)/Profile/%.o: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Profile/.dir |
| 653 | #@echo "Compiling $<" |
| 654 | #$(VERB) $(CompileCP) $< -o $@ |
| 655 | |
| 656 | #$(BUILD_OBJ_DIR)/Debug/%.o: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Debug/.dir |
| 657 | #@echo "Compiling $<" |
| 658 | #$(VERB) $(CompileG) $< -o $@ |
| 659 | |
| 660 | #$(BUILD_OBJ_DIR)/Debug/%.o: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Debug/.dir |
| 661 | #$(VERB) $(CompileCG) $< -o $@ |
| 662 | |
| 663 | # Create .lo files in the ObjectFiles directory from the .cpp and .c files... |
| 664 | $(BUILD_OBJ_DIR)/Release/%.lo: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Release/.dir |
Misha Brukman | b5f096f | 2002-09-12 16:05:39 +0000 | [diff] [blame] | 665 | @echo "Compiling $<" |
| 666 | $(VERB) $(CompileO) $< -o $@ |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 667 | |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 668 | $(BUILD_OBJ_DIR)/Release/%.lo: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Release/.dir |
| 669 | @echo "Compiling $<" |
Chris Lattner | 1eeac66 | 2002-10-22 23:28:23 +0000 | [diff] [blame] | 670 | $(VERB) $(CompileCO) $< -o $@ |
Vikram S. Adve | 112a72c | 2001-07-15 13:16:47 +0000 | [diff] [blame] | 671 | |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 672 | $(BUILD_OBJ_DIR)/Profile/%.lo: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Profile/.dir |
Vikram S. Adve | 41e7891 | 2002-09-20 14:03:13 +0000 | [diff] [blame] | 673 | @echo "Compiling $<" |
| 674 | $(VERB) $(CompileP) $< -o $@ |
| 675 | |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 676 | $(BUILD_OBJ_DIR)/Profile/%.lo: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Profile/.dir |
Chris Lattner | 172b648 | 2002-09-22 02:47:15 +0000 | [diff] [blame] | 677 | @echo "Compiling $<" |
| 678 | $(VERB) $(CompileCP) $< -o $@ |
| 679 | |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 680 | $(BUILD_OBJ_DIR)/Debug/%.lo: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Debug/.dir |
Misha Brukman | b5f096f | 2002-09-12 16:05:39 +0000 | [diff] [blame] | 681 | @echo "Compiling $<" |
| 682 | $(VERB) $(CompileG) $< -o $@ |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 683 | |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 684 | $(BUILD_OBJ_DIR)/Debug/%.lo: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Debug/.dir |
| 685 | @echo "Compiling $<" |
| 686 | $(VERB) $(CompileCG) $< -o $@ |
| 687 | |
| 688 | # Create .lo files in the ObjectFiles directory from the .cpp and .c files... |
| 689 | $(BUILD_OBJ_DIR)/Release/%.lo: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Release/.dir |
| 690 | @echo "Compiling $<" |
| 691 | $(VERB) $(CompileO) $< -o $@ |
| 692 | |
| 693 | $(BUILD_OBJ_DIR)/Release/%.lo: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Release/.dir |
| 694 | $(VERB) $(CompileCO) $< -o $@ |
| 695 | |
| 696 | $(BUILD_OBJ_DIR)/Profile/%.lo: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Profile/.dir |
| 697 | @echo "Compiling $<" |
| 698 | $(VERB) $(CompileP) $< -o $@ |
| 699 | |
| 700 | $(BUILD_OBJ_DIR)/Profile/%.lo: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Profile/.dir |
| 701 | @echo "Compiling $<" |
| 702 | $(VERB) $(CompileCP) $< -o $@ |
| 703 | |
| 704 | $(BUILD_OBJ_DIR)/Debug/%.lo: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Debug/.dir |
| 705 | @echo "Compiling $<" |
| 706 | $(VERB) $(CompileG) $< -o $@ |
| 707 | |
| 708 | $(BUILD_OBJ_DIR)/Debug/%.lo: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Debug/.dir |
Chris Lattner | 172b648 | 2002-09-22 02:47:15 +0000 | [diff] [blame] | 709 | $(VERB) $(CompileCG) $< -o $@ |
Vikram S. Adve | 112a72c | 2001-07-15 13:16:47 +0000 | [diff] [blame] | 710 | |
Chris Lattner | e899678 | 2003-01-16 22:44:19 +0000 | [diff] [blame] | 711 | # |
| 712 | # Rules for building lex/yacc files |
| 713 | # |
| 714 | LEX_FILES = $(filter %.l, $(Source)) |
| 715 | LEX_OUTPUT = $(LEX_FILES:%.l=%.cpp) |
| 716 | YACC_FILES = $(filter %.y, $(Source)) |
| 717 | YACC_OUTPUT = $(addprefix $(YACC_FILES:%.y=%), .h .cpp .output) |
| 718 | .PRECIOUS: $(LEX_OUTPUT) $(YACC_OUTPUT) |
| 719 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 720 | # Create a .cpp source file from a flex input file... this uses sed to cut down |
| 721 | # on the warnings emited by GCC... |
Chris Lattner | 6d131b4 | 2003-01-23 16:33:10 +0000 | [diff] [blame] | 722 | # |
| 723 | # The last line is a gross hack to work around flex aparently not being able to |
| 724 | # resize the buffer on a large token input. Currently, for uninitialized string |
| 725 | # buffers in LLVM we can generate very long tokens, so this is a hack around it. |
| 726 | # FIXME. (f.e. char Buffer[10000]; ) |
| 727 | # |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 728 | %.cpp: %.l |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 729 | $(FLEX) -t $< | $(SED) '/^find_rule/d' | \ |
| 730 | $(SED) 's/void yyunput/inline void yyunput/' | \ |
| 731 | $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \ |
| 732 | $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' > $@ |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 733 | |
| 734 | # Rule for building the bison parsers... |
Chris Lattner | 694c5df | 2003-05-15 21:28:55 +0000 | [diff] [blame] | 735 | %.c: %.y # Cancel built-in rules for yacc |
| 736 | %.h: %.y # Cancel built-in rules for yacc |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 737 | %.cpp %.h : %.y |
Chris Lattner | 694c5df | 2003-05-15 21:28:55 +0000 | [diff] [blame] | 738 | @echo Bison\'ing $<... |
Chris Lattner | e899678 | 2003-01-16 22:44:19 +0000 | [diff] [blame] | 739 | $(VERB) $(BISON) -v -d -p $(<:%Parser.y=%) $*.y |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 740 | $(VERB) ${MV} -f $*.tab.c $*.cpp |
| 741 | $(VERB) ${MV} -f $*.tab.h $*.h |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 742 | |
| 743 | # To create the directories... |
| 744 | %/.dir: |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 745 | $(VERB) ${MKDIR} $* > /dev/null |
| 746 | @$(DATE) > $@ |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 747 | |
Chris Lattner | 30440c6 | 2003-01-16 21:06:18 +0000 | [diff] [blame] | 748 | # To create postscript files from dot files... |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 749 | ifdef DOT |
Chris Lattner | 30440c6 | 2003-01-16 21:06:18 +0000 | [diff] [blame] | 750 | %.ps: %.dot |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 751 | ${DOT} -Tps < $< > $@ |
| 752 | else |
| 753 | %.ps: %.dot |
| 754 | ${ECHO} "Cannot build $@: The program dot is not installed" |
| 755 | endif |
Chris Lattner | 30440c6 | 2003-01-16 21:06:18 +0000 | [diff] [blame] | 756 | |
Chris Lattner | 172b648 | 2002-09-22 02:47:15 +0000 | [diff] [blame] | 757 | # 'make clean' nukes the tree |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 758 | clean:: |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 759 | $(VERB) $(RM) -rf $(BUILD_OBJ_DIR)/Debug $(BUILD_OBJ_DIR)/Release $(BUILD_OBJ_DIR)/Profile $(BUILD_OBJ_DIR)/Depend |
| 760 | $(VERB) $(RM) -f core core.[0-9][0-9]* *.o *.d *.so *~ *.flc |
| 761 | $(VERB) $(RM) -f $(LEX_OUTPUT) $(YACC_OUTPUT) |
| 762 | |
| 763 | distclean:: clean |
| 764 | $(VERB) (cd $(LLVM_SRC_ROOT); $(RM) -rf $(LEVEL)/Makefile.config \ |
| 765 | $(LEVEL)/include/Config/config.h \ |
| 766 | $(LEVEL)/autom4te.cache \ |
| 767 | $(LEVEL)/config.log) |
| 768 | |
| 769 | ########################################################################### |
| 770 | # C/C++ Dependencies |
| 771 | # Define variables and rules that generate header file dependencies |
| 772 | # from C/C++ source files. |
| 773 | ########################################################################### |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 774 | |
Chris Lattner | 694c5df | 2003-05-15 21:28:55 +0000 | [diff] [blame] | 775 | # If dependencies were generated for the file that included this file, |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 776 | # include the dependancies now... |
| 777 | # |
Chris Lattner | 694c5df | 2003-05-15 21:28:55 +0000 | [diff] [blame] | 778 | SourceBaseNames := $(basename $(notdir $(filter-out Debug/%, $(Source)))) |
John Criswell | 8bff509 | 2003-06-11 13:55:44 +0000 | [diff] [blame] | 779 | SourceDepend := $(SourceBaseNames:%=$(BUILD_OBJ_DIR)/Depend/%.d) |
Chris Lattner | 694c5df | 2003-05-15 21:28:55 +0000 | [diff] [blame] | 780 | |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 781 | # |
| 782 | # Depend target: |
| 783 | # This allows a user to manually ask for an update in the dependencies |
| 784 | # |
| 785 | depend: $(SourceDepend) |
| 786 | |
| 787 | |
Chris Lattner | 694c5df | 2003-05-15 21:28:55 +0000 | [diff] [blame] | 788 | # Create dependencies for the *.cpp files... |
| 789 | #$(SourceDepend): \x |
John Criswell | 8bff509 | 2003-06-11 13:55:44 +0000 | [diff] [blame] | 790 | $(BUILD_OBJ_DIR)/Depend/%.d: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Depend/.dir |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 791 | $(VERB) $(Depend) $< | $(SED) 's|\.o|\.lo|' | $(SED) 's|$*\.lo *|$(BUILD_OBJ_DIR)/Release/& $(BUILD_OBJ_DIR)/Profile/& $(BUILD_OBJ_DIR)/Debug/& $(BUILD_OBJ_DIR)/Depend/$(@F)|g' > $@ |
Chris Lattner | 694c5df | 2003-05-15 21:28:55 +0000 | [diff] [blame] | 792 | |
| 793 | # Create dependencies for the *.c files... |
| 794 | #$(SourceDepend): \x |
John Criswell | 8bff509 | 2003-06-11 13:55:44 +0000 | [diff] [blame] | 795 | $(BUILD_OBJ_DIR)/Depend/%.d: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Depend/.dir |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 796 | $(VERB) $(DependC) -o $@ $< | $(SED) 's|\.o|\.lo|' | $(SED) 's|$*\.lo *|$(BUILD_OBJ_DIR)/Release/& $(BUILD_OBJ_DIR)/Profile/& $(BUILD_OBJ_DIR)/Debug/& $(BUILD_OBJ_DIR)/Depend/$(@F)|g' > $@ |
Chris Lattner | 694c5df | 2003-05-15 21:28:55 +0000 | [diff] [blame] | 797 | |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 798 | # |
| 799 | # Include dependencies generated from C/C++ source files, but not if we |
| 800 | # are cleaning (this example taken from the GNU Make Manual). |
| 801 | # |
| 802 | ifneq ($(MAKECMDGOALS),clean) |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 803 | ifneq ($(SourceDepend),) |
Chris Lattner | ed03bc9 | 2002-10-25 14:32:42 +0000 | [diff] [blame] | 804 | -include $(SourceDepend) |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 805 | endif |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame^] | 806 | endif |