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