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