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