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