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