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