Misha Brukman | 6d5ab86 | 2004-04-24 00:10:56 +0000 | [diff] [blame] | 1 | #===-- Makefile.rules - Common make rules for LLVM ---------*- Makefile -*--===# |
| 2 | # |
John Criswell | d8846c1 | 2003-10-21 14:33:46 +0000 | [diff] [blame] | 3 | # The LLVM Compiler Infrastructure |
| 4 | # |
| 5 | # This file was developed by the LLVM research group and is distributed under |
| 6 | # the University of Illinois Open Source License. See LICENSE.TXT for details. |
| 7 | # |
Misha Brukman | 6d5ab86 | 2004-04-24 00:10:56 +0000 | [diff] [blame] | 8 | #===------------------------------------------------------------------------===# |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 9 | # |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 10 | # This file is included by all of the LLVM makefiles. For details on how to use |
| 11 | # it properly, please see the document MakefileGuide.html in the docs directory. |
Chris Lattner | af06a08 | 2003-08-15 03:02:52 +0000 | [diff] [blame] | 12 | # |
Vikram S. Adve | d60aede | 2002-07-09 12:04:21 +0000 | [diff] [blame] | 13 | #===-----------------------------------------------------------------------==== |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 14 | |
John Criswell | 2a6530f | 2003-06-27 16:58:44 +0000 | [diff] [blame] | 15 | # |
John Criswell | 7f33695 | 2003-09-06 14:44:17 +0000 | [diff] [blame] | 16 | # Set the VPATH so that we can find source files. |
John Criswell | 8bff509 | 2003-06-11 13:55:44 +0000 | [diff] [blame] | 17 | # |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 18 | VPATH=$(BUILD_SRC_DIR) |
John Criswell | 8bff509 | 2003-06-11 13:55:44 +0000 | [diff] [blame] | 19 | |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 20 | ############################################################################### |
| 21 | # TARGETS: Define standard targets that can be invoked |
| 22 | ############################################################################### |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame] | 23 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 24 | #-------------------------------------------------------------------- |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 25 | # Define the various target sets |
| 26 | #-------------------------------------------------------------------- |
| 27 | RECURSIVE_TARGETS := all clean check install uninstall |
| 28 | LOCAL_TARGETS := all-local clean-local check-local install-local printvars\ |
| 29 | uninstall-local |
Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 30 | TOPLEV_TARGETS := dist dist-check dist-clean tags |
| 31 | INTERNAL_TARGETS := preconditions \ |
| 32 | install-config-dir install-shared-library install-bytecode-library \ |
| 33 | install-archive-library install-relinked-library install-tool \ |
| 34 | uninstall-config-dir uninstall-shared-library uninstall-bytecode-library \ |
| 35 | uninstall-archive-library uninstall-relinked-library uninstall-tool |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 36 | |
| 37 | #-------------------------------------------------------------------- |
| 38 | # Mark all of these targets as phony to avoid implicit rule search |
| 39 | #-------------------------------------------------------------------- |
| 40 | .PHONY: $(RECURSIVE_TARGETS) $(LOCAL_TARGETS) $(TOP_TARGETS) $(INTERNAL_TARGETS) |
| 41 | |
| 42 | #-------------------------------------------------------------------- |
| 43 | # Make sure all the user-target rules are double colon rules and that |
| 44 | # the preconditions are run first. |
| 45 | #-------------------------------------------------------------------- |
| 46 | |
| 47 | all :: all-local |
| 48 | check:: check-local |
| 49 | clean:: clean-local |
| 50 | install :: install-local |
| 51 | uninstall :: uninstall-local |
| 52 | |
| 53 | all-local :: preconditions |
| 54 | clean-local :: preconditions |
| 55 | check-local :: all-local |
| 56 | install-local :: all-local |
| 57 | printvars :: preconditions |
| 58 | uninstall-local :: preconditions |
| 59 | |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 60 | ############################################################################### |
| 61 | # SUFFIXES: Reset the list of suffixes we know how to build |
| 62 | ############################################################################### |
| 63 | .SUFFIXES: |
| 64 | .SUFFIXES: .c .cpp .h .hpp .y .l .lo .o .a $(SHLIBEXT) .bc .td .ps .dot $(SUFFIXES) |
| 65 | |
| 66 | ############################################################################### |
| 67 | # VARIABLES: Set up various variables based on configuration data |
| 68 | ############################################################################### |
| 69 | |
| 70 | #-------------------------------------------------------------------- |
| 71 | # Variables derived from configuration we are building |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 72 | #-------------------------------------------------------------------- |
| 73 | |
Chris Lattner | 760da06 | 2003-03-14 20:25:22 +0000 | [diff] [blame] | 74 | ifdef ENABLE_PROFILING |
Chris Lattner | 760da06 | 2003-03-14 20:25:22 +0000 | [diff] [blame] | 75 | CONFIGURATION := Profile |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 76 | CXXFLAGS += -O3 -DNDEBUG -felide-constructors -finline-functions -pg |
| 77 | CFLAGS += -O3 -DNDEBUG -pg |
| 78 | LDFLAGS += -O3 -DNDEBUG -pg |
Chris Lattner | 760da06 | 2003-03-14 20:25:22 +0000 | [diff] [blame] | 79 | else |
| 80 | ifdef ENABLE_OPTIMIZED |
| 81 | CONFIGURATION := Release |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 82 | CXXFLAGS += -O3 -DNDEBUG -finline-functions -felide-constructors -fomit-frame-pointer |
| 83 | CFLAGS += -O3 -DNDEBUG -fomit-frame-pointer |
| 84 | LDFLAGS += -O3 -DNDEBUG |
Chris Lattner | 760da06 | 2003-03-14 20:25:22 +0000 | [diff] [blame] | 85 | else |
| 86 | CONFIGURATION := Debug |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 87 | CXXFLAGS += -g -D_DEBUG |
| 88 | CFLAGS += -g -D_DEBUG |
| 89 | LDFLAGS += -g -D_DEBUG |
| 90 | KEEP_SYMBOLS := 1 |
Chris Lattner | 760da06 | 2003-03-14 20:25:22 +0000 | [diff] [blame] | 91 | endif |
| 92 | endif |
| 93 | |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 94 | ARFLAGS := cru |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 95 | |
| 96 | #-------------------------------------------------------------------- |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 97 | # Directory locations |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 98 | #-------------------------------------------------------------------- |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 99 | OBJDIR := $(BUILD_OBJ_DIR)/$(CONFIGURATION) |
| 100 | LIBDIR := $(BUILD_OBJ_ROOT)/lib/$(CONFIGURATION) |
| 101 | TOOLDIR := $(BUILD_OBJ_ROOT)/tools/$(CONFIGURATION) |
| 102 | LLVMLIBDIR := $(LLVM_OBJ_ROOT)/lib/$(CONFIGURATION) |
| 103 | LLVMTOOLDIR := $(LLVM_OBJ_ROOT)/tools/$(CONFIGURATION) |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame] | 104 | |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 105 | #-------------------------------------------------------------------- |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 106 | # Full Paths To Compiled Tools and Utilities |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 107 | #-------------------------------------------------------------------- |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 108 | LIBTOOL := $(LLVM_OBJ_ROOT)/mklib |
| 109 | LLVMAS := $(LLVMTOOLDIR)/llvm-as$(EXEEXT) |
| 110 | BURG := $(LLVMTOOLDIR)/burg$(EXEEXT) |
| 111 | TBLGEN := $(LLVMTOOLDIR)/tblgen$(EXEEXT) |
| 112 | GCCLD := $(LLVMTOOLDIR)/gccld$(EXEEXT) |
| 113 | LLVMGCC := PATH=$(LLVMTOOLDIR):$(PATH) $(LLVMGCCDIR)/bin/gcc |
| 114 | LLVMGXX := PATH=$(LLVMTOOLDIR):$(PATH) $(LLVMGCCDIR)/bin/g++ |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame] | 115 | |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 116 | # Need a better way to compute this. |
| 117 | LLVMGCCLIBDIR := $(dir $(shell $(LLVMGCC) -print-file-name=libgcc.a))/ |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame] | 118 | |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 119 | #-------------------------------------------------------------------- |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 120 | # Adjust to user's request |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 121 | #-------------------------------------------------------------------- |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame] | 122 | |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 123 | # Adjust LIBTOOL options for shared libraries, or not. |
John Criswell | 82f4a5a | 2003-07-31 20:58:51 +0000 | [diff] [blame] | 124 | ifndef SHARED_LIBRARY |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 125 | LIBTOOL += --tag=disable-shared |
| 126 | else |
| 127 | LDFLAGS += -rpath $(LIBDIR) |
John Criswell | 82f4a5a | 2003-07-31 20:58:51 +0000 | [diff] [blame] | 128 | endif |
| 129 | |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 130 | # Adjust settings for verbose mode |
Chris Lattner | 760da06 | 2003-03-14 20:25:22 +0000 | [diff] [blame] | 131 | ifndef VERBOSE |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 132 | VERB := @ |
| 133 | LIBTOOL += --silent |
| 134 | AR += >/dev/null 2>/dev/null |
Misha Brukman | b5f096f | 2002-09-12 16:05:39 +0000 | [diff] [blame] | 135 | endif |
| 136 | |
Vikram S. Adve | feeae58 | 2002-09-18 11:55:13 +0000 | [diff] [blame] | 137 | # By default, strip symbol information from executable |
Chris Lattner | 760da06 | 2003-03-14 20:25:22 +0000 | [diff] [blame] | 138 | ifndef KEEP_SYMBOLS |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 139 | STRIP = $(PLATFORMSTRIPOPTS) |
| 140 | STRIP_WARN_MSG = "(without symbols)" |
Vikram S. Adve | feeae58 | 2002-09-18 11:55:13 +0000 | [diff] [blame] | 141 | endif |
| 142 | |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 143 | # Adjust linker flags for building an executable |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 144 | ifdef TOOLNAME |
| 145 | LDFLAGS += -rpath $(TOOLDIR) -export-dynamic $(TOOLLINKOPTS) |
| 146 | endif |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 147 | |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 148 | # Use TOOLLINKOPTSB to pass options to the linker like library search |
| 149 | # path etc. |
Dinakar Dhurjati | 87ea8aa | 2003-10-29 14:28:35 +0000 | [diff] [blame] | 150 | # Note that this is different from TOOLLINKOPTS, these options |
| 151 | # are passed to the linker *before* the USEDLIBS options are passed. |
| 152 | # e.g. usage TOOLLINKOPTSB = -L/home/xxx/lib |
| 153 | ifdef TOOLLINKOPTSB |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 154 | LDFLAGS += $(TOOLLINKOPTSB) |
Dinakar Dhurjati | 87ea8aa | 2003-10-29 14:28:35 +0000 | [diff] [blame] | 155 | endif |
| 156 | |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 157 | #---------------------------------------------------------- |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 158 | # Options To Invoke Tools |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 159 | #---------------------------------------------------------- |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 160 | |
| 161 | CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused |
| 162 | |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 163 | LDFLAGS += -L$(LIBDIR) -L$(LLVMLIBDIR) |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 164 | CPPFLAGS += -I$(BUILD_OBJ_DIR) \ |
| 165 | -I$(BUILD_SRC_DIR) \ |
| 166 | -I$(BUILD_SRC_ROOT)/include \ |
| 167 | -I$(BUILD_OBJ_ROOT)/include \ |
| 168 | -I$(LLVM_OBJ_ROOT)/include \ |
| 169 | -I$(LLVM_SRC_ROOT)/include \ |
| 170 | -D_GNU_SOURCE -D__STDC_LIMIT_MACROS |
| 171 | |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 172 | Compile.C = $(CC) $(CPPFLAGS) $(CompileCommonOpts) -c $(CFLAGS) |
| 173 | Compile.CXX = $(CXX) $(CPPFLAGS) $(CompileCommonOpts) $(CXXFLAGS) -c |
| 174 | LTCompile.C = $(LIBTOOL) --mode=compile $(Compile.C) |
| 175 | LTCompile.CXX = $(LIBTOOL) --tag=CXX --mode=compile $(Compile.CXX) |
| 176 | BCCompile.CXX = $(LLVMGXX) $(CPPFLAGS) $(CompileCommonOpts) $(CXXFLAGS) -c |
| 177 | BCCompile.C = $(LLVMGCC) $(CPPFLAGS) $(CompileCommonOpts) $(CFLAGS) -c |
| 178 | Link = $(LIBTOOL) --tag=CXX --mode=link $(CXX) $(CPPFLAGS) \ |
| 179 | $(CompileCommonOpts) $(LDFLAGS) $(STRIP) |
| 180 | Relink = $(LIBTOOL) --tag=CXX --mode=link $(CXX) |
| 181 | BCLinkLib = $(LLVMGCC) -shared -nostdlib |
| 182 | Burg = $(BURG) -I $(BUILD_SRC_DIR) |
| 183 | TableGen = $(TBLGEN) -I $(BUILD_SRC_DIR) |
| 184 | Archive = $(AR) $(ARFLAGS) |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 185 | ifdef RANLIB |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 186 | Ranlib = $(RANLIB) |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 187 | else |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 188 | Ranlib = ranlib |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame] | 189 | endif |
| 190 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 191 | #---------------------------------------------------------- |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 192 | # Get the list of source files |
| 193 | #---------------------------------------------------------- |
| 194 | ifndef SOURCES |
| 195 | SOURCES := $(notdir $(wildcard $(BUILD_SRC_DIR)/*.cpp \ |
| 196 | $(BUILD_SRC_DIR)/*.cc $(BUILD_SRC_DIR)/*.c $(BUILD_SRC_DIR)/*.y \ |
| 197 | $(BUILD_SRC_DIR)/*.l)) |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 198 | endif |
| 199 | |
| 200 | ifdef BUILT_SOURCES |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 201 | SOURCES += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES)) |
Vikram S. Adve | ad9ea7e | 2002-10-14 16:40:04 +0000 | [diff] [blame] | 202 | endif |
Vikram S. Adve | 112a72c | 2001-07-15 13:16:47 +0000 | [diff] [blame] | 203 | |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 204 | #---------------------------------------------------------- |
| 205 | # Types of objects that can be built from sources |
| 206 | #---------------------------------------------------------- |
| 207 | BASENAME_SOURCES := $(sort $(basename $(SOURCES))) |
| 208 | ObjectsO := $(BASENAME_SOURCES:%=$(OBJDIR)/%.o) |
| 209 | ObjectsLO := $(BASENAME_SOURCES:%=$(OBJDIR)/%.lo) |
| 210 | ObjectsBC := $(BASENAME_SOURCES:%=$(OBJDIR)/%.bc) |
| 211 | |
| 212 | |
| 213 | ############################################################################### |
| 214 | # DIRECTORIES: Handle recursive descent of directory structure |
| 215 | ############################################################################### |
John Criswell | 82f4a5a | 2003-07-31 20:58:51 +0000 | [diff] [blame] | 216 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 217 | #--------------------------------------------------------- |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 218 | # Handle the DIRS options for sequential construction |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 219 | #--------------------------------------------------------- |
| 220 | |
Anand Shukla | 7c7a07e | 2002-09-18 04:29:30 +0000 | [diff] [blame] | 221 | ifdef DIRS |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 222 | $(RECURSIVE_TARGETS):: |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 223 | $(VERB) for dir in $(DIRS); do \ |
| 224 | if [ ! -f $$dir/Makefile ]; then \ |
| 225 | $(MKDIR) $$dir; \ |
| 226 | cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \ |
| 227 | fi; \ |
| 228 | ($(MAKE) -C $$dir $@ $(MFLAGS)) || exit 1; \ |
Chris Lattner | f1ffd99 | 2002-09-17 23:35:02 +0000 | [diff] [blame] | 229 | done |
Anand Shukla | 7c7a07e | 2002-09-18 04:29:30 +0000 | [diff] [blame] | 230 | endif |
Chris Lattner | a8abc22 | 2002-09-18 03:22:27 +0000 | [diff] [blame] | 231 | |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 232 | #--------------------------------------------------------- |
| 233 | # Handle the EXPERIMENTAL_DIRS options ensuring success |
| 234 | # after each directory is built. |
| 235 | #--------------------------------------------------------- |
| 236 | ifdef EXPERIMENTAL_DIRS |
| 237 | $(RECURSIVE_TARGETS):: |
| 238 | $(VERB) for dir in $(EXPERIMENTAL_DIRS); do \ |
| 239 | if [ ! -f $$dir/Makefile ]; then \ |
| 240 | $(MKDIR) $$dir; \ |
| 241 | cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \ |
| 242 | fi; \ |
Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 243 | ($(MAKE) -C $$dir $@ $(MFLAGS)) || exit 0; \ |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 244 | done |
| 245 | endif |
Chris Lattner | a8abc22 | 2002-09-18 03:22:27 +0000 | [diff] [blame] | 246 | |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 247 | #--------------------------------------------------------- |
| 248 | # Handle the PARALLEL_DIRS options for parallel construction |
| 249 | #--------------------------------------------------------- |
| 250 | ifdef PARALLEL_DIRS |
| 251 | |
| 252 | # Unfortunately, this list must be maintained if new |
| 253 | # recursive targets are added. |
| 254 | all :: $(addsuffix /.makeall , $(PARALLEL_DIRS)) |
| 255 | clean :: $(addsuffix /.makeclean , $(PARALLEL_DIRS)) |
| 256 | check :: $(addsuffix /.makecheck , $(PARALLEL_DIRS)) |
| 257 | install :: $(addsuffix /.makeinstall , $(PARALLEL_DIRS)) |
| 258 | uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS)) |
| 259 | |
| 260 | Parallel_Targets := $(foreach T,$(RECURSIVE_TARGETS),%/.make$(T)) |
| 261 | |
| 262 | $(Parallel_Targets) : |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 263 | $(VERB) if [ ! -f $(@D)/Makefile ]; then \ |
| 264 | $(MKDIR) $(@D); \ |
| 265 | cp $(BUILD_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \ |
John Criswell | b3866b6 | 2003-11-25 19:32:22 +0000 | [diff] [blame] | 266 | fi; \ |
Misha Brukman | 694b3ff | 2004-05-21 23:21:11 +0000 | [diff] [blame] | 267 | $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@) $(MFLAGS) |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 268 | endif |
| 269 | |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 270 | #--------------------------------------------------------- |
| 271 | # Handle the OPTIONAL_DIRS options for directores that may |
| 272 | # or may not exist. |
| 273 | #--------------------------------------------------------- |
John Criswell | 2a6530f | 2003-06-27 16:58:44 +0000 | [diff] [blame] | 274 | ifdef OPTIONAL_DIRS |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 275 | $(RECURSIVE_TARGETS):: |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 276 | $(VERB) for dir in $(OPTIONAL_DIRS); do \ |
| 277 | if [ -d $(BUILD_SRC_DIR)/$$dir ]; then\ |
| 278 | if [ ! -f $$dir/Makefile ]; then \ |
| 279 | $(MKDIR) $$dir; \ |
| 280 | cp $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \ |
| 281 | fi; \ |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 282 | ($(MAKE) -C$$dir $@ $(MFLAGS)) || exit 1; \ |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 283 | fi \ |
John Criswell | 2a6530f | 2003-06-27 16:58:44 +0000 | [diff] [blame] | 284 | done |
| 285 | endif |
| 286 | |
Reid Spencer | fc94508 | 2004-08-20 09:20:05 +0000 | [diff] [blame] | 287 | #--------------------------------------------------------- |
| 288 | # Handle the CONFIG_FILES options |
| 289 | #--------------------------------------------------------- |
| 290 | ifdef CONFIG_FILES |
Reid Spencer | fc94508 | 2004-08-20 09:20:05 +0000 | [diff] [blame] | 291 | |
Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 292 | install-local:: install-config-dir |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 293 | |
| 294 | install-config-dir: $(sysconfdir) $(CONFIG_FILES) |
Reid Spencer | 37130d2 | 2004-10-04 07:05:07 +0000 | [diff] [blame] | 295 | $(VERB)$(ECHO) Installing Configuration Files To $(sysconfdir) |
| 296 | $(VERB)for file in $(CONFIG_FILES); do \ |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 297 | $(INSTALL) $(BUILD_SRC_DIR)/$${file} $(sysconfdir) ; \ |
Reid Spencer | fc94508 | 2004-08-20 09:20:05 +0000 | [diff] [blame] | 298 | done |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 299 | |
Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 300 | uninstall-local:: uninstall-config-dir |
| 301 | |
| 302 | uninstall-config-dir: |
| 303 | $(VERB)$(ECHO) Uninstalling Configuration Files From $(sysconfdir) |
| 304 | $(VERB)for file in $(CONFIG_FILES); do \ |
| 305 | $(RM) -f $(sysconfdir)/$${file} ; \ |
| 306 | done |
| 307 | |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 308 | $(sysconfdir): |
| 309 | $(MKDIR) $(sysconfdir) |
| 310 | |
Reid Spencer | fc94508 | 2004-08-20 09:20:05 +0000 | [diff] [blame] | 311 | endif |
| 312 | |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 313 | ############################################################################### |
| 314 | # Library Build Rules: Four ways to build a library |
| 315 | ############################################################################### |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 316 | |
Brian Gaeke | 8abff79 | 2004-01-22 22:53:48 +0000 | [diff] [blame] | 317 | |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 318 | # if we're building a library ... |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 319 | ifdef LIBRARYNAME |
Vikram S. Adve | 112a72c | 2001-07-15 13:16:47 +0000 | [diff] [blame] | 320 | |
Chris Lattner | 2a548c5 | 2002-09-16 22:36:42 +0000 | [diff] [blame] | 321 | # Make sure there isn't any extranous whitespace on the LIBRARYNAME option |
Chris Lattner | ccb4ebd | 2002-09-16 22:34:56 +0000 | [diff] [blame] | 322 | LIBRARYNAME := $(strip $(LIBRARYNAME)) |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 323 | LIBNAME_LA := $(LIBDIR)/lib$(LIBRARYNAME).la |
| 324 | LIBNAME_A := $(LIBDIR)/lib$(LIBRARYNAME).a |
| 325 | LIBNAME_O := $(LIBDIR)/$(LIBRARYNAME).o |
| 326 | LIBNAME_BC := $(LIBDIR)/lib$(LIBRARYNAME).bc |
Chris Lattner | ccb4ebd | 2002-09-16 22:34:56 +0000 | [diff] [blame] | 327 | |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 328 | #--------------------------------------------------------- |
| 329 | # Shared Library Targets: |
| 330 | # If the user asked for a shared library to be built |
| 331 | # with the SHARED_LIBRARY variable, then we provide |
| 332 | # targets for building them. |
| 333 | #--------------------------------------------------------- |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 334 | ifdef SHARED_LIBRARY |
| 335 | |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 336 | all-local:: $(LIBNAME_LA) |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 337 | |
| 338 | $(LIBNAME_LA): $(BUILT_SOURCES) $(ObjectsLO) $(LIBDIR)/.dir |
| 339 | @$(ECHO) Linking shared library $(notdir $@) |
| 340 | $(VERB) $(Link) -o $@ $(ObjectsLO) |
| 341 | $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $@ $(LIBDIR) |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 342 | |
| 343 | clean-local:: |
Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 344 | ifneq ($(strip $(LIBNAME_LA)),) |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 345 | $(VERB) $(RM) -f $(LIBNAME_LA) |
Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 346 | endif |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 347 | |
Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 348 | DestSharedLib = $(libdir)/lib$(LIBRARYNAME)$(SHLIBEXT) |
| 349 | install-local:: install-shared-library |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 350 | |
Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 351 | install-shared-library: $(DestSharedLib) |
| 352 | |
| 353 | $(DestSharedLib): $(LIBNAME_LA) |
| 354 | @$(ECHO) Installing shared library $(DestSharedLib) |
| 355 | $(VERB) $(MKDIR) $(libdir) |
| 356 | $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $(LIBNAME_LA) $(DestSharedLib) |
| 357 | $(VERB) $(LIBTOOL) --finish $(libdir) |
| 358 | |
| 359 | uninstall-local:: uninstall-shared-library |
| 360 | |
| 361 | uninstall-shared-library: |
| 362 | @$(ECHO) Uninstalling shared library $(DestSharedLib) |
| 363 | $(VERB) $(RM) -f $(DestSharedLib) |
| 364 | |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 365 | endif |
| 366 | |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 367 | #--------------------------------------------------------- |
| 368 | # Bytecode Library Targets: |
| 369 | # If the user asked for a bytecode library to be built |
| 370 | # with the BYTECODE_LIBRARY variable, then we provide |
| 371 | # targets for building them. |
| 372 | #--------------------------------------------------------- |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 373 | ifdef BYTECODE_LIBRARY |
| 374 | |
| 375 | ifdef EXPORTED_SYMBOL_LIST |
| 376 | BCLinkLib += -Xlinker -internalize-public-api-list=$(EXPORTED_SYMBOL_LIST) |
| 377 | else |
| 378 | ifdef EXPORTED_SYMBOL_FILE |
| 379 | BCLinkLib += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE) |
| 380 | else |
| 381 | BCLinkLib += -Xlinker -disable-internalize |
| 382 | endif |
| 383 | endif |
| 384 | |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 385 | all-local:: $(LIBNAME_BC) |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 386 | |
| 387 | $(LIBNAME_BC): $(BUILT_SOURCES) $(ObjectsBC) $(LIBDIR)/.dir |
| 388 | @$(ECHO) Linking bytecode library $(notdir $@) |
| 389 | $(VERB) $(BCLinkLib) -o $@ $(ObjectsBC) |
| 390 | |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 391 | clean-local:: |
Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 392 | ifneq ($(strip $(LIBNAME_BC)),) |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 393 | $(VERB) $(RM) -f $(LIBNAME_BC) |
Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 394 | endif |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 395 | |
Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 396 | DestBytecodeLib = $(bytecode_libdir)/lib$(LIBRARYNAME).bc |
| 397 | install-local:: install-bytecode-library |
Chris Lattner | 481cc7c | 2003-08-15 02:18:35 +0000 | [diff] [blame] | 398 | |
Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 399 | install-bytecode-library: $(DestBytecodeLib) |
| 400 | |
| 401 | $(DestBytecodeLib): $(LIBNAME_BC) $(bytecode_libdir) |
| 402 | @$(ECHO) Installing bytecode library $(DestBytecodeLib) |
| 403 | $(VERB) $(INSTALL) $< $@ |
| 404 | |
| 405 | uninstall-local:: uninstall-bytecode-library |
| 406 | |
| 407 | uninstall-bytecode-library: |
| 408 | @$(ECHO) Uninstalling bytecode library $(DestBytecodeLib) |
| 409 | $(VERB) $(RM) -f $(DestBytecodeLib) |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 410 | |
| 411 | endif |
Vikram S. Adve | 60f5606 | 2002-08-02 18:34:12 +0000 | [diff] [blame] | 412 | |
Chris Lattner | 760da06 | 2003-03-14 20:25:22 +0000 | [diff] [blame] | 413 | # Does the library want a .o version built? |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 414 | ifndef DONT_BUILD_RELINKED |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 415 | all-local:: $(LIBNAME_O) |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 416 | |
| 417 | $(LIBNAME_O): $(BUILT_SOURCES) $(ObjectsO) $(LIBDIR)/.dir |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 418 | @$(ECHO) Linking object library $(notdir $@) |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 419 | $(VERB) $(Relink) -o $@ $(ObjectsO) |
| 420 | |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 421 | clean-local:: |
Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 422 | ifneq ($(strip $(LIBNAME_O)),) |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 423 | $(VERB) $(RM) -f $(LIBNAME_O) |
Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 424 | endif |
| 425 | |
| 426 | DestRelinkedLib = $(libdir)/$(LIBRARYNAME).o |
| 427 | |
| 428 | install-local:: install-relinked-library |
| 429 | |
| 430 | install-relinked-library: $(DestRelinkedLib) |
| 431 | |
| 432 | $(DestRelinkedLib): $(LIBNAME_O) |
| 433 | @$(ECHO) Installing object library $(DestRelinkedLib) |
| 434 | $(VERB) $(MKDIR) $(libdir) |
| 435 | $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $(LIBNAME_O) $(DestRelinkedLib) |
| 436 | |
| 437 | uninstall-local:: uninstall-relinked-library |
| 438 | |
| 439 | uninstall-relinked-library: |
| 440 | @$(ECHO) Uninstalling object library $(DestRelinkedLib) |
| 441 | $(VERB) $(RM) -f $(DestRelinkedLib) |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 442 | |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 443 | endif |
Chris Lattner | 760da06 | 2003-03-14 20:25:22 +0000 | [diff] [blame] | 444 | |
| 445 | # Does the library want an archive version built? |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 446 | ifdef BUILD_ARCHIVE |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 447 | all-local:: $(LIBNAME_A) |
Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 448 | |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 449 | $(LIBNAME_A): $(BUILT_SOURCES) $(ObjectsO) $(LIBDIR)/.dir |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 450 | @$(ECHO) Building archive library $(notdir $@) |
Reid Spencer | 37130d2 | 2004-10-04 07:05:07 +0000 | [diff] [blame] | 451 | $(VERB)$(RM) -f $@ |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 452 | $(VERB) $(Archive) $@ $(ObjectsO) |
| 453 | $(VERB) $(Ranlib) $@ |
Vikram S. Adve | 41e7891 | 2002-09-20 14:03:13 +0000 | [diff] [blame] | 454 | |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 455 | clean-local:: |
Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 456 | ifneq ($(strip $(LIBNAME_A)),) |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 457 | $(VERB) $(RM) -f $(LIBNAME_A) |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 458 | endif |
| 459 | |
Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 460 | DestArchiveLib := $(libdir)/lib$(LIBRARYNAME).a |
| 461 | |
| 462 | install-local:: install-archive-library |
| 463 | |
| 464 | install-archive-library: $(DestArchiveLib) |
| 465 | |
| 466 | $(DestArchiveLib): $(LIBNAME_A) |
| 467 | @$(ECHO) Installing archive library $(DestArchiveLib) |
| 468 | $(VERB) $(MKDIR) $(libdir) |
| 469 | $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $(LIBNAME_A) $(DestArchiveLib) |
| 470 | |
Reid Spencer | b1dd3dd | 2004-10-24 08:21:04 +0000 | [diff] [blame^] | 471 | uninstall-local:: uninstall-archive-library |
Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 472 | |
| 473 | uninstall-archive-library: |
| 474 | @$(ECHO) Uninstalling archive library $(DestArchiveLib) |
| 475 | $(VERB) $(RM) -f $(DestArchiveLib) |
| 476 | |
| 477 | endif |
| 478 | |
| 479 | # endif LIBRARYNAME |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 480 | endif |
| 481 | |
Reid Spencer | b1dd3dd | 2004-10-24 08:21:04 +0000 | [diff] [blame^] | 482 | ############################################################################### |
| 483 | # Tool Build Rules: Build executable tool based on TOOLNAME option |
| 484 | ############################################################################### |
| 485 | |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 486 | ifdef TOOLNAME |
| 487 | |
Reid Spencer | b1dd3dd | 2004-10-24 08:21:04 +0000 | [diff] [blame^] | 488 | #--------------------------------------------------------- |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 489 | # TOOLLINKOPTSB to pass options to the linker like library search path etc |
| 490 | # Note that this is different from TOOLLINKOPTS, these options |
| 491 | # are passed to the linker *before* the USEDLIBS options are passed. |
| 492 | # e.g. usage TOOLLINKOPTSB = -L/home/xxx/lib |
Reid Spencer | b1dd3dd | 2004-10-24 08:21:04 +0000 | [diff] [blame^] | 493 | #--------------------------------------------------------- |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 494 | ifdef TOOLLINKOPTSB |
| 495 | Link += $(TOOLLINKOPTSB) |
Reid Spencer | 37130d2 | 2004-10-04 07:05:07 +0000 | [diff] [blame] | 496 | endif |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 497 | |
Reid Spencer | b1dd3dd | 2004-10-24 08:21:04 +0000 | [diff] [blame^] | 498 | # TOOLEXENAME - This is the output filenames to generate |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 499 | TOOLEXENAME := $(TOOLDIR)/$(TOOLNAME) |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 500 | |
Reid Spencer | b1dd3dd | 2004-10-24 08:21:04 +0000 | [diff] [blame^] | 501 | # LIBS_OPTIONS - Compute the options lines that add -llib1 -llib2, etc. |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 502 | PROJ_LIBS_OPTIONS := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS))) |
| 503 | PROJ_LIBS_OPTIONS := $(patsubst %.o, $(LIBDIR)/%.o, $(PROJ_LIBS_OPTIONS)) |
| 504 | LLVM_LIBS_OPTIONS := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS))) |
| 505 | LLVM_LIBS_OPTIONS := $(patsubst %.o, $(LLVMLIBDIR)/%.o, $(LLVM_LIBS_OPTIONS)) |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame] | 506 | |
Reid Spencer | b1dd3dd | 2004-10-24 08:21:04 +0000 | [diff] [blame^] | 507 | # USED_LIBS/LIBS_PATHS - Compute dependent library file paths |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 508 | PROJ_USED_LIBS := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS))) |
| 509 | LLVM_USED_LIBS := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS))) |
| 510 | PROJ_LIBS_PATHS := $(addprefix $(LIBDIR)/,$(PROJ_USED_LIBS)) |
| 511 | LLVM_LIBS_PATHS := $(addprefix $(LLVMLIBDIR)/,$(LLVM_USED_LIBS)) |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame] | 512 | |
Reid Spencer | b1dd3dd | 2004-10-24 08:21:04 +0000 | [diff] [blame^] | 513 | # Concatenate all the optoins |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 514 | LINK_OPTS := $(TOOLLINKOPTS) $(PROJ_LIBS_OPTIONS) $(LLVM_LIBS_OPTIONS) |
John Criswell | fe785bd | 2004-09-16 14:11:25 +0000 | [diff] [blame] | 515 | |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 516 | # Handle compression libraries automatically |
| 517 | ifeq ($(HAVE_BZIP2),1) |
| 518 | LIBS += -lbz2 |
| 519 | endif |
| 520 | ifeq ($(HAVE_ZLIB),1) |
| 521 | LIBS += -lz |
| 522 | endif |
Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame] | 523 | |
Chris Lattner | 8d7dfb3 | 2003-01-22 16:13:31 +0000 | [diff] [blame] | 524 | # Tell make that we need to rebuild subdirectories before we can link the tool. |
| 525 | # This affects things like LLI which has library subdirectories. |
Reid Spencer | b1dd3dd | 2004-10-24 08:21:04 +0000 | [diff] [blame^] | 526 | $(TOOLEXENAME): $(addsuffix /.makeall, $(PARALLEL_DIRS)) |
Chris Lattner | 8d7dfb3 | 2003-01-22 16:13:31 +0000 | [diff] [blame] | 527 | |
Reid Spencer | b1dd3dd | 2004-10-24 08:21:04 +0000 | [diff] [blame^] | 528 | all-local:: $(TOOLEXENAME) |
John Criswell | 2a6530f | 2003-06-27 16:58:44 +0000 | [diff] [blame] | 529 | |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 530 | clean-local:: |
Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 531 | ifneq ($(strip $(TOOLEXENAME)),) |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 532 | $(VERB) $(RM) -f $(TOOLEXENAME) |
Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 533 | endif |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 534 | |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 535 | $(TOOLEXENAME): $(BUILT_SOURCES) $(ObjectsO) $(PROJ_LIBS_PATHS) $(LLVM_LIBS_PATHS) $(TOOLDIR)/.dir |
| 536 | @$(ECHO) Linking $(CONFIGURATION) executable $(TOOLNAME) $(STRIP_WARN_MSG) |
| 537 | $(VERB) $(Link) -o $@ $(ObjectsO) $(PROJ_LIBS_OPTIONS) $(LLVM_LIBS_OPTIONS) $(LIBS) |
| 538 | @$(ECHO) ======= Finished linking $(CONFIGURATION) executable $(TOOLNAME) $(STRIP_WARN_MSG) |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 539 | |
Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 540 | install-local:: install-tool |
| 541 | |
| 542 | DestTool = $(bindir)/$(TOOLNAME) |
| 543 | |
| 544 | install-tool: $(DestTool) |
| 545 | |
| 546 | $(DestTool): $(TOOLEXENAME) |
| 547 | @$(ECHO) Installing $(DestTool) |
| 548 | $(VERB) $(INSTALL) $(TOOLEXENAME) $(bindir) |
| 549 | |
| 550 | uninstall-local:: uninstall-tool |
| 551 | |
| 552 | uninstall-tool: |
| 553 | @$(ECHO) Uninstalling $(DestTool) |
| 554 | $(VERB) $(RM) -f $(DestTool) |
| 555 | |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 556 | endif |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 557 | |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 558 | ifndef DISABLE_AUTO_DEPENDENCIES |
Vikram S. Adve | 41e7891 | 2002-09-20 14:03:13 +0000 | [diff] [blame] | 559 | |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 560 | # Create .lo files in the OBJDIR directory from the .cpp and .c files... |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 561 | ifdef SHARED_LIBRARY |
| 562 | |
| 563 | $(OBJDIR)/%.lo $(OBJDIR)/%.o: %.cpp $(OBJDIR)/.dir |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 564 | @$(ECHO) "Compiling $(CONFIGURATION) $*.cpp For Shared Library" |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 565 | $(VERB) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(OBJDIR)/$*.LACXXd $< -o $@ ; \ |
| 566 | then $(MV) -f "$(OBJDIR)/$*.LACXXd" "$(OBJDIR)/$*.d"; \ |
| 567 | else $(RM) -f "$(OBJDIR)/$*.LACXXd"; exit 1; fi |
| 568 | |
| 569 | $(OBJDIR)/%.lo $(OBJDIR)/%.o: %.c $(OBJDIR)/.dir |
| 570 | @$(ECHO) "Compiling $(CONFIGURATION) $*.c For Shared Library" |
| 571 | $(VERB) if $(LTCompile.C) -MD -MT $@ -MP -MF $(OBJDIR)/$*.LACd $< -o $@ ; \ |
| 572 | then $(MV) -f "$(OBJDIR)/$*.LACd" "$(OBJDIR)/$*.d"; \ |
| 573 | else $(RM) -f "$(OBJDIR)/$*.LACd"; exit 1; fi |
| 574 | |
| 575 | else |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 576 | |
| 577 | $(OBJDIR)/%.o: %.cpp $(OBJDIR)/.dir |
| 578 | @$(ECHO) "Compiling $(CONFIGURATION) $*.cpp For Archive" |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 579 | $(VERB) if $(Compile.CXX) -MD -MT $@ -MP -MF $(OBJDIR)/$*.CXXd $< -o $@ ; \ |
| 580 | then $(MV) -f "$(OBJDIR)/$*.CXXd" "$(OBJDIR)/$*.d"; \ |
| 581 | else $(RM) -f "$(OBJDIR)/$*.CXXd"; exit 1; fi |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 582 | |
| 583 | $(OBJDIR)/%.o: %.c $(OBJDIR)/.dir |
| 584 | @$(ECHO) "Compiling $(CONFIGURATION) $*.c For Archive" |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 585 | $(VERB) if $(Compile.C) -MD -MT $@ -MP -MF $(OBJDIR)/$*.Cd $< -o $@ ; \ |
| 586 | then $(MV) -f "$(OBJDIR)/$*.Cd" "$(OBJDIR)/$*.d"; \ |
| 587 | else $(RM) -f "$(OBJDIR)/$*.Cd"; exit 1; fi |
| 588 | |
| 589 | endif |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 590 | |
| 591 | # Create .bc files in the OBJDIR directory from .cpp and .c files... |
| 592 | $(OBJDIR)/%.bc: %.cpp $(OBJDIR)/.dir |
| 593 | @$(ECHO) "Compiling $(CONFIGURATION) $*.cpp to bytecode" |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 594 | $(VERB) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(OBJDIR)/$*.BCCXXd" $< -o $@ ; \ |
| 595 | then $(MV) -f "$(OBJDIR)/$*.BCCXXd" "$(OBJDIR)/$*.d"; \ |
| 596 | else $(RM) -f "$(OBJDIR)/$*.BCCXXd"; exit 1; fi |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 597 | |
| 598 | $(OBJDIR)/%.bc: %.c $(OBJDIR)/.dir |
| 599 | @$(ECHO) "Compiling $(CONFIGURATION) $*.c to bytecode" |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 600 | $(VERB) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(OBJDIR)/$*.BCCd" $< -o $@ ; \ |
| 601 | then $(MV) -f "$(OBJDIR)/$*.BCCd" "$(OBJDIR)/$*.d"; \ |
| 602 | else $(RM) -f "$(OBJDIR)/$*.BCCd"; exit 1; fi |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 603 | |
| 604 | else |
| 605 | |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 606 | ifdef SHARED_LIBRARY |
| 607 | |
| 608 | $(OBJDIR)/%.lo $(OBJDIR)/%.o: %.cpp $(OBJDIR)/.dir |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 609 | @$(ECHO) "Compiling $(CONFIGURATION) $*.cpp For Shared Library" |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 610 | $(LTCompile.CXX) $< -o $@ |
| 611 | |
| 612 | $(OBJDIR)/%.lo $(OBJDIR)/%.o: %.c $(OBJDIR)/.dir |
| 613 | @$(ECHO) "Compiling $(CONFIGURATION) $*.cpp For Shared Library" |
| 614 | $(LTCompile.C) $< -o $@ |
| 615 | |
| 616 | else |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 617 | |
| 618 | $(OBJDIR)/%.o: %.cpp $(OBJDIR)/.dir |
| 619 | @$(ECHO) "Compiling $(CONFIGURATION) $*.cpp For Archive" |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 620 | $(Compile.CXX) $< -o $@ |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 621 | |
| 622 | $(OBJDIR)/%.o: %.c $(OBJDIR)/.dir |
| 623 | @$(ECHO) "Compiling $(CONFIGURATION) $*.cpp For Archive" |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 624 | $(Compile.C) $< -o $@ |
| 625 | endif |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 626 | |
| 627 | # Create .bc files in the OBJDIR directory from .cpp and .c files... |
| 628 | $(OBJDIR)/%.bc: %.cpp $(OBJDIR)/.dir |
| 629 | @$(ECHO) "Compiling $(CONFIGURATION) $*.cpp To Bytecode" |
| 630 | $(BCCompileCPP) $< -o $@ |
| 631 | |
| 632 | $(OBJDIR)/%.bc: %.c $(OBJDIR)/.dir |
| 633 | @$(ECHO) "Compiling $(CONFIGURATION) $*.c To Bytecode" |
| 634 | $(BCCompileC) $< -o $@ |
Brian Gaeke | 44909cf | 2003-12-10 00:26:28 +0000 | [diff] [blame] | 635 | |
Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 636 | endif |
| 637 | |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 638 | $(OBJDIR)/%.bc: %.ll $(OBJDIR)/.dir $(LLVMAS) |
| 639 | @$(ECHO) "Compiling $*.ll To Bytecode" |
Chris Lattner | 481cc7c | 2003-08-15 02:18:35 +0000 | [diff] [blame] | 640 | $(VERB) $(LLVMAS) $< -f -o $@ |
| 641 | |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 642 | ifdef TARGET |
| 643 | |
Reid Spencer | c64b2b3 | 2004-10-23 08:19:37 +0000 | [diff] [blame] | 644 | TDFILES := $(strip $(wildcard $(BUILD_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td) |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 645 | |
| 646 | $(BUILT_SOURCES): $(TDFILES) |
| 647 | |
| 648 | %GenRegisterNames.inc : %.td |
| 649 | @echo "Building $(<F) register names with tblgen" |
| 650 | $(VERB) $(TableGen) -gen-register-enums -o $@ $< |
| 651 | |
| 652 | %GenRegisterInfo.h.inc : %.td |
| 653 | @echo "Building $(<F) register information header with tblgen" |
| 654 | $(VERB) $(TableGen) -gen-register-desc-header -o $@ $< |
| 655 | |
| 656 | %GenRegisterInfo.inc : %.td |
| 657 | @echo "Building $(<F) register info implementation with tblgen" |
| 658 | $(VERB) $(TableGen) -gen-register-desc -o $@ $< |
| 659 | |
| 660 | %GenInstrNames.inc : %.td |
| 661 | @echo "Building $(<F) instruction names with tblgen" |
| 662 | $(VERB) $(TableGen) -gen-instr-enums -o $@ $< |
| 663 | |
| 664 | %GenInstrInfo.inc : %.td |
| 665 | @echo "Building $(<F) instruction information with tblgen" |
| 666 | $(VERB) $(TableGen) -gen-instr-desc -o $@ $< |
| 667 | |
| 668 | %GenAsmWriter.inc : %.td |
| 669 | @echo "Building $(<F) assembly writer with tblgen" |
| 670 | $(VERB) $(TableGen) -gen-asm-writer -o $@ $< |
| 671 | |
| 672 | %GenATTAsmWriter.inc : %.td |
| 673 | @echo "Building $(<F) AT&T assembly writer with tblgen" |
| 674 | $(VERB) $(TableGen) -gen-asm-writer -o $@ $< |
| 675 | |
| 676 | %GenIntelAsmWriter.inc : %.td |
| 677 | @echo "Building $(<F) Intel assembly writer with tblgen" |
| 678 | $(VERB) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $< |
| 679 | |
| 680 | %GenInstrSelector.inc: %.td |
| 681 | @echo "Building $(<F) instruction selector with tblgen" |
| 682 | $(VERB) $(TableGen) -gen-instr-selector -o $@ $< |
| 683 | |
| 684 | %GenCodeEmitter.inc:: %.td |
| 685 | @echo "Building $(<F) code emitter with tblgen" |
| 686 | $(VERB) $(TableGen) -gen-emitter -o $@ $< |
| 687 | |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 688 | clean-local:: |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 689 | $(VERB) rm -f *.inc |
| 690 | |
| 691 | endif |
Chris Lattner | 481cc7c | 2003-08-15 02:18:35 +0000 | [diff] [blame] | 692 | |
Chris Lattner | e899678 | 2003-01-16 22:44:19 +0000 | [diff] [blame] | 693 | # |
| 694 | # Rules for building lex/yacc files |
| 695 | # |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 696 | LEX_FILES = $(filter %.l, $(SOURCES)) |
Chris Lattner | e899678 | 2003-01-16 22:44:19 +0000 | [diff] [blame] | 697 | LEX_OUTPUT = $(LEX_FILES:%.l=%.cpp) |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 698 | YACC_FILES = $(filter %.y, $(SOURCES)) |
Chris Lattner | e899678 | 2003-01-16 22:44:19 +0000 | [diff] [blame] | 699 | YACC_OUTPUT = $(addprefix $(YACC_FILES:%.y=%), .h .cpp .output) |
| 700 | .PRECIOUS: $(LEX_OUTPUT) $(YACC_OUTPUT) |
| 701 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 702 | # Create a .cpp source file from a flex input file... this uses sed to cut down |
| 703 | # on the warnings emited by GCC... |
Chris Lattner | 6d131b4 | 2003-01-23 16:33:10 +0000 | [diff] [blame] | 704 | # |
| 705 | # The last line is a gross hack to work around flex aparently not being able to |
| 706 | # resize the buffer on a large token input. Currently, for uninitialized string |
| 707 | # buffers in LLVM we can generate very long tokens, so this is a hack around it. |
Chris Lattner | b7dc2b9 | 2003-08-15 20:00:47 +0000 | [diff] [blame] | 708 | # FIXME. (f.e. char Buffer[10000] ) |
Chris Lattner | 6d131b4 | 2003-01-23 16:33:10 +0000 | [diff] [blame] | 709 | # |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 710 | %.cpp: %.l |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 711 | @$(ECHO) Flexing $< |
Chris Lattner | 7bb107d | 2003-08-04 19:48:10 +0000 | [diff] [blame] | 712 | $(VERB) $(FLEX) -t $< | \ |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 713 | $(SED) '/^find_rule/d' | \ |
| 714 | $(SED) 's/void yyunput/inline void yyunput/' | \ |
| 715 | $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \ |
| 716 | $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \ |
| 717 | > $@.tmp |
| 718 | $(VERB) cmp -s $@ $@.tmp > /dev/null || $(MV) -f $@.tmp $@ |
Chris Lattner | a328f88 | 2003-08-04 19:47:06 +0000 | [diff] [blame] | 719 | @# remove the output of flex if it didn't get moved over... |
| 720 | @rm -f $@.tmp |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 721 | |
| 722 | # Rule for building the bison parsers... |
Chris Lattner | 694c5df | 2003-05-15 21:28:55 +0000 | [diff] [blame] | 723 | %.c: %.y # Cancel built-in rules for yacc |
| 724 | %.h: %.y # Cancel built-in rules for yacc |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 725 | %.cpp %.h : %.y |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 726 | @$(ECHO) "Bisoning $*.y" |
John Criswell | 410d1b5 | 2003-09-09 20:57:03 +0000 | [diff] [blame] | 727 | $(VERB) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $< |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 728 | $(VERB) cmp -s $*.tab.c $*.cpp > /dev/null || $(MV) -f $*.tab.c $*.cpp |
| 729 | $(VERB) cmp -s $*.tab.h $*.h > /dev/null || $(MV) -f $*.tab.h $*.h |
Chris Lattner | a328f88 | 2003-08-04 19:47:06 +0000 | [diff] [blame] | 730 | @# If the files were not updated, don't leave them lying around... |
| 731 | @rm -f $*.tab.c $*.tab.h |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 732 | |
| 733 | # To create the directories... |
| 734 | %/.dir: |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 735 | $(VERB) $(MKDIR) $* > /dev/null |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame] | 736 | @$(DATE) > $@ |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 737 | |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 738 | .PRECIOUS: $(OBJDIR)/.dir $(LIBDIR)/.dir $(TOOLDIR)/.dir $(LLVMLIBDIR)/.dir |
| 739 | .PRECIOUS: $(LLVMTOOLDIR)/.dir |
| 740 | |
Chris Lattner | 30440c6 | 2003-01-16 21:06:18 +0000 | [diff] [blame] | 741 | # To create postscript files from dot files... |
John Criswell | e0f9ac6 | 2003-10-02 19:02:02 +0000 | [diff] [blame] | 742 | ifneq ($(DOT),false) |
Chris Lattner | 30440c6 | 2003-01-16 21:06:18 +0000 | [diff] [blame] | 743 | %.ps: %.dot |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 744 | $(DOT) -Tps < $< > $@ |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame] | 745 | else |
| 746 | %.ps: %.dot |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 747 | $(ECHO) "Cannot build $@: The program dot is not installed" |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame] | 748 | endif |
Chris Lattner | 30440c6 | 2003-01-16 21:06:18 +0000 | [diff] [blame] | 749 | |
John Criswell | 7f33695 | 2003-09-06 14:44:17 +0000 | [diff] [blame] | 750 | # |
| 751 | # This rules ensures that header files that are removed still have a rule for |
| 752 | # which they can be "generated." This allows make to ignore them and |
| 753 | # reproduce the dependency lists. |
| 754 | # |
John Criswell | 4b6e5d1 | 2003-09-18 18:37:08 +0000 | [diff] [blame] | 755 | %.h:: ; |
John Criswell | 7f33695 | 2003-09-06 14:44:17 +0000 | [diff] [blame] | 756 | |
Chris Lattner | 172b648 | 2002-09-22 02:47:15 +0000 | [diff] [blame] | 757 | # 'make clean' nukes the tree |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 758 | clean-local:: |
Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 759 | ifneq ($(strip $(OBJDIR)),) |
Reid Spencer | 83cbcb9 | 2004-10-24 02:26:09 +0000 | [diff] [blame] | 760 | $(VERB) $(RM) -rf $(OBJDIR) |
Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 761 | endif |
Brian Gaeke | 9d3cd40 | 2004-01-21 19:53:11 +0000 | [diff] [blame] | 762 | $(VERB) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc |
| 763 | ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set |
| 764 | $(VERB) $(RM) -f *$(SHLIBEXT) |
| 765 | endif |
Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 766 | ifneq ($(strip $(LEX_OUTPUT)),) |
| 767 | $(VERB) $(RM) -f $(LEX_OUTPUT) |
| 768 | endif |
| 769 | ifneq ($(strip $(YACC_OUTPUT)),) |
| 770 | $(VERB) $(RM) -f $(YACC_OUTPUT) |
| 771 | endif |
John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame] | 772 | |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 773 | ############################################################################### |
| 774 | # DEPENDENCIES: Include the dependency files if we should |
| 775 | ############################################################################### |
Chris Lattner | 33ad24a | 2003-08-22 14:10:16 +0000 | [diff] [blame] | 776 | ifndef DISABLE_AUTO_DEPENDENCIES |
| 777 | |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 778 | # If its not one of the cleaning targets |
| 779 | ifneq ($strip($(filter-out clean clean-local dist-clean, $(MAKECMDGOALS))),) |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 780 | |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 781 | # Get the list of dependency files |
| 782 | DependFiles := $(basename $(filter %.cpp %.c %.cc, $(SOURCES))) |
| 783 | DependFiles := $(patsubst %,$(BUILD_OBJ_DIR)/$(CONFIGURATION)/%.d,$(DependFiles)) |
Misha Brukman | 4f7a8cf | 2003-11-09 21:36:19 +0000 | [diff] [blame] | 784 | |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 785 | -include /dev/null $(DependFiles) |
| 786 | |
John Criswell | d741bcf | 2003-08-12 18:51:51 +0000 | [diff] [blame] | 787 | endif |
Chris Lattner | 1ddb6b6 | 2003-08-18 17:27:40 +0000 | [diff] [blame] | 788 | |
Chris Lattner | 33ad24a | 2003-08-22 14:10:16 +0000 | [diff] [blame] | 789 | endif # ifndef DISABLE_AUTO_DEPENDENCIES |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 790 | |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 791 | ################################################################################ |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 792 | # PRECONDITIONS - that which must be built/checked first |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 793 | ################################################################################ |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 794 | |
| 795 | OBJMKFILE := $(BUILD_OBJ_DIR)/Makefile |
| 796 | SRCMKFILE := $(BUILD_SRC_DIR)/Makefile |
| 797 | CONFIGURE := $(LLVM_SRC_ROOT)/configure |
| 798 | CONFIG_STATUS := $(LLVM_OBJ_ROOT)/config.status |
| 799 | MAKE_CONFIG_IN := $(LLVM_SRC_ROOT)/Makefile.config.in |
| 800 | MAKE_CONFIG := $(LLVM_OBJ_ROOT)/Makefile.config |
| 801 | |
| 802 | #------------------------------------------------------------------------ |
| 803 | # List of the preconditions |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 804 | #------------------------------------------------------------------------ |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 805 | preconditions: $(CONFIG_STATUS) $(MAKE_CONFIG) $(OBJMKFILE) |
| 806 | |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 807 | all all-local check check-local dist dist-check install:: $(BUILT_SOURCES) |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 808 | |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 809 | clean-local:: |
Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 810 | ifneq ($(strip $(BUILT_SOURCES)),) |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 811 | $(VERB) $(RM) -f $(BUILT_SOURCES) |
Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 812 | endif |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 813 | |
| 814 | #------------------------------------------------------------------------ |
| 815 | # Make sure we're not using a stale configuration |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 816 | #------------------------------------------------------------------------ |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 817 | .PRECIOUS: $(CONFIG_STATUS) |
| 818 | $(CONFIG_STATUS): $(CONFIGURE) |
| 819 | @$(ECHO) Reconfiguring with $@ |
| 820 | $(VERB) $(CONFIG_STATUS) --recheck |
| 821 | |
| 822 | #------------------------------------------------------------------------ |
| 823 | # Make sure the configuration makefile is up to date |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 824 | #------------------------------------------------------------------------ |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 825 | $(MAKE_CONFIG): $(MAKE_CONFIG_IN) |
| 826 | @$(ECHO) Regenerating $@ |
| 827 | $(VERB) cd $(LLVM_OBJ_ROOT) ; $(CONFIG_STATUS) Makefile.config |
Reid Spencer | c64b2b3 | 2004-10-23 08:19:37 +0000 | [diff] [blame] | 828 | $(VERB) $(MAKE) $(MFLAGS) $(MAKECMDGOALS) |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 829 | @exit 0; |
| 830 | |
Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 831 | |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 832 | #------------------------------------------------------------------------ |
| 833 | # If the Makefile in the source tree has been updated, copy it over into the |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 834 | # build tree. But, only do this if the source and object makefiles differ |
| 835 | #------------------------------------------------------------------------ |
Reid Spencer | e53e397 | 2004-10-22 23:06:30 +0000 | [diff] [blame] | 836 | ifneq ($(OBJMKFILE),$(SRCMKFILE)) |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 837 | .PRECIOUS: $(OBJMKFILE) |
| 838 | $(OBJMKFILE): $(SRCMKFILE) |
| 839 | @$(ECHO) "Updating Makefile from : $(dir $<)" |
| 840 | $(VERB) $(MKDIR) $(@D) |
| 841 | $(VERB) cp -f $< $@ |
Reid Spencer | c64b2b3 | 2004-10-23 08:19:37 +0000 | [diff] [blame] | 842 | $(VERB) $(MAKE) $(MFLAGS) $(MAKECMDGOALS) |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 843 | @exit 0; |
Reid Spencer | e53e397 | 2004-10-22 23:06:30 +0000 | [diff] [blame] | 844 | endif |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 845 | |
| 846 | ############################################################################### |
Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 847 | # TOP LEVEL - targets only to apply at the top level directory |
| 848 | ############################################################################### |
| 849 | |
| 850 | ifeq ($(LEVEL),.) |
| 851 | |
| 852 | #------------------------------------------------------------------------ |
| 853 | # Handle construction of a distribution |
| 854 | dist:: preconditions |
| 855 | @$(ECHO) Target dist is not implemented yet |
| 856 | |
| 857 | dist-check:: preconditions dist |
| 858 | @$(ECHO) Target dist-check is not implemented yet |
| 859 | |
| 860 | dist-clean:: preconditions |
| 861 | @$(ECHO) Target dist-clean is not implemented yet |
| 862 | |
| 863 | #------------------------------------------------------------------------ |
| 864 | # Install support for project's include files: |
| 865 | #------------------------------------------------------------------------ |
| 866 | install-local:: |
| 867 | @$(ECHO) Installing include files |
| 868 | $(VERB) $(MKDIR) $(includedir) |
| 869 | $(VERB) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \ |
| 870 | cd $(BUILD_SRC_ROOT)/include && \ |
| 871 | find . -path '*/Internal' -prune -o '(' -type f \ |
| 872 | '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \ |
| 873 | -print ')' | grep -v CVS | pax -rwdvpe $(includedir) ; \ |
| 874 | fi |
| 875 | |
| 876 | uninstall-local:: |
| 877 | @$(ECHO) Uninstalling include files |
| 878 | $(VERB) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \ |
| 879 | cd $(BUILD_SRC_ROOT)/include && \ |
| 880 | $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \ |
| 881 | '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \ |
| 882 | -print ')' | grep -v CVS | sed 's#^#$(includedir)/#'` ; \ |
| 883 | fi |
| 884 | |
| 885 | #------------------------------------------------------------------------ |
| 886 | # Build tags database for Emacs/Xemacs: |
| 887 | #------------------------------------------------------------------------ |
| 888 | TAGS: tags |
| 889 | |
| 890 | tags:: |
| 891 | find include lib tools examples -name '*.cpp' -o -name '*.h' | $(ETAGS) $(ETAGSFLAGS) - |
| 892 | |
| 893 | dist-clean:: clean |
| 894 | $(VERB) $(RM) -rf $(LEVEL)/Makefile.config \ |
| 895 | $(LEVEL)/include/llvm/Config/config.h \ |
| 896 | $(LEVEL)/autoconf/autom4te.cache \ |
| 897 | $(LEVEL)/config.log \ |
| 898 | $(LEVEL)/TAGS |
| 899 | endif |
| 900 | |
| 901 | ############################################################################### |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 902 | # MISCELLANEOUS - utility targets |
| 903 | ############################################################################### |
| 904 | |
| 905 | #------------------------------------------------------------------------ |
| 906 | # Print out the directories used for building |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 907 | printvars:: |
Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 908 | @$(ECHO) "BUILD_SRC_ROOT: " $(BUILD_SRC_ROOT) |
| 909 | @$(ECHO) "BUILD_SRC_DIR : " $(BUILD_SRC_DIR) |
| 910 | @$(ECHO) "BUILD_OBJ_ROOT: " $(BUILD_OBJ_ROOT) |
| 911 | @$(ECHO) "BUILD_OBJ_DIR : " $(BUILD_OBJ_DIR) |
| 912 | @$(ECHO) "LLVM_SRC_ROOT : " $(LLVM_SRC_ROOT) |
| 913 | @$(ECHO) "LLVM_OBJ_ROOT : " $(LLVM_OBJ_ROOT) |
| 914 | @$(ECHO) "CONFIGURATION : " $(CONFIGURATION) |
| 915 | @$(ECHO) "OBJDIR: " $(OBJDIR) |
| 916 | @$(ECHO) "LIBDIR: " $(LIBDIR) |
| 917 | @$(ECHO) "TOOLDIR: " $(TOOLDIR) |
| 918 | @$(ECHO) "TDFILES:" '$(TDFILES)' |
Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 919 | @$(ECHO) "Compile.CXX: " '$(Compile.CXX)' |
| 920 | @$(ECHO) "Compile.C: " '$(Compile.C)' |
Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 921 | |
| 922 | # This frivolous target provided for Resistor who requested that the makefiles |
| 923 | # be hardened and that he get a "pony" after the makefiles (accidentally) |
| 924 | # deleted his unix kernel. |
| 925 | pony:: |
| 926 | @wget -q \ |
| 927 | http://search.cpan.org/src/ASAVIGE/Acme-EyeDrops-1.40/lib/Acme/EyeDrops/pony2.eye \ |
| 928 | -O /tmp/resistor.pony |
| 929 | @cat /tmp/resistor.pony |