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 | # |
| 8 | # The following functionality may be set by setting incoming variables: |
| 9 | # |
| 10 | # 1. LEVEL - The level of the current subdirectory from the top of the |
| 11 | # MagicStats view. This level should be expressed as a path, for |
| 12 | # example, ../.. for two levels deep. |
| 13 | # |
| 14 | # 2. DIRS - A list of subdirectories to be built. Fake targets are set up |
| 15 | # so that each of the targets "all", "install", and "clean" each build. |
| 16 | # the subdirectories before the local target. |
| 17 | # |
| 18 | # 3. Source - If specified, this sets the source code filenames. If this |
| 19 | # 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] | 20 | # in the current directory. Also, if you want to build files in addition |
| 21 | # to the local files, you can use the ExtraSource variable |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 22 | # |
Vikram S. Adve | d60aede | 2002-07-09 12:04:21 +0000 | [diff] [blame] | 23 | #===-----------------------------------------------------------------------==== |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 24 | |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 25 | # These are options that can either be enabled here, or can be enabled on the |
| 26 | # make command line (make ENABLE_PROFILING=1) |
| 27 | # |
| 28 | #ENABLE_PROFILING = 1 |
| 29 | #ENABLE_PURIFY = 1 |
| 30 | #ENABLE_OPTIMIZED = 1 |
| 31 | |
Chris Lattner | edf1f23 | 2002-07-23 19:21:31 +0000 | [diff] [blame] | 32 | ifdef SHARED_LIBRARY |
| 33 | # if SHARED_LIBRARY is specified, the default is to build the dynamic lib |
| 34 | dynamic :: |
| 35 | endif |
| 36 | |
Chris Lattner | b19e59c | 2001-06-29 05:20:16 +0000 | [diff] [blame] | 37 | # Default Rule: Make sure it's also a :: rule |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 38 | all :: |
| 39 | |
| 40 | # Default for install is to at least build everything... |
| 41 | install :: |
| 42 | |
| 43 | #-------------------------------------------------------------------- |
| 44 | # Installation configuration options... |
| 45 | #-------------------------------------------------------------------- |
| 46 | |
| 47 | #BinInstDir=/usr/local/bin |
| 48 | #LibInstDir=/usrl/local/lib/xxx |
| 49 | #DocInstDir=/usr/doc/xxx |
| 50 | |
Vikram S. Adve | dba59ef | 2001-08-06 19:01:20 +0000 | [diff] [blame] | 51 | BURG = /home/vadve/vadve/Research/DynOpt/Burg/burg |
| 52 | BURG_OPTS = -I |
| 53 | |
Chris Lattner | 6e39070 | 2001-10-30 20:24:08 +0000 | [diff] [blame] | 54 | |
Chris Lattner | ec6bed2 | 2002-04-07 06:18:40 +0000 | [diff] [blame] | 55 | PURIFY = /usr/dcs/applications/purify/bin/purify -cache-dir="$(HOME)/purifycache" -chain-length="30" -messages=all |
Chris Lattner | 6e39070 | 2001-10-30 20:24:08 +0000 | [diff] [blame] | 56 | |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 57 | # Shorthand for commonly accessed directories |
| 58 | LIBDEBUG = $(LEVEL)/lib/Debug |
| 59 | LIBRELEASE = $(LEVEL)/lib/Release |
| 60 | TOOLDEBUG = $(LEVEL)/tools/Debug |
| 61 | TOOLRELEASE = $(LEVEL)/tools/Release |
| 62 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 63 | #--------------------------------------------------------- |
| 64 | # Compilation options... |
| 65 | #--------------------------------------------------------- |
| 66 | |
Vikram S. Adve | dba59ef | 2001-08-06 19:01:20 +0000 | [diff] [blame] | 67 | # Special tools used while building |
| 68 | RunBurg = $(BURG) $(BURG_OPTS) |
| 69 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 70 | # Enable this for profiling support with 'gprof' |
Chris Lattner | 18f4701 | 2002-05-10 18:51:54 +0000 | [diff] [blame] | 71 | ifdef ENABLE_PROFILING |
| 72 | PROFILE = -pg |
| 73 | else |
| 74 | PROFILE = |
| 75 | endif |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 76 | |
Chris Lattner | c7acf81 | 2002-01-23 05:46:01 +0000 | [diff] [blame] | 77 | # -Wno-unused-parameter |
Chris Lattner | 18f4701 | 2002-05-10 18:51:54 +0000 | [diff] [blame] | 78 | CompileCommonOpts = $(PROFILE) -Wall -W -Wwrite-strings -Wno-unused -I$(LEVEL)/include |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 79 | |
| 80 | # Compile a file, don't link... |
Chris Lattner | 18f4701 | 2002-05-10 18:51:54 +0000 | [diff] [blame] | 81 | Compile = $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(CompileCommonOpts) $(PROFILE) |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 82 | CompileG = $(Compile) -g -D_DEBUG |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 83 | CompileO = $(Compile) -O3 -DNDEBUG -finline-functions -felide-constructors -fnonnull-objects -freg-struct-return -fshort-enums |
| 84 | |
| 85 | # Link final executable |
Chris Lattner | 6e39070 | 2001-10-30 20:24:08 +0000 | [diff] [blame] | 86 | |
Chris Lattner | 1917e95 | 2002-07-31 21:32:05 +0000 | [diff] [blame] | 87 | ifdef ENABLE_PURIFY # To enable purify, build with 'gmake ENABLE_PURIFY=1' |
| 88 | Link = $(PURIFY) $(CXX) $(PROFILE) -static |
Chris Lattner | 12604ed | 2002-04-05 18:56:58 +0000 | [diff] [blame] | 89 | else |
Chris Lattner | 1917e95 | 2002-07-31 21:32:05 +0000 | [diff] [blame] | 90 | Link = $(CXX) $(PROFILE) |
Chris Lattner | 12604ed | 2002-04-05 18:56:58 +0000 | [diff] [blame] | 91 | endif |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 92 | LinkG = $(Link) -g -L $(LIBDEBUG) |
| 93 | LinkO = $(Link) -O3 -L $(LIBRELEASE) |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 94 | |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 95 | # Create a .so file from a .o files... |
Chris Lattner | 1917e95 | 2002-07-31 21:32:05 +0000 | [diff] [blame] | 96 | #MakeSO = $(CXX) -shared $(PROFILE) |
| 97 | MakeSO = $(CXX) -G $(PROFILE) |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 98 | MakeSOO = $(MakeSO) -O3 |
| 99 | |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 100 | # Create one .o file from a bunch of .o files... |
| 101 | Relink = ld -r |
| 102 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 103 | # Create dependancy file from CPP file, send to stdout. |
| 104 | Depend = $(CXX) -MM -I$(LEVEL)/include $(CPPFLAGS) |
| 105 | |
| 106 | # Archive a bunch of .o files into a .a file... |
| 107 | AR = ar cq |
Vikram S. Adve | 112a72c | 2001-07-15 13:16:47 +0000 | [diff] [blame] | 108 | MakeLib = $(AR) |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 109 | |
| 110 | #---------------------------------------------------------- |
| 111 | |
| 112 | # Source includes all of the cpp files, and objects are derived from the |
| 113 | # source files... |
Chris Lattner | e001059 | 2001-10-18 01:48:09 +0000 | [diff] [blame] | 114 | # The local Makefile can list other Source files via ExtraSource = ... |
Vikram S. Adve | c4bed34 | 2001-10-17 12:33:55 +0000 | [diff] [blame] | 115 | # |
Chris Lattner | e001059 | 2001-10-18 01:48:09 +0000 | [diff] [blame] | 116 | Source := $(ExtraSource) $(wildcard *.cpp *.c *.y *.l) |
Vikram S. Adve | 112a72c | 2001-07-15 13:16:47 +0000 | [diff] [blame] | 117 | |
Chris Lattner | 4fa128c | 2002-07-25 15:01:19 +0000 | [diff] [blame] | 118 | Objs := $(sort $(patsubst Debug/%.o, %.o, $(addsuffix .o,$(basename $(Source))))) |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 119 | ObjectsO = $(addprefix Release/,$(Objs)) |
| 120 | ObjectsG = $(addprefix Debug/,$(Objs)) |
| 121 | |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 122 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 123 | #--------------------------------------------------------- |
| 124 | # Handle the DIRS option |
| 125 | #--------------------------------------------------------- |
| 126 | |
| 127 | ifdef DIRS # Only do this if we're using DIRS! |
| 128 | |
| 129 | all :: $(addsuffix /.makeall , $(DIRS)) |
| 130 | install :: $(addsuffix /.makeinstall, $(DIRS)) |
| 131 | clean :: $(addsuffix /.makeclean , $(DIRS)) |
| 132 | |
| 133 | %/.makeall %/.makeclean %/.makeinstall: |
| 134 | cd $(@D); $(MAKE) $(subst $(@D)/.make,,$@) |
| 135 | endif |
| 136 | |
| 137 | #--------------------------------------------------------- |
| 138 | # Handle the LIBRARYNAME option - used when building libs... |
| 139 | #--------------------------------------------------------- |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 140 | # |
| 141 | # When libraries are built, they are allowed to optionally define the |
| 142 | # DONT_BUILD_RELINKED make variable, which, when defined, prevents a .o file |
| 143 | # from being built for the library. This .o files may then be linked to by a |
| 144 | # tool if the tool does not need (or want) the semantics a .a file provides |
| 145 | # (linking in only object files that are "needed"). If a library is never to |
| 146 | # be used in this way, it is better to define DONT_BUILD_RELINKED, and define |
| 147 | # BUILD_ARCHIVE instead. |
| 148 | # |
| 149 | # 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] | 150 | # 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] | 151 | # linked into tools (for example gccas) even if they only use one of the parts |
| 152 | # 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] | 153 | |
| 154 | ifdef LIBRARYNAME |
Vikram S. Adve | 112a72c | 2001-07-15 13:16:47 +0000 | [diff] [blame] | 155 | |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 156 | LIBNAME_O := $(LIBRELEASE)/lib$(LIBRARYNAME).so |
| 157 | LIBNAME_G := $(LIBDEBUG)/lib$(LIBRARYNAME).so |
| 158 | LIBNAME_AO := $(LIBRELEASE)/lib$(LIBRARYNAME).a |
| 159 | LIBNAME_AG := $(LIBDEBUG)/lib$(LIBRARYNAME).a |
| 160 | LIBNAME_OBJO := $(LIBRELEASE)/$(LIBRARYNAME).o |
| 161 | LIBNAME_OBJG := $(LIBDEBUG)/$(LIBRARYNAME).o |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 162 | |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 163 | BUILD_LIBNAME_G := $(LIBNAME_G) |
| 164 | ifndef DONT_BUILD_RELINKED |
| 165 | BUILD_LIBNAME_OBJG := $(LIBNAME_OBJG) |
| 166 | endif |
| 167 | ifdef BUILD_ARCHIVE |
| 168 | BUILD_LIBNAME_AG := $(LIBNAME_AG) |
| 169 | endif |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 170 | |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 171 | # If optimized builds are enabled... |
| 172 | ifdef ENABLE_OPTIMIZED |
| 173 | BUILD_LIBNAME_O := $(LIBNAME_O) |
| 174 | ifndef DONT_BUILD_RELINKED |
| 175 | BUILD_LIBNAME_OBJO := $(LIBNAME_OBJO) |
| 176 | endif |
| 177 | ifdef BUILD_ARCHIVE |
| 178 | BUILD_LIBNAME_AO := $(LIBNAME_AO) |
| 179 | endif |
| 180 | endif |
| 181 | |
| 182 | all:: $(BUILD_LIBNAME_AG) $(BUILD_LIBNAME_OBJG) # Debug |
| 183 | all:: $(BUILD_LIBNAME_AO) $(BUILD_LIBNAME_OBJO) # Release |
| 184 | dynamic:: $(BUILD_LIBNAME_G) $(BUILD_LIBNAME_O) # .so files |
| 185 | |
| 186 | $(LIBNAME_O): $(ObjectsO) $(LibSubDirs) $(LIBRELEASE)/.dir Depend/.dir |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 187 | @echo ======= Linking $(LIBRARYNAME) release library ======= |
| 188 | $(MakeSOO) -o $@ $(ObjectsO) $(LibSubDirs) $(LibLinkOpts) |
| 189 | |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 190 | $(LIBNAME_G): $(ObjectsG) $(LibSubDirs) $(LIBDEBUG)/.dir Depend/.dir |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 191 | @echo ======= Linking $(LIBRARYNAME) debug library ======= |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 192 | $(MakeSO) -g -o $@ $(ObjectsG) $(LibSubDirs) $(LibLinkOpts) |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 193 | |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 194 | $(LIBNAME_AO): $(ObjectsO) $(LibSubDirs) $(LIBRELEASE)/.dir Depend/.dir |
Vikram S. Adve | 112a72c | 2001-07-15 13:16:47 +0000 | [diff] [blame] | 195 | @echo ======= Linking $(LIBRARYNAME) release library ======= |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 196 | @rm -f $@ |
Vikram S. Adve | 112a72c | 2001-07-15 13:16:47 +0000 | [diff] [blame] | 197 | $(MakeLib) $@ $(ObjectsO) $(LibSubDirs) |
| 198 | |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 199 | $(LIBNAME_AG): $(ObjectsG) $(LibSubDirs) $(LIBDEBUG)/.dir Depend/.dir |
Vikram S. Adve | 112a72c | 2001-07-15 13:16:47 +0000 | [diff] [blame] | 200 | @echo ======= Linking $(LIBRARYNAME) debug library ======= |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 201 | @rm -f $@ |
Vikram S. Adve | 112a72c | 2001-07-15 13:16:47 +0000 | [diff] [blame] | 202 | $(MakeLib) $@ $(ObjectsG) $(LibSubDirs) |
| 203 | |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 204 | $(LIBNAME_OBJO): $(ObjectsO) $(LibSubDirs) $(LIBRELEASE)/.dir Depend/.dir |
| 205 | $(Relink) -o $@ $(ObjectsO) $(LibSubDirs) |
| 206 | |
| 207 | $(LIBNAME_OBJG): $(ObjectsG) $(LibSubDirs) $(LIBDEBUG)/.dir Depend/.dir |
| 208 | $(Relink) -o $@ $(ObjectsG) $(LibSubDirs) |
| 209 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 210 | endif |
| 211 | |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 212 | #------------------------------------------------------------------------ |
Vikram S. Adve | 0193d5e | 2001-10-10 22:35:00 +0000 | [diff] [blame] | 213 | # Create a TAGS database for emacs |
| 214 | #------------------------------------------------------------------------ |
| 215 | |
Vikram S. Adve | 022d06c | 2001-10-13 12:26:59 +0000 | [diff] [blame] | 216 | ifeq ($(LEVEL), .) |
Vikram S. Adve | 022d06c | 2001-10-13 12:26:59 +0000 | [diff] [blame] | 217 | tags: |
Chris Lattner | 18f4701 | 2002-05-10 18:51:54 +0000 | [diff] [blame] | 218 | 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] | 219 | all:: tags |
Vikram S. Adve | 022d06c | 2001-10-13 12:26:59 +0000 | [diff] [blame] | 220 | endif |
Vikram S. Adve | 0193d5e | 2001-10-10 22:35:00 +0000 | [diff] [blame] | 221 | |
| 222 | #------------------------------------------------------------------------ |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 223 | # Handle the TOOLNAME option - used when building tool executables... |
| 224 | #------------------------------------------------------------------------ |
| 225 | # |
| 226 | # 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] | 227 | # libraries (and the order of the libs) that should be linked to the |
| 228 | # tool. USEDLIBS should contain a list of library names (some with .a extension) |
| 229 | # 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] | 230 | # |
| 231 | ifdef TOOLNAME |
| 232 | |
| 233 | # TOOLEXENAME* - These compute the output filenames to generate... |
| 234 | TOOLEXENAME_G = $(LEVEL)/tools/Debug/$(TOOLNAME) |
| 235 | TOOLEXENAME_O = $(LEVEL)/tools/Release/$(TOOLNAME) |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 236 | TOOLEXENAMES := $(TOOLEXENAME_G) |
| 237 | ifdef ENABLE_OPTIMIZED |
| 238 | TOOLEXENAMES += $(TOOLEXENAME_O) |
| 239 | endif |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 240 | |
| 241 | # USED_LIBS_OPTIONS - Compute the options line that add -llib1 -llib2, etc. |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 242 | USED_LIBS_OPTIONS := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS))) |
| 243 | USED_LIBS_OPTIONS_G := $(patsubst %.o, $(LIBDEBUG)/%.o, $(USED_LIBS_OPTIONS)) |
| 244 | USED_LIBS_OPTIONS_O := $(patsubst %.o, $(LIBRELEASE)/%.o,$(USED_LIBS_OPTIONS)) |
| 245 | |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 246 | |
| 247 | # 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] | 248 | # rebuilt if libraries change. This has to make sure to handle .a/.so and .o |
| 249 | # files seperately. |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 250 | # |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 251 | STATICUSEDLIBS := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS))) |
| 252 | USED_LIB_PATHS_G := $(addprefix $(LIBDEBUG)/, $(STATICUSEDLIBS)) |
| 253 | USED_LIB_PATHS_O := $(addprefix $(LIBRELEASE)/, $(STATICUSEDLIBS)) |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 254 | |
Chris Lattner | 669bd7c | 2001-10-13 05:10:29 +0000 | [diff] [blame] | 255 | all:: $(TOOLEXENAMES) |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 256 | clean:: |
| 257 | rm -f $(TOOLEXENAMES) |
| 258 | |
Chris Lattner | bf2f043 | 2001-09-09 20:59:28 +0000 | [diff] [blame] | 259 | $(TOOLEXENAME_G): $(ObjectsG) $(USED_LIB_PATHS_G) $(LEVEL)/tools/Debug/.dir |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 260 | $(LinkG) -o $@ $(ObjectsG) $(USED_LIBS_OPTIONS_G) $(TOOLLINKOPTS) |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 261 | |
Chris Lattner | bf2f043 | 2001-09-09 20:59:28 +0000 | [diff] [blame] | 262 | $(TOOLEXENAME_O): $(ObjectsO) $(USED_LIB_PATHS_O) $(LEVEL)/tools/Release/.dir |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 263 | $(LinkO) -o $@ $(ObjectsG) $(USED_LIBS_OPTIONS_O) $(TOOLLINKOPTS) |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 264 | |
| 265 | endif |
| 266 | |
| 267 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 268 | |
| 269 | #--------------------------------------------------------- |
Chris Lattner | aa6ec73 | 2001-11-07 14:50:58 +0000 | [diff] [blame] | 270 | .PRECIOUS: Depend/.dir Debug/.dir Release/.dir |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 271 | |
Vikram S. Adve | 112a72c | 2001-07-15 13:16:47 +0000 | [diff] [blame] | 272 | # Create dependencies for the *.cpp files... |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 273 | Depend/%.d: %.cpp Depend/.dir |
| 274 | $(Depend) $< | sed 's|$*\.o *|Release/& Debug/& Depend/$(@F)|g' > $@ |
| 275 | |
Vikram S. Adve | 112a72c | 2001-07-15 13:16:47 +0000 | [diff] [blame] | 276 | # Create dependencies for the *.c files... |
| 277 | Depend/%.d: %.c Depend/.dir |
| 278 | $(Depend) $< | sed 's|$*\.o *|Release/& Debug/& Depend/$(@F)|g' > $@ |
| 279 | |
| 280 | # Create .o files in the ObjectFiles directory from the .cpp and .c files... |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 281 | Release/%.o: %.cpp Release/.dir Depend/.dir |
| 282 | $(CompileO) $< -o $@ |
| 283 | |
Chris Lattner | c7acf81 | 2002-01-23 05:46:01 +0000 | [diff] [blame] | 284 | #Release/%.o: %.c Release/.dir Depend/.dir |
| 285 | # $(CompileOC) $< -o $@ |
Vikram S. Adve | 112a72c | 2001-07-15 13:16:47 +0000 | [diff] [blame] | 286 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 287 | Debug/%.o: %.cpp Debug/.dir Depend/.dir |
| 288 | $(CompileG) $< -o $@ |
| 289 | |
Chris Lattner | c7acf81 | 2002-01-23 05:46:01 +0000 | [diff] [blame] | 290 | #Debug/%.o: %.c Debug/.dir Depend/.dir |
| 291 | # $(CompileGC) $< -o $@ |
Vikram S. Adve | 112a72c | 2001-07-15 13:16:47 +0000 | [diff] [blame] | 292 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 293 | # Create a .cpp source file from a flex input file... this uses sed to cut down |
| 294 | # on the warnings emited by GCC... |
| 295 | %.cpp: %.l |
| 296 | flex -t $< | sed '/^find_rule/d' | sed 's/void yyunput/inline void yyunput/' | sed 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' > $@ |
| 297 | |
| 298 | # Rule for building the bison parsers... |
| 299 | |
| 300 | %.cpp %.h : %.y |
Chris Lattner | 18f4701 | 2002-05-10 18:51:54 +0000 | [diff] [blame] | 301 | bison -v -d -p $(<:%Parser.y=%) $(basename $@).y |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 302 | mv -f $(basename $@).tab.c $(basename $@).cpp |
| 303 | mv -f $(basename $@).tab.h $(basename $@).h |
| 304 | |
| 305 | # To create the directories... |
| 306 | %/.dir: |
| 307 | mkdir -p $(@D) |
| 308 | @date > $@ |
| 309 | |
Chris Lattner | 1917e95 | 2002-07-31 21:32:05 +0000 | [diff] [blame] | 310 | # Clean nukes the tree |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 311 | clean:: |
| 312 | rm -rf Debug Release Depend |
| 313 | rm -f core *.o *.d *.so *~ *.flc |
| 314 | |
| 315 | # If dependancies were generated for the file that included this file, |
| 316 | # include the dependancies now... |
| 317 | # |
Chris Lattner | 4fa128c | 2002-07-25 15:01:19 +0000 | [diff] [blame] | 318 | SourceDepend = $(addsuffix .d,$(addprefix Depend/,$(basename $(filter-out Debug/%, $(Source))))) |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 319 | ifneq ($(SourceDepend),) |
| 320 | include $(SourceDepend) |
| 321 | endif |