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