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