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