Vikram S. Adve | d60aede | 2002-07-09 12:04:21 +0000 | [diff] [blame] | 1 | #===-- Makefile.common - Common make rules for LLVM -------*- makefile -*--==== |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2 | # |
| 3 | # This file is included by all of the LLVM makefiles. This file defines common |
| 4 | # rules to do things like compile a .cpp file or generate dependancy info. |
| 5 | # These are platform dependant, so this is the file used to specify these |
| 6 | # system dependant operations. |
| 7 | # |
Vikram S. Adve | c214e71 | 2002-08-29 23:28:46 +0000 | [diff] [blame] | 8 | # The following functionality can be set by setting incoming variables. |
| 9 | # The variable $(LEVEL) *must* be set: |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 10 | # |
| 11 | # 1. LEVEL - The level of the current subdirectory from the top of the |
| 12 | # MagicStats view. This level should be expressed as a path, for |
| 13 | # example, ../.. for two levels deep. |
| 14 | # |
| 15 | # 2. DIRS - A list of subdirectories to be built. Fake targets are set up |
Chris Lattner | a8abc22 | 2002-09-18 03:22:27 +0000 | [diff] [blame] | 16 | # so that each of the targets "all", "install", and "clean" each build |
| 17 | # the subdirectories before the local target. DIRS are guaranteed to be |
| 18 | # built in order. |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 19 | # |
Chris Lattner | a8abc22 | 2002-09-18 03:22:27 +0000 | [diff] [blame] | 20 | # 3. PARALLEL_DIRS - A list of subdirectories to be built, but that may be |
| 21 | # built in any order. All DIRS are built in order before PARALLEL_DIRS are |
| 22 | # built, which are then built in any order. |
| 23 | # |
| 24 | # 4. Source - If specified, this sets the source code filenames. If this |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 25 | # is not set, it defaults to be all of the .cpp, .c, .y, and .l files |
Chris Lattner | e001059 | 2001-10-18 01:48:09 +0000 | [diff] [blame] | 26 | # in the current directory. Also, if you want to build files in addition |
| 27 | # to the local files, you can use the ExtraSource variable |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 28 | # |
Chris Lattner | 694c5df | 2003-05-15 21:28:55 +0000 | [diff] [blame] | 29 | # 5. SourceDir - If specified, this specifies a directory that the source files |
| 30 | # are in, if they are not in the current directory. This should include a |
| 31 | # trailing / character. |
| 32 | # |
Vikram S. Adve | d60aede | 2002-07-09 12:04:21 +0000 | [diff] [blame] | 33 | #===-----------------------------------------------------------------------==== |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 34 | |
Vikram S. Adve | c214e71 | 2002-08-29 23:28:46 +0000 | [diff] [blame] | 35 | # Configuration file to set paths specific to local installation of LLVM |
| 36 | # |
| 37 | include $(LEVEL)/Makefile.config |
| 38 | |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 39 | # These are options that can either be enabled here, or can be enabled on the |
Chris Lattner | 9dd794e | 2002-08-03 20:19:30 +0000 | [diff] [blame] | 40 | # make command line (ie, make ENABLE_PROFILING=1) |
| 41 | # |
| 42 | |
| 43 | # When ENABLE_PROFILING is enabled, the llvm source base is built with profile |
| 44 | # information to allow gprof to be used to get execution frequencies. |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 45 | # |
| 46 | #ENABLE_PROFILING = 1 |
Chris Lattner | 9dd794e | 2002-08-03 20:19:30 +0000 | [diff] [blame] | 47 | |
| 48 | # When ENABLE_PURIFY is enabled, the LLVM tools are linked with purify (which |
| 49 | # must be locally installed) to allow for some automated memory error debugging. |
| 50 | # |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 51 | #ENABLE_PURIFY = 1 |
Chris Lattner | 9dd794e | 2002-08-03 20:19:30 +0000 | [diff] [blame] | 52 | |
| 53 | # When ENABLE_OPTIMIZED is enabled, Release builds of all of the LLVM code are |
| 54 | # turned on, and Debug builds are turned off. |
| 55 | # |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 56 | #ENABLE_OPTIMIZED = 1 |
| 57 | |
Chris Lattner | 4bb13b8 | 2002-09-13 22:14:47 +0000 | [diff] [blame] | 58 | |
| 59 | # Figure out how to do platform specific stuff on this platform. This is really |
| 60 | # gross and should be autoconfiscated (automake actually), but should hopefully |
| 61 | # work on Linux and solaris (SunOS). |
| 62 | # |
| 63 | UNAME := $(shell uname) |
| 64 | include $(LEVEL)/Makefile.$(UNAME) |
| 65 | |
Chris Lattner | edf1f23 | 2002-07-23 19:21:31 +0000 | [diff] [blame] | 66 | ifdef SHARED_LIBRARY |
| 67 | # if SHARED_LIBRARY is specified, the default is to build the dynamic lib |
| 68 | dynamic :: |
| 69 | endif |
| 70 | |
Chris Lattner | b19e59c | 2001-06-29 05:20:16 +0000 | [diff] [blame] | 71 | # Default Rule: Make sure it's also a :: rule |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 72 | all :: |
| 73 | |
| 74 | # Default for install is to at least build everything... |
| 75 | install :: |
| 76 | |
Chris Lattner | e16b1b4 | 2002-08-09 15:41:55 +0000 | [diff] [blame] | 77 | |
| 78 | # Figure out which directory to build stuff into. We want to build into the |
| 79 | # /shared directory by default because it is guaranteed to be local to the |
| 80 | # current machine. |
| 81 | # |
Vikram S. Adve | c214e71 | 2002-08-29 23:28:46 +0000 | [diff] [blame] | 82 | ifeq ($(LLVM_OBJ_DIR),.) |
| 83 | BUILD_ROOT = $(LLVM_OBJ_DIR) |
| 84 | BUILD_ROOT_TOP = $(LEVEL) |
Chris Lattner | 285af38 | 2002-08-12 21:19:28 +0000 | [diff] [blame] | 85 | else |
| 86 | |
Vikram S. Adve | c214e71 | 2002-08-29 23:28:46 +0000 | [diff] [blame] | 87 | BUILD_ROOT := $(LLVM_OBJ_DIR)$(patsubst $(HOME)%,%,$(shell pwd)) |
Chris Lattner | 285af38 | 2002-08-12 21:19:28 +0000 | [diff] [blame] | 88 | |
| 89 | # Calculate the BUILD_ROOT_TOP variable, which is the top of the llvm/ tree. |
| 90 | # Note that although this is just equal to $(BUILD_ROOT)/$(LEVEL), we cannot use |
| 91 | # this expression because some of the directories on the source tree may not |
| 92 | # exist in the build tree (for example the test/ heirarchy). Thus we evaluate |
| 93 | # the directory to eliminate the ../'s |
| 94 | # |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame^] | 95 | ifdef PROJ_COMPILE |
| 96 | TOP_DIRECTORY := $(shell cd $(TOPLEVEL); pwd) |
| 97 | else |
Chris Lattner | 285af38 | 2002-08-12 21:19:28 +0000 | [diff] [blame] | 98 | TOP_DIRECTORY := $(shell cd $(LEVEL); pwd) |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame^] | 99 | endif |
| 100 | |
Vikram S. Adve | c214e71 | 2002-08-29 23:28:46 +0000 | [diff] [blame] | 101 | BUILD_ROOT_TOP := $(LLVM_OBJ_DIR)$(patsubst $(HOME)%,%,$(TOP_DIRECTORY)) |
Chris Lattner | e16b1b4 | 2002-08-09 15:41:55 +0000 | [diff] [blame] | 102 | endif |
| 103 | |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame^] | 104 | |
| 105 | |
| 106 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 107 | #-------------------------------------------------------------------- |
Vikram S. Adve | c214e71 | 2002-08-29 23:28:46 +0000 | [diff] [blame] | 108 | # Variables derived from configuration options... |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 109 | #-------------------------------------------------------------------- |
| 110 | |
| 111 | #BinInstDir=/usr/local/bin |
| 112 | #LibInstDir=/usrl/local/lib/xxx |
| 113 | #DocInstDir=/usr/doc/xxx |
| 114 | |
Vikram S. Adve | dba59ef | 2001-08-06 19:01:20 +0000 | [diff] [blame] | 115 | BURG_OPTS = -I |
| 116 | |
Vikram S. Adve | c214e71 | 2002-08-29 23:28:46 +0000 | [diff] [blame] | 117 | PURIFY := $(PURIFY) -cache-dir="$(BUILD_ROOT_TOP)/../purifycache" -chain-length="30" -messages=all |
Chris Lattner | 6e39070 | 2001-10-30 20:24:08 +0000 | [diff] [blame] | 118 | |
Chris Lattner | 760da06 | 2003-03-14 20:25:22 +0000 | [diff] [blame] | 119 | ifdef ENABLE_PROFILING |
| 120 | ENABLE_OPTIMIZED = 1 |
| 121 | CONFIGURATION := Profile |
| 122 | else |
| 123 | ifdef ENABLE_OPTIMIZED |
| 124 | CONFIGURATION := Release |
| 125 | else |
| 126 | CONFIGURATION := Debug |
| 127 | endif |
| 128 | endif |
| 129 | |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 130 | # Shorthand for commonly accessed directories |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame^] | 131 | DESTLIBDEBUG := $(BUILD_ROOT_TOP)/lib/Debug |
| 132 | DESTLIBRELEASE := $(BUILD_ROOT_TOP)/lib/Release |
| 133 | DESTLIBPROFILE := $(BUILD_ROOT_TOP)/lib/Profile |
| 134 | DESTLIBCURRENT := $(BUILD_ROOT_TOP)/lib/$(CONFIGURATION) |
| 135 | |
| 136 | ifdef PROJ_COMPILE |
| 137 | LLVMLIBDEBUGSOURCE := $(LLVM_LIB_DIR)/lib/Debug |
| 138 | LLVMLIBRELEASESOURCE := $(LLVM_LIB_DIR)/lib/Release |
| 139 | LLVMLIBPROFILESOURCE := $(LLVM_LIB_DIR)/lib/Profile |
| 140 | LLVMLIBCURRENTSOURCE := $(LLVM_LIB_DIR)/lib/$(CONFIGURATION) |
| 141 | |
| 142 | PROJLIBDEBUGSOURCE := $(BUILD_ROOT_TOP)/lib/Debug |
| 143 | PROJLIBRELEASESOURCE := $(BUILD_ROOT_TOP)/lib/Release |
| 144 | PROJLIBPROFILESOURCE := $(BUILD_ROOT_TOP)/lib/Profile |
| 145 | PROJLIBCURRENTSOURCE := $(BUILD_ROOT_TOP)/lib/$(CONFIGURATION) |
| 146 | |
| 147 | else |
| 148 | |
| 149 | LLVMLIBDEBUGSOURCE := $(BUILD_ROOT_TOP)/lib/Debug |
| 150 | LLVMLIBRELEASESOURCE := $(BUILD_ROOT_TOP)/lib/Release |
| 151 | LLVMLIBPROFILESOURCE := $(BUILD_ROOT_TOP)/lib/Profile |
| 152 | LLVMLIBCURRENTSOURCE := $(BUILD_ROOT_TOP)/lib/$(CONFIGURATION) |
| 153 | endif |
| 154 | |
Chris Lattner | 760da06 | 2003-03-14 20:25:22 +0000 | [diff] [blame] | 155 | |
Chris Lattner | 285af38 | 2002-08-12 21:19:28 +0000 | [diff] [blame] | 156 | TOOLDEBUG := $(BUILD_ROOT_TOP)/tools/Debug |
| 157 | TOOLRELEASE := $(BUILD_ROOT_TOP)/tools/Release |
Vikram S. Adve | 41e7891 | 2002-09-20 14:03:13 +0000 | [diff] [blame] | 158 | TOOLPROFILE := $(BUILD_ROOT_TOP)/tools/Profile |
Chris Lattner | 760da06 | 2003-03-14 20:25:22 +0000 | [diff] [blame] | 159 | TOOLCURRENT := $(BUILD_ROOT_TOP)/tools/$(CONFIGURATION) |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 160 | |
Misha Brukman | b5f096f | 2002-09-12 16:05:39 +0000 | [diff] [blame] | 161 | # Verbosity levels |
Chris Lattner | 760da06 | 2003-03-14 20:25:22 +0000 | [diff] [blame] | 162 | ifndef VERBOSE |
Misha Brukman | b5f096f | 2002-09-12 16:05:39 +0000 | [diff] [blame] | 163 | VERB := @ |
| 164 | endif |
| 165 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 166 | #--------------------------------------------------------- |
| 167 | # Compilation options... |
| 168 | #--------------------------------------------------------- |
| 169 | |
Chris Lattner | 9b94701 | 2002-09-19 19:42:24 +0000 | [diff] [blame] | 170 | # Special tools used while building the LLVM tree. Burg is built as part of the |
| 171 | # utils directory. |
| 172 | # |
Chris Lattner | 760da06 | 2003-03-14 20:25:22 +0000 | [diff] [blame] | 173 | BURG := $(TOOLCURRENT)/burg |
Chris Lattner | 9b94701 | 2002-09-19 19:42:24 +0000 | [diff] [blame] | 174 | RunBurg := $(BURG) $(BURG_OPTS) |
| 175 | |
Vikram S. Adve | dba59ef | 2001-08-06 19:01:20 +0000 | [diff] [blame] | 176 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 177 | # Enable this for profiling support with 'gprof' |
Vikram S. Adve | 41e7891 | 2002-09-20 14:03:13 +0000 | [diff] [blame] | 178 | # This automatically enables optimized builds. |
Chris Lattner | 18f4701 | 2002-05-10 18:51:54 +0000 | [diff] [blame] | 179 | ifdef ENABLE_PROFILING |
Vikram S. Adve | 41e7891 | 2002-09-20 14:03:13 +0000 | [diff] [blame] | 180 | PROFILE = -pg |
Chris Lattner | 18f4701 | 2002-05-10 18:51:54 +0000 | [diff] [blame] | 181 | endif |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 182 | |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame^] | 183 | #if PROJDIR is defined then we include PROJ DIR includes and libraries |
| 184 | ifndef PROJ_COMPILE |
| 185 | PROJ_INCLUDE = "." |
| 186 | else |
| 187 | PROJ_INCLUDE = $(PROJ_DIR)/include |
| 188 | endif |
| 189 | |
Vikram S. Adve | feeae58 | 2002-09-18 11:55:13 +0000 | [diff] [blame] | 190 | # By default, strip symbol information from executable |
Chris Lattner | 760da06 | 2003-03-14 20:25:22 +0000 | [diff] [blame] | 191 | ifndef KEEP_SYMBOLS |
Chris Lattner | 527002c | 2003-01-31 19:00:26 +0000 | [diff] [blame] | 192 | STRIP = $(PLATFORMSTRIPOPTS) |
| 193 | STRIP_WARN_MSG = "(without symbols) " |
Vikram S. Adve | feeae58 | 2002-09-18 11:55:13 +0000 | [diff] [blame] | 194 | endif |
| 195 | |
Chris Lattner | 73e1d0f | 2002-09-13 16:02:26 +0000 | [diff] [blame] | 196 | # Allow gnu extensions... |
| 197 | CPPFLAGS += -D_GNU_SOURCE |
| 198 | |
Chris Lattner | c7acf81 | 2002-01-23 05:46:01 +0000 | [diff] [blame] | 199 | # -Wno-unused-parameter |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame^] | 200 | CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused -I$(LEVEL)/include -I$(PROJ_INCLUDE) |
Chris Lattner | 1d1e5b5 | 2003-02-13 16:56:30 +0000 | [diff] [blame] | 201 | CompileOptimizeOpts := -O3 -DNDEBUG -finline-functions -fshort-enums |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 202 | |
Chris Lattner | 172b648 | 2002-09-22 02:47:15 +0000 | [diff] [blame] | 203 | # Compile a cpp file, don't link... |
Chris Lattner | 285af38 | 2002-08-12 21:19:28 +0000 | [diff] [blame] | 204 | Compile := $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(CompileCommonOpts) |
| 205 | CompileG := $(Compile) -g -D_DEBUG |
Chris Lattner | 1d1e5b5 | 2003-02-13 16:56:30 +0000 | [diff] [blame] | 206 | CompileO := $(Compile) $(CompileOptimizeOpts) -felide-constructors -fomit-frame-pointer |
| 207 | CompileP := $(Compile) $(CompileOptimizeOpts) -felide-constructors $(PROFILE) |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 208 | |
Chris Lattner | 172b648 | 2002-09-22 02:47:15 +0000 | [diff] [blame] | 209 | # Compile a c file, don't link... |
| 210 | CompileC := $(CC) -c $(CPPFLAGS) $(CCFLAGS) $(CompileCommonOpts) |
| 211 | CompileCG := $(CompileC) -g -D_DEBUG |
Chris Lattner | fe95dae | 2003-02-19 22:12:20 +0000 | [diff] [blame] | 212 | CompileCO := $(CompileC) $(CompileOptimizeOpts) -fomit-frame-pointer |
| 213 | CompileCP := $(CompileC) $(CompileOptimizeOpts) $(PROFILE) |
Chris Lattner | 172b648 | 2002-09-22 02:47:15 +0000 | [diff] [blame] | 214 | |
| 215 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 216 | # Link final executable |
Chris Lattner | 6e39070 | 2001-10-30 20:24:08 +0000 | [diff] [blame] | 217 | |
Chris Lattner | 1917e95 | 2002-07-31 21:32:05 +0000 | [diff] [blame] | 218 | ifdef ENABLE_PURIFY # To enable purify, build with 'gmake ENABLE_PURIFY=1' |
Vikram S. Adve | 41e7891 | 2002-09-20 14:03:13 +0000 | [diff] [blame] | 219 | Link := $(PURIFY) $(CXX) -static |
Chris Lattner | 12604ed | 2002-04-05 18:56:58 +0000 | [diff] [blame] | 220 | else |
Vikram S. Adve | 41e7891 | 2002-09-20 14:03:13 +0000 | [diff] [blame] | 221 | Link := $(CXX) |
Chris Lattner | 12604ed | 2002-04-05 18:56:58 +0000 | [diff] [blame] | 222 | endif |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame^] | 223 | |
| 224 | ifdef PROJ_COMPILE |
| 225 | LinkG := $(Link) -g -L$(PROJLIBDEBUGSOURCE) -L$(LLVMLIBDEBUGSOURCE) $(STRIP) |
| 226 | LinkO := $(Link) -O3 -L$(PROJLIBRELEASESOURCE) -L$(LLVMLIBRELEASESOURCE) |
| 227 | LinkP := $(Link) -O3 -L$(PROJLIBPROFILESOURCE) -L$(LLVMLIBPROFILESOURCE) $(PROFILE) |
| 228 | else |
| 229 | LinkG := $(Link) -g -L$(LLVMLIBDEBUGSOURCE) $(STRIP) |
| 230 | LinkO := $(Link) -O3 -L$(LLVMLIBRELEASESOURCE) |
| 231 | LinkP := $(Link) -O3 -L$(LLVMLIBPROFILESOURCE) $(PROFILE) |
| 232 | endif |
| 233 | |
| 234 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 235 | |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 236 | # Create one .o file from a bunch of .o files... |
| 237 | Relink = ld -r |
| 238 | |
Chris Lattner | 4bb13b8 | 2002-09-13 22:14:47 +0000 | [diff] [blame] | 239 | # MakeSO - Create a .so file from a .o files... |
Vikram S. Adve | 41e7891 | 2002-09-20 14:03:13 +0000 | [diff] [blame] | 240 | MakeSO := $(CXX) $(MakeSharedObjectOption) |
Chris Lattner | 4bb13b8 | 2002-09-13 22:14:47 +0000 | [diff] [blame] | 241 | MakeSOO := $(MakeSO) -O3 |
Vikram S. Adve | 41e7891 | 2002-09-20 14:03:13 +0000 | [diff] [blame] | 242 | MakeSOP := $(MakeSOO) $(PROFILE) |
Chris Lattner | 4bb13b8 | 2002-09-13 22:14:47 +0000 | [diff] [blame] | 243 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 244 | # Create dependancy file from CPP file, send to stdout. |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame^] | 245 | Depend := $(CXX) -MM -I$(LEVEL)/include -I$(PROJ_INCLUDE) $(CPPFLAGS) |
| 246 | DependC := $(CC) -MM -I$(LEVEL)/include -I$(PROJ_INCLUDE) $(CPPFLAGS) |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 247 | |
| 248 | # Archive a bunch of .o files into a .a file... |
| 249 | AR = ar cq |
Chris Lattner | 172b648 | 2002-09-22 02:47:15 +0000 | [diff] [blame] | 250 | BISON = bison |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 251 | |
| 252 | #---------------------------------------------------------- |
| 253 | |
| 254 | # Source includes all of the cpp files, and objects are derived from the |
| 255 | # source files... |
Chris Lattner | e001059 | 2001-10-18 01:48:09 +0000 | [diff] [blame] | 256 | # The local Makefile can list other Source files via ExtraSource = ... |
Vikram S. Adve | c4bed34 | 2001-10-17 12:33:55 +0000 | [diff] [blame] | 257 | # |
Vikram S. Adve | ad9ea7e | 2002-10-14 16:40:04 +0000 | [diff] [blame] | 258 | ifndef Source |
Chris Lattner | e001059 | 2001-10-18 01:48:09 +0000 | [diff] [blame] | 259 | Source := $(ExtraSource) $(wildcard *.cpp *.c *.y *.l) |
Vikram S. Adve | ad9ea7e | 2002-10-14 16:40:04 +0000 | [diff] [blame] | 260 | endif |
Vikram S. Adve | 112a72c | 2001-07-15 13:16:47 +0000 | [diff] [blame] | 261 | |
Chris Lattner | 694c5df | 2003-05-15 21:28:55 +0000 | [diff] [blame] | 262 | Objs := $(sort $(patsubst Debug/%.o, %.o, $(addsuffix .o,$(notdir $(basename $(Source)))))) |
Vikram S. Adve | 41e7891 | 2002-09-20 14:03:13 +0000 | [diff] [blame] | 263 | ObjectsO := $(addprefix $(BUILD_ROOT)/Release/,$(Objs)) |
| 264 | ObjectsP := $(addprefix $(BUILD_ROOT)/Profile/,$(Objs)) |
Chris Lattner | 9b94701 | 2002-09-19 19:42:24 +0000 | [diff] [blame] | 265 | ObjectsG := $(addprefix $(BUILD_ROOT)/Debug/,$(Objs)) |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 266 | |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 267 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 268 | #--------------------------------------------------------- |
Chris Lattner | a8abc22 | 2002-09-18 03:22:27 +0000 | [diff] [blame] | 269 | # Handle the DIRS and PARALLEL_DIRS options |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 270 | #--------------------------------------------------------- |
| 271 | |
Anand Shukla | 7c7a07e | 2002-09-18 04:29:30 +0000 | [diff] [blame] | 272 | ifdef DIRS |
Chris Lattner | dc95ade | 2003-01-16 20:02:30 +0000 | [diff] [blame] | 273 | all install clean test :: |
Chris Lattner | 16d1f73 | 2002-09-17 23:45:34 +0000 | [diff] [blame] | 274 | $(VERB) for dir in ${DIRS}; do \ |
Chris Lattner | f1ffd99 | 2002-09-17 23:35:02 +0000 | [diff] [blame] | 275 | (cd $$dir; $(MAKE) $@) || exit 1; \ |
| 276 | done |
Anand Shukla | 7c7a07e | 2002-09-18 04:29:30 +0000 | [diff] [blame] | 277 | endif |
Chris Lattner | a8abc22 | 2002-09-18 03:22:27 +0000 | [diff] [blame] | 278 | |
| 279 | # Handle PARALLEL_DIRS |
| 280 | ifdef PARALLEL_DIRS |
| 281 | all :: $(addsuffix /.makeall , $(PARALLEL_DIRS)) |
| 282 | install :: $(addsuffix /.makeinstall, $(PARALLEL_DIRS)) |
| 283 | clean :: $(addsuffix /.makeclean , $(PARALLEL_DIRS)) |
Chris Lattner | dc95ade | 2003-01-16 20:02:30 +0000 | [diff] [blame] | 284 | test :: $(addsuffix /.maketest , $(PARALLEL_DIRS)) |
Chris Lattner | a8abc22 | 2002-09-18 03:22:27 +0000 | [diff] [blame] | 285 | |
Chris Lattner | dc95ade | 2003-01-16 20:02:30 +0000 | [diff] [blame] | 286 | %/.makeall %/.makeinstall %/.makeclean %/.maketest: |
Chris Lattner | a8abc22 | 2002-09-18 03:22:27 +0000 | [diff] [blame] | 287 | $(VERB) cd $(@D); $(MAKE) $(subst $(@D)/.make,,$@) |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 288 | endif |
| 289 | |
| 290 | #--------------------------------------------------------- |
| 291 | # Handle the LIBRARYNAME option - used when building libs... |
| 292 | #--------------------------------------------------------- |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 293 | # |
| 294 | # When libraries are built, they are allowed to optionally define the |
| 295 | # DONT_BUILD_RELINKED make variable, which, when defined, prevents a .o file |
| 296 | # from being built for the library. This .o files may then be linked to by a |
| 297 | # tool if the tool does not need (or want) the semantics a .a file provides |
| 298 | # (linking in only object files that are "needed"). If a library is never to |
| 299 | # be used in this way, it is better to define DONT_BUILD_RELINKED, and define |
| 300 | # BUILD_ARCHIVE instead. |
| 301 | # |
| 302 | # 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] | 303 | # 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] | 304 | # linked into tools (for example gccas) even if they only use one of the parts |
| 305 | # of it. For this reason, sometimes it's useful to use libraries as .a files. |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 306 | |
| 307 | ifdef LIBRARYNAME |
Vikram S. Adve | 112a72c | 2001-07-15 13:16:47 +0000 | [diff] [blame] | 308 | |
Chris Lattner | 2a548c5 | 2002-09-16 22:36:42 +0000 | [diff] [blame] | 309 | # Make sure there isn't any extranous whitespace on the LIBRARYNAME option |
Chris Lattner | ccb4ebd | 2002-09-16 22:34:56 +0000 | [diff] [blame] | 310 | LIBRARYNAME := $(strip $(LIBRARYNAME)) |
| 311 | |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame^] | 312 | LIBNAME_O := $(DESTLIBRELEASE)/lib$(LIBRARYNAME).so |
| 313 | LIBNAME_P := $(DESTLIBPROFILE)/lib$(LIBRARYNAME).so |
| 314 | LIBNAME_G := $(DESTLIBDEBUG)/lib$(LIBRARYNAME).so |
| 315 | LIBNAME_AO := $(DESTLIBRELEASE)/lib$(LIBRARYNAME).a |
| 316 | LIBNAME_AP := $(DESTLIBPROFILE)/lib$(LIBRARYNAME).a |
| 317 | LIBNAME_AG := $(DESTLIBDEBUG)/lib$(LIBRARYNAME).a |
| 318 | LIBNAME_OBJO := $(DESTLIBRELEASE)/$(LIBRARYNAME).o |
| 319 | LIBNAME_OBJP := $(DESTLIBPROFILE)/$(LIBRARYNAME).o |
| 320 | LIBNAME_OBJG := $(DESTLIBDEBUG)/$(LIBRARYNAME).o |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 321 | |
Chris Lattner | 760da06 | 2003-03-14 20:25:22 +0000 | [diff] [blame] | 322 | # dynamic target builds a shared object version of the library... |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame^] | 323 | dynamic:: $(DESTLIBCURRENT)/lib$(LIBRARYNAME).so |
Vikram S. Adve | 60f5606 | 2002-08-02 18:34:12 +0000 | [diff] [blame] | 324 | |
Chris Lattner | 760da06 | 2003-03-14 20:25:22 +0000 | [diff] [blame] | 325 | # Does the library want a .o version built? |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 326 | ifndef DONT_BUILD_RELINKED |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame^] | 327 | all:: $(DESTLIBCURRENT)/$(LIBRARYNAME).o |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 328 | endif |
Chris Lattner | 760da06 | 2003-03-14 20:25:22 +0000 | [diff] [blame] | 329 | |
| 330 | # Does the library want an archive version built? |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 331 | ifdef BUILD_ARCHIVE |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame^] | 332 | all:: $(DESTLIBCURRENT)/lib$(LIBRARYNAME).a |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 333 | endif |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 334 | |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame^] | 335 | $(LIBNAME_O): $(ObjectsO) $(LibSubDirs) $(DESTLIBRELEASE)/.dir |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 336 | @echo ======= Linking $(LIBRARYNAME) release library ======= |
Misha Brukman | b5f096f | 2002-09-12 16:05:39 +0000 | [diff] [blame] | 337 | $(VERB) $(MakeSOO) -o $@ $(ObjectsO) $(LibSubDirs) $(LibLinkOpts) |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 338 | |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame^] | 339 | $(LIBNAME_P): $(ObjectsP) $(LibSubDirs) $(DESTLIBPROFILE)/.dir |
Vikram S. Adve | 41e7891 | 2002-09-20 14:03:13 +0000 | [diff] [blame] | 340 | @echo ======= Linking $(LIBRARYNAME) profile library ======= |
| 341 | $(VERB) $(MakeSOP) -o $@ $(ObjectsP) $(LibSubDirs) $(LibLinkOpts) |
| 342 | |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame^] | 343 | $(LIBNAME_G): $(ObjectsG) $(LibSubDirs) $(DESTLIBDEBUG)/.dir |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 344 | @echo ======= Linking $(LIBRARYNAME) debug library ======= |
Misha Brukman | b5f096f | 2002-09-12 16:05:39 +0000 | [diff] [blame] | 345 | $(VERB) $(MakeSO) -g -o $@ $(ObjectsG) $(LibSubDirs) $(LibLinkOpts) |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 346 | |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame^] | 347 | $(LIBNAME_AO): $(ObjectsO) $(LibSubDirs) $(DESTLIBRELEASE)/.dir |
Vikram S. Adve | 112a72c | 2001-07-15 13:16:47 +0000 | [diff] [blame] | 348 | @echo ======= Linking $(LIBRARYNAME) release library ======= |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 349 | @rm -f $@ |
Misha Brukman | b5f096f | 2002-09-12 16:05:39 +0000 | [diff] [blame] | 350 | $(VERB) $(AR) $@ $(ObjectsO) $(LibSubDirs) |
Vikram S. Adve | 112a72c | 2001-07-15 13:16:47 +0000 | [diff] [blame] | 351 | |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame^] | 352 | $(LIBNAME_AP): $(ObjectsP) $(LibSubDirs) $(DESTLIBPROFILE)/.dir |
Vikram S. Adve | 41e7891 | 2002-09-20 14:03:13 +0000 | [diff] [blame] | 353 | @echo ======= Linking $(LIBRARYNAME) profile library ======= |
| 354 | @rm -f $@ |
| 355 | $(VERB) $(AR) $@ $(ObjectsP) $(LibSubDirs) |
| 356 | |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame^] | 357 | $(LIBNAME_AG): $(ObjectsG) $(LibSubDirs) $(DESTLIBDEBUG)/.dir |
Vikram S. Adve | 112a72c | 2001-07-15 13:16:47 +0000 | [diff] [blame] | 358 | @echo ======= Linking $(LIBRARYNAME) debug library ======= |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 359 | @rm -f $@ |
Misha Brukman | b5f096f | 2002-09-12 16:05:39 +0000 | [diff] [blame] | 360 | $(VERB) $(AR) $@ $(ObjectsG) $(LibSubDirs) |
Vikram S. Adve | 112a72c | 2001-07-15 13:16:47 +0000 | [diff] [blame] | 361 | |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame^] | 362 | $(LIBNAME_OBJO): $(ObjectsO) $(LibSubDirs) $(DESTLIBRELEASE)/.dir |
Misha Brukman | b5f096f | 2002-09-12 16:05:39 +0000 | [diff] [blame] | 363 | @echo "Linking $@" |
| 364 | $(VERB) $(Relink) -o $@ $(ObjectsO) $(LibSubDirs) |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 365 | |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame^] | 366 | $(LIBNAME_OBJP): $(ObjectsP) $(LibSubDirs) $(DESTLIBPROFILE)/.dir |
Vikram S. Adve | 41e7891 | 2002-09-20 14:03:13 +0000 | [diff] [blame] | 367 | @echo "Linking $@" |
| 368 | $(VERB) $(Relink) -o $@ $(ObjectsP) $(LibSubDirs) |
| 369 | |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame^] | 370 | $(LIBNAME_OBJG): $(ObjectsG) $(LibSubDirs) $(DESTLIBDEBUG)/.dir |
Chris Lattner | 9e39816 | 2002-09-25 17:15:22 +0000 | [diff] [blame] | 371 | @echo "Linking $@" |
Misha Brukman | b5f096f | 2002-09-12 16:05:39 +0000 | [diff] [blame] | 372 | $(VERB) $(Relink) -o $@ $(ObjectsG) $(LibSubDirs) |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 373 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 374 | endif |
| 375 | |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 376 | #------------------------------------------------------------------------ |
Vikram S. Adve | 0193d5e | 2001-10-10 22:35:00 +0000 | [diff] [blame] | 377 | # Create a TAGS database for emacs |
| 378 | #------------------------------------------------------------------------ |
| 379 | |
Vikram S. Adve | 022d06c | 2001-10-13 12:26:59 +0000 | [diff] [blame] | 380 | ifeq ($(LEVEL), .) |
Vikram S. Adve | 022d06c | 2001-10-13 12:26:59 +0000 | [diff] [blame] | 381 | tags: |
Chris Lattner | 18f4701 | 2002-05-10 18:51:54 +0000 | [diff] [blame] | 382 | etags -l c++ `find include lib tools -name '*.cpp' -o -name '*.h'` |
Vikram S. Adve | 022d06c | 2001-10-13 12:26:59 +0000 | [diff] [blame] | 383 | all:: tags |
Vikram S. Adve | 022d06c | 2001-10-13 12:26:59 +0000 | [diff] [blame] | 384 | endif |
Vikram S. Adve | 0193d5e | 2001-10-10 22:35:00 +0000 | [diff] [blame] | 385 | |
| 386 | #------------------------------------------------------------------------ |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 387 | # Handle the TOOLNAME option - used when building tool executables... |
| 388 | #------------------------------------------------------------------------ |
| 389 | # |
| 390 | # 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] | 391 | # libraries (and the order of the libs) that should be linked to the |
| 392 | # tool. USEDLIBS should contain a list of library names (some with .a extension) |
| 393 | # 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] | 394 | # |
| 395 | ifdef TOOLNAME |
| 396 | |
| 397 | # TOOLEXENAME* - These compute the output filenames to generate... |
Chris Lattner | 285af38 | 2002-08-12 21:19:28 +0000 | [diff] [blame] | 398 | TOOLEXENAME_G := $(BUILD_ROOT_TOP)/tools/Debug/$(TOOLNAME) |
| 399 | TOOLEXENAME_O := $(BUILD_ROOT_TOP)/tools/Release/$(TOOLNAME) |
Vikram S. Adve | 41e7891 | 2002-09-20 14:03:13 +0000 | [diff] [blame] | 400 | TOOLEXENAME_P := $(BUILD_ROOT_TOP)/tools/Profile/$(TOOLNAME) |
Chris Lattner | 760da06 | 2003-03-14 20:25:22 +0000 | [diff] [blame] | 401 | TOOLEXENAMES := $(BUILD_ROOT_TOP)/tools/$(CONFIGURATION)/$(TOOLNAME) |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 402 | |
| 403 | # USED_LIBS_OPTIONS - Compute the options line that add -llib1 -llib2, etc. |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame^] | 404 | ifdef PROJ_COMPILE |
| 405 | |
| 406 | PROJ_LIBS_OPTIONS := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS))) |
| 407 | PROJ_LIBS_OPTIONS_G := $(patsubst %.o, $(PROJLIBDEBUGSOURCE)/%.o, $(PROJ_LIBS_OPTIONS)) |
| 408 | PROJ_LIBS_OPTIONS_O := $(patsubst %.o, $(PROJLIBRELEASESOURCE)/%.o,$(PROJ_LIBS_OPTIONS)) |
| 409 | PROJ_LIBS_OPTIONS_P := $(patsubst %.o, $(PROJLIBPROFILESOURCE)/%.o,$(PROJ_LIBS_OPTIONS)) |
| 410 | |
| 411 | LLVM_LIBS_OPTIONS := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS))) |
| 412 | LLVM_LIBS_OPTIONS_G := $(patsubst %.o, $(LLVMLIBDEBUGSOURCE)/%.o, $(LLVM_LIBS_OPTIONS)) |
| 413 | LLVM_LIBS_OPTIONS_O := $(patsubst %.o, $(LLVMLIBRELEASESOURCE)/%.o,$(LLVM_LIBS_OPTIONS)) |
| 414 | LLVM_LIBS_OPTIONS_P := $(patsubst %.o, $(LLVMLIBPROFILESOURCE)/%.o,$(LLVM_LIBS_OPTIONS)) |
| 415 | |
| 416 | LIB_OPTS_G := $(LLVM_LIBS_OPTIONS_G) $(PROJ_LIBS_OPTIONS_G) |
| 417 | LIB_OPTS_O := $(LLVM_LIBS_OPTIONS_O) $(PROJ_LIBS_OPTIONS_P) |
| 418 | LIB_OPTS_P := $(LLVM_LIBS_OPTIONS_P) $(PROJ_LIBS_OPTIONS_P) |
| 419 | |
| 420 | else |
| 421 | |
| 422 | LLVM_LIBS_OPTIONS := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS))) |
| 423 | LLVM_LIBS_OPTIONS_G := $(patsubst %.o, $(LLVMLIBDEBUGSOURCE)/%.o, $(LLVM_LIBS_OPTIONS)) |
| 424 | LLVM_LIBS_OPTIONS_O := $(patsubst %.o, $(LLVMLIBRELEASESOURCE)/%.o,$(LLVM_LIBS_OPTIONS)) |
| 425 | LLVM_LIBS_OPTIONS_P := $(patsubst %.o, $(LLVMLIBPROFILESOURCE)/%.o,$(LLVM_LIBS_OPTIONS)) |
| 426 | |
| 427 | LIB_OPTS_G := $(LLVM_LIBS_OPTIONS_G) |
| 428 | LIB_OPTS_O := $(LLVM_LIBS_OPTIONS_O) |
| 429 | LIB_OPTS_P := $(LLVM_LIBS_OPTIONS_P) |
| 430 | endif |
| 431 | |
| 432 | |
| 433 | |
| 434 | |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 435 | |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 436 | |
| 437 | # 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] | 438 | # rebuilt if libraries change. This has to make sure to handle .a/.so and .o |
| 439 | # files seperately. |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 440 | # |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 441 | STATICUSEDLIBS := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS))) |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame^] | 442 | USED_LIB_PATHS_G := $(addprefix $(DESTLIBDEBUG)/, $(STATICUSEDLIBS)) |
| 443 | USED_LIB_PATHS_O := $(addprefix $(DESTLIBRELEASE)/, $(STATICUSEDLIBS)) |
| 444 | USED_LIB_PATHS_P := $(addprefix $(DESTLIBPROFILE)/, $(STATICUSEDLIBS)) |
Chris Lattner | 1c58850 | 2002-11-04 20:50:33 +0000 | [diff] [blame] | 445 | LINK_OPTS := $(TOOLLINKOPTS) $(PLATFORMLINKOPTS) |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 446 | |
Chris Lattner | 8d7dfb3 | 2003-01-22 16:13:31 +0000 | [diff] [blame] | 447 | |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame^] | 448 | |
| 449 | |
| 450 | |
| 451 | |
Chris Lattner | 8d7dfb3 | 2003-01-22 16:13:31 +0000 | [diff] [blame] | 452 | # Tell make that we need to rebuild subdirectories before we can link the tool. |
| 453 | # This affects things like LLI which has library subdirectories. |
| 454 | $(USED_LIB_PATHS_G) $(USED_LIB_PATHS_O) $(USED_LIB_PATHS_P): \ |
| 455 | $(addsuffix /.makeall, $(PARALLEL_DIRS)) |
| 456 | |
Chris Lattner | 669bd7c | 2001-10-13 05:10:29 +0000 | [diff] [blame] | 457 | all:: $(TOOLEXENAMES) |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 458 | clean:: |
Misha Brukman | b5f096f | 2002-09-12 16:05:39 +0000 | [diff] [blame] | 459 | $(VERB) rm -f $(TOOLEXENAMES) |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 460 | |
Chris Lattner | 8d7dfb3 | 2003-01-22 16:13:31 +0000 | [diff] [blame] | 461 | $(TOOLEXENAME_G): $(ObjectsG) $(USED_LIB_PATHS_G) $(TOOLDEBUG)/.dir |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame^] | 462 | @echo ======= Linking $(TOOLNAME) debug executable $(STRIP_WARN_MSG)======= |
| 463 | $(VERB) $(LinkG) -o $@ $(ObjectsG) $(LIB_OPTS_G) $(LINK_OPTS) |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 464 | |
Chris Lattner | 8d7dfb3 | 2003-01-22 16:13:31 +0000 | [diff] [blame] | 465 | $(TOOLEXENAME_O): $(ObjectsO) $(USED_LIB_PATHS_O) $(TOOLRELEASE)/.dir |
Chris Lattner | 287d443 | 2002-09-12 17:02:40 +0000 | [diff] [blame] | 466 | @echo ======= Linking $(TOOLNAME) release executable ======= |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame^] | 467 | $(VERB) $(LinkO) -o $@ $(ObjectsO) $(LIB_OPTS_O) $(LINK_OPTS) |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 468 | |
Chris Lattner | 8d7dfb3 | 2003-01-22 16:13:31 +0000 | [diff] [blame] | 469 | $(TOOLEXENAME_P): $(ObjectsP) $(USED_LIB_PATHS_P) $(TOOLPROFILE)/.dir |
Vikram S. Adve | 41e7891 | 2002-09-20 14:03:13 +0000 | [diff] [blame] | 470 | @echo ======= Linking $(TOOLNAME) profile executable ======= |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame^] | 471 | $(VERB) $(LinkP) -o $@ $(ObjectsP) $(LIB_OPTS_P) $(LINK_OPTS) |
Vikram S. Adve | 41e7891 | 2002-09-20 14:03:13 +0000 | [diff] [blame] | 472 | |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 473 | endif |
| 474 | |
| 475 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 476 | |
| 477 | #--------------------------------------------------------- |
Chris Lattner | e16b1b4 | 2002-08-09 15:41:55 +0000 | [diff] [blame] | 478 | .PRECIOUS: $(BUILD_ROOT)/Depend/.dir |
| 479 | .PRECIOUS: $(BUILD_ROOT)/Debug/.dir $(BUILD_ROOT)/Release/.dir |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 480 | |
Vikram S. Adve | 112a72c | 2001-07-15 13:16:47 +0000 | [diff] [blame] | 481 | # Create .o files in the ObjectFiles directory from the .cpp and .c files... |
Chris Lattner | 694c5df | 2003-05-15 21:28:55 +0000 | [diff] [blame] | 482 | $(BUILD_ROOT)/Release/%.o: $(SourceDir)%.cpp $(BUILD_ROOT)/Release/.dir |
Misha Brukman | b5f096f | 2002-09-12 16:05:39 +0000 | [diff] [blame] | 483 | @echo "Compiling $<" |
| 484 | $(VERB) $(CompileO) $< -o $@ |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 485 | |
Chris Lattner | 694c5df | 2003-05-15 21:28:55 +0000 | [diff] [blame] | 486 | $(BUILD_ROOT)/Release/%.o: $(SourceDir)%.c $(BUILD_ROOT)/Release/.dir |
Chris Lattner | 1eeac66 | 2002-10-22 23:28:23 +0000 | [diff] [blame] | 487 | $(VERB) $(CompileCO) $< -o $@ |
Vikram S. Adve | 112a72c | 2001-07-15 13:16:47 +0000 | [diff] [blame] | 488 | |
Chris Lattner | 694c5df | 2003-05-15 21:28:55 +0000 | [diff] [blame] | 489 | $(BUILD_ROOT)/Profile/%.o: $(SourceDir)%.cpp $(BUILD_ROOT)/Profile/.dir |
Vikram S. Adve | 41e7891 | 2002-09-20 14:03:13 +0000 | [diff] [blame] | 490 | @echo "Compiling $<" |
| 491 | $(VERB) $(CompileP) $< -o $@ |
| 492 | |
Chris Lattner | 694c5df | 2003-05-15 21:28:55 +0000 | [diff] [blame] | 493 | $(BUILD_ROOT)/Profile/%.o: $(SourceDir)%.c $(BUILD_ROOT)/Profile/.dir |
Chris Lattner | 172b648 | 2002-09-22 02:47:15 +0000 | [diff] [blame] | 494 | @echo "Compiling $<" |
| 495 | $(VERB) $(CompileCP) $< -o $@ |
| 496 | |
Chris Lattner | 694c5df | 2003-05-15 21:28:55 +0000 | [diff] [blame] | 497 | $(BUILD_ROOT)/Debug/%.o: $(SourceDir)%.cpp $(BUILD_ROOT)/Debug/.dir |
Misha Brukman | b5f096f | 2002-09-12 16:05:39 +0000 | [diff] [blame] | 498 | @echo "Compiling $<" |
| 499 | $(VERB) $(CompileG) $< -o $@ |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 500 | |
Chris Lattner | 694c5df | 2003-05-15 21:28:55 +0000 | [diff] [blame] | 501 | $(BUILD_ROOT)/Debug/%.o: $(SourceDir)%.c $(BUILD_ROOT)/Debug/.dir |
Chris Lattner | 172b648 | 2002-09-22 02:47:15 +0000 | [diff] [blame] | 502 | $(VERB) $(CompileCG) $< -o $@ |
Vikram S. Adve | 112a72c | 2001-07-15 13:16:47 +0000 | [diff] [blame] | 503 | |
Chris Lattner | e899678 | 2003-01-16 22:44:19 +0000 | [diff] [blame] | 504 | # |
| 505 | # Rules for building lex/yacc files |
| 506 | # |
| 507 | LEX_FILES = $(filter %.l, $(Source)) |
| 508 | LEX_OUTPUT = $(LEX_FILES:%.l=%.cpp) |
| 509 | YACC_FILES = $(filter %.y, $(Source)) |
| 510 | YACC_OUTPUT = $(addprefix $(YACC_FILES:%.y=%), .h .cpp .output) |
| 511 | .PRECIOUS: $(LEX_OUTPUT) $(YACC_OUTPUT) |
| 512 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 513 | # Create a .cpp source file from a flex input file... this uses sed to cut down |
| 514 | # on the warnings emited by GCC... |
Chris Lattner | 6d131b4 | 2003-01-23 16:33:10 +0000 | [diff] [blame] | 515 | # |
| 516 | # The last line is a gross hack to work around flex aparently not being able to |
| 517 | # resize the buffer on a large token input. Currently, for uninitialized string |
| 518 | # buffers in LLVM we can generate very long tokens, so this is a hack around it. |
| 519 | # FIXME. (f.e. char Buffer[10000]; ) |
| 520 | # |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 521 | %.cpp: %.l |
Chris Lattner | 6d131b4 | 2003-01-23 16:33:10 +0000 | [diff] [blame] | 522 | flex -t $< | sed '/^find_rule/d' | \ |
| 523 | sed 's/void yyunput/inline void yyunput/' | \ |
| 524 | sed 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \ |
| 525 | sed 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' > $@ |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 526 | |
| 527 | # Rule for building the bison parsers... |
Chris Lattner | 694c5df | 2003-05-15 21:28:55 +0000 | [diff] [blame] | 528 | %.c: %.y # Cancel built-in rules for yacc |
| 529 | %.h: %.y # Cancel built-in rules for yacc |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 530 | %.cpp %.h : %.y |
Chris Lattner | 694c5df | 2003-05-15 21:28:55 +0000 | [diff] [blame] | 531 | @echo Bison\'ing $<... |
Chris Lattner | e899678 | 2003-01-16 22:44:19 +0000 | [diff] [blame] | 532 | $(VERB) $(BISON) -v -d -p $(<:%Parser.y=%) $*.y |
| 533 | $(VERB) mv -f $*.tab.c $*.cpp |
| 534 | $(VERB) mv -f $*.tab.h $*.h |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 535 | |
| 536 | # To create the directories... |
| 537 | %/.dir: |
Chris Lattner | e899678 | 2003-01-16 22:44:19 +0000 | [diff] [blame] | 538 | $(VERB) mkdir -p $* |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 539 | @date > $@ |
| 540 | |
Chris Lattner | 30440c6 | 2003-01-16 21:06:18 +0000 | [diff] [blame] | 541 | # To create postscript files from dot files... |
| 542 | %.ps: %.dot |
| 543 | dot -Tps < $< > $@ |
| 544 | |
Chris Lattner | 172b648 | 2002-09-22 02:47:15 +0000 | [diff] [blame] | 545 | # 'make clean' nukes the tree |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 546 | clean:: |
Vikram S. Adve | 41e7891 | 2002-09-20 14:03:13 +0000 | [diff] [blame] | 547 | $(VERB) rm -rf $(BUILD_ROOT)/Debug $(BUILD_ROOT)/Release $(BUILD_ROOT)/Profile $(BUILD_ROOT)/Depend |
Misha Brukman | ab6d293 | 2002-12-04 17:08:15 +0000 | [diff] [blame] | 548 | $(VERB) rm -f core core.[0-9][0-9]* *.o *.d *.so *~ *.flc |
Chris Lattner | e899678 | 2003-01-16 22:44:19 +0000 | [diff] [blame] | 549 | $(VERB) rm -f $(LEX_OUTPUT) $(YACC_OUTPUT) |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 550 | |
Chris Lattner | 694c5df | 2003-05-15 21:28:55 +0000 | [diff] [blame] | 551 | # If dependencies were generated for the file that included this file, |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 552 | # include the dependancies now... |
| 553 | # |
Chris Lattner | 694c5df | 2003-05-15 21:28:55 +0000 | [diff] [blame] | 554 | SourceBaseNames := $(basename $(notdir $(filter-out Debug/%, $(Source)))) |
| 555 | SourceDepend := $(SourceBaseNames:%=$(BUILD_ROOT)/Depend/%.d) |
| 556 | |
| 557 | # Create dependencies for the *.cpp files... |
| 558 | #$(SourceDepend): \x |
| 559 | $(BUILD_ROOT)/Depend/%.d: $(SourceDir)%.cpp $(BUILD_ROOT)/Depend/.dir |
| 560 | $(VERB) $(Depend) $< | sed 's|$*\.o *|$(BUILD_ROOT)/Release/& $(BUILD_ROOT)/Profile/& $(BUILD_ROOT)/Debug/& $(BUILD_ROOT)/Depend/$(@F)|g' > $@ |
| 561 | |
| 562 | # Create dependencies for the *.c files... |
| 563 | #$(SourceDepend): \x |
| 564 | $(BUILD_ROOT)/Depend/%.d: $(SourceDir)%.c $(BUILD_ROOT)/Depend/.dir |
| 565 | $(VERB) $(DependC) $< | sed 's|$*\.o *|Release/& Profile/& Debug/& Depend/$(@F)|g' > $@ |
| 566 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 567 | ifneq ($(SourceDepend),) |
Chris Lattner | ed03bc9 | 2002-10-25 14:32:42 +0000 | [diff] [blame] | 568 | -include $(SourceDepend) |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 569 | endif |