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