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