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