Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 847 lines (711 sloc) 30.049 kB
d60aede Add makefile-mode flag for emacs.
Vikram S. Adve authored
1 #===-- Makefile.common - Common make rules for LLVM -------*- makefile -*--====
0095054 Initial revision
Chris Lattner authored
2 #
3 # This file is included by all of the LLVM makefiles. This file defines common
4 # rules to do things like compile a .cpp file or generate dependancy info.
5 # These are platform dependant, so this is the file used to specify these
6 # system dependant operations.
7 #
c214e71 Simplified significantly by pulling out local configuration options
Vikram S. Adve authored
8 # The following functionality can be set by setting incoming variables.
9 # The variable $(LEVEL) *must* be set:
0095054 Initial revision
Chris Lattner authored
10 #
11 # 1. LEVEL - The level of the current subdirectory from the top of the
12 # MagicStats view. This level should be expressed as a path, for
13 # example, ../.. for two levels deep.
14 #
15 # 2. DIRS - A list of subdirectories to be built. Fake targets are set up
a8abc22 Add support for the new PARALLEL_DIRS option
Chris Lattner authored
16 # so that each of the targets "all", "install", and "clean" each build
17 # the subdirectories before the local target. DIRS are guaranteed to be
18 # built in order.
0095054 Initial revision
Chris Lattner authored
19 #
a8abc22 Add support for the new PARALLEL_DIRS option
Chris Lattner authored
20 # 3. PARALLEL_DIRS - A list of subdirectories to be built, but that may be
21 # built in any order. All DIRS are built in order before PARALLEL_DIRS are
22 # built, which are then built in any order.
23 #
24 # 4. Source - If specified, this sets the source code filenames. If this
0095054 Initial revision
Chris Lattner authored
25 # is not set, it defaults to be all of the .cpp, .c, .y, and .l files
e001059 Change Sources specifier to ExtraSources
Chris Lattner authored
26 # in the current directory. Also, if you want to build files in addition
27 # to the local files, you can use the ExtraSource variable
0095054 Initial revision
Chris Lattner authored
28 #
694c5df Add facilities for building source that is outside of the current dir…
Chris Lattner authored
29 # 5. SourceDir - If specified, this specifies a directory that the source files
30 # are in, if they are not in the current directory. This should include a
31 # trailing / character.
32 #
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
33 # 6. LLVM_SRC_ROOT - If specified, points to the top of the LLVM source tree.
584dd18 Added documentation for the project options
Dinakar Dhurjati authored
34 #
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
35 # 7. LLVM_OBJ_ROOT - If specified, points to the top directory where LLVM
36 # object files are placed.
37 #
38 # 8. BUILD_SRC_DIR - The directory which contains the current set of Makefiles
39 # and usually the source code too (unless SourceDir is set).
40 #
41 # 9. BUILD_SRC_ROOT - The root directory of the source code being compiled.
42 #
43 # 10. BUILD_OBJ_DIR - The directory where object code should be placed.
44 #
45 # 11. BUILD_OBJ_ROOT - The root directory for where object code should be
46 # placed.
47 #
48 # For building,
49 # LLVM, LLVM_SRC_ROOT = BUILD_SRC_ROOT, and
50 # LLVM_OBJ_ROOT = BUILD_OBJ_ROOT.
af06a08 Make sure to create the directory before we cram a .bc file into it
Chris Lattner authored
51 #
d60aede Add makefile-mode flag for emacs.
Vikram S. Adve authored
52 #===-----------------------------------------------------------------------====
0095054 Initial revision
Chris Lattner authored
53
2a6530f Added the OPTIONAL_DIRS variable for specifying optional directories …
John Criswell authored
54 #
c214e71 Simplified significantly by pulling out local configuration options
Vikram S. Adve authored
55 # Configuration file to set paths specific to local installation of LLVM
56 #
57 include $(LEVEL)/Makefile.config
58
8bff509 Modified Makefile.common to handle compilation of projects inside and…
John Criswell authored
59 ###########################################################################
60 # Directory Configuration
61 # This section of the Makefile determines what is where. To be
62 # specific, there are several locations that need to be defined:
4bb13b8 Factor platform specific makefile directives out into their own makefile
Chris Lattner authored
63 #
8bff509 Modified Makefile.common to handle compilation of projects inside and…
John Criswell authored
64 # o LLVM_SRC_ROOT : The root directory of the LLVM source code.
65 # o LLVM_OBJ_ROOT : The root directory containing the built LLVM code.
66 #
67 # o BUILD_SRC_DIR : The directory containing the code to build.
68 # o BUILD_SRC_ROOT : The root directory of the code to build.
69 #
70 # o BUILD_OBJ_DIR : The directory in which compiled code will be placed.
71 # o BUILD_OBJ_ROOT : The root directory in which compiled code is placed.
72 #
73 ###########################################################################
4bb13b8 Factor platform specific makefile directives out into their own makefile
Chris Lattner authored
74
8bff509 Modified Makefile.common to handle compilation of projects inside and…
John Criswell authored
75 #
76 # Set the source build directory. That is almost always the current directory.
77 #
78 ifndef BUILD_SRC_DIR
79 BUILD_SRC_DIR = $(shell pwd)
edf1f23 Allow directories to specify that they want to be built as a shared o…
Chris Lattner authored
80 endif
81
e16b1b4 * Remove some bogus dependencies on Depend/.dir
Chris Lattner authored
82 #
8bff509 Modified Makefile.common to handle compilation of projects inside and…
John Criswell authored
83 # Set the source root directory.
84 #
85 ifndef BUILD_SRC_ROOT
890d5bd Modified the environment variables that determine where things are lo…
John Criswell authored
86 BUILD_SRC_ROOT = $(shell cd $(BUILD_SRC_DIR)/$(LEVEL); pwd)
8bff509 Modified Makefile.common to handle compilation of projects inside and…
John Criswell authored
87 endif
584dd18 Added documentation for the project options
Dinakar Dhurjati authored
88
8bff509 Modified Makefile.common to handle compilation of projects inside and…
John Criswell authored
89 #
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
90 # Determine the path of the source tree relative from $HOME (the mythical
91 # home directory).
92 #
f8873ed Removed an extra slash that appears in the path name when these varia…
Misha Brukman authored
93 HOME_OBJ_ROOT := $(OBJ_ROOT)$(patsubst $(HOME)%,%,$(BUILD_SRC_ROOT))
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
94
95 #
8bff509 Modified Makefile.common to handle compilation of projects inside and…
John Criswell authored
96 # Set the object build directory. Its location depends upon the source path
97 # and where object files should go.
98 #
99 ifndef BUILD_OBJ_DIR
100 ifeq ($(OBJ_ROOT),.)
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
101 BUILD_OBJ_DIR = $(BUILD_SRC_DIR)
584dd18 Added documentation for the project options
Dinakar Dhurjati authored
102 else
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
103 BUILD_OBJ_DIR := $(HOME_OBJ_ROOT)$(patsubst $(BUILD_SRC_ROOT)%,%,$(BUILD_SRC_DIR))
8bff509 Modified Makefile.common to handle compilation of projects inside and…
John Criswell authored
104 endif
105 endif
584dd18 Added documentation for the project options
Dinakar Dhurjati authored
106
8bff509 Modified Makefile.common to handle compilation of projects inside and…
John Criswell authored
107 #
108 # Set the root of the object directory.
109 #
110 ifndef BUILD_OBJ_ROOT
111 ifeq ($(OBJ_ROOT),.)
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
112 BUILD_OBJ_ROOT = $(BUILD_SRC_ROOT)
285af38 - Makefile changes:
Chris Lattner authored
113 else
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
114 BUILD_OBJ_ROOT := $(HOME_OBJ_ROOT)
8bff509 Modified Makefile.common to handle compilation of projects inside and…
John Criswell authored
115 endif
116 endif
285af38 - Makefile changes:
Chris Lattner authored
117
8bff509 Modified Makefile.common to handle compilation of projects inside and…
John Criswell authored
118 #
119 # Set the LLVM source directory.
120 # It is typically the root directory of what we're compiling now.
121 #
122 ifndef LLVM_SRC_ROOT
481cc7c Implement BYTECODE_LIBRARY support
Chris Lattner authored
123 LLVM_SRC_ROOT := $(BUILD_SRC_ROOT)
8bff509 Modified Makefile.common to handle compilation of projects inside and…
John Criswell authored
124 endif
285af38 - Makefile changes:
Chris Lattner authored
125
126 #
8bff509 Modified Makefile.common to handle compilation of projects inside and…
John Criswell authored
127 # Set the LLVM object directory.
128 #
129 ifndef LLVM_OBJ_ROOT
481cc7c Implement BYTECODE_LIBRARY support
Chris Lattner authored
130 LLVM_OBJ_ROOT := $(BUILD_OBJ_ROOT)
ffb55cd Added project options to the Makefile.common
Dinakar Dhurjati authored
131 endif
132
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
133 ###########################################################################
134 # Default Targets:
135 # The following targets are the standard top level targets for
136 # building.
137 ###########################################################################
8bff509 Modified Makefile.common to handle compilation of projects inside and…
John Criswell authored
138
139 ifdef SHARED_LIBRARY
140 # if SHARED_LIBRARY is specified, the default is to build the dynamic lib
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
141 all:: dynamic
e16b1b4 * Remove some bogus dependencies on Depend/.dir
Chris Lattner authored
142 endif
143
95cc1b3 Simplifications to Makefile.common, remove support for Purify since i…
Chris Lattner authored
144 ifdef BYTECODE_LIBRARY
145 # if BYTECODE_LIBRARY is specified, the default is to build the bytecode lib
146 all:: bytecodelib
481cc7c Implement BYTECODE_LIBRARY support
Chris Lattner authored
147 install:: bytecodelib-install
95cc1b3 Simplifications to Makefile.common, remove support for Purify since i…
Chris Lattner authored
148 endif
149
8bff509 Modified Makefile.common to handle compilation of projects inside and…
John Criswell authored
150 # Default Rule: Make sure it's also a :: rule
151 all ::
ffb55cd Added project options to the Makefile.common
Dinakar Dhurjati authored
152
8bff509 Modified Makefile.common to handle compilation of projects inside and…
John Criswell authored
153 # Default for install is to at least build everything...
154 install ::
ffb55cd Added project options to the Makefile.common
Dinakar Dhurjati authored
155
8bff509 Modified Makefile.common to handle compilation of projects inside and…
John Criswell authored
156 # Default rule for test. It ensures everything has a test rule
157 test::
ffb55cd Added project options to the Makefile.common
Dinakar Dhurjati authored
158
6edfe27 Add phony target "bytecode" to ensure that it works in recursive makes.
Vikram S. Adve authored
159 # Default rule for building only bytecode.
160 bytecode::
161
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
162 # Print out the directories used for building
163 prdirs::
b7dc2b9 Remove extraneous ;'s, no functional changes
Chris Lattner authored
164 echo "Home Offset : " $(HOME_OBJ_ROOT)
165 echo "Build Source Root: " $(BUILD_SRC_ROOT)
166 echo "Build Source Dir : " $(BUILD_SRC_DIR)
167 echo "Build Object Root: " $(BUILD_OBJ_ROOT)
168 echo "Build Object Dir : " $(BUILD_OBJ_DIR)
169 echo "LLVM Source Root: " $(LLVM_SRC_ROOT)
170 echo "LLVM Object Root: " $(LLVM_OBJ_ROOT)
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
171
9691439 Marked some of the phony targets are PHONY. This will hopefully speed
John Criswell authored
172 #
173 # Mark all of these targets as phony. This will hopefully speed up builds
174 # slightly since GNU Make will not try to find implicit rules for targets
175 # which are marked as Phony.
176 #
481cc7c Implement BYTECODE_LIBRARY support
Chris Lattner authored
177 .PHONY: all dynamic bytecodelib bytecodelib-install
1ddb6b6 Add new cleandeps target, to allow easy cleaning out of .d files
Chris Lattner authored
178 .PHONY: clean cleandeps distclean install test bytecode prdirs
9691439 Marked some of the phony targets are PHONY. This will hopefully speed
John Criswell authored
179
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
180 ###########################################################################
181 # Miscellaneous paths and commands:
182 # This section defines various configuration macros, such as where
183 # to find burg, tblgen, and libtool.
184 ###########################################################################
185
0095054 Initial revision
Chris Lattner authored
186 #--------------------------------------------------------------------
c214e71 Simplified significantly by pulling out local configuration options
Vikram S. Adve authored
187 # Variables derived from configuration options...
0095054 Initial revision
Chris Lattner authored
188 #--------------------------------------------------------------------
189
190 #BinInstDir=/usr/local/bin
65aa593 Removed configuration options that are better served in Makefile.config.
John Criswell authored
191 #LibInstDir=/usr/local/lib/xxx
0095054 Initial revision
Chris Lattner authored
192 #DocInstDir=/usr/doc/xxx
193
dba59ef Add path and options for burg.
Vikram S. Adve authored
194 BURG_OPTS = -I
195
760da06 Fix several bugs in the build system, including the use of the Debug …
Chris Lattner authored
196 ifdef ENABLE_PROFILING
197 ENABLE_OPTIMIZED = 1
198 CONFIGURATION := Profile
199 else
200 ifdef ENABLE_OPTIMIZED
201 CONFIGURATION := Release
202 else
203 CONFIGURATION := Debug
204 endif
205 endif
206
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
207 #
208 # Enable this for profiling support with 'gprof'
209 # This automatically enables optimized builds.
210 #
211 ifdef ENABLE_PROFILING
212 PROFILE = -pg
213 endif
214
215 #
216 # Suffixes for library compilation rules
217 #
218 .SUFFIXES: .so
219
8bff509 Modified Makefile.common to handle compilation of projects inside and…
John Criswell authored
220 ###########################################################################
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
221 # Library Locations:
8bff509 Modified Makefile.common to handle compilation of projects inside and…
John Criswell authored
222 # These variables describe various library locations:
223 #
224 # DEST* = Location of where libraries that are built will be placed.
225 # LLVM* = Location of LLVM libraries used for linking.
226 # PROJ* = Location of previously built libraries used for linking.
227 ###########################################################################
228
229 # Libraries that are being built
230 DESTLIBDEBUG := $(BUILD_OBJ_ROOT)/lib/Debug
231 DESTLIBRELEASE := $(BUILD_OBJ_ROOT)/lib/Release
232 DESTLIBPROFILE := $(BUILD_OBJ_ROOT)/lib/Profile
481cc7c Implement BYTECODE_LIBRARY support
Chris Lattner authored
233 DESTLIBBYTECODE := $(BUILD_OBJ_ROOT)/lib/Bytecode
8bff509 Modified Makefile.common to handle compilation of projects inside and…
John Criswell authored
234 DESTLIBCURRENT := $(BUILD_OBJ_ROOT)/lib/$(CONFIGURATION)
235
236 # LLVM libraries used for linking
237 LLVMLIBDEBUGSOURCE := $(LLVM_OBJ_ROOT)/lib/Debug
238 LLVMLIBRELEASESOURCE := $(LLVM_OBJ_ROOT)/lib/Release
239 LLVMLIBPROFILESOURCE := $(LLVM_OBJ_ROOT)/lib/Profile
240 LLVMLIBCURRENTSOURCE := $(LLVM_OBJ_ROOT)/lib/$(CONFIGURATION)
241
242 # Libraries that were built that will now be used for linking
243 PROJLIBDEBUGSOURCE := $(BUILD_OBJ_ROOT)/lib/Debug
244 PROJLIBRELEASESOURCE := $(BUILD_OBJ_ROOT)/lib/Release
245 PROJLIBPROFILESOURCE := $(BUILD_OBJ_ROOT)/lib/Profile
246 PROJLIBCURRENTSOURCE := $(BUILD_OBJ_ROOT)/lib/$(CONFIGURATION)
247
248 ###########################################################################
249 # Tool Locations
250 # These variables describe various tool locations:
251 #
252 # DEST* = Location of where tools that are built will be placed.
253 # LLVM* = Location of LLVM tools used for building.
254 # PROJ* = Location of previously built tools used for linking.
255 ###########################################################################
256
257 DESTTOOLDEBUG := $(BUILD_OBJ_ROOT)/tools/Debug
258 DESTTOOLRELEASE := $(BUILD_OBJ_ROOT)/tools/Release
259 DESTTOOLPROFILE := $(BUILD_OBJ_ROOT)/tools/Profile
260 DESTTOOLCURRENT := $(BUILD_OBJ_ROOT)/tools/$(CONFIGURATION)
261
262 LLVMTOOLDEBUG := $(LLVM_OBJ_ROOT)/tools/Debug
263 LLVMTOOLRELEASE := $(LLVM_OBJ_ROOT)/tools/Release
264 LLVMTOOLPROFILE := $(LLVM_OBJ_ROOT)/tools/Profile
265 LLVMTOOLCURRENT := $(LLVM_OBJ_ROOT)/tools/$(CONFIGURATION)
266
267 PROJTOOLDEBUG := $(BUILD_OBJ_ROOT)/tools/Debug
268 PROJTOOLRELEASE := $(BUILD_OBJ_ROOT)/tools/Release
269 PROJTOOLPROFILE := $(BUILD_OBJ_ROOT)/tools/Profile
270 PROJTOOLCURRENT := $(BUILD_OBJ_ROOT)/tools/$(CONFIGURATION)
e62dbe9 Enable USEDLIBS to contain .a and .o files
Chris Lattner authored
271
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
272 #
273 # Libtool is found in the current directory.
274 #
95cc1b3 Simplifications to Makefile.common, remove support for Purify since i…
Chris Lattner authored
275 LIBTOOL := $(LLVM_SRC_ROOT)/mklib
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
276
277 #
82f4a5a Modified the use of libtool so that we don't compile every file twice.
John Criswell authored
278 # If we're not building a shared library, use the disable-shared tag with
279 # libtool. This will disable the building of objects for shared libraries and
280 # only generate static library objects.
281 #
282 # For dynamic libraries, we'll take the performance hit for now, since we
283 # almost never build them.
284 #
285 # This should speed up compilation and require no modifications to future
286 # versions of libtool.
287 #
288 ifndef SHARED_LIBRARY
95cc1b3 Simplifications to Makefile.common, remove support for Purify since i…
Chris Lattner authored
289 LIBTOOL += --tag=disable-shared
82f4a5a Modified the use of libtool so that we don't compile every file twice.
John Criswell authored
290 endif
291
292 #
b5f096f Compiling with "gmake" should produce less output. The compilation/li…
Misha Brukman authored
293 # Verbosity levels
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
294 #
760da06 Fix several bugs in the build system, including the use of the Debug …
Chris Lattner authored
295 ifndef VERBOSE
b5f096f Compiling with "gmake" should produce less output. The compilation/li…
Misha Brukman authored
296 VERB := @
95cc1b3 Simplifications to Makefile.common, remove support for Purify since i…
Chris Lattner authored
297 LIBTOOL += --silent
b5f096f Compiling with "gmake" should produce less output. The compilation/li…
Misha Brukman authored
298 endif
299
8bff509 Modified Makefile.common to handle compilation of projects inside and…
John Criswell authored
300 ###########################################################################
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
301 # Miscellaneous paths and commands (part deux):
302 # This section defines various configuration macros, such as where
303 # to find burg, tblgen, and libtool.
8bff509 Modified Makefile.common to handle compilation of projects inside and…
John Criswell authored
304 ###########################################################################
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
305
306 #--------------------------------------------------------------------------
481cc7c Implement BYTECODE_LIBRARY support
Chris Lattner authored
307 # Utilities used while building the LLVM tree, which live in the utils dir
308 #
8bff509 Modified Makefile.common to handle compilation of projects inside and…
John Criswell authored
309 BURG := $(LLVMTOOLCURRENT)/burg
9b94701 Move the burg option out of Makefile.config into Makefile.common since
Chris Lattner authored
310 RunBurg := $(BURG) $(BURG_OPTS)
8bff509 Modified Makefile.common to handle compilation of projects inside and…
John Criswell authored
311 TBLGEN := $(LLVMTOOLCURRENT)/tblgen
dba59ef Add path and options for burg.
Vikram S. Adve authored
312
481cc7c Implement BYTECODE_LIBRARY support
Chris Lattner authored
313 #--------------------------------------------------------------------------
314 # The LLVM GCC front-end in C and C++ flavors
315 #
9a86a01 Add llvm tools to path of LLVMGCC
Chris Lattner authored
316 LLVMGCC := PATH=$(LLVMTOOLCURRENT):$(PATH) $(LLVMGCCDIR)/bin/gcc
481cc7c Implement BYTECODE_LIBRARY support
Chris Lattner authored
317 LCC1 := $(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH)/cc1
9a86a01 Add llvm tools to path of LLVMGCC
Chris Lattner authored
318 LLVMGXX := PATH=$(LLVMTOOLCURRENT):$(PATH) $(LLVMGCCDIR)/bin/g++
481cc7c Implement BYTECODE_LIBRARY support
Chris Lattner authored
319 LCC1XX := $(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH)/cc1plus
320
321 #--------------------------------------------------------------------------
322 # Some of the compiled LLVM tools which are used for compilation of runtime
323 # libraries.
324 #
325 LLVMAS := $(LLVMTOOLCURRENT)/as
326
0095054 Initial revision
Chris Lattner authored
327
8bff509 Modified Makefile.common to handle compilation of projects inside and…
John Criswell authored
328 ###########################################################################
329 # Compile Time Flags
330 ###########################################################################
331
332 #
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
333 # Include both the project headers and the LLVM headers for compilation and
334 # dependency computation.
8bff509 Modified Makefile.common to handle compilation of projects inside and…
John Criswell authored
335 #
336 CPPFLAGS += -I$(BUILD_SRC_ROOT)/include -I$(LLVM_SRC_ROOT)/include
ffb55cd Added project options to the Makefile.common
Dinakar Dhurjati authored
337
feeae58 Strip tools/Debug/ executables by default. Define KEEP_SYMBOLS to
Vikram S. Adve authored
338 # By default, strip symbol information from executable
760da06 Fix several bugs in the build system, including the use of the Debug …
Chris Lattner authored
339 ifndef KEEP_SYMBOLS
527002c Fix strip issue Joel ran into
Chris Lattner authored
340 STRIP = $(PLATFORMSTRIPOPTS)
9b51b6f Move the space separator to where it really belongs: in the print sta…
Misha Brukman authored
341 STRIP_WARN_MSG = "(without symbols)"
feeae58 Strip tools/Debug/ executables by default. Define KEEP_SYMBOLS to
Vikram S. Adve authored
342 endif
343
73e1d0f Build with -D_GNU_SOURCE to enable gnu extensions in header files
Chris Lattner authored
344 # Allow gnu extensions...
345 CPPFLAGS += -D_GNU_SOURCE
346
8bff509 Modified Makefile.common to handle compilation of projects inside and…
John Criswell authored
347 CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused -I$(LEVEL)/include
1d1e5b5 Fix profile builds
Chris Lattner authored
348 CompileOptimizeOpts := -O3 -DNDEBUG -finline-functions -fshort-enums
0095054 Initial revision
Chris Lattner authored
349
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
350 #
351 # Compile commands with libtool.
352 #
353 Compile := $(LIBTOOL) --mode=compile $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(CompileCommonOpts)
354 CompileC := $(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CCFLAGS) $(CompileCommonOpts)
355
172b648 * Minor fixes to support C files.
Chris Lattner authored
356 # Compile a cpp file, don't link...
285af38 - Makefile changes:
Chris Lattner authored
357 CompileG := $(Compile) -g -D_DEBUG
1d1e5b5 Fix profile builds
Chris Lattner authored
358 CompileO := $(Compile) $(CompileOptimizeOpts) -felide-constructors -fomit-frame-pointer
359 CompileP := $(Compile) $(CompileOptimizeOpts) -felide-constructors $(PROFILE)
0095054 Initial revision
Chris Lattner authored
360
172b648 * Minor fixes to support C files.
Chris Lattner authored
361 # Compile a c file, don't link...
362 CompileCG := $(CompileC) -g -D_DEBUG
fe95dae Fix warnings compiling C files
Chris Lattner authored
363 CompileCO := $(CompileC) $(CompileOptimizeOpts) -fomit-frame-pointer
364 CompileCP := $(CompileC) $(CompileOptimizeOpts) $(PROFILE)
172b648 * Minor fixes to support C files.
Chris Lattner authored
365
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
366 ###########################################################################
367 # Link Time Options
368 ###########################################################################
172b648 * Minor fixes to support C files.
Chris Lattner authored
369
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
370 #
0095054 Initial revision
Chris Lattner authored
371 # Link final executable
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
372 # (Note that we always link with the C++ compiler).
373 #
374 Link := $(LIBTOOL) --mode=link $(CXX)
ffb55cd Added project options to the Makefile.common
Dinakar Dhurjati authored
375
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
376 # link both projlib and llvmlib libraries
ffb55cd Added project options to the Makefile.common
Dinakar Dhurjati authored
377 LinkG := $(Link) -g -L$(PROJLIBDEBUGSOURCE) -L$(LLVMLIBDEBUGSOURCE) $(STRIP)
378 LinkO := $(Link) -O3 -L$(PROJLIBRELEASESOURCE) -L$(LLVMLIBRELEASESOURCE)
379 LinkP := $(Link) -O3 -L$(PROJLIBPROFILESOURCE) -L$(LLVMLIBPROFILESOURCE) $(PROFILE)
0095054 Initial revision
Chris Lattner authored
380
e62dbe9 Enable USEDLIBS to contain .a and .o files
Chris Lattner authored
381 # Create one .o file from a bunch of .o files...
95cc1b3 Simplifications to Makefile.common, remove support for Purify since i…
Chris Lattner authored
382 Relink := ${LIBTOOL} --mode=link $(CXX)
383 ifndef SHARED_LIBRARY
384 Relink += -only-static
385 endif
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
386
387 #
388 # Configure where the item being compiled should go.
389 #
390 ifdef SHARED_LIBRARY
95cc1b3 Simplifications to Makefile.common, remove support for Purify since i…
Chris Lattner authored
391 Link += -rpath $(DESTLIBCURRENT)
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
392 endif
393
394 ifdef TOOLNAME
95cc1b3 Simplifications to Makefile.common, remove support for Purify since i…
Chris Lattner authored
395 Link += -rpath $(DESTTOOLCURRENT)
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
396 endif
4bb13b8 Factor platform specific makefile directives out into their own makefile
Chris Lattner authored
397
0095054 Initial revision
Chris Lattner authored
398 # Create dependancy file from CPP file, send to stdout.
8bff509 Modified Makefile.common to handle compilation of projects inside and…
John Criswell authored
399 Depend := $(CXX) -MM -I$(LEVEL)/include $(CPPFLAGS)
400 DependC := $(CC) -MM -I$(LEVEL)/include $(CPPFLAGS)
0095054 Initial revision
Chris Lattner authored
401
402 # Archive a bunch of .o files into a .a file...
794fcd2 Added configurable options for the Linker and Archiver.
John Criswell authored
403 AR = ${AR_PATH} cq
0095054 Initial revision
Chris Lattner authored
404
405 #----------------------------------------------------------
406
407 # Source includes all of the cpp files, and objects are derived from the
408 # source files...
e001059 Change Sources specifier to ExtraSources
Chris Lattner authored
409 # The local Makefile can list other Source files via ExtraSource = ...
c4bed34 Allow only extra Source files to be listed in a local Makefile.
Vikram S. Adve authored
410 #
ad9ea7e Allow the Source variable to be overridden completely if needed.
Vikram S. Adve authored
411 ifndef Source
e001059 Change Sources specifier to ExtraSources
Chris Lattner authored
412 Source := $(ExtraSource) $(wildcard *.cpp *.c *.y *.l)
ad9ea7e Allow the Source variable to be overridden completely if needed.
Vikram S. Adve authored
413 endif
112a72c Changed default to building library archives instead of shared objects.
Vikram S. Adve authored
414
82f4a5a Modified the use of libtool so that we don't compile every file twice.
John Criswell authored
415 #
416 # Libtool Objects
417 #
481cc7c Implement BYTECODE_LIBRARY support
Chris Lattner authored
418 Srcs := $(sort $(notdir $(basename $(Source))))
419 Objs := $(addsuffix .lo, $(Srcs))
f4ccd99 Renamed all of the LObj* variables (which represent libtool objects) …
John Criswell authored
420 ObjectsO := $(addprefix $(BUILD_OBJ_DIR)/Release/,$(Objs))
421 ObjectsP := $(addprefix $(BUILD_OBJ_DIR)/Profile/,$(Objs))
422 ObjectsG := $(addprefix $(BUILD_OBJ_DIR)/Debug/,$(Objs))
481cc7c Implement BYTECODE_LIBRARY support
Chris Lattner authored
423 ObjectsBC := $(addprefix $(BUILD_OBJ_DIR)/Bytecode/,$(addsuffix .bc, $(Srcs)))
e62dbe9 Enable USEDLIBS to contain .a and .o files
Chris Lattner authored
424
82f4a5a Modified the use of libtool so that we don't compile every file twice.
John Criswell authored
425 #
426 # The real objects underlying the libtool objects
427 #
428 RObjs := $(sort $(patsubst Debug/%.o, %.o, $(addsuffix .o,$(notdir $(basename $(Source))))))
429 RObjectsO := $(addprefix $(BUILD_OBJ_DIR)/Release/,$(RObjs))
430 RObjectsP := $(addprefix $(BUILD_OBJ_DIR)/Profile/,$(RObjs))
431 RObjectsG := $(addprefix $(BUILD_OBJ_DIR)/Debug/,$(RObjs))
432
0095054 Initial revision
Chris Lattner authored
433 #---------------------------------------------------------
a8abc22 Add support for the new PARALLEL_DIRS option
Chris Lattner authored
434 # Handle the DIRS and PARALLEL_DIRS options
0095054 Initial revision
Chris Lattner authored
435 #---------------------------------------------------------
436
7c7a07e corrected small bug, to handle when DIRS is not defined.
Anand Shukla authored
437 ifdef DIRS
1ddb6b6 Add new cleandeps target, to allow easy cleaning out of .d files
Chris Lattner authored
438 all install clean cleandeps test bytecode ::
16d1f73 Allow the VERBOSE=1 option to turn on output of recursive make behavior
Chris Lattner authored
439 $(VERB) for dir in ${DIRS}; do \
f1ffd99 Fix parallel recursive make to build directories in order
Chris Lattner authored
440 (cd $$dir; $(MAKE) $@) || exit 1; \
441 done
7c7a07e corrected small bug, to handle when DIRS is not defined.
Anand Shukla authored
442 endif
a8abc22 Add support for the new PARALLEL_DIRS option
Chris Lattner authored
443
444 # Handle PARALLEL_DIRS
445 ifdef PARALLEL_DIRS
6edfe27 Add phony target "bytecode" to ensure that it works in recursive makes.
Vikram S. Adve authored
446 all :: $(addsuffix /.makeall , $(PARALLEL_DIRS))
447 install :: $(addsuffix /.makeinstall , $(PARALLEL_DIRS))
448 clean :: $(addsuffix /.makeclean , $(PARALLEL_DIRS))
1ddb6b6 Add new cleandeps target, to allow easy cleaning out of .d files
Chris Lattner authored
449 cleandeps:: $(addsuffix /.makecleandeps, $(PARALLEL_DIRS))
6edfe27 Add phony target "bytecode" to ensure that it works in recursive makes.
Vikram S. Adve authored
450 test :: $(addsuffix /.maketest , $(PARALLEL_DIRS))
451 bytecode :: $(addsuffix /.makebytecode, $(PARALLEL_DIRS))
a8abc22 Add support for the new PARALLEL_DIRS option
Chris Lattner authored
452
1ddb6b6 Add new cleandeps target, to allow easy cleaning out of .d files
Chris Lattner authored
453 %/.makeall %/.makeinstall %/.makeclean %/.makecleandeps %/.maketest \
454 %/.makebytecode:
a8abc22 Add support for the new PARALLEL_DIRS option
Chris Lattner authored
455 $(VERB) cd $(@D); $(MAKE) $(subst $(@D)/.make,,$@)
0095054 Initial revision
Chris Lattner authored
456 endif
457
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
458 # Handle directories that may or may not exist
2a6530f Added the OPTIONAL_DIRS variable for specifying optional directories …
John Criswell authored
459 ifdef OPTIONAL_DIRS
1ddb6b6 Add new cleandeps target, to allow easy cleaning out of .d files
Chris Lattner authored
460 all install clean cleandeps test bytecode ::
2a6530f Added the OPTIONAL_DIRS variable for specifying optional directories …
John Criswell authored
461 $(VERB) for dir in ${OPTIONAL_DIRS}; do \
462 if [ -d $$dir ]; \
463 then\
464 (cd $$dir; $(MAKE) $@) || exit 1; \
465 fi \
466 done
467 endif
468
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
469 ###########################################################################
470 # Library Build Rules:
471 #
0095054 Initial revision
Chris Lattner authored
472 #---------------------------------------------------------
473 # Handle the LIBRARYNAME option - used when building libs...
474 #---------------------------------------------------------
e62dbe9 Enable USEDLIBS to contain .a and .o files
Chris Lattner authored
475 #
476 # When libraries are built, they are allowed to optionally define the
477 # DONT_BUILD_RELINKED make variable, which, when defined, prevents a .o file
478 # from being built for the library. This .o files may then be linked to by a
479 # tool if the tool does not need (or want) the semantics a .a file provides
480 # (linking in only object files that are "needed"). If a library is never to
481 # be used in this way, it is better to define DONT_BUILD_RELINKED, and define
482 # BUILD_ARCHIVE instead.
483 #
484 # Some libraries must be built as .a files (libscalar for example) because if
1917e95 Cleanup Makefile a bit
Chris Lattner authored
485 # it's built as a .o file, then all of the constituent .o files in it will be
e62dbe9 Enable USEDLIBS to contain .a and .o files
Chris Lattner authored
486 # linked into tools (for example gccas) even if they only use one of the parts
487 # of it. For this reason, sometimes it's useful to use libraries as .a files.
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
488 ###########################################################################
0095054 Initial revision
Chris Lattner authored
489
490 ifdef LIBRARYNAME
112a72c Changed default to building library archives instead of shared objects.
Vikram S. Adve authored
491
2a548c5 Comment line of the makefile
Chris Lattner authored
492 # Make sure there isn't any extranous whitespace on the LIBRARYNAME option
ccb4ebd Handle whitespace in LIBRARYNAME gracefully
Chris Lattner authored
493 LIBRARYNAME := $(strip $(LIBRARYNAME))
494
ffb55cd Added project options to the Makefile.common
Dinakar Dhurjati authored
495 LIBNAME_O := $(DESTLIBRELEASE)/lib$(LIBRARYNAME).so
496 LIBNAME_P := $(DESTLIBPROFILE)/lib$(LIBRARYNAME).so
497 LIBNAME_G := $(DESTLIBDEBUG)/lib$(LIBRARYNAME).so
498 LIBNAME_AO := $(DESTLIBRELEASE)/lib$(LIBRARYNAME).a
499 LIBNAME_AP := $(DESTLIBPROFILE)/lib$(LIBRARYNAME).a
500 LIBNAME_AG := $(DESTLIBDEBUG)/lib$(LIBRARYNAME).a
501 LIBNAME_OBJO := $(DESTLIBRELEASE)/$(LIBRARYNAME).o
502 LIBNAME_OBJP := $(DESTLIBPROFILE)/$(LIBRARYNAME).o
503 LIBNAME_OBJG := $(DESTLIBDEBUG)/$(LIBRARYNAME).o
481cc7c Implement BYTECODE_LIBRARY support
Chris Lattner authored
504 LIBNAME_BC := $(DESTLIBBYTECODE)/lib$(LIBRARYNAME).bc
e62dbe9 Enable USEDLIBS to contain .a and .o files
Chris Lattner authored
505
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
506 #--------------------------------------------------------------------
507 # Library Targets
508 # Modify the top level targets to build the desired libraries.
509 #--------------------------------------------------------------------
510
760da06 Fix several bugs in the build system, including the use of the Debug …
Chris Lattner authored
511 # dynamic target builds a shared object version of the library...
ffb55cd Added project options to the Makefile.common
Dinakar Dhurjati authored
512 dynamic:: $(DESTLIBCURRENT)/lib$(LIBRARYNAME).so
481cc7c Implement BYTECODE_LIBRARY support
Chris Lattner authored
513 bytecodelib:: $(LIBNAME_BC)
514 bytecodelib-install:: $(LLVMGCCDIR)/bytecode-libs/lib$(LIBRARYNAME).bc
515
516 $(LLVMGCCDIR)/bytecode-libs/lib$(LIBRARYNAME).bc: $(LIBNAME_BC)
517 @echo ======= Installing $(LIBRARYNAME) bytecode library =======
518 cp $< $@
60f5606 Don't build Debug/ versions when ENABLE_OPTIMIZED is on.
Vikram S. Adve authored
519
760da06 Fix several bugs in the build system, including the use of the Debug …
Chris Lattner authored
520 # Does the library want a .o version built?
e62dbe9 Enable USEDLIBS to contain .a and .o files
Chris Lattner authored
521 ifndef DONT_BUILD_RELINKED
ffb55cd Added project options to the Makefile.common
Dinakar Dhurjati authored
522 all:: $(DESTLIBCURRENT)/$(LIBRARYNAME).o
60f5606 Don't build Debug/ versions when ENABLE_OPTIMIZED is on.
Vikram S. Adve authored
523 endif
e62dbe9 Enable USEDLIBS to contain .a and .o files
Chris Lattner authored
524
760da06 Fix several bugs in the build system, including the use of the Debug …
Chris Lattner authored
525 # Does the library want an archive version built?
526 ifdef BUILD_ARCHIVE
ffb55cd Added project options to the Makefile.common
Dinakar Dhurjati authored
527 all:: $(DESTLIBCURRENT)/lib$(LIBRARYNAME).a
e62dbe9 Enable USEDLIBS to contain .a and .o files
Chris Lattner authored
528 endif
0095054 Initial revision
Chris Lattner authored
529
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
530 #--------------------------------------------------------------------
531 # Rules for building libraries
532 #--------------------------------------------------------------------
533
481cc7c Implement BYTECODE_LIBRARY support
Chris Lattner authored
534 LinkBCLib := $(LLVMGCC) -shared
535 ifdef EXPORTED_SYMBOL_LIST
536 LinkBCLib += -Xlinker -internalize-public-api-list=$(EXPORTED_SYMBOL_LIST)
537 else
538 LinkBCLib += -Xlinker -disable-internalize
539 endif
540
541
542 # Rule for building bytecode libraries.
af06a08 Make sure to create the directory before we cram a .bc file into it
Chris Lattner authored
543 $(LIBNAME_BC): $(ObjectsBC) $(LibSubDirs) $(DESTLIBBYTECODE)/.dir
481cc7c Implement BYTECODE_LIBRARY support
Chris Lattner authored
544 @echo ======= Linking $(LIBRARYNAME) bytecode library =======
545 $(VERB) $(LinkBCLib) -o $@ $(ObjectsBC) $(LibSubDirs) $(LibLinkOpts)
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
546 #
547 # Rules for building dynamically linked libraries.
548 #
f4ccd99 Renamed all of the LObj* variables (which represent libtool objects) …
John Criswell authored
549 $(LIBNAME_O): $(ObjectsO) $(LibSubDirs) $(DESTLIBRELEASE)/.dir
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
550 @echo ======= Linking $(LIBRARYNAME) dynamic release library =======
b7dc2b9 Remove extraneous ;'s, no functional changes
Chris Lattner authored
551 $(VERB) $(Link) -o $*.la $(ObjectsO) $(LibSubDirs) $(LibLinkOpts)
552 $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $*.la $(DESTLIBCURRENT)
0095054 Initial revision
Chris Lattner authored
553
f4ccd99 Renamed all of the LObj* variables (which represent libtool objects) …
John Criswell authored
554 $(LIBNAME_P): $(ObjectsP) $(LibSubDirs) $(DESTLIBPROFILE)/.dir
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
555 @echo ======= Linking $(LIBRARYNAME) dynamic profile library =======
b7dc2b9 Remove extraneous ;'s, no functional changes
Chris Lattner authored
556 $(VERB) $(Link) -o $*.la $(ObjectsP) $(LibSubDirs) $(LibLinkOpts)
557 $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $*.la $(DESTLIBCURRENT)
41e7891 The ENABLE_PROFILING flag now builds the profiled libraries and execu…
Vikram S. Adve authored
558
f4ccd99 Renamed all of the LObj* variables (which represent libtool objects) …
John Criswell authored
559 $(LIBNAME_G): $(ObjectsG) $(LibSubDirs) $(DESTLIBDEBUG)/.dir
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
560 @echo ======= Linking $(LIBRARYNAME) dynamic debug library =======
b7dc2b9 Remove extraneous ;'s, no functional changes
Chris Lattner authored
561 $(VERB) $(Link) -o $*.la $(ObjectsG) $(LibSubDirs) $(LibLinkOpts)
562 $(VERB) $(LIBTOOL) --mode=install $(INSTALL) $*.la $(DESTLIBCURRENT)
0095054 Initial revision
Chris Lattner authored
563
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
564 #
565 # Rules for building static archive libraries.
566 #
f4ccd99 Renamed all of the LObj* variables (which represent libtool objects) …
John Criswell authored
567 $(LIBNAME_AO): $(ObjectsO) $(LibSubDirs) $(DESTLIBRELEASE)/.dir
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
568 @echo ======= Linking $(LIBRARYNAME) archive release library =======
569 @$(RM) -f $@
f4ccd99 Renamed all of the LObj* variables (which represent libtool objects) …
John Criswell authored
570 $(VERB) $(Link) -03 -o $@ $(ObjectsO) $(LibSubDirs) -static
112a72c Changed default to building library archives instead of shared objects.
Vikram S. Adve authored
571
f4ccd99 Renamed all of the LObj* variables (which represent libtool objects) …
John Criswell authored
572 $(LIBNAME_AP): $(ObjectsP) $(LibSubDirs) $(DESTLIBPROFILE)/.dir
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
573 @echo ======= Linking $(LIBRARYNAME) archive profile library =======
574 @$(RM) -f $@
f4ccd99 Renamed all of the LObj* variables (which represent libtool objects) …
John Criswell authored
575 $(VERB) $(Link) -03 $(PROFILE) -o $@ $(ObjectsP) $(LibSubDirs) -static
41e7891 The ENABLE_PROFILING flag now builds the profiled libraries and execu…
Vikram S. Adve authored
576
f4ccd99 Renamed all of the LObj* variables (which represent libtool objects) …
John Criswell authored
577 $(LIBNAME_AG): $(ObjectsG) $(LibSubDirs) $(DESTLIBDEBUG)/.dir
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
578 @echo ======= Linking $(LIBRARYNAME) archive debug library =======
579 @$(RM) -f $@
f4ccd99 Renamed all of the LObj* variables (which represent libtool objects) …
John Criswell authored
580 $(VERB) $(Link) -g $(STRIP) -o $@ $(ObjectsG) $(LibSubDirs) -static
112a72c Changed default to building library archives instead of shared objects.
Vikram S. Adve authored
581
481cc7c Implement BYTECODE_LIBRARY support
Chris Lattner authored
582
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
583 #
584 # Rules for building .o libraries.
585 #
82f4a5a Modified the use of libtool so that we don't compile every file twice.
John Criswell authored
586 # JTC:
587 # Note that for this special case, we specify the actual object files
588 # instead of their libtool counterparts. This is because libtool
589 # doesn't want to generate a reloadable object file unless it is given
590 # .o files explicitly.
591 #
592 # Note that we're making an assumption here: If we build a .lo file,
593 # it's corresponding .o file will be placed in the same directory.
594 #
595 # I think that is safe.
596 #
f4ccd99 Renamed all of the LObj* variables (which represent libtool objects) …
John Criswell authored
597 $(LIBNAME_OBJO): $(ObjectsO) $(LibSubDirs) $(DESTLIBRELEASE)/.dir
b5f096f Compiling with "gmake" should produce less output. The compilation/li…
Misha Brukman authored
598 @echo "Linking $@"
82f4a5a Modified the use of libtool so that we don't compile every file twice.
John Criswell authored
599 $(VERB) $(Relink) -o $@ $(RObjectsO) $(LibSubDirs)
e62dbe9 Enable USEDLIBS to contain .a and .o files
Chris Lattner authored
600
f4ccd99 Renamed all of the LObj* variables (which represent libtool objects) …
John Criswell authored
601 $(LIBNAME_OBJP): $(ObjectsP) $(LibSubDirs) $(DESTLIBPROFILE)/.dir
41e7891 The ENABLE_PROFILING flag now builds the profiled libraries and execu…
Vikram S. Adve authored
602 @echo "Linking $@"
82f4a5a Modified the use of libtool so that we don't compile every file twice.
John Criswell authored
603 $(VERB) $(Relink) -o $@ $(RObjectsP) $(LibSubDirs)
41e7891 The ENABLE_PROFILING flag now builds the profiled libraries and execu…
Vikram S. Adve authored
604
f4ccd99 Renamed all of the LObj* variables (which represent libtool objects) …
John Criswell authored
605 $(LIBNAME_OBJG): $(ObjectsG) $(LibSubDirs) $(DESTLIBDEBUG)/.dir
9e39816 Make sure to print message when linking a debug .o file
Chris Lattner authored
606 @echo "Linking $@"
82f4a5a Modified the use of libtool so that we don't compile every file twice.
John Criswell authored
607 $(VERB) $(Relink) -o $@ $(RObjectsG) $(LibSubDirs)
e62dbe9 Enable USEDLIBS to contain .a and .o files
Chris Lattner authored
608
0095054 Initial revision
Chris Lattner authored
609 endif
610
1cbc29f Support TOOLNAME and USEDLIBS options for easier tool building
Chris Lattner authored
611 #------------------------------------------------------------------------
0193d5e Added a rule for building TAGS.
Vikram S. Adve authored
612 # Create a TAGS database for emacs
613 #------------------------------------------------------------------------
614
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
615 ifdef ETAGS
022d06c Fixed tags target so it only happens at root level.
Vikram S. Adve authored
616 ifeq ($(LEVEL), .)
0193d5e Added a rule for building TAGS.
Vikram S. Adve authored
617 tags:
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
618 $(ETAGS) -l c++ `find include lib tools -name '*.cpp' -o -name '*.h'`
022d06c Fixed tags target so it only happens at root level.
Vikram S. Adve authored
619 all:: tags
620 endif
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
621 else
622 tags:
623 ${ECHO} "Cannot build $@: The program etags is not installed"
624 endif
0193d5e Added a rule for building TAGS.
Vikram S. Adve authored
625
626 #------------------------------------------------------------------------
1cbc29f Support TOOLNAME and USEDLIBS options for easier tool building
Chris Lattner authored
627 # Handle the TOOLNAME option - used when building tool executables...
628 #------------------------------------------------------------------------
629 #
630 # The TOOLNAME option should be used with a USEDLIBS variable that tells the
e62dbe9 Enable USEDLIBS to contain .a and .o files
Chris Lattner authored
631 # libraries (and the order of the libs) that should be linked to the
632 # tool. USEDLIBS should contain a list of library names (some with .a extension)
633 # that are automatically linked in as .o files unless the .a suffix is added.
1cbc29f Support TOOLNAME and USEDLIBS options for easier tool building
Chris Lattner authored
634 #
635 ifdef TOOLNAME
636
637 # TOOLEXENAME* - These compute the output filenames to generate...
8bff509 Modified Makefile.common to handle compilation of projects inside and…
John Criswell authored
638 TOOLEXENAME_G := $(DESTTOOLDEBUG)/$(TOOLNAME)
639 TOOLEXENAME_O := $(DESTTOOLRELEASE)/$(TOOLNAME)
640 TOOLEXENAME_P := $(DESTTOOLPROFILE)/$(TOOLNAME)
641 TOOLEXENAMES := $(DESTTOOLCURRENT)/$(TOOLNAME)
1cbc29f Support TOOLNAME and USEDLIBS options for easier tool building
Chris Lattner authored
642
643 # USED_LIBS_OPTIONS - Compute the options line that add -llib1 -llib2, etc.
ffb55cd Added project options to the Makefile.common
Dinakar Dhurjati authored
644 PROJ_LIBS_OPTIONS := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
645 PROJ_LIBS_OPTIONS_G := $(patsubst %.o, $(PROJLIBDEBUGSOURCE)/%.o, $(PROJ_LIBS_OPTIONS))
646 PROJ_LIBS_OPTIONS_O := $(patsubst %.o, $(PROJLIBRELEASESOURCE)/%.o,$(PROJ_LIBS_OPTIONS))
647 PROJ_LIBS_OPTIONS_P := $(patsubst %.o, $(PROJLIBPROFILESOURCE)/%.o,$(PROJ_LIBS_OPTIONS))
648
649 LLVM_LIBS_OPTIONS := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
650 LLVM_LIBS_OPTIONS_G := $(patsubst %.o, $(LLVMLIBDEBUGSOURCE)/%.o, $(LLVM_LIBS_OPTIONS))
651 LLVM_LIBS_OPTIONS_O := $(patsubst %.o, $(LLVMLIBRELEASESOURCE)/%.o,$(LLVM_LIBS_OPTIONS))
652 LLVM_LIBS_OPTIONS_P := $(patsubst %.o, $(LLVMLIBPROFILESOURCE)/%.o,$(LLVM_LIBS_OPTIONS))
653
654 LIB_OPTS_G := $(LLVM_LIBS_OPTIONS_G) $(PROJ_LIBS_OPTIONS_G)
e3ba95e Fix problem building optmized build
Chris Lattner authored
655 LIB_OPTS_O := $(LLVM_LIBS_OPTIONS_O) $(PROJ_LIBS_OPTIONS_O)
ffb55cd Added project options to the Makefile.common
Dinakar Dhurjati authored
656 LIB_OPTS_P := $(LLVM_LIBS_OPTIONS_P) $(PROJ_LIBS_OPTIONS_P)
657
1cbc29f Support TOOLNAME and USEDLIBS options for easier tool building
Chris Lattner authored
658 # USED_LIB_PATHS - Compute the path of the libraries used so that tools are
e62dbe9 Enable USEDLIBS to contain .a and .o files
Chris Lattner authored
659 # rebuilt if libraries change. This has to make sure to handle .a/.so and .o
1ba3138 The word `separate' only has one `e'.
Misha Brukman authored
660 # files separately.
1cbc29f Support TOOLNAME and USEDLIBS options for easier tool building
Chris Lattner authored
661 #
e62dbe9 Enable USEDLIBS to contain .a and .o files
Chris Lattner authored
662 STATICUSEDLIBS := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
ffb55cd Added project options to the Makefile.common
Dinakar Dhurjati authored
663 USED_LIB_PATHS_G := $(addprefix $(DESTLIBDEBUG)/, $(STATICUSEDLIBS))
664 USED_LIB_PATHS_O := $(addprefix $(DESTLIBRELEASE)/, $(STATICUSEDLIBS))
665 USED_LIB_PATHS_P := $(addprefix $(DESTLIBPROFILE)/, $(STATICUSEDLIBS))
1cbc29f Support TOOLNAME and USEDLIBS options for easier tool building
Chris Lattner authored
666
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
667 #
668 # Libtool link options:
669 # Ensure that all binaries have their symbols exported so that they can
670 # by dlsym'ed.
671 #
672 LINK_OPTS := -export-dynamic $(TOOLLINKOPTS)
8d7dfb3 Fix lli build problem with parallel makes
Chris Lattner authored
673
ffb55cd Added project options to the Makefile.common
Dinakar Dhurjati authored
674
675
676
677
8d7dfb3 Fix lli build problem with parallel makes
Chris Lattner authored
678 # Tell make that we need to rebuild subdirectories before we can link the tool.
679 # This affects things like LLI which has library subdirectories.
680 $(USED_LIB_PATHS_G) $(USED_LIB_PATHS_O) $(USED_LIB_PATHS_P): \
681 $(addsuffix /.makeall, $(PARALLEL_DIRS))
682
669bd7c Each tools should not make tags
Chris Lattner authored
683 all:: $(TOOLEXENAMES)
2a6530f Added the OPTIONAL_DIRS variable for specifying optional directories …
John Criswell authored
684
1cbc29f Support TOOLNAME and USEDLIBS options for easier tool building
Chris Lattner authored
685 clean::
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
686 $(VERB) $(RM) -f $(TOOLEXENAMES)
1cbc29f Support TOOLNAME and USEDLIBS options for easier tool building
Chris Lattner authored
687
f4ccd99 Renamed all of the LObj* variables (which represent libtool objects) …
John Criswell authored
688 $(TOOLEXENAME_G): $(ObjectsG) $(USED_LIB_PATHS_G) $(DESTTOOLDEBUG)/.dir
9b51b6f Move the space separator to where it really belongs: in the print sta…
Misha Brukman authored
689 @echo ======= Linking $(TOOLNAME) debug executable $(STRIP_WARN_MSG) =======
f4ccd99 Renamed all of the LObj* variables (which represent libtool objects) …
John Criswell authored
690 $(VERB) $(LinkG) -o $@ $(ObjectsG) $(LIB_OPTS_G) $(LINK_OPTS) $(LIBS)
1cbc29f Support TOOLNAME and USEDLIBS options for easier tool building
Chris Lattner authored
691
f4ccd99 Renamed all of the LObj* variables (which represent libtool objects) …
John Criswell authored
692 $(TOOLEXENAME_O): $(ObjectsO) $(USED_LIB_PATHS_O) $(DESTTOOLRELEASE)/.dir
287d443 Make sure to print a message when linking a tool
Chris Lattner authored
693 @echo ======= Linking $(TOOLNAME) release executable =======
f4ccd99 Renamed all of the LObj* variables (which represent libtool objects) …
John Criswell authored
694 $(VERB) $(LinkO) -o $@ $(ObjectsO) $(LIB_OPTS_O) $(LINK_OPTS) $(LIBS)
1cbc29f Support TOOLNAME and USEDLIBS options for easier tool building
Chris Lattner authored
695
f4ccd99 Renamed all of the LObj* variables (which represent libtool objects) …
John Criswell authored
696 $(TOOLEXENAME_P): $(ObjectsP) $(USED_LIB_PATHS_P) $(DESTTOOLPROFILE)/.dir
41e7891 The ENABLE_PROFILING flag now builds the profiled libraries and execu…
Vikram S. Adve authored
697 @echo ======= Linking $(TOOLNAME) profile executable =======
f4ccd99 Renamed all of the LObj* variables (which represent libtool objects) …
John Criswell authored
698 $(VERB) $(LinkP) -o $@ $(ObjectsP) $(LIB_OPTS_P) $(LINK_OPTS) $(LIBS)
41e7891 The ENABLE_PROFILING flag now builds the profiled libraries and execu…
Vikram S. Adve authored
699
1cbc29f Support TOOLNAME and USEDLIBS options for easier tool building
Chris Lattner authored
700 endif
701
702
0095054 Initial revision
Chris Lattner authored
703
704 #---------------------------------------------------------
481cc7c Implement BYTECODE_LIBRARY support
Chris Lattner authored
705 .PRECIOUS: $(BUILD_OBJ_DIR)/Depend/.dir $(BUILD_OBJ_DIR)/Bytecode/.dir
8bff509 Modified Makefile.common to handle compilation of projects inside and…
John Criswell authored
706 .PRECIOUS: $(BUILD_OBJ_DIR)/Debug/.dir $(BUILD_OBJ_DIR)/Release/.dir
0095054 Initial revision
Chris Lattner authored
707
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
708 # Create .lo files in the ObjectFiles directory from the .cpp and .c files...
709 $(BUILD_OBJ_DIR)/Release/%.lo: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Release/.dir
b5f096f Compiling with "gmake" should produce less output. The compilation/li…
Misha Brukman authored
710 @echo "Compiling $<"
711 $(VERB) $(CompileO) $< -o $@
0095054 Initial revision
Chris Lattner authored
712
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
713 $(BUILD_OBJ_DIR)/Release/%.lo: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Release/.dir
714 @echo "Compiling $<"
1eeac66 Fix misspelled variable
Chris Lattner authored
715 $(VERB) $(CompileCO) $< -o $@
112a72c Changed default to building library archives instead of shared objects.
Vikram S. Adve authored
716
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
717 $(BUILD_OBJ_DIR)/Profile/%.lo: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Profile/.dir
41e7891 The ENABLE_PROFILING flag now builds the profiled libraries and execu…
Vikram S. Adve authored
718 @echo "Compiling $<"
719 $(VERB) $(CompileP) $< -o $@
720
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
721 $(BUILD_OBJ_DIR)/Profile/%.lo: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Profile/.dir
172b648 * Minor fixes to support C files.
Chris Lattner authored
722 @echo "Compiling $<"
723 $(VERB) $(CompileCP) $< -o $@
724
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
725 $(BUILD_OBJ_DIR)/Debug/%.lo: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Debug/.dir
b5f096f Compiling with "gmake" should produce less output. The compilation/li…
Misha Brukman authored
726 @echo "Compiling $<"
727 $(VERB) $(CompileG) $< -o $@
0095054 Initial revision
Chris Lattner authored
728
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
729 $(BUILD_OBJ_DIR)/Debug/%.lo: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Debug/.dir
730 @echo "Compiling $<"
731 $(VERB) $(CompileCG) $< -o $@
732
481cc7c Implement BYTECODE_LIBRARY support
Chris Lattner authored
733 $(BUILD_OBJ_DIR)/Bytecode/%.bc: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Bytecode/.dir $(LCC1XX)
734 @echo "Compiling $< to bytecode"
735 $(VERB) $(LLVMGXX) $(CPPFLAGS) -c $< -o $@
736
737 $(BUILD_OBJ_DIR)/Bytecode/%.bc: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Bytecode/.dir $(LCC1)
738 @echo "Compiling $< to bytecode"
739 $(VERB) $(LLVMGCC) $(CPPFLAGS) -c $< -o $@
740
741 $(BUILD_OBJ_DIR)/Bytecode/%.bc: $(SourceDir)%.ll $(BUILD_OBJ_DIR)/Bytecode/.dir $(LCC1)
742 @echo "Compiling $< to bytecode"
743 $(VERB) $(LLVMAS) $< -f -o $@
744
745
e899678 Simplify and correct rules for building lex/yacc files. Make sure to…
Chris Lattner authored
746 #
747 # Rules for building lex/yacc files
748 #
749 LEX_FILES = $(filter %.l, $(Source))
750 LEX_OUTPUT = $(LEX_FILES:%.l=%.cpp)
751 YACC_FILES = $(filter %.y, $(Source))
752 YACC_OUTPUT = $(addprefix $(YACC_FILES:%.y=%), .h .cpp .output)
753 .PRECIOUS: $(LEX_OUTPUT) $(YACC_OUTPUT)
754
0095054 Initial revision
Chris Lattner authored
755 # Create a .cpp source file from a flex input file... this uses sed to cut down
756 # on the warnings emited by GCC...
6d131b4 Fix problem with flex scanners and huge token sizes
Chris Lattner authored
757 #
758 # The last line is a gross hack to work around flex aparently not being able to
759 # resize the buffer on a large token input. Currently, for uninitialized string
760 # buffers in LLVM we can generate very long tokens, so this is a hack around it.
b7dc2b9 Remove extraneous ;'s, no functional changes
Chris Lattner authored
761 # FIXME. (f.e. char Buffer[10000] )
6d131b4 Fix problem with flex scanners and huge token sizes
Chris Lattner authored
762 #
0095054 Initial revision
Chris Lattner authored
763 %.cpp: %.l
a328f88 * Don't print out HOW we are running Flex unless in verbose mode. We…
Chris Lattner authored
764 @echo Flex\'ing $<...
7bb107d While I'm looking at it, line up the SED lines
Chris Lattner authored
765 $(VERB) $(FLEX) -t $< | \
766 $(SED) '/^find_rule/d' | \
767 $(SED) 's/void yyunput/inline void yyunput/' | \
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
768 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
a328f88 * Don't print out HOW we are running Flex unless in verbose mode. We…
Chris Lattner authored
769 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
770 > $@.tmp
d741bcf Merged in changes between PRE11_ROOT and LLVM_PRE111 (i.e. the beginn…
John Criswell authored
771 $(VERB) cmp -s $@ $@.tmp > /dev/null || ${MV} -f $@.tmp $@
a328f88 * Don't print out HOW we are running Flex unless in verbose mode. We…
Chris Lattner authored
772 @# remove the output of flex if it didn't get moved over...
773 @rm -f $@.tmp
0095054 Initial revision
Chris Lattner authored
774
775 # Rule for building the bison parsers...
694c5df Add facilities for building source that is outside of the current dir…
Chris Lattner authored
776 %.c: %.y # Cancel built-in rules for yacc
777 %.h: %.y # Cancel built-in rules for yacc
0095054 Initial revision
Chris Lattner authored
778 %.cpp %.h : %.y
694c5df Add facilities for building source that is outside of the current dir…
Chris Lattner authored
779 @echo Bison\'ing $<...
e899678 Simplify and correct rules for building lex/yacc files. Make sure to…
Chris Lattner authored
780 $(VERB) $(BISON) -v -d -p $(<:%Parser.y=%) $*.y
d741bcf Merged in changes between PRE11_ROOT and LLVM_PRE111 (i.e. the beginn…
John Criswell authored
781 $(VERB) cmp -s $*.tab.c $*.cpp > /dev/null || ${MV} -f $*.tab.c $*.cpp
782 $(VERB) cmp -s $*.tab.h $*.h > /dev/null || ${MV} -f $*.tab.h $*.h
a328f88 * Don't print out HOW we are running Flex unless in verbose mode. We…
Chris Lattner authored
783 @# If the files were not updated, don't leave them lying around...
784 @rm -f $*.tab.c $*.tab.h
0095054 Initial revision
Chris Lattner authored
785
786 # To create the directories...
787 %/.dir:
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
788 $(VERB) ${MKDIR} $* > /dev/null
789 @$(DATE) > $@
0095054 Initial revision
Chris Lattner authored
790
30440c6 Add helper
Chris Lattner authored
791 # To create postscript files from dot files...
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
792 ifdef DOT
793 %.ps: %.dot
794 ${DOT} -Tps < $< > $@
795 else
30440c6 Add helper
Chris Lattner authored
796 %.ps: %.dot
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
797 ${ECHO} "Cannot build $@: The program dot is not installed"
798 endif
30440c6 Add helper
Chris Lattner authored
799
172b648 * Minor fixes to support C files.
Chris Lattner authored
800 # 'make clean' nukes the tree
0095054 Initial revision
Chris Lattner authored
801 clean::
481cc7c Implement BYTECODE_LIBRARY support
Chris Lattner authored
802 $(VERB) $(RM) -rf $(BUILD_OBJ_DIR)/Debug $(BUILD_OBJ_DIR)/Release
803 $(VERB) $(RM) -rf $(BUILD_OBJ_DIR)/Profile $(BUILD_OBJ_DIR)/Depend
804 $(VERB) $(RM) -rf $(BUILD_OBJ_DIR)/Bytecode
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
805 $(VERB) $(RM) -f core core.[0-9][0-9]* *.o *.d *.so *~ *.flc
806 $(VERB) $(RM) -f $(LEX_OUTPUT) $(YACC_OUTPUT)
807
808 ###########################################################################
809 # C/C++ Dependencies
810 # Define variables and rules that generate header file dependencies
811 # from C/C++ source files.
812 ###########################################################################
0095054 Initial revision
Chris Lattner authored
813
694c5df Add facilities for building source that is outside of the current dir…
Chris Lattner authored
814 # If dependencies were generated for the file that included this file,
0095054 Initial revision
Chris Lattner authored
815 # include the dependancies now...
816 #
694c5df Add facilities for building source that is outside of the current dir…
Chris Lattner authored
817 SourceBaseNames := $(basename $(notdir $(filter-out Debug/%, $(Source))))
8bff509 Modified Makefile.common to handle compilation of projects inside and…
John Criswell authored
818 SourceDepend := $(SourceBaseNames:%=$(BUILD_OBJ_DIR)/Depend/%.d)
694c5df Add facilities for building source that is outside of the current dir…
Chris Lattner authored
819
820 # Create dependencies for the *.cpp files...
821 #$(SourceDepend): \x
8bff509 Modified Makefile.common to handle compilation of projects inside and…
John Criswell authored
822 $(BUILD_OBJ_DIR)/Depend/%.d: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Depend/.dir
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
823 $(VERB) $(Depend) $< | $(SED) 's|\.o|\.lo|' | $(SED) 's|$*\.lo *|$(BUILD_OBJ_DIR)/Release/& $(BUILD_OBJ_DIR)/Profile/& $(BUILD_OBJ_DIR)/Debug/& $(BUILD_OBJ_DIR)/Depend/$(@F)|g' > $@
694c5df Add facilities for building source that is outside of the current dir…
Chris Lattner authored
824
825 # Create dependencies for the *.c files...
826 #$(SourceDepend): \x
8bff509 Modified Makefile.common to handle compilation of projects inside and…
John Criswell authored
827 $(BUILD_OBJ_DIR)/Depend/%.d: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Depend/.dir
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
828 $(VERB) $(DependC) -o $@ $< | $(SED) 's|\.o|\.lo|' | $(SED) 's|$*\.lo *|$(BUILD_OBJ_DIR)/Release/& $(BUILD_OBJ_DIR)/Profile/& $(BUILD_OBJ_DIR)/Debug/& $(BUILD_OBJ_DIR)/Depend/$(@F)|g' > $@
694c5df Add facilities for building source that is outside of the current dir…
Chris Lattner authored
829
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
830 #
831 # Include dependencies generated from C/C++ source files, but not if we
832 # are cleaning (this example taken from the GNU Make Manual).
833 #
834 ifneq ($(MAKECMDGOALS),clean)
d741bcf Merged in changes between PRE11_ROOT and LLVM_PRE111 (i.e. the beginn…
John Criswell authored
835 ifneq ($(MAKECMDGOALS),distclean)
1ddb6b6 Add new cleandeps target, to allow easy cleaning out of .d files
Chris Lattner authored
836 ifneq ($(MAKECMDGOALS),cleandeps)
0095054 Initial revision
Chris Lattner authored
837 ifneq ($(SourceDepend),)
ed03bc9 Patch submited by Casey to remove obnoxious warnings.
Chris Lattner authored
838 -include $(SourceDepend)
0095054 Initial revision
Chris Lattner authored
839 endif
7a73b80 Merged in autoconf branch. This provides configuration via the autoconf
John Criswell authored
840 endif
d741bcf Merged in changes between PRE11_ROOT and LLVM_PRE111 (i.e. the beginn…
John Criswell authored
841 endif
1ddb6b6 Add new cleandeps target, to allow easy cleaning out of .d files
Chris Lattner authored
842 endif
843
844 cleandeps::
845 $(VERB) rm -f $(SourceDepend)
846
Something went wrong with that request. Please try again.