| 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 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 15 | ################################################################################ |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 16 | # TARGETS: Define standard targets that can be invoked |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 17 | ################################################################################ |
| John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame] | 18 | |
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 19 | #-------------------------------------------------------------------- |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 20 | # Define the various target sets |
| 21 | #-------------------------------------------------------------------- |
| Chris Lattner | 7dc0282 | 2004-12-03 21:05:57 +0000 | [diff] [blame] | 22 | RecursiveTargets := all clean clean-all install uninstall install-bytecode |
| Reid Spencer | 9e8d54a | 2004-12-06 05:35:13 +0000 | [diff] [blame] | 23 | LocalTargets := all-local clean-local clean-all-local check-local \ |
| Reid Spencer | 44cb1b3 | 2004-12-03 20:08:48 +0000 | [diff] [blame] | 24 | install-local printvars uninstall-local \ |
| 25 | install-bytecode-local |
| Reid Spencer | 9e8d54a | 2004-12-06 05:35:13 +0000 | [diff] [blame] | 26 | TopLevelTargets := check dist dist-check dist-clean tags dist-gzip dist-bzip2 \ |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 27 | dist-zip |
| 28 | UserTargets := $(RecursiveTargets) $(LocalTargets) $(TopLevelTargets) |
| 29 | InternalTargets := preconditions distdir dist-hook |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 30 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 31 | ################################################################################ |
| Reid Spencer | 9411c64 | 2004-10-26 22:26:33 +0000 | [diff] [blame] | 32 | # INITIALIZATION: Basic things the makefile needs |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 33 | ################################################################################ |
| 34 | |
| 35 | #-------------------------------------------------------------------- |
| 36 | # Set the VPATH so that we can find source files. |
| 37 | #-------------------------------------------------------------------- |
| 38 | VPATH=$(BUILD_SRC_DIR) |
| Reid Spencer | 9411c64 | 2004-10-26 22:26:33 +0000 | [diff] [blame] | 39 | |
| 40 | #-------------------------------------------------------------------- |
| 41 | # Reset the list of suffixes we know how to build |
| 42 | #-------------------------------------------------------------------- |
| 43 | .SUFFIXES: |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 44 | .SUFFIXES: .c .cpp .h .hpp .y .l .lo .o .a .bc .td .ps .dot |
| 45 | .SUFFIXES: $(SHLIBEXT) $(SUFFIXES) |
| Reid Spencer | 9411c64 | 2004-10-26 22:26:33 +0000 | [diff] [blame] | 46 | |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 47 | #-------------------------------------------------------------------- |
| 48 | # Mark all of these targets as phony to avoid implicit rule search |
| 49 | #-------------------------------------------------------------------- |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 50 | .PHONY: $(UserTargets) $(InternalTargets) |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 51 | |
| 52 | #-------------------------------------------------------------------- |
| Reid Spencer | 9411c64 | 2004-10-26 22:26:33 +0000 | [diff] [blame] | 53 | # Make sure all the user-target rules are double colon rules and |
| 54 | # they are defined first. |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 55 | #-------------------------------------------------------------------- |
| 56 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 57 | $(UserTargets):: |
| Reid Spencer | 151f8ba | 2004-10-25 08:27:37 +0000 | [diff] [blame] | 58 | |
| Reid Spencer | 9411c64 | 2004-10-26 22:26:33 +0000 | [diff] [blame] | 59 | ################################################################################ |
| 60 | # PRECONDITIONS: that which must be built/checked first |
| 61 | ################################################################################ |
| 62 | |
| Reid Spencer | 44cb1b3 | 2004-12-03 20:08:48 +0000 | [diff] [blame] | 63 | SrcMakefiles := $(filter %Makefile %Makefile.tests,\ |
| Reid Spencer | 023c446 | 2004-11-17 19:08:44 +0000 | [diff] [blame] | 64 | $(wildcard $(BUILD_SRC_DIR)/Makefile*)) |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 65 | ObjMakefiles := $(subst $(BUILD_SRC_DIR),$(BUILD_OBJ_DIR),$(SrcMakefiles)) |
| Reid Spencer | f3664e0 | 2004-12-27 08:50:27 +0000 | [diff] [blame] | 66 | ConfigureScript := $(BUILD_SRC_ROOT)/configure |
| 67 | ConfigStatusScript := $(BUILD_OBJ_ROOT)/config.status |
| 68 | LConfigStatusScript:= $(LLVM_OBJ_ROOT)/config.status |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 69 | MakefileConfigIn := $(LLVM_SRC_ROOT)/Makefile.config.in |
| 70 | MakefileConfig := $(LLVM_OBJ_ROOT)/Makefile.config |
| 71 | PreConditions := $(ConfigStatusScript) $(MakefileConfig) $(ObjMakefiles) |
| Reid Spencer | 9411c64 | 2004-10-26 22:26:33 +0000 | [diff] [blame] | 72 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 73 | preconditions : $(PreConditions) |
| Reid Spencer | 9411c64 | 2004-10-26 22:26:33 +0000 | [diff] [blame] | 74 | |
| 75 | #------------------------------------------------------------------------ |
| 76 | # Make sure the BUILT_SOURCES are built first |
| 77 | #------------------------------------------------------------------------ |
| Reid Spencer | 07a549a | 2004-12-16 07:15:16 +0000 | [diff] [blame] | 78 | $(filter-out clean clean-local,$(UserTargets)):: $(BUILT_SOURCES) |
| Reid Spencer | 9411c64 | 2004-10-26 22:26:33 +0000 | [diff] [blame] | 79 | |
| 80 | clean-local:: |
| 81 | ifneq ($(strip $(BUILT_SOURCES)),) |
| Reid Spencer | ca5fe8f | 2004-11-02 16:56:15 +0000 | [diff] [blame] | 82 | -$(Verb) $(RM) -f $(BUILT_SOURCES) |
| Reid Spencer | 9411c64 | 2004-10-26 22:26:33 +0000 | [diff] [blame] | 83 | endif |
| 84 | |
| Reid Spencer | 31f9524 | 2004-12-16 08:00:46 +0000 | [diff] [blame] | 85 | ifneq ($(BUILD_OBJ_ROOT),$(BUILD_SRC_ROOT)) |
| 86 | spotless: |
| Reid Spencer | 31f9524 | 2004-12-16 08:00:46 +0000 | [diff] [blame] | 87 | $(Verb) if test -x config.status ; then \ |
| Reid Spencer | 39b7363 | 2004-12-17 07:45:03 +0000 | [diff] [blame] | 88 | $(EchoCmd) Wiping out $(BUILD_OBJ_ROOT) ; \ |
| 89 | $(MKDIR) .spotless.save ; \ |
| 90 | $(MV) config.status .spotless.save ; \ |
| 91 | $(MV) mklib .spotless.save ; \ |
| 92 | $(MV) projects .spotless.save ; \ |
| Reid Spencer | 31f9524 | 2004-12-16 08:00:46 +0000 | [diff] [blame] | 93 | $(RM) -rf * ; \ |
| Reid Spencer | 39b7363 | 2004-12-17 07:45:03 +0000 | [diff] [blame] | 94 | $(MV) .spotless.save/config.status . ; \ |
| 95 | $(MV) .spotless.save/mklib . ; \ |
| 96 | $(MV) .spotless.save/projects . ; \ |
| 97 | $(RM) -rf .spotless.save ; \ |
| 98 | $(EchoCmd) Rebuilding configuration of $(BUILD_OBJ_ROOT) ; \ |
| 99 | $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \ |
| 100 | $(ConfigStatusScript) ; \ |
| Reid Spencer | 31f9524 | 2004-12-16 08:00:46 +0000 | [diff] [blame] | 101 | else \ |
| 102 | $(EchoCmd) "make spotless" can only be run from $(BUILD_OBJ_ROOT); \ |
| 103 | fi |
| 104 | endif |
| 105 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 106 | $(BUILT_SOURCES) : $(ObjMakefiles) |
| Reid Spencer | 80f0ef7 | 2004-10-28 00:41:43 +0000 | [diff] [blame] | 107 | |
| Reid Spencer | 9411c64 | 2004-10-26 22:26:33 +0000 | [diff] [blame] | 108 | #------------------------------------------------------------------------ |
| 109 | # Make sure we're not using a stale configuration |
| 110 | #------------------------------------------------------------------------ |
| Reid Spencer | c371984 | 2004-12-16 18:26:53 +0000 | [diff] [blame] | 111 | reconfigure: |
| 112 | $(Echo) Reconfiguring $(BUILD_OBJ_ROOT) |
| 113 | $(Verb) cd $(BUILD_OBJ_ROOT) && \ |
| Reid Spencer | 32924e0 | 2004-12-24 03:36:31 +0000 | [diff] [blame] | 114 | if test -w $(BUILD_OBJ_ROOT)/config.cache ; then \ |
| 115 | $(RM) $(BUILD_OBJ_ROOT)/config.cache ; \ |
| 116 | fi ; \ |
| Reid Spencer | c371984 | 2004-12-16 18:26:53 +0000 | [diff] [blame] | 117 | $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \ |
| 118 | $(ConfigStatusScript) |
| 119 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 120 | .PRECIOUS: $(ConfigStatusScript) |
| 121 | $(ConfigStatusScript): $(ConfigureScript) |
| 122 | $(Echo) Reconfiguring with $< |
| Reid Spencer | 7d27700 | 2004-11-29 12:37:44 +0000 | [diff] [blame] | 123 | $(Verb) cd $(BUILD_OBJ_ROOT) && \ |
| Reid Spencer | 32924e0 | 2004-12-24 03:36:31 +0000 | [diff] [blame] | 124 | if test -w $(BUILD_OBJ_ROOT)/config.cache ; then \ |
| 125 | $(RM) $(BUILD_OBJ_ROOT)/config.cache ; \ |
| 126 | fi ; \ |
| Reid Spencer | 7d27700 | 2004-11-29 12:37:44 +0000 | [diff] [blame] | 127 | $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \ |
| 128 | $(ConfigStatusScript) |
| Reid Spencer | 9411c64 | 2004-10-26 22:26:33 +0000 | [diff] [blame] | 129 | |
| 130 | #------------------------------------------------------------------------ |
| 131 | # Make sure the configuration makefile is up to date |
| 132 | #------------------------------------------------------------------------ |
| Reid Spencer | f3664e0 | 2004-12-27 08:50:27 +0000 | [diff] [blame] | 133 | $(MakefileConfig): $(MakefileConfigIn) $(LConfigStatusScript) |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 134 | $(Echo) Regenerating $@ |
| Reid Spencer | f3664e0 | 2004-12-27 08:50:27 +0000 | [diff] [blame] | 135 | $(Verb) cd $(LLVM_OBJ_ROOT) ; $(LConfigStatusScript) Makefile.config |
| Reid Spencer | 9411c64 | 2004-10-26 22:26:33 +0000 | [diff] [blame] | 136 | |
| 137 | #------------------------------------------------------------------------ |
| 138 | # If the Makefile in the source tree has been updated, copy it over into the |
| 139 | # build tree. But, only do this if the source and object makefiles differ |
| 140 | #------------------------------------------------------------------------ |
| 141 | ifneq ($(BUILD_OBJ_DIR),$(BUILD_SRC_DIR)) |
| 142 | |
| Reid Spencer | 023c446 | 2004-11-17 19:08:44 +0000 | [diff] [blame] | 143 | Makefile: $(BUILD_SRC_DIR)/Makefile |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 144 | $(Echo) "Updating Makefile" |
| 145 | $(Verb) $(MKDIR) $(@D) |
| Reid Spencer | c371984 | 2004-12-16 18:26:53 +0000 | [diff] [blame] | 146 | $(Verb) $(CP) -f $< $@ |
| Reid Spencer | 9411c64 | 2004-10-26 22:26:33 +0000 | [diff] [blame] | 147 | |
| 148 | # Copy the Makefile.* files unless we're in the root directory which avoids |
| 149 | # the copying of Makefile.config.in or other things that should be explicitly |
| 150 | # taken care of. |
| Reid Spencer | 9411c64 | 2004-10-26 22:26:33 +0000 | [diff] [blame] | 151 | $(BUILD_OBJ_DIR)/Makefile% : $(BUILD_SRC_DIR)/Makefile% |
| Reid Spencer | 8660678 | 2004-10-26 23:10:00 +0000 | [diff] [blame] | 152 | @case '$?' in \ |
| 153 | *Makefile.rules) ;; \ |
| 154 | *.in) ;; \ |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 155 | *) $(Echo) "Updating $(@F)" ; \ |
| Reid Spencer | 8660678 | 2004-10-26 23:10:00 +0000 | [diff] [blame] | 156 | $(MKDIR) $(@D) ; \ |
| Reid Spencer | c371984 | 2004-12-16 18:26:53 +0000 | [diff] [blame] | 157 | $(CP) -f $< $@ ;; \ |
| Reid Spencer | 8660678 | 2004-10-26 23:10:00 +0000 | [diff] [blame] | 158 | esac |
| 159 | |
| Reid Spencer | 9411c64 | 2004-10-26 22:26:33 +0000 | [diff] [blame] | 160 | endif |
| 161 | |
| 162 | #------------------------------------------------------------------------ |
| 163 | # Set up the basic dependencies |
| 164 | #------------------------------------------------------------------------ |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 165 | $(UserTargets):: $(PreConditions) |
| Reid Spencer | 9411c64 | 2004-10-26 22:26:33 +0000 | [diff] [blame] | 166 | |
| 167 | all:: all-local |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 168 | clean:: clean-local |
| Reid Spencer | 3d65949 | 2004-11-02 16:36:03 +0000 | [diff] [blame] | 169 | clean-all:: clean-local clean-all-local |
| Reid Spencer | 9411c64 | 2004-10-26 22:26:33 +0000 | [diff] [blame] | 170 | install:: install-local |
| 171 | uninstall:: uninstall-local |
| Reid Spencer | 9411c64 | 2004-10-26 22:26:33 +0000 | [diff] [blame] | 172 | install-local:: all-local |
| Reid Spencer | 44cb1b3 | 2004-12-03 20:08:48 +0000 | [diff] [blame] | 173 | install-bytecode:: install-bytecode-local |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 174 | |
| 175 | ############################################################################### |
| 176 | # VARIABLES: Set up various variables based on configuration data |
| 177 | ############################################################################### |
| 178 | |
| 179 | #-------------------------------------------------------------------- |
| 180 | # Variables derived from configuration we are building |
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 181 | #-------------------------------------------------------------------- |
| 182 | |
| Reid Spencer | 325a87e | 2005-01-02 17:43:20 +0000 | [diff] [blame] | 183 | |
| Chris Lattner | 760da06 | 2003-03-14 20:25:22 +0000 | [diff] [blame] | 184 | ifdef ENABLE_PROFILING |
| Reid Spencer | 9af3b29 | 2004-11-01 07:50:27 +0000 | [diff] [blame] | 185 | BuildMode := Profile |
| Reid Spencer | 519799e | 2004-12-08 04:34:51 +0000 | [diff] [blame] | 186 | CXX.Flags := -O3 -DNDEBUG -felide-constructors -finline-functions -pg |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 187 | C.Flags := -O3 -DNDEBUG -pg |
| 188 | LD.Flags := -O3 -DNDEBUG -pg |
| Chris Lattner | 760da06 | 2003-03-14 20:25:22 +0000 | [diff] [blame] | 189 | else |
| 190 | ifdef ENABLE_OPTIMIZED |
| Reid Spencer | 9af3b29 | 2004-11-01 07:50:27 +0000 | [diff] [blame] | 191 | BuildMode := Release |
| Reid Spencer | 325a87e | 2005-01-02 17:43:20 +0000 | [diff] [blame] | 192 | # Don't use -fomit-frame-pointer on FreeBSD |
| 193 | ifneq ($(OS),FreeBSD) |
| 194 | OmitFramePointer := -fomit-frame-pointer |
| 195 | endif |
| 196 | CXX.Flags := -O3 -DNDEBUG -finline-functions -felide-constructors \ |
| 197 | $(OmitFramePointer) |
| 198 | C.Flags := -O3 -DNDEBUG $(OmitFramePointer) |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 199 | LD.Flags := -O3 -DNDEBUG |
| Chris Lattner | 760da06 | 2003-03-14 20:25:22 +0000 | [diff] [blame] | 200 | else |
| Reid Spencer | 9af3b29 | 2004-11-01 07:50:27 +0000 | [diff] [blame] | 201 | BuildMode := Debug |
| Reid Spencer | 519799e | 2004-12-08 04:34:51 +0000 | [diff] [blame] | 202 | CXX.Flags := -g -D_DEBUG |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 203 | C.Flags := -g -D_DEBUG |
| 204 | LD.Flags := -g -D_DEBUG |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 205 | KEEP_SYMBOLS := 1 |
| Chris Lattner | 760da06 | 2003-03-14 20:25:22 +0000 | [diff] [blame] | 206 | endif |
| 207 | endif |
| 208 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 209 | CXX.Flags += $(CXXFLAGS) |
| 210 | C.Flags += $(CFLAGS) |
| 211 | CPP.Flags += $(CPPFLAGS) |
| 212 | LD.Flags += $(LDFLAGS) |
| 213 | AR.Flags := cru |
| 214 | LibTool.Flags := --tag=CXX |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 215 | |
| 216 | #-------------------------------------------------------------------- |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 217 | # Directory locations |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 218 | #-------------------------------------------------------------------- |
| Reid Spencer | 9af3b29 | 2004-11-01 07:50:27 +0000 | [diff] [blame] | 219 | ObjDir := $(BUILD_OBJ_DIR)/$(BuildMode) |
| Reid Spencer | 815cbcf | 2004-11-18 10:03:46 +0000 | [diff] [blame] | 220 | LibDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/lib |
| Reid Spencer | 9a5acaf | 2004-11-18 20:04:39 +0000 | [diff] [blame] | 221 | ToolDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/bin |
| Reid Spencer | 815cbcf | 2004-11-18 10:03:46 +0000 | [diff] [blame] | 222 | ExmplDir := $(BUILD_OBJ_ROOT)/$(BuildMode)/examples |
| 223 | LLVMLibDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/lib |
| Reid Spencer | 9a5acaf | 2004-11-18 20:04:39 +0000 | [diff] [blame] | 224 | LLVMToolDir := $(LLVM_OBJ_ROOT)/$(BuildMode)/bin |
| Reid Spencer | 775bf89 | 2004-12-28 07:59:22 +0000 | [diff] [blame] | 225 | LLVMExmplDir:= $(LLVM_OBJ_ROOT)/$(BuildMode)/examples |
| Reid Spencer | 2f138e7 | 2004-12-22 05:57:21 +0000 | [diff] [blame] | 226 | CFERuntimeLibDir := $(LLVMGCCDIR)/lib |
| John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame] | 227 | |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 228 | #-------------------------------------------------------------------- |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 229 | # Full Paths To Compiled Tools and Utilities |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 230 | #-------------------------------------------------------------------- |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 231 | EchoCmd := $(ECHO) llvm[$(MAKELEVEL)]: |
| 232 | Echo := @$(EchoCmd) |
| 233 | ifndef LIBTOOL |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 234 | LIBTOOL := $(LLVM_OBJ_ROOT)/mklib |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 235 | endif |
| 236 | ifndef LLVMAS |
| 237 | LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT) |
| 238 | endif |
| 239 | ifndef BURG |
| 240 | BURG := $(LLVMToolDir)/burg$(EXEEXT) |
| 241 | endif |
| 242 | ifndef TBLGEN |
| 243 | TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT) |
| 244 | endif |
| Chris Lattner | 478b3b4 | 2004-11-29 19:47:58 +0000 | [diff] [blame] | 245 | ifndef GCCAS |
| 246 | GCCAS := $(LLVMToolDir)/gccas$(EXEEXT) |
| 247 | endif |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 248 | ifndef GCCLD |
| 249 | GCCLD := $(LLVMToolDir)/gccld$(EXEEXT) |
| 250 | endif |
| Alkis Evlogimenos | 7e80cd9 | 2004-12-13 17:44:14 +0000 | [diff] [blame] | 251 | ifndef LDIS |
| 252 | LLVMDIS := $(LLVMToolDir)/llvm-dis$(EXEEXT) |
| 253 | endif |
| 254 | ifndef LLI |
| 255 | LLI := $(LLVMToolDir)/lli$(EXEEXT) |
| 256 | endif |
| 257 | ifndef LOPT |
| Alkis Evlogimenos | 20d793a | 2004-12-13 18:08:29 +0000 | [diff] [blame] | 258 | LOPT := $(LLVMToolDir)/opt$(EXEEXT) |
| Alkis Evlogimenos | 7e80cd9 | 2004-12-13 17:44:14 +0000 | [diff] [blame] | 259 | endif |
| John Criswell | f5629d0 | 2005-01-03 17:42:57 +0000 | [diff] [blame] | 260 | LLVMGCCWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGCC) |
| 261 | LLVMGXXWITHPATH := PATH="$(LLVMToolDir):$(PATH)" $(LLVMGXX) |
| Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame] | 262 | |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 263 | #-------------------------------------------------------------------- |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 264 | # Adjust to user's request |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 265 | #-------------------------------------------------------------------- |
| Dinakar Dhurjati | ffb55cd | 2003-05-29 16:18:20 +0000 | [diff] [blame] | 266 | |
| Reid Spencer | 492c293 | 2005-01-11 04:31:07 +0000 | [diff] [blame] | 267 | # Adjust LD.Flags and Libtool.Flags depending on the kind of library that is |
| 268 | # to be built. Note that if LOADABLE_MODULE is specified then the resulting |
| 269 | # shared library can be opened with dlopen |
| 270 | ifdef SHARED_LIBRARY |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 271 | LD.Flags += -rpath $(LibDir) |
| Reid Spencer | 492c293 | 2005-01-11 04:31:07 +0000 | [diff] [blame] | 272 | ifdef LOADABLE_MODULE |
| 273 | LD.Flags += -module |
| 274 | endif |
| 275 | else |
| 276 | LibTool.Flags += --tag=disable-shared |
| John Criswell | 82f4a5a | 2003-07-31 20:58:51 +0000 | [diff] [blame] | 277 | endif |
| 278 | |
| Reid Spencer | cceed9f | 2004-11-08 17:32:12 +0000 | [diff] [blame] | 279 | ifdef TOOL_VERBOSE |
| 280 | C.Flags += -v |
| 281 | CXX.Flags += -v |
| 282 | LD.Flags += -v |
| Reid Spencer | cceed9f | 2004-11-08 17:32:12 +0000 | [diff] [blame] | 283 | VERBOSE := 1 |
| 284 | endif |
| 285 | |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 286 | # Adjust settings for verbose mode |
| Chris Lattner | 760da06 | 2003-03-14 20:25:22 +0000 | [diff] [blame] | 287 | ifndef VERBOSE |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 288 | Verb := @ |
| 289 | LibTool.Flags += --silent |
| 290 | AR.Flags += >/dev/null 2>/dev/null |
| 291 | ConfigureScriptFLAGS += >$(BUILD_OBJ_DIR)/configure.out 2>&1 |
| Reid Spencer | 151f8ba | 2004-10-25 08:27:37 +0000 | [diff] [blame] | 292 | else |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 293 | ConfigureScriptFLAGS := |
| Misha Brukman | b5f096f | 2002-09-12 16:05:39 +0000 | [diff] [blame] | 294 | endif |
| 295 | |
| Vikram S. Adve | feeae58 | 2002-09-18 11:55:13 +0000 | [diff] [blame] | 296 | # By default, strip symbol information from executable |
| Chris Lattner | 760da06 | 2003-03-14 20:25:22 +0000 | [diff] [blame] | 297 | ifndef KEEP_SYMBOLS |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 298 | Strip := $(PLATFORMSTRIPOPTS) |
| 299 | StripWarnMsg := "(without symbols)" |
| Vikram S. Adve | feeae58 | 2002-09-18 11:55:13 +0000 | [diff] [blame] | 300 | endif |
| 301 | |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 302 | # Adjust linker flags for building an executable |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 303 | ifdef TOOLNAME |
| Reid Spencer | 815cbcf | 2004-11-18 10:03:46 +0000 | [diff] [blame] | 304 | ifdef EXAMPLE_TOOL |
| 305 | LD.Flags += -rpath $(ExmplDir) -export-dynamic |
| 306 | else |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 307 | LD.Flags += -rpath $(ToolDir) -export-dynamic |
| Dinakar Dhurjati | 87ea8aa | 2003-10-29 14:28:35 +0000 | [diff] [blame] | 308 | endif |
| Reid Spencer | 815cbcf | 2004-11-18 10:03:46 +0000 | [diff] [blame] | 309 | endif |
| Dinakar Dhurjati | 87ea8aa | 2003-10-29 14:28:35 +0000 | [diff] [blame] | 310 | |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 311 | #---------------------------------------------------------- |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 312 | # Options To Invoke Tools |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 313 | #---------------------------------------------------------- |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 314 | |
| 315 | CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused |
| 316 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 317 | LD.Flags += -L$(LibDir) -L$(LLVMLibDir) |
| 318 | CPP.Flags += -I$(BUILD_OBJ_DIR) \ |
| Reid Spencer | 151f8ba | 2004-10-25 08:27:37 +0000 | [diff] [blame] | 319 | -I$(BUILD_SRC_DIR) \ |
| 320 | -I$(BUILD_SRC_ROOT)/include \ |
| 321 | -I$(BUILD_OBJ_ROOT)/include \ |
| 322 | -I$(LLVM_OBJ_ROOT)/include \ |
| 323 | -I$(LLVM_SRC_ROOT)/include \ |
| 324 | -D_GNU_SOURCE -D__STDC_LIMIT_MACROS |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 325 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 326 | Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags) |
| 327 | LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C) |
| Reid Spencer | 2f138e7 | 2004-12-22 05:57:21 +0000 | [diff] [blame] | 328 | BCCompile.C = $(LLVMGCCWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \ |
| 329 | $(C.Flags) -c |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 330 | Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c |
| 331 | LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX) |
| Reid Spencer | bc52ad7 | 2004-12-24 14:47:34 +0000 | [diff] [blame] | 332 | BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \ |
| 333 | $(CXX.Flags) -c |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 334 | Link = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \ |
| 335 | $(CompileCommonOpts) $(LD.Flags) $(Strip) |
| 336 | Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \ |
| Reid Spencer | a69b1ea | 2004-10-28 09:15:28 +0000 | [diff] [blame] | 337 | $(CompileCommonOpts) |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 338 | LTInstall = $(LIBTOOL) $(LibTool.Flags) --mode=install $(INSTALL) |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 339 | Burg = $(BURG) -I $(BUILD_SRC_DIR) |
| 340 | TableGen = $(TBLGEN) -I $(BUILD_SRC_DIR) |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 341 | Archive = $(AR) $(AR.Flags) |
| Reid Spencer | 9a2f137 | 2004-12-02 09:28:21 +0000 | [diff] [blame] | 342 | LArchive = $(LLVMToolDir)/llvm-ar rcsf |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 343 | ifdef RANLIB |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 344 | Ranlib = $(RANLIB) |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 345 | else |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 346 | Ranlib = ranlib |
| John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame] | 347 | endif |
| 348 | |
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 349 | #---------------------------------------------------------- |
| Reid Spencer | 345235ca | 2004-12-04 22:34:09 +0000 | [diff] [blame] | 350 | # Get the list of source files and compute object file |
| 351 | # names from them. |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 352 | #---------------------------------------------------------- |
| Reid Spencer | 345235ca | 2004-12-04 22:34:09 +0000 | [diff] [blame] | 353 | ifdef FAKE_SOURCES |
| 354 | Sources := |
| 355 | FakeSources := $(FAKE_SOURCES) |
| 356 | ifdef BUILT_SOURCES |
| 357 | FakeSources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES)) |
| 358 | endif |
| 359 | BaseNameSources := $(sort $(basename $(FakeSources))) |
| 360 | ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o) |
| 361 | ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo) |
| 362 | ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc) |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 363 | else |
| Reid Spencer | 345235ca | 2004-12-04 22:34:09 +0000 | [diff] [blame] | 364 | ifndef SOURCES |
| 365 | Sources := $(notdir $(wildcard $(BUILD_SRC_DIR)/*.cpp \ |
| 366 | $(BUILD_SRC_DIR)/*.cc $(BUILD_SRC_DIR)/*.c $(BUILD_SRC_DIR)/*.y \ |
| 367 | $(BUILD_SRC_DIR)/*.l)) |
| 368 | else |
| 369 | Sources := $(SOURCES) |
| 370 | endif |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 371 | |
| Reid Spencer | 345235ca | 2004-12-04 22:34:09 +0000 | [diff] [blame] | 372 | ifdef BUILT_SOURCES |
| 373 | Sources += $(filter %.cpp %.c %.cc %.y %.l,$(BUILT_SOURCES)) |
| 374 | endif |
| Vikram S. Adve | 112a72c | 2001-07-15 13:16:47 +0000 | [diff] [blame] | 375 | |
| Reid Spencer | 345235ca | 2004-12-04 22:34:09 +0000 | [diff] [blame] | 376 | BaseNameSources := $(sort $(basename $(Sources))) |
| 377 | ObjectsO := $(BaseNameSources:%=$(ObjDir)/%.o) |
| 378 | ObjectsLO := $(BaseNameSources:%=$(ObjDir)/%.lo) |
| 379 | ObjectsBC := $(BaseNameSources:%=$(ObjDir)/%.bc) |
| 380 | endif |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 381 | |
| 382 | ############################################################################### |
| 383 | # DIRECTORIES: Handle recursive descent of directory structure |
| 384 | ############################################################################### |
| John Criswell | 82f4a5a | 2003-07-31 20:58:51 +0000 | [diff] [blame] | 385 | |
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 386 | #--------------------------------------------------------- |
| Reid Spencer | a69b1ea | 2004-10-28 09:15:28 +0000 | [diff] [blame] | 387 | # Provide rules to make install dirs. This must be early |
| 388 | # in the file so they get built before dependencies |
| 389 | #--------------------------------------------------------- |
| 390 | |
| 391 | $(bindir): |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 392 | $(Verb) $(MKDIR) $(bindir) |
| Chris Lattner | e4cb90f | 2004-11-01 06:14:59 +0000 | [diff] [blame] | 393 | |
| Reid Spencer | a69b1ea | 2004-10-28 09:15:28 +0000 | [diff] [blame] | 394 | $(libdir): |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 395 | $(Verb) $(MKDIR) $(libdir) |
| Reid Spencer | a69b1ea | 2004-10-28 09:15:28 +0000 | [diff] [blame] | 396 | |
| Reid Spencer | ab3690b | 2004-12-13 07:38:07 +0000 | [diff] [blame] | 397 | $(includedir): |
| 398 | $(Verb) $(MKDIR) $(includedir) |
| Reid Spencer | a69b1ea | 2004-10-28 09:15:28 +0000 | [diff] [blame] | 399 | |
| 400 | $(sysconfdir): |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 401 | $(Verb) $(MKDIR) $(sysconfdir) |
| Reid Spencer | a69b1ea | 2004-10-28 09:15:28 +0000 | [diff] [blame] | 402 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 403 | # To create other directories, as needed, and timestamp their creation |
| 404 | %/.dir: |
| 405 | $(Verb) $(MKDIR) $* > /dev/null |
| Reid Spencer | fbbf307 | 2004-11-29 05:00:33 +0000 | [diff] [blame] | 406 | $(Verb) $(DATE) > $@ |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 407 | |
| Reid Spencer | 815cbcf | 2004-11-18 10:03:46 +0000 | [diff] [blame] | 408 | .PRECIOUS: $(ObjDir)/.dir $(LibDir)/.dir $(ToolDir)/.dir $(ExmplDir)/.dir |
| 409 | .PRECIOUS: $(LLVMLibDir)/.dir $(LLVMToolDir)/.dir $(LLVMExmplDir)/.dir |
| Reid Spencer | a69b1ea | 2004-10-28 09:15:28 +0000 | [diff] [blame] | 410 | |
| 411 | #--------------------------------------------------------- |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 412 | # Handle the DIRS options for sequential construction |
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 413 | #--------------------------------------------------------- |
| 414 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 415 | SubDirs := |
| Anand Shukla | 7c7a07e | 2002-09-18 04:29:30 +0000 | [diff] [blame] | 416 | ifdef DIRS |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 417 | SubDirs += $(DIRS) |
| 418 | $(RecursiveTargets):: |
| 419 | $(Verb) for dir in $(DIRS); do \ |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 420 | if [ ! -f $$dir/Makefile ]; then \ |
| 421 | $(MKDIR) $$dir; \ |
| Reid Spencer | c371984 | 2004-12-16 18:26:53 +0000 | [diff] [blame] | 422 | $(CP) $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \ |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 423 | fi; \ |
| Reid Spencer | a23c066 | 2004-12-08 22:58:34 +0000 | [diff] [blame] | 424 | if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \ |
| 425 | ($(MAKE) -C $$dir $@ ) || exit 1; \ |
| 426 | fi ; \ |
| Chris Lattner | f1ffd99 | 2002-09-17 23:35:02 +0000 | [diff] [blame] | 427 | done |
| Anand Shukla | 7c7a07e | 2002-09-18 04:29:30 +0000 | [diff] [blame] | 428 | endif |
| Chris Lattner | a8abc22 | 2002-09-18 03:22:27 +0000 | [diff] [blame] | 429 | |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 430 | #--------------------------------------------------------- |
| 431 | # Handle the EXPERIMENTAL_DIRS options ensuring success |
| 432 | # after each directory is built. |
| 433 | #--------------------------------------------------------- |
| 434 | ifdef EXPERIMENTAL_DIRS |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 435 | $(RecursiveTargets):: |
| 436 | $(Verb) for dir in $(EXPERIMENTAL_DIRS); do \ |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 437 | if [ ! -f $$dir/Makefile ]; then \ |
| 438 | $(MKDIR) $$dir; \ |
| Reid Spencer | c371984 | 2004-12-16 18:26:53 +0000 | [diff] [blame] | 439 | $(CP) $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \ |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 440 | fi; \ |
| Reid Spencer | a23c066 | 2004-12-08 22:58:34 +0000 | [diff] [blame] | 441 | if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \ |
| 442 | ($(MAKE) -C $$dir $@ ) || exit 0; \ |
| 443 | fi ; \ |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 444 | done |
| 445 | endif |
| Chris Lattner | a8abc22 | 2002-09-18 03:22:27 +0000 | [diff] [blame] | 446 | |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 447 | #--------------------------------------------------------- |
| 448 | # Handle the PARALLEL_DIRS options for parallel construction |
| 449 | #--------------------------------------------------------- |
| 450 | ifdef PARALLEL_DIRS |
| 451 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 452 | SubDirs += $(PARALLEL_DIRS) |
| 453 | |
| Reid Spencer | 44cb1b3 | 2004-12-03 20:08:48 +0000 | [diff] [blame] | 454 | # Unfortunately, this list must be maintained if new recursive targets are added |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 455 | all :: $(addsuffix /.makeall ,$(PARALLEL_DIRS)) |
| 456 | clean :: $(addsuffix /.makeclean ,$(PARALLEL_DIRS)) |
| Reid Spencer | ca5fe8f | 2004-11-02 16:56:15 +0000 | [diff] [blame] | 457 | clean-all:: $(addsuffix /.makeclean-all,$(PARALLEL_DIRS)) |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 458 | install :: $(addsuffix /.makeinstall ,$(PARALLEL_DIRS)) |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 459 | uninstall:: $(addsuffix /.makeuninstall,$(PARALLEL_DIRS)) |
| Reid Spencer | 44cb1b3 | 2004-12-03 20:08:48 +0000 | [diff] [blame] | 460 | install-bytecode :: $(addsuffix /.makeinstall-bytecode,$(PARALLEL_DIRS)) |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 461 | |
| Reid Spencer | 345235ca | 2004-12-04 22:34:09 +0000 | [diff] [blame] | 462 | ParallelTargets := $(foreach T,$(RecursiveTargets),%/.make$(T)) |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 463 | |
| Reid Spencer | 345235ca | 2004-12-04 22:34:09 +0000 | [diff] [blame] | 464 | $(ParallelTargets) : |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 465 | $(Verb) if [ ! -f $(@D)/Makefile ]; then \ |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 466 | $(MKDIR) $(@D); \ |
| Reid Spencer | c371984 | 2004-12-16 18:26:53 +0000 | [diff] [blame] | 467 | $(CP) $(BUILD_SRC_DIR)/$(@D)/Makefile $(@D)/Makefile; \ |
| John Criswell | b3866b6 | 2003-11-25 19:32:22 +0000 | [diff] [blame] | 468 | fi; \ |
| Reid Spencer | a23c066 | 2004-12-08 22:58:34 +0000 | [diff] [blame] | 469 | if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \ |
| 470 | $(MAKE) -C $(@D) $(subst $(@D)/.make,,$@) ; \ |
| 471 | fi |
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 472 | endif |
| 473 | |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 474 | #--------------------------------------------------------- |
| 475 | # Handle the OPTIONAL_DIRS options for directores that may |
| 476 | # or may not exist. |
| 477 | #--------------------------------------------------------- |
| John Criswell | 2a6530f | 2003-06-27 16:58:44 +0000 | [diff] [blame] | 478 | ifdef OPTIONAL_DIRS |
| Reid Spencer | 151f8ba | 2004-10-25 08:27:37 +0000 | [diff] [blame] | 479 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 480 | SubDirs += $(OPTIONAL_DIRS) |
| Reid Spencer | 151f8ba | 2004-10-25 08:27:37 +0000 | [diff] [blame] | 481 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 482 | $(RecursiveTargets):: |
| 483 | $(Verb) for dir in $(OPTIONAL_DIRS); do \ |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 484 | if [ -d $(BUILD_SRC_DIR)/$$dir ]; then\ |
| 485 | if [ ! -f $$dir/Makefile ]; then \ |
| 486 | $(MKDIR) $$dir; \ |
| Reid Spencer | c371984 | 2004-12-16 18:26:53 +0000 | [diff] [blame] | 487 | $(CP) $(BUILD_SRC_DIR)/$$dir/Makefile $$dir/Makefile; \ |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 488 | fi; \ |
| Reid Spencer | a23c066 | 2004-12-08 22:58:34 +0000 | [diff] [blame] | 489 | if [ ! -f $$dir/LLVM_DO_NOT_BUILD ]; then \ |
| 490 | ($(MAKE) -C$$dir $@ ) || exit 1; \ |
| 491 | fi ; \ |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 492 | fi \ |
| John Criswell | 2a6530f | 2003-06-27 16:58:44 +0000 | [diff] [blame] | 493 | done |
| 494 | endif |
| 495 | |
| Reid Spencer | fc94508 | 2004-08-20 09:20:05 +0000 | [diff] [blame] | 496 | #--------------------------------------------------------- |
| 497 | # Handle the CONFIG_FILES options |
| 498 | #--------------------------------------------------------- |
| 499 | ifdef CONFIG_FILES |
| Reid Spencer | fc94508 | 2004-08-20 09:20:05 +0000 | [diff] [blame] | 500 | |
| Reid Spencer | c6dcc6a | 2004-10-28 07:57:28 +0000 | [diff] [blame] | 501 | install-local:: $(sysconfdir) $(CONFIG_FILES) |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 502 | $(Echo) Installing Configuration Files To $(sysconfdir) |
| 503 | $(Verb)for file in $(CONFIG_FILES); do \ |
| Reid Spencer | 1b426ab | 2004-11-23 05:59:53 +0000 | [diff] [blame] | 504 | if test -f $(BUILD_OBJ_DIR)/$${file} ; then \ |
| 505 | $(INSTALL) $(BUILD_OBJ_DIR)/$${file} $(sysconfdir) ; \ |
| 506 | elif test -f $(BUILD_SRC_DIR)/$${file} ; then \ |
| 507 | $(INSTALL) $(BUILD_SRC_DIR)/$${file} $(sysconfdir) ; \ |
| 508 | else \ |
| 509 | $(ECHO) Error: cannot find config file $${file}. ; \ |
| 510 | fi \ |
| Reid Spencer | fc94508 | 2004-08-20 09:20:05 +0000 | [diff] [blame] | 511 | done |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 512 | |
| Reid Spencer | c6dcc6a | 2004-10-28 07:57:28 +0000 | [diff] [blame] | 513 | uninstall-local:: |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 514 | $(Echo) Uninstalling Configuration Files From $(sysconfdir) |
| 515 | $(Verb)for file in $(CONFIG_FILES); do \ |
| Reid Spencer | 151f8ba | 2004-10-25 08:27:37 +0000 | [diff] [blame] | 516 | $(RM) -f $(sysconfdir)/$${file} ; \ |
| Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 517 | done |
| 518 | |
| Reid Spencer | fc94508 | 2004-08-20 09:20:05 +0000 | [diff] [blame] | 519 | endif |
| 520 | |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 521 | ############################################################################### |
| 522 | # Library Build Rules: Four ways to build a library |
| 523 | ############################################################################### |
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 524 | |
| Reid Spencer | 7980ea4 | 2004-12-05 05:17:22 +0000 | [diff] [blame] | 525 | #--------------------------------------------------------- |
| 526 | # Bytecode Module Targets: |
| 527 | # If the user set MODULE_NAME then they want to build a |
| 528 | # bytecode module from the sources. We compile all the |
| 529 | # sources and link it together into a single bytecode |
| 530 | # module. |
| 531 | #--------------------------------------------------------- |
| 532 | |
| 533 | ifdef MODULE_NAME |
| 534 | |
| 535 | Module := $(LibDir)/$(MODULE_NAME).bc |
| Reid Spencer | 2f138e7 | 2004-12-22 05:57:21 +0000 | [diff] [blame] | 536 | LinkModule := $(LLVMGCCWITHPATH) -shared -nostdlib |
| Reid Spencer | 7980ea4 | 2004-12-05 05:17:22 +0000 | [diff] [blame] | 537 | |
| 538 | ifdef EXPORTED_SYMBOL_FILE |
| 539 | LinkMOdule += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE) |
| 540 | endif |
| 541 | |
| 542 | $(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD) |
| 543 | $(Echo) Building $(BuildMOde) Bytecode Module $(notdir $@) |
| 544 | $(Verb) $(LinkModule) -o $@ $(ObjectsBC) |
| 545 | |
| 546 | all-local:: $(Module) |
| 547 | |
| 548 | clean-local:: |
| 549 | ifneq ($(strip $(Module)),) |
| 550 | -$(Verb) $(RM) -f $(Module) |
| 551 | endif |
| 552 | |
| Reid Spencer | ab3690b | 2004-12-13 07:38:07 +0000 | [diff] [blame] | 553 | ifdef BYTECODE_DESTINATION |
| 554 | ModuleDestDir := $(BYTECODE_DESTINATION) |
| 555 | else |
| Reid Spencer | 18d3b98 | 2004-12-14 22:44:05 +0000 | [diff] [blame] | 556 | ModuleDestDir := $(libdir) |
| Reid Spencer | ab3690b | 2004-12-13 07:38:07 +0000 | [diff] [blame] | 557 | endif |
| Reid Spencer | 7980ea4 | 2004-12-05 05:17:22 +0000 | [diff] [blame] | 558 | |
| Reid Spencer | ab3690b | 2004-12-13 07:38:07 +0000 | [diff] [blame] | 559 | DestModule := $(ModuleDestDir)/$(MODULE_NAME).bc |
| 560 | |
| 561 | install-module:: $(DestModule) |
| Reid Spencer | 7980ea4 | 2004-12-05 05:17:22 +0000 | [diff] [blame] | 562 | install-local:: $(DestModule) |
| 563 | |
| Reid Spencer | ab3690b | 2004-12-13 07:38:07 +0000 | [diff] [blame] | 564 | $(DestModule): $(ModuleDestDir) $(Module) |
| Reid Spencer | 7980ea4 | 2004-12-05 05:17:22 +0000 | [diff] [blame] | 565 | $(Echo) Installing $(BuildMode) Bytecode Module $(DestModule) |
| 566 | $(Verb) $(INSTALL) $(Module) $@ |
| 567 | |
| 568 | uninstall-local:: |
| 569 | $(Echo) Uninstalling $(BuildMode) Bytecode Module $(DestModule) |
| 570 | -$(Verb) $(RM) -f $(DestModule) |
| 571 | |
| 572 | endif |
| Brian Gaeke | 8abff79 | 2004-01-22 22:53:48 +0000 | [diff] [blame] | 573 | |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 574 | # if we're building a library ... |
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 575 | ifdef LIBRARYNAME |
| Vikram S. Adve | 112a72c | 2001-07-15 13:16:47 +0000 | [diff] [blame] | 576 | |
| Chris Lattner | 2a548c5 | 2002-09-16 22:36:42 +0000 | [diff] [blame] | 577 | # Make sure there isn't any extranous whitespace on the LIBRARYNAME option |
| Chris Lattner | ccb4ebd | 2002-09-16 22:34:56 +0000 | [diff] [blame] | 578 | LIBRARYNAME := $(strip $(LIBRARYNAME)) |
| Reid Spencer | 492c293 | 2005-01-11 04:31:07 +0000 | [diff] [blame] | 579 | ifdef LOADABLE_MODULE |
| 580 | LibName.LA := $(LibDir)/$(LIBRARYNAME).la |
| 581 | else |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 582 | LibName.LA := $(LibDir)/lib$(LIBRARYNAME).la |
| Reid Spencer | 492c293 | 2005-01-11 04:31:07 +0000 | [diff] [blame] | 583 | endif |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 584 | LibName.A := $(LibDir)/lib$(LIBRARYNAME).a |
| 585 | LibName.O := $(LibDir)/$(LIBRARYNAME).o |
| Reid Spencer | 9a2f137 | 2004-12-02 09:28:21 +0000 | [diff] [blame] | 586 | LibName.BCA:= $(LibDir)/lib$(LIBRARYNAME).bca |
| Chris Lattner | ccb4ebd | 2002-09-16 22:34:56 +0000 | [diff] [blame] | 587 | |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 588 | #--------------------------------------------------------- |
| 589 | # Shared Library Targets: |
| 590 | # If the user asked for a shared library to be built |
| 591 | # with the SHARED_LIBRARY variable, then we provide |
| 592 | # targets for building them. |
| 593 | #--------------------------------------------------------- |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 594 | ifdef SHARED_LIBRARY |
| 595 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 596 | all-local:: $(LibName.LA) |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 597 | |
| Reid Spencer | f2ac189 | 2004-12-16 07:36:08 +0000 | [diff] [blame] | 598 | $(LibName.LA): $(ObjectsLO) $(LibDir)/.dir |
| Reid Spencer | 9af3b29 | 2004-11-01 07:50:27 +0000 | [diff] [blame] | 599 | $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT) |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 600 | $(Verb) $(Link) -o $@ $(ObjectsLO) |
| 601 | $(Verb) $(LTInstall) $@ $(LibDir) |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 602 | |
| 603 | clean-local:: |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 604 | ifneq ($(strip $(LibName.LA)),) |
| Reid Spencer | ca5fe8f | 2004-11-02 16:56:15 +0000 | [diff] [blame] | 605 | -$(Verb) $(RM) -f $(LibName.LA) |
| Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 606 | endif |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 607 | |
| Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 608 | DestSharedLib = $(libdir)/lib$(LIBRARYNAME)$(SHLIBEXT) |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 609 | |
| Reid Spencer | c6dcc6a | 2004-10-28 07:57:28 +0000 | [diff] [blame] | 610 | install-local:: $(DestSharedLib) |
| Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 611 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 612 | $(DestSharedLib): $(libdir) $(LibName.LA) |
| Reid Spencer | 9af3b29 | 2004-11-01 07:50:27 +0000 | [diff] [blame] | 613 | $(Echo) Installing $(BuildMode) Shared Library $(DestSharedLib) |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 614 | $(Verb) $(LTInstall) $(LibName.LA) $(DestSharedLib) |
| 615 | $(Verb) $(LIBTOOL) --finish $(libdir) |
| Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 616 | |
| Reid Spencer | c6dcc6a | 2004-10-28 07:57:28 +0000 | [diff] [blame] | 617 | uninstall-local:: |
| Reid Spencer | 9af3b29 | 2004-11-01 07:50:27 +0000 | [diff] [blame] | 618 | $(Echo) Uninstalling $(BuildMode) Shared Library $(DestSharedLib) |
| Reid Spencer | 12d7951 | 2004-11-12 02:27:36 +0000 | [diff] [blame] | 619 | -$(Verb) $(RM) -f $(libdir)/lib$(LIBRARYNAME).* |
| Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 620 | |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 621 | endif |
| 622 | |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 623 | #--------------------------------------------------------- |
| 624 | # Bytecode Library Targets: |
| 625 | # If the user asked for a bytecode library to be built |
| 626 | # with the BYTECODE_LIBRARY variable, then we provide |
| 627 | # targets for building them. |
| 628 | #--------------------------------------------------------- |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 629 | ifdef BYTECODE_LIBRARY |
| 630 | |
| Reid Spencer | 776b805 | 2004-12-03 06:04:35 +0000 | [diff] [blame] | 631 | # make the C and C++ compilers strip debug info out of bytecode libraries. |
| 632 | BCCompile.C += -Wa,-strip-debug |
| 633 | BCCompile.CXX += -Wa,-strip-debug |
| 634 | |
| Reid Spencer | 9a2f137 | 2004-12-02 09:28:21 +0000 | [diff] [blame] | 635 | all-local:: $(LibName.BCA) |
| 636 | |
| 637 | ifdef EXPORTED_SYMBOL_FILE |
| Reid Spencer | 2f138e7 | 2004-12-22 05:57:21 +0000 | [diff] [blame] | 638 | BCLinkLib = $(LLVMGCCWITHPATH) -shared -nostdlib -Xlinker \ |
| Reid Spencer | 9a2f137 | 2004-12-02 09:28:21 +0000 | [diff] [blame] | 639 | -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE) |
| 640 | |
| Reid Spencer | f2ac189 | 2004-12-16 07:36:08 +0000 | [diff] [blame] | 641 | $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir $(GCCLD) \ |
| Chris Lattner | 264ccbe | 2004-12-15 17:14:06 +0000 | [diff] [blame] | 642 | $(LLVMToolDir)/llvm-ar |
| Reid Spencer | 9a2f137 | 2004-12-02 09:28:21 +0000 | [diff] [blame] | 643 | $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) \ |
| 644 | "(internalize)" |
| Chris Lattner | b0ea864 | 2004-12-02 21:23:43 +0000 | [diff] [blame] | 645 | $(Verb) $(BCLinkLib) -o $(ObjDir)/$(LIBRARYNAME).o $(ObjectsBC) |
| Reid Spencer | efd6bb3 | 2004-12-13 03:59:35 +0000 | [diff] [blame] | 646 | $(Verb) $(RM) -f $@ |
| Reid Spencer | 9a2f137 | 2004-12-02 09:28:21 +0000 | [diff] [blame] | 647 | $(Verb) $(LArchive) $@ $(ObjDir)/$(LIBRARYNAME).o |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 648 | else |
| Reid Spencer | f2ac189 | 2004-12-16 07:36:08 +0000 | [diff] [blame] | 649 | $(LibName.BCA): $(ObjectsBC) $(LibDir)/.dir \ |
| Chris Lattner | 264ccbe | 2004-12-15 17:14:06 +0000 | [diff] [blame] | 650 | $(LLVMToolDir)/llvm-ar |
| Reid Spencer | 9a2f137 | 2004-12-02 09:28:21 +0000 | [diff] [blame] | 651 | $(Echo) Building $(BuildMode) Bytecode Archive $(notdir $@) |
| Reid Spencer | efd6bb3 | 2004-12-13 03:59:35 +0000 | [diff] [blame] | 652 | $(Verb) $(RM) -f $@ |
| Reid Spencer | 9a2f137 | 2004-12-02 09:28:21 +0000 | [diff] [blame] | 653 | $(Verb) $(LArchive) $@ $(ObjectsBC) |
| 654 | |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 655 | endif |
| 656 | |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 657 | clean-local:: |
| Reid Spencer | 9a2f137 | 2004-12-02 09:28:21 +0000 | [diff] [blame] | 658 | ifneq ($(strip $(LibName.BCA)),) |
| 659 | -$(Verb) $(RM) -f $(LibName.BCA) |
| Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 660 | endif |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 661 | |
| Reid Spencer | 8f094f3 | 2004-12-13 07:28:21 +0000 | [diff] [blame] | 662 | ifdef BYTECODE_DESTINATION |
| 663 | BytecodeDestDir := $(BYTECODE_DESTINATION) |
| 664 | else |
| 665 | BytecodeDestDir := $(libdir) |
| 666 | endif |
| 667 | |
| 668 | DestBytecodeLib = $(BytecodeDestDir)/lib$(LIBRARYNAME).a |
| Reid Spencer | 9a2f137 | 2004-12-02 09:28:21 +0000 | [diff] [blame] | 669 | |
| Reid Spencer | 44cb1b3 | 2004-12-03 20:08:48 +0000 | [diff] [blame] | 670 | install-bytecode-local:: $(DestBytecodeLib) |
| Reid Spencer | e45ebfa | 2004-10-26 07:09:33 +0000 | [diff] [blame] | 671 | |
| Reid Spencer | c6dcc6a | 2004-10-28 07:57:28 +0000 | [diff] [blame] | 672 | install-local:: $(DestBytecodeLib) |
| Chris Lattner | 481cc7c | 2003-08-15 02:18:35 +0000 | [diff] [blame] | 673 | |
| Reid Spencer | 8f094f3 | 2004-12-13 07:28:21 +0000 | [diff] [blame] | 674 | $(DestBytecodeLib): $(BytecodeDestDir) $(LibName.BCA) |
| Reid Spencer | 9a2f137 | 2004-12-02 09:28:21 +0000 | [diff] [blame] | 675 | $(Echo) Installing $(BuildMode) Bytecode Archive $(DestBytecodeLib) |
| 676 | $(Verb) $(INSTALL) $(LibName.BCA) $@ |
| Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 677 | |
| Reid Spencer | c6dcc6a | 2004-10-28 07:57:28 +0000 | [diff] [blame] | 678 | uninstall-local:: |
| Reid Spencer | 9a2f137 | 2004-12-02 09:28:21 +0000 | [diff] [blame] | 679 | $(Echo) Uninstalling $(BuildMode) Bytecode Archive $(DestBytecodeLib) |
| Reid Spencer | ca5fe8f | 2004-11-02 16:56:15 +0000 | [diff] [blame] | 680 | -$(Verb) $(RM) -f $(DestBytecodeLib) |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 681 | |
| 682 | endif |
| Vikram S. Adve | 60f5606 | 2002-08-02 18:34:12 +0000 | [diff] [blame] | 683 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 684 | #--------------------------------------------------------- |
| 685 | # ReLinked Library Targets: |
| 686 | # If the user didn't explicitly forbid building a |
| 687 | # relinked then we provide targets for building them. |
| 688 | #--------------------------------------------------------- |
| Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 689 | ifndef DONT_BUILD_RELINKED |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 690 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 691 | all-local:: $(LibName.O) |
| 692 | |
| Reid Spencer | f2ac189 | 2004-12-16 07:36:08 +0000 | [diff] [blame] | 693 | $(LibName.O): $(ObjectsO) $(LibDir)/.dir |
| Reid Spencer | 9af3b29 | 2004-11-01 07:50:27 +0000 | [diff] [blame] | 694 | $(Echo) Linking $(BuildMode) Object Library $(notdir $@) |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 695 | $(Verb) $(Relink) -o $@ $(ObjectsO) |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 696 | |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 697 | clean-local:: |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 698 | ifneq ($(strip $(LibName.O)),) |
| Reid Spencer | ca5fe8f | 2004-11-02 16:56:15 +0000 | [diff] [blame] | 699 | -$(Verb) $(RM) -f $(LibName.O) |
| Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 700 | endif |
| 701 | |
| 702 | DestRelinkedLib = $(libdir)/$(LIBRARYNAME).o |
| 703 | |
| Reid Spencer | c6dcc6a | 2004-10-28 07:57:28 +0000 | [diff] [blame] | 704 | install-local:: $(DestRelinkedLib) |
| Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 705 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 706 | $(DestRelinkedLib): $(libdir) $(LibName.O) |
| Reid Spencer | 9af3b29 | 2004-11-01 07:50:27 +0000 | [diff] [blame] | 707 | $(Echo) Installing $(BuildMode) Object Library $(DestRelinkedLib) |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 708 | $(Verb) $(LTInstall) $(LibName.O) $(DestRelinkedLib) |
| Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 709 | |
| Reid Spencer | c6dcc6a | 2004-10-28 07:57:28 +0000 | [diff] [blame] | 710 | uninstall-local:: |
| Reid Spencer | 9af3b29 | 2004-11-01 07:50:27 +0000 | [diff] [blame] | 711 | $(Echo) Uninstalling $(BuildMode) Object Library $(DestRelinkedLib) |
| Reid Spencer | ca5fe8f | 2004-11-02 16:56:15 +0000 | [diff] [blame] | 712 | -$(Verb) $(RM) -f $(DestRelinkedLib) |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 713 | |
| Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 714 | endif |
| Chris Lattner | 760da06 | 2003-03-14 20:25:22 +0000 | [diff] [blame] | 715 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 716 | #--------------------------------------------------------- |
| 717 | # Archive Library Targets: |
| 718 | # If the user wanted a regular archive library built, |
| 719 | # then we provide targets for building them. |
| 720 | #--------------------------------------------------------- |
| Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 721 | ifdef BUILD_ARCHIVE |
| Chris Lattner | e62dbe9 | 2002-07-23 17:56:16 +0000 | [diff] [blame] | 722 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 723 | all-local:: $(LibName.A) |
| 724 | |
| Reid Spencer | f2ac189 | 2004-12-16 07:36:08 +0000 | [diff] [blame] | 725 | $(LibName.A): $(ObjectsO) $(LibDir)/.dir |
| Reid Spencer | 9af3b29 | 2004-11-01 07:50:27 +0000 | [diff] [blame] | 726 | $(Echo) Building $(BuildMode) Archive Library $(notdir $@) |
| Reid Spencer | ca5fe8f | 2004-11-02 16:56:15 +0000 | [diff] [blame] | 727 | -$(Verb) $(RM) -f $@ |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 728 | $(Verb) $(Archive) $@ $(ObjectsO) |
| 729 | $(Verb) $(Ranlib) $@ |
| Vikram S. Adve | 41e7891 | 2002-09-20 14:03:13 +0000 | [diff] [blame] | 730 | |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 731 | clean-local:: |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 732 | ifneq ($(strip $(LibName.A)),) |
| Reid Spencer | ca5fe8f | 2004-11-02 16:56:15 +0000 | [diff] [blame] | 733 | -$(Verb) $(RM) -f $(LibName.A) |
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 734 | endif |
| 735 | |
| Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 736 | DestArchiveLib := $(libdir)/lib$(LIBRARYNAME).a |
| 737 | |
| Reid Spencer | c6dcc6a | 2004-10-28 07:57:28 +0000 | [diff] [blame] | 738 | install-local:: $(DestArchiveLib) |
| Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 739 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 740 | $(DestArchiveLib): $(libdir) $(LibName.A) |
| Reid Spencer | 9af3b29 | 2004-11-01 07:50:27 +0000 | [diff] [blame] | 741 | $(Echo) Installing $(BuildMode) Archive Library $(DestArchiveLib) |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 742 | $(Verb) $(MKDIR) $(libdir) |
| 743 | $(Verb) $(LTInstall) $(LibName.A) $(DestArchiveLib) |
| Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 744 | |
| Reid Spencer | c6dcc6a | 2004-10-28 07:57:28 +0000 | [diff] [blame] | 745 | uninstall-local:: |
| Reid Spencer | 9af3b29 | 2004-11-01 07:50:27 +0000 | [diff] [blame] | 746 | $(Echo) Uninstalling $(BuildMode) Archive Library $(DestArchiveLib) |
| Reid Spencer | ca5fe8f | 2004-11-02 16:56:15 +0000 | [diff] [blame] | 747 | -$(Verb) $(RM) -f $(DestArchiveLib) |
| Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 748 | |
| 749 | endif |
| 750 | |
| 751 | # endif LIBRARYNAME |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 752 | endif |
| 753 | |
| Reid Spencer | b1dd3dd | 2004-10-24 08:21:04 +0000 | [diff] [blame] | 754 | ############################################################################### |
| 755 | # Tool Build Rules: Build executable tool based on TOOLNAME option |
| 756 | ############################################################################### |
| 757 | |
| Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 758 | ifdef TOOLNAME |
| 759 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 760 | #--------------------------------------------------------- |
| Reid Spencer | 7c787c9 | 2004-11-29 07:17:07 +0000 | [diff] [blame] | 761 | # Handle the special "JIT" value for LLVM_LIBS which is a |
| 762 | # shorthand for a bunch of libraries that get the correct |
| 763 | # JIT support for a tool that runs JIT. |
| 764 | #--------------------------------------------------------- |
| 765 | ifeq ($(LLVMLIBS),JIT) |
| 766 | |
| 767 | # Make sure we can get our own symbols in the tool |
| 768 | Link += -dlopen self |
| 769 | |
| 770 | # Generic JIT libraries |
| 771 | JIT_LIBS := LLVMInterpreter LLVMJIT LLVMCodeGen LLVMExecutionEngine |
| 772 | |
| 773 | # You can enable the X86 JIT on a non-X86 host by setting the flag |
| 774 | # ENABLE_X86_JIT on the make command line. If not, it will still be |
| 775 | # enabled automagically on an X86 host. |
| 776 | ifeq ($(ARCH), x86) |
| 777 | ENABLE_X86_JIT = 1 |
| 778 | endif |
| 779 | |
| 780 | # What the X86 JIT requires |
| 781 | ifdef ENABLE_X86_JIT |
| Chris Lattner | 85139f5 | 2005-01-07 07:51:11 +0000 | [diff] [blame] | 782 | JIT_LIBS += LLVMX86 LLVMSelectionDAG |
| Reid Spencer | 7c787c9 | 2004-11-29 07:17:07 +0000 | [diff] [blame] | 783 | endif |
| 784 | |
| 785 | # You can enable the SparcV9 JIT on a non-SparcV9 host by setting the flag |
| 786 | # ENABLE_SPARCV9_JIT on the make command line. If not, it will still be |
| 787 | # enabled automagically on an SparcV9 host. |
| 788 | ifeq ($(ARCH), Sparc) |
| 789 | ENABLE_SPARCV9_JIT = 1 |
| 790 | endif |
| 791 | |
| 792 | # What the Sparc JIT requires |
| 793 | ifdef ENABLE_SPARCV9_JIT |
| 794 | JIT_LIBS += LLVMSparcV9 LLVMSparcV9ModuloSched LLVMSparcV9InstrSched \ |
| 795 | LLVMSparcV9LiveVar LLVMInstrumentation.a LLVMProfilePaths \ |
| 796 | LLVMBCWriter LLVMTransforms.a LLVMipo.a LLVMipa.a \ |
| 797 | LLVMDataStructure.a LLVMSparcV9RegAlloc |
| 798 | endif |
| 799 | |
| 800 | # You can enable the PowerPC JIT on a non-PowerPC host by setting the flag |
| 801 | # ENABLE_PPC_JIT on the make command line. If not, it will still be |
| 802 | # enabled automagically on an PowerPC host. |
| 803 | ifeq ($(ARCH), PowerPC) |
| 804 | ENABLE_PPC_JIT = 1 |
| 805 | endif |
| 806 | |
| 807 | # What the PowerPC JIT requires |
| 808 | ifdef ENABLE_PPC_JIT |
| 809 | JIT_LIBS += LLVMPowerPC |
| 810 | endif |
| 811 | |
| 812 | LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts LLVMAnalysis.a LLVMTransformUtils.a \ |
| 813 | LLVMBCReader LLVMCore LLVMSupport.a LLVMTarget.a LLVMbzip2 \ |
| 814 | LLVMSystem.a $(PLATFORMLIBDL) |
| 815 | endif |
| 816 | |
| 817 | #--------------------------------------------------------- |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 818 | # Set up variables for building a tool. |
| 819 | #--------------------------------------------------------- |
| Reid Spencer | 815cbcf | 2004-11-18 10:03:46 +0000 | [diff] [blame] | 820 | ifdef EXAMPLE_TOOL |
| 821 | ToolBuildPath := $(ExmplDir)/$(TOOLNAME)$(EXEEXT) |
| 822 | else |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 823 | ToolBuildPath := $(ToolDir)/$(TOOLNAME)$(EXEEXT) |
| Reid Spencer | 815cbcf | 2004-11-18 10:03:46 +0000 | [diff] [blame] | 824 | endif |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 825 | ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS))) |
| 826 | ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions)) |
| 827 | LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS))) |
| 828 | LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions)) |
| 829 | ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS))) |
| 830 | LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS))) |
| 831 | ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs)) |
| 832 | LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs)) |
| Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 833 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 834 | #--------------------------------------------------------- |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 835 | # Tell make that we need to rebuild subdirectories before |
| 836 | # we can link the tool. This affects things like LLI which |
| 837 | # has library subdirectories. |
| 838 | #--------------------------------------------------------- |
| 839 | $(ToolBuildPath): $(addsuffix /.makeall, $(PARALLEL_DIRS)) |
| Chris Lattner | 8d7dfb3 | 2003-01-22 16:13:31 +0000 | [diff] [blame] | 840 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 841 | #--------------------------------------------------------- |
| 842 | # Provide targets for building the tools |
| 843 | #--------------------------------------------------------- |
| 844 | all-local:: $(ToolBuildPath) |
| John Criswell | 2a6530f | 2003-06-27 16:58:44 +0000 | [diff] [blame] | 845 | |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 846 | clean-local:: |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 847 | ifneq ($(strip $(ToolBuildPath)),) |
| Reid Spencer | ca5fe8f | 2004-11-02 16:56:15 +0000 | [diff] [blame] | 848 | -$(Verb) $(RM) -f $(ToolBuildPath) |
| Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 849 | endif |
| Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 850 | |
| Reid Spencer | 815cbcf | 2004-11-18 10:03:46 +0000 | [diff] [blame] | 851 | ifdef EXAMPLE_TOOL |
| 852 | $(ToolBuildPath): $(ExmplDir)/.dir |
| 853 | else |
| 854 | $(ToolBuildPath): $(ToolDir)/.dir |
| 855 | endif |
| 856 | |
| Reid Spencer | f2ac189 | 2004-12-16 07:36:08 +0000 | [diff] [blame] | 857 | $(ToolBuildPath): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) |
| Reid Spencer | 9af3b29 | 2004-11-01 07:50:27 +0000 | [diff] [blame] | 858 | $(Echo) Linking $(BuildMode) executable $(TOOLNAME) $(StripWarnMsg) |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 859 | $(Verb) $(Link) -o $@ $(TOOLLINKOPTS) $(ObjectsO) $(ProjLibsOptions) \ |
| 860 | $(LLVMLibsOptions) $(ExtraLibs) $(TOOLLINKOPTSB) |
| Reid Spencer | 9af3b29 | 2004-11-01 07:50:27 +0000 | [diff] [blame] | 861 | $(Echo) ======= Finished Linking $(BuildMode) Executable $(TOOLNAME) $(StripWarnMsg) |
| Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 862 | |
| 863 | DestTool = $(bindir)/$(TOOLNAME) |
| 864 | |
| Reid Spencer | c6dcc6a | 2004-10-28 07:57:28 +0000 | [diff] [blame] | 865 | install-local:: $(DestTool) |
| Reid Spencer | e45ebfa | 2004-10-26 07:09:33 +0000 | [diff] [blame] | 866 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 867 | $(DestTool): $(bindir) $(ToolBuildPath) |
| Reid Spencer | 9af3b29 | 2004-11-01 07:50:27 +0000 | [diff] [blame] | 868 | $(Echo) Installing $(BuildMode) $(DestTool) |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 869 | $(Verb) $(INSTALL) $(ToolBuildPath) $(DestTool) |
| Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 870 | |
| Reid Spencer | c6dcc6a | 2004-10-28 07:57:28 +0000 | [diff] [blame] | 871 | uninstall-local:: |
| Reid Spencer | 9af3b29 | 2004-11-01 07:50:27 +0000 | [diff] [blame] | 872 | $(Echo) Uninstalling $(BuildMode) $(DestTool) |
| Reid Spencer | ca5fe8f | 2004-11-02 16:56:15 +0000 | [diff] [blame] | 873 | -$(Verb) $(RM) -f $(DestTool) |
| Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 874 | |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 875 | endif |
| Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 876 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 877 | ############################################################################### |
| 878 | # Object Build Rules: Build object files based on sources |
| 879 | ############################################################################### |
| 880 | |
| 881 | # Provide rule sets for when dependency generation is enabled |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 882 | ifndef DISABLE_AUTO_DEPENDENCIES |
| Vikram S. Adve | 41e7891 | 2002-09-20 14:03:13 +0000 | [diff] [blame] | 883 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 884 | #--------------------------------------------------------- |
| 885 | # Create .lo files in the ObjDir directory from the .cpp and .c files... |
| 886 | #--------------------------------------------------------- |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 887 | ifdef SHARED_LIBRARY |
| 888 | |
| Chris Lattner | 3c47347 | 2004-12-16 17:28:50 +0000 | [diff] [blame] | 889 | $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) |
| Reid Spencer | 9af3b29 | 2004-11-01 07:50:27 +0000 | [diff] [blame] | 890 | $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)" |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 891 | $(Verb) if $(LTCompile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACXXd $< -o $@ ; \ |
| 892 | then $(MV) -f "$(ObjDir)/$*.LACXXd" "$(ObjDir)/$*.d"; \ |
| 893 | else $(RM) -f "$(ObjDir)/$*.LACXXd"; exit 1; fi |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 894 | |
| Chris Lattner | 3c47347 | 2004-12-16 17:28:50 +0000 | [diff] [blame] | 895 | $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES) |
| Reid Spencer | 9af3b29 | 2004-11-01 07:50:27 +0000 | [diff] [blame] | 896 | $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)" |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 897 | $(Verb) if $(LTCompile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.LACd $< -o $@ ; \ |
| 898 | then $(MV) -f "$(ObjDir)/$*.LACd" "$(ObjDir)/$*.d"; \ |
| 899 | else $(RM) -f "$(ObjDir)/$*.LACd"; exit 1; fi |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 900 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 901 | #--------------------------------------------------------- |
| 902 | # Create .o files in the ObjDir directory from the .cpp and .c files... |
| 903 | #--------------------------------------------------------- |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 904 | else |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 905 | |
| Chris Lattner | 3c47347 | 2004-12-16 17:28:50 +0000 | [diff] [blame] | 906 | $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) |
| Reid Spencer | 9af3b29 | 2004-11-01 07:50:27 +0000 | [diff] [blame] | 907 | $(Echo) "Compiling $*.cpp for $(BuildMode) build" |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 908 | $(Verb) if $(Compile.CXX) -MD -MT $@ -MP -MF $(ObjDir)/$*.CXXd $< -o $@ ; \ |
| 909 | then $(MV) -f "$(ObjDir)/$*.CXXd" "$(ObjDir)/$*.d"; \ |
| 910 | else $(RM) -f "$(ObjDir)/$*.CXXd"; exit 1; fi |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 911 | |
| Chris Lattner | 3c47347 | 2004-12-16 17:28:50 +0000 | [diff] [blame] | 912 | $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES) |
| Reid Spencer | 9af3b29 | 2004-11-01 07:50:27 +0000 | [diff] [blame] | 913 | $(Echo) "Compiling $*.c for $(BuildMode) build" |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 914 | $(Verb) if $(Compile.C) -MD -MT $@ -MP -MF $(ObjDir)/$*.Cd $< -o $@ ; \ |
| 915 | then $(MV) -f "$(ObjDir)/$*.Cd" "$(ObjDir)/$*.d"; \ |
| 916 | else $(RM) -f "$(ObjDir)/$*.Cd"; exit 1; fi |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 917 | |
| 918 | endif |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 919 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 920 | #--------------------------------------------------------- |
| 921 | # Create .bc files in the ObjDir directory from .cpp and .c files... |
| 922 | #--------------------------------------------------------- |
| Chris Lattner | 3c47347 | 2004-12-16 17:28:50 +0000 | [diff] [blame] | 923 | $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES) |
| Reid Spencer | 9af3b29 | 2004-11-01 07:50:27 +0000 | [diff] [blame] | 924 | $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)" |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 925 | $(Verb) if $(BCCompile.CXX) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCXXd" $< -o $@ ; \ |
| 926 | then $(MV) -f "$(ObjDir)/$*.BCCXXd" "$(ObjDir)/$*.d"; \ |
| 927 | else $(RM) -f "$(ObjDir)/$*.BCCXXd"; exit 1; fi |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 928 | |
| Chris Lattner | 3c47347 | 2004-12-16 17:28:50 +0000 | [diff] [blame] | 929 | $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES) |
| Reid Spencer | 9af3b29 | 2004-11-01 07:50:27 +0000 | [diff] [blame] | 930 | $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)" |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 931 | $(Verb) if $(BCCompile.C) -MD -MT $@ -MP -MF "$(ObjDir)/$*.BCCd" $< -o $@ ; \ |
| 932 | then $(MV) -f "$(ObjDir)/$*.BCCd" "$(ObjDir)/$*.d"; \ |
| 933 | else $(RM) -f "$(ObjDir)/$*.BCCd"; exit 1; fi |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 934 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 935 | # Provide alternate rule sets if dependencies are disabled |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 936 | else |
| 937 | |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 938 | ifdef SHARED_LIBRARY |
| 939 | |
| Chris Lattner | 3c47347 | 2004-12-16 17:28:50 +0000 | [diff] [blame] | 940 | $(ObjDir)/%.lo $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) |
| Reid Spencer | 9af3b29 | 2004-11-01 07:50:27 +0000 | [diff] [blame] | 941 | $(Echo) "Compiling $*.cpp for $(BuildMode) build (PIC)" |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 942 | $(LTCompile.CXX) $< -o $@ |
| 943 | |
| Chris Lattner | 3c47347 | 2004-12-16 17:28:50 +0000 | [diff] [blame] | 944 | $(ObjDir)/%.lo $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES) |
| Reid Spencer | c371984 | 2004-12-16 18:26:53 +0000 | [diff] [blame] | 945 | $(Echo) "Compiling $*.c for $(BuildMode) build (PIC)" |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 946 | $(LTCompile.C) $< -o $@ |
| 947 | |
| 948 | else |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 949 | |
| Chris Lattner | 3c47347 | 2004-12-16 17:28:50 +0000 | [diff] [blame] | 950 | $(ObjDir)/%.o: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) |
| Reid Spencer | 9af3b29 | 2004-11-01 07:50:27 +0000 | [diff] [blame] | 951 | $(Echo) "Compiling $*.cpp for $(BuildMode) build" |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 952 | $(Compile.CXX) $< -o $@ |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 953 | |
| Chris Lattner | 3c47347 | 2004-12-16 17:28:50 +0000 | [diff] [blame] | 954 | $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES) |
| Reid Spencer | c371984 | 2004-12-16 18:26:53 +0000 | [diff] [blame] | 955 | $(Echo) "Compiling $*.c for $(BuildMode) build" |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 956 | $(Compile.C) $< -o $@ |
| 957 | endif |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 958 | |
| Chris Lattner | 3c47347 | 2004-12-16 17:28:50 +0000 | [diff] [blame] | 959 | $(ObjDir)/%.bc: %.cpp $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES) |
| Reid Spencer | 9af3b29 | 2004-11-01 07:50:27 +0000 | [diff] [blame] | 960 | $(Echo) "Compiling $*.cpp for $(BuildMode) build (bytecode)" |
| Reid Spencer | 8676b7e | 2004-10-31 18:52:15 +0000 | [diff] [blame] | 961 | $(BCCompile.CXX) $< -o $@ |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 962 | |
| Chris Lattner | 3c47347 | 2004-12-16 17:28:50 +0000 | [diff] [blame] | 963 | $(ObjDir)/%.bc: %.c $(ObjDir)/.dir $(GCCAS) $(BUILT_SOURCES) |
| Reid Spencer | 9af3b29 | 2004-11-01 07:50:27 +0000 | [diff] [blame] | 964 | $(Echo) "Compiling $*.c for $(BuildMode) build (bytecode)" |
| Reid Spencer | 8676b7e | 2004-10-31 18:52:15 +0000 | [diff] [blame] | 965 | $(BCCompile.C) $< -o $@ |
| Brian Gaeke | 44909cf | 2003-12-10 00:26:28 +0000 | [diff] [blame] | 966 | |
| Chris Lattner | 1cbc29f | 2001-09-07 22:57:58 +0000 | [diff] [blame] | 967 | endif |
| 968 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 969 | #--------------------------------------------------------- |
| 970 | # Provide rule to build .bc files from .ll sources, |
| 971 | # regardless of dependencies |
| 972 | #--------------------------------------------------------- |
| 973 | $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS) |
| Reid Spencer | 9af3b29 | 2004-11-01 07:50:27 +0000 | [diff] [blame] | 974 | $(Echo) "Compiling $*.ll for $(BuildMode) build" |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 975 | $(Verb) $(LLVMAS) $< -f -o $@ |
| 976 | |
| 977 | ############################################################################### |
| 978 | # TABLEGEN: Provide rules for running tblgen to produce *.inc files |
| 979 | ############################################################################### |
| Chris Lattner | 481cc7c | 2003-08-15 02:18:35 +0000 | [diff] [blame] | 980 | |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 981 | ifdef TARGET |
| 982 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 983 | TDFiles := $(strip $(wildcard $(BUILD_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td) |
| 984 | INCFiles := $(filter %.inc,$(BUILT_SOURCES)) |
| Chris Lattner | 3c47347 | 2004-12-16 17:28:50 +0000 | [diff] [blame] | 985 | INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp) |
| 986 | .PRECIOUS: $(INCTMPFiles) $(INCFiles) |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 987 | |
| Chris Lattner | 3c47347 | 2004-12-16 17:28:50 +0000 | [diff] [blame] | 988 | # All of these files depend on tblgen and the .td files. |
| 989 | $(INCTMPFiles) : $(TBLGEN) $(TDFiles) |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 990 | |
| Chris Lattner | 23ee795 | 2004-12-16 17:38:56 +0000 | [diff] [blame] | 991 | # INCFiles rule: All of the tblgen generated files are emitted to |
| 992 | # $(ObjDir)/%.inc.tmp, instead of emitting them directly to %.inc. This allows |
| 993 | # us to only "touch" the real file if the contents of it change. IOW, if |
| 994 | # tblgen is modified, all of the .inc.tmp files are regereated, but no |
| 995 | # dependencies of the .inc files are, unless the contents of the .inc file |
| 996 | # changes. |
| 997 | $(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp |
| Reid Spencer | c371984 | 2004-12-16 18:26:53 +0000 | [diff] [blame] | 998 | $(Verb) $(CMP) -s $@ $< || $(CP) $< $@ |
| Chris Lattner | 3c47347 | 2004-12-16 17:28:50 +0000 | [diff] [blame] | 999 | |
| 1000 | $(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \ |
| 1001 | $(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1002 | $(Echo) "Building $(<F) register names with tblgen" |
| 1003 | $(Verb) $(TableGen) -gen-register-enums -o $@ $< |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 1004 | |
| Chris Lattner | 3c47347 | 2004-12-16 17:28:50 +0000 | [diff] [blame] | 1005 | $(TARGET:%=$(ObjDir)/%GenRegisterInfo.h.inc.tmp): \ |
| 1006 | $(ObjDir)/%GenRegisterInfo.h.inc.tmp : %.td $(ObjDir)/.dir |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1007 | $(Echo) "Building $(<F) register information header with tblgen" |
| 1008 | $(Verb) $(TableGen) -gen-register-desc-header -o $@ $< |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 1009 | |
| Chris Lattner | 3c47347 | 2004-12-16 17:28:50 +0000 | [diff] [blame] | 1010 | $(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \ |
| 1011 | $(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1012 | $(Echo) "Building $(<F) register info implementation with tblgen" |
| 1013 | $(Verb) $(TableGen) -gen-register-desc -o $@ $< |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 1014 | |
| Chris Lattner | 3c47347 | 2004-12-16 17:28:50 +0000 | [diff] [blame] | 1015 | $(TARGET:%=$(ObjDir)/%GenInstrNames.inc.tmp): \ |
| 1016 | $(ObjDir)/%GenInstrNames.inc.tmp : %.td $(ObjDir)/.dir |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1017 | $(Echo) "Building $(<F) instruction names with tblgen" |
| 1018 | $(Verb) $(TableGen) -gen-instr-enums -o $@ $< |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 1019 | |
| Chris Lattner | 3c47347 | 2004-12-16 17:28:50 +0000 | [diff] [blame] | 1020 | $(TARGET:%=$(ObjDir)/%GenInstrInfo.inc.tmp): \ |
| 1021 | $(ObjDir)/%GenInstrInfo.inc.tmp : %.td $(ObjDir)/.dir |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1022 | $(Echo) "Building $(<F) instruction information with tblgen" |
| 1023 | $(Verb) $(TableGen) -gen-instr-desc -o $@ $< |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 1024 | |
| Chris Lattner | 3c47347 | 2004-12-16 17:28:50 +0000 | [diff] [blame] | 1025 | $(TARGET:%=$(ObjDir)/%GenAsmWriter.inc.tmp): \ |
| 1026 | $(ObjDir)/%GenAsmWriter.inc.tmp : %.td $(ObjDir)/.dir |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1027 | $(Echo) "Building $(<F) assembly writer with tblgen" |
| 1028 | $(Verb) $(TableGen) -gen-asm-writer -o $@ $< |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 1029 | |
| Chris Lattner | 02a4f90 | 2004-12-16 17:34:04 +0000 | [diff] [blame] | 1030 | $(TARGET:%=$(ObjDir)/%GenAsmWriter1.inc.tmp): \ |
| 1031 | $(ObjDir)/%GenAsmWriter1.inc.tmp : %.td $(ObjDir)/.dir |
| 1032 | $(Echo) "Building $(<F) assembly writer #1 with tblgen" |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1033 | $(Verb) $(TableGen) -gen-asm-writer -asmwriternum=1 -o $@ $< |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 1034 | |
| Chris Lattner | 3c47347 | 2004-12-16 17:28:50 +0000 | [diff] [blame] | 1035 | $(TARGET:%=$(ObjDir)/%GenCodeEmitter.inc.tmp): \ |
| 1036 | $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1037 | $(Echo) "Building $(<F) code emitter with tblgen" |
| 1038 | $(Verb) $(TableGen) -gen-emitter -o $@ $< |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 1039 | |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 1040 | clean-local:: |
| Reid Spencer | ca5fe8f | 2004-11-02 16:56:15 +0000 | [diff] [blame] | 1041 | -$(Verb) $(RM) -f $(INCFiles) |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 1042 | |
| 1043 | endif |
| Chris Lattner | 481cc7c | 2003-08-15 02:18:35 +0000 | [diff] [blame] | 1044 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1045 | ############################################################################### |
| 1046 | # LEX AND YACC: Provide rules for generating sources with lex and yacc |
| 1047 | ############################################################################### |
| Chris Lattner | e899678 | 2003-01-16 22:44:19 +0000 | [diff] [blame] | 1048 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1049 | #--------------------------------------------------------- |
| 1050 | # Provide rules for generating a .cpp source file from |
| 1051 | # (f)lex input sources. |
| 1052 | #--------------------------------------------------------- |
| 1053 | |
| Reid Spencer | 3d65949 | 2004-11-02 16:36:03 +0000 | [diff] [blame] | 1054 | LexFiles := $(filter %.l,$(Sources)) |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1055 | |
| Reid Spencer | 3d65949 | 2004-11-02 16:36:03 +0000 | [diff] [blame] | 1056 | ifneq ($(LexFiles),) |
| 1057 | |
| 1058 | LexOutput := $(strip $(patsubst %.l,%.cpp,$(LexFiles))) |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1059 | |
| 1060 | .PRECIOUS: $(LexOutput) |
| 1061 | |
| 1062 | # Note the extra sed filtering here, used to cut down on the warnings emited |
| 1063 | # by GCC. The last line is a gross hack to work around flex aparently not |
| 1064 | # being able to resize the buffer on a large token input. Currently, for |
| 1065 | # uninitialized string buffers in LLVM we can generate very long tokens, so |
| 1066 | # this is a hack around it. |
| Chris Lattner | b7dc2b9 | 2003-08-15 20:00:47 +0000 | [diff] [blame] | 1067 | # FIXME. (f.e. char Buffer[10000] ) |
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1068 | %.cpp: %.l |
| Reid Spencer | c2ef8cd | 2004-12-10 19:44:16 +0000 | [diff] [blame] | 1069 | $(Echo) Flexing $*.l |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1070 | $(Verb) $(FLEX) -t $< | \ |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 1071 | $(SED) 's/void yyunput/inline void yyunput/' | \ |
| 1072 | $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \ |
| 1073 | $(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] | 1074 | > $@ |
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1075 | |
| Reid Spencer | 9af3b29 | 2004-11-01 07:50:27 +0000 | [diff] [blame] | 1076 | clean-local:: |
| Reid Spencer | ca5fe8f | 2004-11-02 16:56:15 +0000 | [diff] [blame] | 1077 | -$(Verb) $(RM) -f $(LexOutput) |
| Reid Spencer | 3d65949 | 2004-11-02 16:36:03 +0000 | [diff] [blame] | 1078 | $(Verb) $(RM) -f $(LexOutput) |
| Reid Spencer | 9af3b29 | 2004-11-01 07:50:27 +0000 | [diff] [blame] | 1079 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1080 | endif |
| 1081 | |
| 1082 | #--------------------------------------------------------- |
| 1083 | # Provide rules for generating a .cpp and .h source files |
| 1084 | # from yacc (bison) input sources. |
| 1085 | #--------------------------------------------------------- |
| 1086 | |
| Reid Spencer | 3d65949 | 2004-11-02 16:36:03 +0000 | [diff] [blame] | 1087 | YaccFiles := $(filter %.y,$(Sources)) |
| 1088 | ifneq ($(YaccFiles),) |
| 1089 | YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.h .cpp .output) |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1090 | |
| 1091 | .PRECIOUS: $(YaccOutput) |
| 1092 | |
| 1093 | # Cancel built-in rules for yacc |
| 1094 | %.c: %.y |
| 1095 | %.cpp: %.y |
| 1096 | %.h: %.y |
| 1097 | |
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1098 | # Rule for building the bison parsers... |
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1099 | %.cpp %.h : %.y |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1100 | $(Echo) "Bisoning $*.y" |
| 1101 | $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $< |
| 1102 | $(Verb) $(MV) -f $*.tab.c $*.cpp |
| 1103 | $(Verb) $(MV) -f $*.tab.h $*.h |
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1104 | |
| Reid Spencer | 9af3b29 | 2004-11-01 07:50:27 +0000 | [diff] [blame] | 1105 | clean-local:: |
| Reid Spencer | ca5fe8f | 2004-11-02 16:56:15 +0000 | [diff] [blame] | 1106 | -$(Verb) $(RM) -f $(YaccOutput) |
| Reid Spencer | 3d65949 | 2004-11-02 16:36:03 +0000 | [diff] [blame] | 1107 | $(Verb) $(RM) -f $(YaccOutput) |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1108 | endif |
| Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1109 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1110 | ############################################################################### |
| 1111 | # OTHER RULES: Other rules needed |
| 1112 | ############################################################################### |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 1113 | |
| Chris Lattner | 30440c6 | 2003-01-16 21:06:18 +0000 | [diff] [blame] | 1114 | # To create postscript files from dot files... |
| John Criswell | e0f9ac6 | 2003-10-02 19:02:02 +0000 | [diff] [blame] | 1115 | ifneq ($(DOT),false) |
| Chris Lattner | 30440c6 | 2003-01-16 21:06:18 +0000 | [diff] [blame] | 1116 | %.ps: %.dot |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 1117 | $(DOT) -Tps < $< > $@ |
| John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame] | 1118 | else |
| 1119 | %.ps: %.dot |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1120 | $(Echo) "Cannot build $@: The program dot is not installed" |
| John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame] | 1121 | endif |
| Chris Lattner | 30440c6 | 2003-01-16 21:06:18 +0000 | [diff] [blame] | 1122 | |
| John Criswell | 7f33695 | 2003-09-06 14:44:17 +0000 | [diff] [blame] | 1123 | # This rules ensures that header files that are removed still have a rule for |
| 1124 | # which they can be "generated." This allows make to ignore them and |
| 1125 | # reproduce the dependency lists. |
| John Criswell | 4b6e5d1 | 2003-09-18 18:37:08 +0000 | [diff] [blame] | 1126 | %.h:: ; |
| John Criswell | 7f33695 | 2003-09-06 14:44:17 +0000 | [diff] [blame] | 1127 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1128 | # Define clean-local to clean the current directory. Note that this uses a |
| 1129 | # very conservative approach ensuring that empty variables do not cause |
| 1130 | # errors or disastrous removal. |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 1131 | clean-local:: |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1132 | ifneq ($(strip $(ObjDir)),) |
| Reid Spencer | ca5fe8f | 2004-11-02 16:56:15 +0000 | [diff] [blame] | 1133 | -$(Verb) $(RM) -rf $(ObjDir) |
| Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 1134 | endif |
| Reid Spencer | ca5fe8f | 2004-11-02 16:56:15 +0000 | [diff] [blame] | 1135 | -$(Verb) $(RM) -f core core.[0-9][0-9]* *.o *.d *~ *.flc |
| Brian Gaeke | 9d3cd40 | 2004-01-21 19:53:11 +0000 | [diff] [blame] | 1136 | ifneq ($(strip $(SHLIBEXT)),) # Extra paranoia - make real sure SHLIBEXT is set |
| Reid Spencer | ca5fe8f | 2004-11-02 16:56:15 +0000 | [diff] [blame] | 1137 | -$(Verb) $(RM) -f *$(SHLIBEXT) |
| Brian Gaeke | 9d3cd40 | 2004-01-21 19:53:11 +0000 | [diff] [blame] | 1138 | endif |
| John Criswell | 7a73b80 | 2003-06-30 21:59:07 +0000 | [diff] [blame] | 1139 | |
| Reid Spencer | 3d65949 | 2004-11-02 16:36:03 +0000 | [diff] [blame] | 1140 | clean-all-local:: |
| Reid Spencer | ca5fe8f | 2004-11-02 16:56:15 +0000 | [diff] [blame] | 1141 | -$(Verb) $(RM) -rf Debug Release Profile |
| Reid Spencer | 3d65949 | 2004-11-02 16:36:03 +0000 | [diff] [blame] | 1142 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1143 | # Build tags database for Emacs/Xemacs: |
| Reid Spencer | 12d7951 | 2004-11-12 02:27:36 +0000 | [diff] [blame] | 1144 | tags:: TAGS CTAGS |
| 1145 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1146 | TAGS: |
| Reid Spencer | 12d7951 | 2004-11-12 02:27:36 +0000 | [diff] [blame] | 1147 | find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \ |
| 1148 | $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \ |
| 1149 | $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \ |
| 1150 | $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \ |
| 1151 | -name '*.cpp' -o -name '*.h' | \ |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1152 | $(ETAGS) $(ETAGSFLAGS) - |
| 1153 | |
| Reid Spencer | 12d7951 | 2004-11-12 02:27:36 +0000 | [diff] [blame] | 1154 | CTAGS: |
| 1155 | find $(BUILD_SRC_ROOT)/include $(BUILD_SRC_ROOT)/lib \ |
| 1156 | $(BUILD_SRC_ROOT)/tools $(BUILD_SRC_ROOT)/examples \ |
| 1157 | $(BUILD_OBJ_ROOT)/include $(BUILD_OBJ_ROOT)/lib \ |
| 1158 | $(BUILD_OBJ_ROOT)/tools $(BUILD_OBJ_ROOT)/examples \ |
| 1159 | \( -name '*.cpp' -o -name '*.h' \) -print | \ |
| 1160 | ctags -ImtT -o $(BUILD_OBJ_ROOT)/CTAGS -L - |
| 1161 | |
| 1162 | |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 1163 | ############################################################################### |
| 1164 | # DEPENDENCIES: Include the dependency files if we should |
| 1165 | ############################################################################### |
| Chris Lattner | 33ad24a | 2003-08-22 14:10:16 +0000 | [diff] [blame] | 1166 | ifndef DISABLE_AUTO_DEPENDENCIES |
| 1167 | |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 1168 | # If its not one of the cleaning targets |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1169 | ifneq ($strip($(filter-out clean clean-local dist-clean,$(MAKECMDGOALS))),) |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 1170 | |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 1171 | # Get the list of dependency files |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1172 | DependFiles := $(basename $(filter %.cpp %.c %.cc, $(Sources))) |
| Reid Spencer | 9af3b29 | 2004-11-01 07:50:27 +0000 | [diff] [blame] | 1173 | DependFiles := $(patsubst %,$(BUILD_OBJ_DIR)/$(BuildMode)/%.d,$(DependFiles)) |
| Misha Brukman | 4f7a8cf | 2003-11-09 21:36:19 +0000 | [diff] [blame] | 1174 | |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 1175 | -include /dev/null $(DependFiles) |
| 1176 | |
| John Criswell | d741bcf | 2003-08-12 18:51:51 +0000 | [diff] [blame] | 1177 | endif |
| Chris Lattner | 1ddb6b6 | 2003-08-18 17:27:40 +0000 | [diff] [blame] | 1178 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1179 | endif |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 1180 | |
| Reid Spencer | 151f8ba | 2004-10-25 08:27:37 +0000 | [diff] [blame] | 1181 | ############################################################################### |
| Reid Spencer | 9e8d54a | 2004-12-06 05:35:13 +0000 | [diff] [blame] | 1182 | # CHECK: Running the test suite |
| 1183 | ############################################################################### |
| 1184 | |
| 1185 | check:: |
| 1186 | $(Verb) if test -d "$(BUILD_OBJ_ROOT)/test" ; then \ |
| 1187 | if test -f "$(BUILD_OBJ_ROOT)/test/Makefile" ; then \ |
| 1188 | $(EchoCmd) Running test suite ; \ |
| 1189 | $(MAKE) -C $(BUILD_OBJ_ROOT)/test check-local \ |
| 1190 | TESTSUITE=$(TESTSUITE) ; \ |
| 1191 | else \ |
| 1192 | $(EchoCmd) No Makefile in test directory ; \ |
| 1193 | fi ; \ |
| 1194 | else \ |
| 1195 | $(EchoCmd) No test directory ; \ |
| 1196 | fi |
| 1197 | |
| 1198 | ############################################################################### |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1199 | # DISTRIBUTION: Handle construction of a distribution tarball |
| Reid Spencer | 151f8ba | 2004-10-25 08:27:37 +0000 | [diff] [blame] | 1200 | ############################################################################### |
| 1201 | |
| Reid Spencer | e45ebfa | 2004-10-26 07:09:33 +0000 | [diff] [blame] | 1202 | #------------------------------------------------------------------------ |
| 1203 | # Define distribution related variables |
| 1204 | #------------------------------------------------------------------------ |
| Reid Spencer | 151f8ba | 2004-10-25 08:27:37 +0000 | [diff] [blame] | 1205 | DistName := $(LLVM_TARBALL_NAME) |
| 1206 | DistDir := $(BUILD_OBJ_ROOT)/$(DistName) |
| Reid Spencer | e45ebfa | 2004-10-26 07:09:33 +0000 | [diff] [blame] | 1207 | TopDistDir := $(BUILD_OBJ_ROOT)/$(DistName) |
| Reid Spencer | 151f8ba | 2004-10-25 08:27:37 +0000 | [diff] [blame] | 1208 | DistTarGZip := $(BUILD_OBJ_ROOT)/$(DistName).tar.gz |
| 1209 | DistZip := $(BUILD_OBJ_ROOT)/$(DistName).zip |
| 1210 | DistTarBZ2 := $(BUILD_OBJ_ROOT)/$(DistName).tar.bz2 |
| 1211 | DistAlways := CREDITS.TXT LICENSE.TXT README.txt README AUTHORS COPYING \ |
| 1212 | ChangeLog INSTALL NEWS Makefile Makefile.common Makefile.rules \ |
| Reid Spencer | e45ebfa | 2004-10-26 07:09:33 +0000 | [diff] [blame] | 1213 | Makefile.config.in configure autoconf |
| 1214 | DistOther := $(notdir $(wildcard \ |
| 1215 | $(BUILD_SRC_DIR)/*.h \ |
| 1216 | $(BUILD_SRC_DIR)/*.td \ |
| 1217 | $(BUILD_SRC_DIR)/*.def \ |
| 1218 | $(BUILD_SRC_DIR)/*.ll \ |
| 1219 | $(BUILD_SRC_DIR)/*.in)) |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1220 | DistSubDirs := $(SubDirs) |
| Reid Spencer | fbbf307 | 2004-11-29 05:00:33 +0000 | [diff] [blame] | 1221 | DistSources = $(Sources) $(EXTRA_DIST) |
| 1222 | DistFiles = $(DistAlways) $(DistSources) $(DistOther) |
| Reid Spencer | 151f8ba | 2004-10-25 08:27:37 +0000 | [diff] [blame] | 1223 | |
| Reid Spencer | e45ebfa | 2004-10-26 07:09:33 +0000 | [diff] [blame] | 1224 | #------------------------------------------------------------------------ |
| 1225 | # We MUST build distribution with OBJ_DIR != SRC_DIR |
| 1226 | #------------------------------------------------------------------------ |
| 1227 | ifeq ($(BUILD_SRC_DIR),$(BUILD_OBJ_DIR)) |
| 1228 | dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip :: |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1229 | $(Echo) ERROR: Target $@ only available with OBJ_DIR != SRC_DIR |
| Reid Spencer | e45ebfa | 2004-10-26 07:09:33 +0000 | [diff] [blame] | 1230 | |
| Reid Spencer | e45ebfa | 2004-10-26 07:09:33 +0000 | [diff] [blame] | 1231 | else |
| 1232 | |
| Reid Spencer | e45ebfa | 2004-10-26 07:09:33 +0000 | [diff] [blame] | 1233 | #------------------------------------------------------------------------ |
| 1234 | # Prevent catastrophic remove |
| 1235 | #------------------------------------------------------------------------ |
| 1236 | ifeq ($(LLVM_TARBALL_NAME),) |
| 1237 | $(error LLVM_TARBALL_NAME is empty. Please rerun configure) |
| 1238 | endif |
| 1239 | |
| 1240 | #------------------------------------------------------------------------ |
| 1241 | # Prevent attempt to run dist targets from anywhere but the top level |
| 1242 | #------------------------------------------------------------------------ |
| 1243 | ifneq ($(LEVEL),.) |
| 1244 | |
| 1245 | dist dist-check dist-clean dist-gzip dist-bzip2 dist-zip :: |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1246 | $(Echo) ERROR: You must run $@ from $(BUILD_OBJ_ROOT) |
| Reid Spencer | e45ebfa | 2004-10-26 07:09:33 +0000 | [diff] [blame] | 1247 | |
| 1248 | else |
| 1249 | |
| 1250 | #------------------------------------------------------------------------ |
| 1251 | # Provide the top level targets |
| 1252 | #------------------------------------------------------------------------ |
| 1253 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1254 | dist-gzip:: $(DistTarGZip) |
| Reid Spencer | e45ebfa | 2004-10-26 07:09:33 +0000 | [diff] [blame] | 1255 | |
| Reid Spencer | 345235ca | 2004-12-04 22:34:09 +0000 | [diff] [blame] | 1256 | $(DistTarGZip) : $(TopDistDir)/.makedistdir |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1257 | $(Echo) Packing gzipped distribution tar file. |
| Reid Spencer | fbbf307 | 2004-11-29 05:00:33 +0000 | [diff] [blame] | 1258 | $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - "$(DistName)" | \ |
| 1259 | $(GZIP) -c > "$(DistTarGZip)" |
| Reid Spencer | e45ebfa | 2004-10-26 07:09:33 +0000 | [diff] [blame] | 1260 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1261 | dist-bzip2:: $(DistTarBZ2) |
| Reid Spencer | e45ebfa | 2004-10-26 07:09:33 +0000 | [diff] [blame] | 1262 | |
| Reid Spencer | 345235ca | 2004-12-04 22:34:09 +0000 | [diff] [blame] | 1263 | $(DistTarBZ2) : $(TopDistDir)/.makedistdir |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1264 | $(Echo) Packing bzipped distribution tar file. |
| Reid Spencer | fbbf307 | 2004-11-29 05:00:33 +0000 | [diff] [blame] | 1265 | $(Verb) cd $(BUILD_OBJ_ROOT) ; $(TAR) chf - $(DistName) | \ |
| 1266 | $(BZIP2) -c >$(DistTarBZ2) |
| Reid Spencer | e45ebfa | 2004-10-26 07:09:33 +0000 | [diff] [blame] | 1267 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1268 | dist-zip:: $(DistZip) |
| Reid Spencer | e45ebfa | 2004-10-26 07:09:33 +0000 | [diff] [blame] | 1269 | |
| Reid Spencer | 345235ca | 2004-12-04 22:34:09 +0000 | [diff] [blame] | 1270 | $(DistZip) : $(TopDistDir)/.makedistdir |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1271 | $(Echo) Packing zipped distribution file. |
| 1272 | $(Verb) rm -f $(DistZip) |
| 1273 | $(Verb) cd $(BUILD_OBJ_ROOT) ; $(ZIP) -rq $(DistZip) $(DistName) |
| Reid Spencer | e45ebfa | 2004-10-26 07:09:33 +0000 | [diff] [blame] | 1274 | |
| 1275 | dist :: $(DistTarGZip) $(DistTarBZ2) $(DistZip) |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1276 | $(Echo) ===== DISTRIBUTION PACKAGING SUCESSFUL ===== |
| Reid Spencer | e45ebfa | 2004-10-26 07:09:33 +0000 | [diff] [blame] | 1277 | |
| 1278 | DistCheckDir := $(LLVM_OBJ_ROOT)/_distcheckdir |
| 1279 | |
| Reid Spencer | 345235ca | 2004-12-04 22:34:09 +0000 | [diff] [blame] | 1280 | dist-check:: $(DistTarGZip) |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1281 | $(Echo) Checking distribution tar file. |
| 1282 | $(Verb) if test -d $(DistCheckDir) ; then \ |
| Reid Spencer | e45ebfa | 2004-10-26 07:09:33 +0000 | [diff] [blame] | 1283 | $(RM) -rf $(DistCheckDir) ; \ |
| 1284 | fi |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1285 | $(Verb) $(MKDIR) $(DistCheckDir) |
| 1286 | $(Verb) cd $(DistCheckDir) && \ |
| Reid Spencer | e45ebfa | 2004-10-26 07:09:33 +0000 | [diff] [blame] | 1287 | $(MKDIR) $(DistCheckDir)/build && \ |
| 1288 | $(MKDIR) $(DistCheckDir)/install && \ |
| 1289 | gunzip -c $(DistTarGZip) | $(TAR) xf - && \ |
| 1290 | cd build && \ |
| 1291 | ../$(DistName)/configure --prefix="$(DistCheckDir)/install" \ |
| Reid Spencer | 32924e0 | 2004-12-24 03:36:31 +0000 | [diff] [blame] | 1292 | --srcdir=../$(DistName) && \ |
| Reid Spencer | 345235ca | 2004-12-04 22:34:09 +0000 | [diff] [blame] | 1293 | $(MAKE) all && \ |
| Reid Spencer | e45ebfa | 2004-10-26 07:09:33 +0000 | [diff] [blame] | 1294 | $(MAKE) check && \ |
| 1295 | $(MAKE) install && \ |
| 1296 | $(MAKE) uninstall && \ |
| 1297 | $(MAKE) dist && \ |
| 1298 | $(MAKE) clean && \ |
| 1299 | $(MAKE) dist-clean && \ |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1300 | $(EchoCmd) ===== $(DistTarGZip) Ready For Distribution ===== |
| Reid Spencer | e45ebfa | 2004-10-26 07:09:33 +0000 | [diff] [blame] | 1301 | |
| 1302 | dist-clean:: |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1303 | $(Echo) Cleaning distribution files |
| Reid Spencer | 345235ca | 2004-12-04 22:34:09 +0000 | [diff] [blame] | 1304 | -$(Verb) $(RM) -rf $(DistTarGZip) $(DistTarBZ2) $(DistZip) $(DistName) \ |
| 1305 | $(DistCheckDir) |
| Reid Spencer | e45ebfa | 2004-10-26 07:09:33 +0000 | [diff] [blame] | 1306 | |
| 1307 | endif |
| 1308 | |
| 1309 | #------------------------------------------------------------------------ |
| 1310 | # Provide the recursive distdir target for building the distribution directory |
| 1311 | #------------------------------------------------------------------------ |
| Reid Spencer | 345235ca | 2004-12-04 22:34:09 +0000 | [diff] [blame] | 1312 | distdir: $(DistDir)/.makedistdir |
| 1313 | $(DistDir)/.makedistdir: $(DistSources) |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1314 | $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \ |
| Reid Spencer | e45ebfa | 2004-10-26 07:09:33 +0000 | [diff] [blame] | 1315 | if test -d "$(DistDir)" ; then \ |
| 1316 | find $(DistDir) -type d ! -perm -200 -exec chmod u+w {} ';' || \ |
| 1317 | exit 1 ; \ |
| 1318 | fi ; \ |
| Reid Spencer | 345235ca | 2004-12-04 22:34:09 +0000 | [diff] [blame] | 1319 | $(EchoCmd) Removing old $(DistDir) ; \ |
| Reid Spencer | e45ebfa | 2004-10-26 07:09:33 +0000 | [diff] [blame] | 1320 | $(RM) -rf $(DistDir); \ |
| Reid Spencer | 9e8d54a | 2004-12-06 05:35:13 +0000 | [diff] [blame] | 1321 | $(EchoCmd) Making 'all' to verify build ; \ |
| Reid Spencer | 345235ca | 2004-12-04 22:34:09 +0000 | [diff] [blame] | 1322 | $(MAKE) all ; \ |
| Reid Spencer | e45ebfa | 2004-10-26 07:09:33 +0000 | [diff] [blame] | 1323 | fi |
| Reid Spencer | fbbf307 | 2004-11-29 05:00:33 +0000 | [diff] [blame] | 1324 | $(Echo) Building Distribution Directory $(DistDir) |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1325 | $(Verb) $(MKDIR) $(DistDir) |
| 1326 | $(Verb) srcdirstrip=`echo "$(BUILD_SRC_DIR)" | sed 's|.|.|g'`; \ |
| Reid Spencer | 151f8ba | 2004-10-25 08:27:37 +0000 | [diff] [blame] | 1327 | srcrootstrip=`echo "$(BUILD_SRC_ROOT)" | sed 's|.|.|g'`; \ |
| 1328 | for file in $(DistFiles) ; do \ |
| 1329 | case "$$file" in \ |
| Reid Spencer | 345235ca | 2004-12-04 22:34:09 +0000 | [diff] [blame] | 1330 | $(BUILD_SRC_DIR)/*) \ |
| 1331 | file=`echo "$$file" | sed "s#^$$srcdirstrip/##"` \ |
| 1332 | ;; \ |
| 1333 | $(BUILD_SRC_ROOT)/*) \ |
| 1334 | file=`echo "$$file" | \ |
| 1335 | sed "s#^$$srcrootstrip/##"` \ |
| 1336 | ;; \ |
| Reid Spencer | 151f8ba | 2004-10-25 08:27:37 +0000 | [diff] [blame] | 1337 | esac; \ |
| Reid Spencer | 345235ca | 2004-12-04 22:34:09 +0000 | [diff] [blame] | 1338 | if test -f "$(BUILD_SRC_DIR)/$$file" || \ |
| 1339 | test -d "$(BUILD_SRC_DIR)/$$file" ; then \ |
| 1340 | from_dir="$(BUILD_SRC_DIR)" ; \ |
| 1341 | elif test -f "$$file" || test -d "$$file" ; then \ |
| Reid Spencer | 151f8ba | 2004-10-25 08:27:37 +0000 | [diff] [blame] | 1342 | from_dir=. ; \ |
| Reid Spencer | 345235ca | 2004-12-04 22:34:09 +0000 | [diff] [blame] | 1343 | fi ; \ |
| 1344 | to_dir=`echo "$$file" | sed -e 's#/[^/]*$$##'` ; \ |
| Reid Spencer | 151f8ba | 2004-10-25 08:27:37 +0000 | [diff] [blame] | 1345 | if test "$$to_dir" != "$$file" && test "$$to_dir" != "."; then \ |
| 1346 | to_dir="$(DistDir)/$$dir"; \ |
| 1347 | $(MKDIR) "$$to_dir" ; \ |
| 1348 | else \ |
| 1349 | to_dir="$(DistDir)"; \ |
| 1350 | fi; \ |
| 1351 | mid_dir=`echo "$$file" | sed -n -e 's#^\(.*\)/[^/]*$$#\1#p'`; \ |
| 1352 | if test -n "$$mid_dir" ; then \ |
| Reid Spencer | e45ebfa | 2004-10-26 07:09:33 +0000 | [diff] [blame] | 1353 | $(MKDIR) "$$to_dir/$$mid_dir" || exit 1; \ |
| Reid Spencer | 151f8ba | 2004-10-25 08:27:37 +0000 | [diff] [blame] | 1354 | fi ; \ |
| 1355 | if test -d "$$from_dir/$$file"; then \ |
| 1356 | if test -d "$(BUILD_SRC_DIR)/$$file" && \ |
| 1357 | test "$$from_dir" != "$(BUILD_SRC_DIR)" ; then \ |
| Reid Spencer | c371984 | 2004-12-16 18:26:53 +0000 | [diff] [blame] | 1358 | $(CP) -pR "$(BUILD_SRC_DIR)/$$file" "$$to_dir" || exit 1; \ |
| Reid Spencer | 151f8ba | 2004-10-25 08:27:37 +0000 | [diff] [blame] | 1359 | fi; \ |
| Reid Spencer | c371984 | 2004-12-16 18:26:53 +0000 | [diff] [blame] | 1360 | $(CP) -pR $$from_dir/$$file $$to_dir || exit 1; \ |
| Reid Spencer | 151f8ba | 2004-10-25 08:27:37 +0000 | [diff] [blame] | 1361 | elif test -f "$$from_dir/$$file" ; then \ |
| Reid Spencer | c371984 | 2004-12-16 18:26:53 +0000 | [diff] [blame] | 1362 | $(CP) -p "$$from_dir/$$file" "$(DistDir)/$$file" || exit 1; \ |
| Reid Spencer | 151f8ba | 2004-10-25 08:27:37 +0000 | [diff] [blame] | 1363 | elif test -L "$$from_dir/$$file" ; then \ |
| Reid Spencer | c371984 | 2004-12-16 18:26:53 +0000 | [diff] [blame] | 1364 | $(CP) -pd "$$from_dir/$$file" $(DistDir)/$$file || exit 1; \ |
| Reid Spencer | 151f8ba | 2004-10-25 08:27:37 +0000 | [diff] [blame] | 1365 | elif echo "$(DistAlways)" | grep -v "$$file" >/dev/null ; then \ |
| Reid Spencer | 345235ca | 2004-12-04 22:34:09 +0000 | [diff] [blame] | 1366 | $(EchoCmd) "===== WARNING: Distribution Source " \ |
| 1367 | "$$from_dir/$$file Not Found!" ; \ |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1368 | elif test "$(Verb)" != '@' ; then \ |
| 1369 | $(EchoCmd) "Skipping non-existent $$from_dir/$$file" ; \ |
| Reid Spencer | 151f8ba | 2004-10-25 08:27:37 +0000 | [diff] [blame] | 1370 | fi; \ |
| 1371 | done |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1372 | $(Verb) for subdir in $(DistSubDirs) ; do \ |
| Reid Spencer | 151f8ba | 2004-10-25 08:27:37 +0000 | [diff] [blame] | 1373 | if test "$$subdir" \!= "." ; then \ |
| Reid Spencer | 151f8ba | 2004-10-25 08:27:37 +0000 | [diff] [blame] | 1374 | new_distdir="$(DistDir)/$$subdir" ; \ |
| Reid Spencer | e45ebfa | 2004-10-26 07:09:33 +0000 | [diff] [blame] | 1375 | test -d "$$new_distdir" || $(MKDIR) "$$new_distdir" || exit 1; \ |
| Reid Spencer | 345235ca | 2004-12-04 22:34:09 +0000 | [diff] [blame] | 1376 | ( cd $$subdir && $(MAKE) DistDir="$$new_distdir" distdir ) || \ |
| 1377 | exit 1; \ |
| Reid Spencer | 151f8ba | 2004-10-25 08:27:37 +0000 | [diff] [blame] | 1378 | fi; \ |
| 1379 | done |
| Reid Spencer | 345235ca | 2004-12-04 22:34:09 +0000 | [diff] [blame] | 1380 | $(Verb) if test "$(DistDir)" = "$(TopDistDir)" ; then \ |
| 1381 | $(EchoCmd) Eliminating CVS directories from distribution ; \ |
| 1382 | $(RM) -rf `find $(TopDistDir) -type d -name CVS -print` ;\ |
| 1383 | $(MAKE) dist-hook ; \ |
| 1384 | $(FIND) $(TopDistDir) -type d ! -perm -777 -exec chmod a+rwx {} \; \ |
| 1385 | -o ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; \ |
| 1386 | -o ! -type d ! -perm -400 -exec chmod a+r {} \; \ |
| 1387 | -o ! -type d ! -perm -444 -exec \ |
| 1388 | $(SHELL) $(INSTALL_SH) -c -m a+r {} {} \; \ |
| 1389 | || chmod -R a+r $(DistDir) ; \ |
| 1390 | fi |
| Reid Spencer | 151f8ba | 2004-10-25 08:27:37 +0000 | [diff] [blame] | 1391 | |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1392 | # This is invoked by distdir target, define it as a no-op to avoid errors if not |
| 1393 | # defined by user. |
| Reid Spencer | 151f8ba | 2004-10-25 08:27:37 +0000 | [diff] [blame] | 1394 | dist-hook:: |
| 1395 | |
| Reid Spencer | e53e397 | 2004-10-22 23:06:30 +0000 | [diff] [blame] | 1396 | endif |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 1397 | |
| 1398 | ############################################################################### |
| Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 1399 | # TOP LEVEL - targets only to apply at the top level directory |
| 1400 | ############################################################################### |
| 1401 | |
| 1402 | ifeq ($(LEVEL),.) |
| 1403 | |
| 1404 | #------------------------------------------------------------------------ |
| Reid Spencer | 9e8d54a | 2004-12-06 05:35:13 +0000 | [diff] [blame] | 1405 | # Install support for the project's include files: |
| Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 1406 | #------------------------------------------------------------------------ |
| 1407 | install-local:: |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1408 | $(Echo) Installing include files |
| 1409 | $(Verb) $(MKDIR) $(includedir) |
| 1410 | $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \ |
| Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 1411 | cd $(BUILD_SRC_ROOT)/include && \ |
| 1412 | find . -path '*/Internal' -prune -o '(' -type f \ |
| 1413 | '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \ |
| 1414 | -print ')' | grep -v CVS | pax -rwdvpe $(includedir) ; \ |
| 1415 | fi |
| 1416 | |
| 1417 | uninstall-local:: |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1418 | $(Echo) Uninstalling include files |
| 1419 | $(Verb) if [ -d "$(BUILD_SRC_ROOT)/include" ] ; then \ |
| Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 1420 | cd $(BUILD_SRC_ROOT)/include && \ |
| 1421 | $(RM) -f `find . -path '*/Internal' -prune -o '(' -type f \ |
| 1422 | '!' '(' -name '*~' -o -name '.cvsignore' -o -name '.#*' ')' \ |
| 1423 | -print ')' | grep -v CVS | sed 's#^#$(includedir)/#'` ; \ |
| 1424 | fi |
| 1425 | |
| Reid Spencer | e5487ba | 2004-10-24 07:53:21 +0000 | [diff] [blame] | 1426 | endif |
| 1427 | |
| Reid Spencer | 4d71b66 | 2004-10-22 21:01:56 +0000 | [diff] [blame] | 1428 | #------------------------------------------------------------------------ |
| 1429 | # Print out the directories used for building |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1430 | #------------------------------------------------------------------------ |
| Reid Spencer | 3a561f5 | 2004-10-23 20:04:14 +0000 | [diff] [blame] | 1431 | printvars:: |
| Reid Spencer | 9af3b29 | 2004-11-01 07:50:27 +0000 | [diff] [blame] | 1432 | $(Echo) "BuildMode : " '$(BuildMode)' |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1433 | $(Echo) "BUILD_SRC_ROOT : " '$(BUILD_SRC_ROOT)' |
| 1434 | $(Echo) "BUILD_SRC_DIR : " '$(BUILD_SRC_DIR)' |
| 1435 | $(Echo) "BUILD_OBJ_ROOT : " '$(BUILD_OBJ_ROOT)' |
| 1436 | $(Echo) "BUILD_OBJ_DIR : " '$(BUILD_OBJ_DIR)' |
| 1437 | $(Echo) "LLVM_SRC_ROOT : " '$(LLVM_SRC_ROOT)' |
| 1438 | $(Echo) "LLVM_OBJ_ROOT : " '$(LLVM_OBJ_ROOT)' |
| 1439 | $(Echo) "libdir : " '$(libdir)' |
| 1440 | $(Echo) "bindir : " '$(bindir)' |
| 1441 | $(Echo) "sysconfdir : " '$(sysconfdir)' |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1442 | $(Echo) "UserTargets : " '$(UserTargets)' |
| 1443 | $(Echo) "ObjMakefiles : " '$(ObjMakefiles)' |
| 1444 | $(Echo) "SrcMakefiles : " '$(SrcMakefiles)' |
| 1445 | $(Echo) "ObjDir : " '$(ObjDir)' |
| 1446 | $(Echo) "LibDir : " '$(LibDir)' |
| 1447 | $(Echo) "ToolDir : " '$(ToolDir)' |
| Reid Spencer | 815cbcf | 2004-11-18 10:03:46 +0000 | [diff] [blame] | 1448 | $(Echo) "ExmplDir : " '$(ExmplDir)' |
| Reid Spencer | 7980ea4 | 2004-12-05 05:17:22 +0000 | [diff] [blame] | 1449 | $(Echo) "Sources : " '$(Sources)' |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1450 | $(Echo) "TDFiles : " '$(TDFiles)' |
| 1451 | $(Echo) "INCFiles : " '$(INCFiles)' |
| Chris Lattner | 3c47347 | 2004-12-16 17:28:50 +0000 | [diff] [blame] | 1452 | $(Echo) "INCTMPFiles : " '$(INCTMPFiles)' |
| Reid Spencer | cc2d1e2 | 2004-10-30 09:19:36 +0000 | [diff] [blame] | 1453 | $(Echo) "Compile.CXX : " '$(Compile.CXX)' |
| 1454 | $(Echo) "Compile.C : " '$(Compile.C)' |
| 1455 | $(Echo) "Archive : " '$(Archive)' |
| Reid Spencer | 3d65949 | 2004-11-02 16:36:03 +0000 | [diff] [blame] | 1456 | $(Echo) "YaccFiles : " '$(YaccFiles)' |
| 1457 | $(Echo) "LexFiles : " '$(LexFiles)' |
| Reid Spencer | 7980ea4 | 2004-12-05 05:17:22 +0000 | [diff] [blame] | 1458 | $(Echo) "Module : " '$(Module)' |