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