blob: 88cdd97c00ad647ff2ab321d11251ad382590497 [file] [log] [blame]
Vikram S. Adved60aede2002-07-09 12:04:21 +00001#===-- Makefile.common - Common make rules for LLVM -------*- makefile -*--====
Chris Lattner00950542001-06-06 20:29:01 +00002#
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#
Vikram S. Advec214e712002-08-29 23:28:46 +00008# The following functionality can be set by setting incoming variables.
9# The variable $(LEVEL) *must* be set:
Chris Lattner00950542001-06-06 20:29:01 +000010#
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
Chris Lattnera8abc222002-09-18 03:22:27 +000016# 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.
Chris Lattner00950542001-06-06 20:29:01 +000019#
Chris Lattnera8abc222002-09-18 03:22:27 +000020# 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
Chris Lattner00950542001-06-06 20:29:01 +000025# is not set, it defaults to be all of the .cpp, .c, .y, and .l files
Chris Lattnere0010592001-10-18 01:48:09 +000026# in the current directory. Also, if you want to build files in addition
27# to the local files, you can use the ExtraSource variable
Chris Lattner00950542001-06-06 20:29:01 +000028#
Chris Lattner694c5df2003-05-15 21:28:55 +000029# 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#
Dinakar Dhurjati584dd182003-05-29 21:49:00 +000033# 6. PROJ_COMPILE - If set to 1, then this makefile can also be used to
34# compile other projects using llvm. Note if this option is set then the
35# following *must* hold
36# PROJLEVEL should be set to the top of the source directory for the
37# project files
38# LEVEL should be set to the top of LLVM source tree
39# LLVM_LIB_DIR should be set to the top of the LLVM build tree
40#
Vikram S. Adved60aede2002-07-09 12:04:21 +000041#===-----------------------------------------------------------------------====
Chris Lattner00950542001-06-06 20:29:01 +000042
John Criswell2a6530f2003-06-27 16:58:44 +000043#
Vikram S. Advec214e712002-08-29 23:28:46 +000044# Configuration file to set paths specific to local installation of LLVM
45#
46include $(LEVEL)/Makefile.config
47
John Criswell8bff5092003-06-11 13:55:44 +000048###########################################################################
49# Directory Configuration
50# This section of the Makefile determines what is where. To be
51# specific, there are several locations that need to be defined:
52#
53# o LLVM_SRC_ROOT : The root directory of the LLVM source code.
54# o LLVM_OBJ_ROOT : The root directory containing the built LLVM code.
55#
56# o BUILD_SRC_DIR : The directory containing the code to build.
57# o BUILD_SRC_ROOT : The root directory of the code to build.
58#
59# o BUILD_OBJ_DIR : The directory in which compiled code will be placed.
60# o BUILD_OBJ_ROOT : The root directory in which compiled code is placed.
61#
62###########################################################################
63
64#
65# Set the source build directory. That is almost always the current directory.
66#
67ifndef BUILD_SRC_DIR
68BUILD_SRC_DIR = $(shell pwd)
69endif
70
71#
72# Set the source root directory.
73#
74ifndef BUILD_SRC_ROOT
John Criswell890d5bd2003-06-16 19:14:31 +000075BUILD_SRC_ROOT = $(shell cd $(BUILD_SRC_DIR)/$(LEVEL); pwd)
John Criswell8bff5092003-06-11 13:55:44 +000076endif
77
78#
79# Set the object build directory. Its location depends upon the source path
80# and where object files should go.
81#
82ifndef BUILD_OBJ_DIR
83ifeq ($(OBJ_ROOT),.)
84BUILD_OBJ_DIR = $(shell pwd)
85else
John Criswell6f4ad0b2003-06-20 21:24:54 +000086BUILD_OBJ_DIR := $(OBJ_ROOT)$(patsubst $(shell dirname $(BUILD_SRC_ROOT))%,%,$(shell cd $(BUILD_SRC_DIR); pwd))
John Criswell8bff5092003-06-11 13:55:44 +000087endif
88endif
89
90#
91# Set the root of the object directory.
92#
93ifndef BUILD_OBJ_ROOT
94ifeq ($(OBJ_ROOT),.)
95BUILD_OBJ_ROOT = $(shell cd $(LEVEL); pwd)
96else
John Criswell6f4ad0b2003-06-20 21:24:54 +000097BUILD_OBJ_ROOT := $(OBJ_ROOT)$(patsubst $(shell dirname $(BUILD_SRC_ROOT))%,%,$(shell cd $(BUILD_SRC_ROOT); pwd))
John Criswell8bff5092003-06-11 13:55:44 +000098endif
99endif
100
101#
102# Set the LLVM source directory.
103# It is typically the root directory of what we're compiling now.
104#
105ifndef LLVM_SRC_ROOT
106LLVM_SRC_ROOT = $(BUILD_SRC_ROOT)
107endif
108
109#
110# Set the LLVM object directory.
111#
112ifndef LLVM_OBJ_ROOT
113LLVM_OBJ_ROOT = $(BUILD_OBJ_ROOT)
114endif
115
Chris Lattner4bb13b82002-09-13 22:14:47 +0000116# Figure out how to do platform specific stuff on this platform. This is really
117# gross and should be autoconfiscated (automake actually), but should hopefully
118# work on Linux and solaris (SunOS).
119#
120UNAME := $(shell uname)
John Criswell8bff5092003-06-11 13:55:44 +0000121include $(LLVM_SRC_ROOT)/Makefile.$(UNAME)
Chris Lattner4bb13b82002-09-13 22:14:47 +0000122
Chris Lattneredf1f232002-07-23 19:21:31 +0000123ifdef SHARED_LIBRARY
124# if SHARED_LIBRARY is specified, the default is to build the dynamic lib
125dynamic ::
126endif
127
Chris Lattnerb19e59c2001-06-29 05:20:16 +0000128# Default Rule: Make sure it's also a :: rule
Chris Lattner00950542001-06-06 20:29:01 +0000129all ::
130
131# Default for install is to at least build everything...
132install ::
133
John Criswell8bff5092003-06-11 13:55:44 +0000134# Default rule for test. It ensures everything has a test rule
135test::
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000136
Chris Lattner00950542001-06-06 20:29:01 +0000137#--------------------------------------------------------------------
Vikram S. Advec214e712002-08-29 23:28:46 +0000138# Variables derived from configuration options...
Chris Lattner00950542001-06-06 20:29:01 +0000139#--------------------------------------------------------------------
140
141#BinInstDir=/usr/local/bin
John Criswell65aa59342003-05-29 18:52:10 +0000142#LibInstDir=/usr/local/lib/xxx
Chris Lattner00950542001-06-06 20:29:01 +0000143#DocInstDir=/usr/doc/xxx
144
Vikram S. Advedba59ef2001-08-06 19:01:20 +0000145BURG_OPTS = -I
146
John Criswell8bff5092003-06-11 13:55:44 +0000147PURIFY := $(PURIFY) -cache-dir="$(BUILD_OBJ_ROOT)/../purifycache" -chain-length="30" -messages=all
Chris Lattner6e390702001-10-30 20:24:08 +0000148
Chris Lattner760da062003-03-14 20:25:22 +0000149ifdef ENABLE_PROFILING
150 ENABLE_OPTIMIZED = 1
151 CONFIGURATION := Profile
152else
153 ifdef ENABLE_OPTIMIZED
154 CONFIGURATION := Release
155 else
156 CONFIGURATION := Debug
157 endif
158endif
159
John Criswell8bff5092003-06-11 13:55:44 +0000160###########################################################################
161# Library Locations
162# These variables describe various library locations:
163#
164# DEST* = Location of where libraries that are built will be placed.
165# LLVM* = Location of LLVM libraries used for linking.
166# PROJ* = Location of previously built libraries used for linking.
167###########################################################################
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000168
John Criswell8bff5092003-06-11 13:55:44 +0000169# Libraries that are being built
170DESTLIBDEBUG := $(BUILD_OBJ_ROOT)/lib/Debug
171DESTLIBRELEASE := $(BUILD_OBJ_ROOT)/lib/Release
172DESTLIBPROFILE := $(BUILD_OBJ_ROOT)/lib/Profile
173DESTLIBCURRENT := $(BUILD_OBJ_ROOT)/lib/$(CONFIGURATION)
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000174
John Criswell8bff5092003-06-11 13:55:44 +0000175# LLVM libraries used for linking
176LLVMLIBDEBUGSOURCE := $(LLVM_OBJ_ROOT)/lib/Debug
177LLVMLIBRELEASESOURCE := $(LLVM_OBJ_ROOT)/lib/Release
178LLVMLIBPROFILESOURCE := $(LLVM_OBJ_ROOT)/lib/Profile
179LLVMLIBCURRENTSOURCE := $(LLVM_OBJ_ROOT)/lib/$(CONFIGURATION)
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000180
John Criswell8bff5092003-06-11 13:55:44 +0000181# Libraries that were built that will now be used for linking
182PROJLIBDEBUGSOURCE := $(BUILD_OBJ_ROOT)/lib/Debug
183PROJLIBRELEASESOURCE := $(BUILD_OBJ_ROOT)/lib/Release
184PROJLIBPROFILESOURCE := $(BUILD_OBJ_ROOT)/lib/Profile
185PROJLIBCURRENTSOURCE := $(BUILD_OBJ_ROOT)/lib/$(CONFIGURATION)
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000186
John Criswell8bff5092003-06-11 13:55:44 +0000187###########################################################################
188# Tool Locations
189# These variables describe various tool locations:
190#
191# DEST* = Location of where tools that are built will be placed.
192# LLVM* = Location of LLVM tools used for building.
193# PROJ* = Location of previously built tools used for linking.
194###########################################################################
Chris Lattner760da062003-03-14 20:25:22 +0000195
John Criswell8bff5092003-06-11 13:55:44 +0000196DESTTOOLDEBUG := $(BUILD_OBJ_ROOT)/tools/Debug
197DESTTOOLRELEASE := $(BUILD_OBJ_ROOT)/tools/Release
198DESTTOOLPROFILE := $(BUILD_OBJ_ROOT)/tools/Profile
199DESTTOOLCURRENT := $(BUILD_OBJ_ROOT)/tools/$(CONFIGURATION)
200
201LLVMTOOLDEBUG := $(LLVM_OBJ_ROOT)/tools/Debug
202LLVMTOOLRELEASE := $(LLVM_OBJ_ROOT)/tools/Release
203LLVMTOOLPROFILE := $(LLVM_OBJ_ROOT)/tools/Profile
204LLVMTOOLCURRENT := $(LLVM_OBJ_ROOT)/tools/$(CONFIGURATION)
205
206PROJTOOLDEBUG := $(BUILD_OBJ_ROOT)/tools/Debug
207PROJTOOLRELEASE := $(BUILD_OBJ_ROOT)/tools/Release
208PROJTOOLPROFILE := $(BUILD_OBJ_ROOT)/tools/Profile
209PROJTOOLCURRENT := $(BUILD_OBJ_ROOT)/tools/$(CONFIGURATION)
Chris Lattnere62dbe92002-07-23 17:56:16 +0000210
Misha Brukmanb5f096f2002-09-12 16:05:39 +0000211# Verbosity levels
Chris Lattner760da062003-03-14 20:25:22 +0000212ifndef VERBOSE
Misha Brukmanb5f096f2002-09-12 16:05:39 +0000213VERB := @
214endif
215
Chris Lattner00950542001-06-06 20:29:01 +0000216#---------------------------------------------------------
217# Compilation options...
218#---------------------------------------------------------
219
John Criswell8bff5092003-06-11 13:55:44 +0000220###########################################################################
Chris Lattner9b947012002-09-19 19:42:24 +0000221# Special tools used while building the LLVM tree. Burg is built as part of the
222# utils directory.
John Criswell8bff5092003-06-11 13:55:44 +0000223###########################################################################
224BURG := $(LLVMTOOLCURRENT)/burg
Chris Lattner9b947012002-09-19 19:42:24 +0000225RunBurg := $(BURG) $(BURG_OPTS)
226
John Criswell8bff5092003-06-11 13:55:44 +0000227TBLGEN := $(LLVMTOOLCURRENT)/tblgen
Vikram S. Advedba59ef2001-08-06 19:01:20 +0000228
Chris Lattner00950542001-06-06 20:29:01 +0000229# Enable this for profiling support with 'gprof'
Vikram S. Adve41e78912002-09-20 14:03:13 +0000230# This automatically enables optimized builds.
Chris Lattner18f47012002-05-10 18:51:54 +0000231ifdef ENABLE_PROFILING
Vikram S. Adve41e78912002-09-20 14:03:13 +0000232 PROFILE = -pg
Chris Lattner18f47012002-05-10 18:51:54 +0000233endif
Chris Lattner00950542001-06-06 20:29:01 +0000234
John Criswell8bff5092003-06-11 13:55:44 +0000235###########################################################################
236# Compile Time Flags
237###########################################################################
238
239#
240# Include both the project headers and the LLVM headers for compilation
241#
242CPPFLAGS += -I$(BUILD_SRC_ROOT)/include -I$(LLVM_SRC_ROOT)/include
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000243
Vikram S. Advefeeae582002-09-18 11:55:13 +0000244# By default, strip symbol information from executable
Chris Lattner760da062003-03-14 20:25:22 +0000245ifndef KEEP_SYMBOLS
Chris Lattner527002c2003-01-31 19:00:26 +0000246STRIP = $(PLATFORMSTRIPOPTS)
247STRIP_WARN_MSG = "(without symbols) "
Vikram S. Advefeeae582002-09-18 11:55:13 +0000248endif
249
Chris Lattner73e1d0f2002-09-13 16:02:26 +0000250# Allow gnu extensions...
251CPPFLAGS += -D_GNU_SOURCE
252
Chris Lattnerc7acf812002-01-23 05:46:01 +0000253# -Wno-unused-parameter
John Criswell8bff5092003-06-11 13:55:44 +0000254CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused -I$(LEVEL)/include
Chris Lattner1d1e5b52003-02-13 16:56:30 +0000255CompileOptimizeOpts := -O3 -DNDEBUG -finline-functions -fshort-enums
Chris Lattner00950542001-06-06 20:29:01 +0000256
Chris Lattner172b6482002-09-22 02:47:15 +0000257# Compile a cpp file, don't link...
Chris Lattner285af382002-08-12 21:19:28 +0000258Compile := $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(CompileCommonOpts)
259CompileG := $(Compile) -g -D_DEBUG
Chris Lattner1d1e5b52003-02-13 16:56:30 +0000260CompileO := $(Compile) $(CompileOptimizeOpts) -felide-constructors -fomit-frame-pointer
261CompileP := $(Compile) $(CompileOptimizeOpts) -felide-constructors $(PROFILE)
Chris Lattner00950542001-06-06 20:29:01 +0000262
Chris Lattner172b6482002-09-22 02:47:15 +0000263# Compile a c file, don't link...
264CompileC := $(CC) -c $(CPPFLAGS) $(CCFLAGS) $(CompileCommonOpts)
265CompileCG := $(CompileC) -g -D_DEBUG
Chris Lattnerfe95dae2003-02-19 22:12:20 +0000266CompileCO := $(CompileC) $(CompileOptimizeOpts) -fomit-frame-pointer
267CompileCP := $(CompileC) $(CompileOptimizeOpts) $(PROFILE)
Chris Lattner172b6482002-09-22 02:47:15 +0000268
269
Chris Lattner00950542001-06-06 20:29:01 +0000270# Link final executable
Chris Lattner6e390702001-10-30 20:24:08 +0000271
Chris Lattner1917e952002-07-31 21:32:05 +0000272ifdef ENABLE_PURIFY # To enable purify, build with 'gmake ENABLE_PURIFY=1'
Vikram S. Adve41e78912002-09-20 14:03:13 +0000273Link := $(PURIFY) $(CXX) -static
Chris Lattner12604ed2002-04-05 18:56:58 +0000274else
Vikram S. Adve41e78912002-09-20 14:03:13 +0000275Link := $(CXX)
Chris Lattner12604ed2002-04-05 18:56:58 +0000276endif
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000277
278ifdef PROJ_COMPILE
Dinakar Dhurjati584dd182003-05-29 21:49:00 +0000279# include both projlib source and llvmlib source
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000280LinkG := $(Link) -g -L$(PROJLIBDEBUGSOURCE) -L$(LLVMLIBDEBUGSOURCE) $(STRIP)
281LinkO := $(Link) -O3 -L$(PROJLIBRELEASESOURCE) -L$(LLVMLIBRELEASESOURCE)
282LinkP := $(Link) -O3 -L$(PROJLIBPROFILESOURCE) -L$(LLVMLIBPROFILESOURCE) $(PROFILE)
283else
284LinkG := $(Link) -g -L$(LLVMLIBDEBUGSOURCE) $(STRIP)
285LinkO := $(Link) -O3 -L$(LLVMLIBRELEASESOURCE)
286LinkP := $(Link) -O3 -L$(LLVMLIBPROFILESOURCE) $(PROFILE)
287endif
288
289
Chris Lattner00950542001-06-06 20:29:01 +0000290
Chris Lattnere62dbe92002-07-23 17:56:16 +0000291# Create one .o file from a bunch of .o files...
John Criswell794fcd22003-05-30 15:50:31 +0000292Relink = ${LD} -r
Chris Lattnere62dbe92002-07-23 17:56:16 +0000293
Chris Lattner4bb13b82002-09-13 22:14:47 +0000294# MakeSO - Create a .so file from a .o files...
Vikram S. Adve41e78912002-09-20 14:03:13 +0000295MakeSO := $(CXX) $(MakeSharedObjectOption)
Chris Lattner4bb13b82002-09-13 22:14:47 +0000296MakeSOO := $(MakeSO) -O3
Vikram S. Adve41e78912002-09-20 14:03:13 +0000297MakeSOP := $(MakeSOO) $(PROFILE)
Chris Lattner4bb13b82002-09-13 22:14:47 +0000298
Chris Lattner00950542001-06-06 20:29:01 +0000299# Create dependancy file from CPP file, send to stdout.
John Criswell8bff5092003-06-11 13:55:44 +0000300Depend := $(CXX) -MM -I$(LEVEL)/include $(CPPFLAGS)
301DependC := $(CC) -MM -I$(LEVEL)/include $(CPPFLAGS)
Chris Lattner00950542001-06-06 20:29:01 +0000302
303# Archive a bunch of .o files into a .a file...
John Criswell794fcd22003-05-30 15:50:31 +0000304AR = ${AR_PATH} cq
Chris Lattner00950542001-06-06 20:29:01 +0000305
306#----------------------------------------------------------
307
308# Source includes all of the cpp files, and objects are derived from the
309# source files...
Chris Lattnere0010592001-10-18 01:48:09 +0000310# The local Makefile can list other Source files via ExtraSource = ...
Vikram S. Advec4bed342001-10-17 12:33:55 +0000311#
Vikram S. Advead9ea7e2002-10-14 16:40:04 +0000312ifndef Source
Chris Lattnere0010592001-10-18 01:48:09 +0000313Source := $(ExtraSource) $(wildcard *.cpp *.c *.y *.l)
Vikram S. Advead9ea7e2002-10-14 16:40:04 +0000314endif
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000315
Chris Lattner694c5df2003-05-15 21:28:55 +0000316Objs := $(sort $(patsubst Debug/%.o, %.o, $(addsuffix .o,$(notdir $(basename $(Source))))))
John Criswell8bff5092003-06-11 13:55:44 +0000317ObjectsO := $(addprefix $(BUILD_OBJ_DIR)/Release/,$(Objs))
318ObjectsP := $(addprefix $(BUILD_OBJ_DIR)/Profile/,$(Objs))
319ObjectsG := $(addprefix $(BUILD_OBJ_DIR)/Debug/,$(Objs))
Chris Lattner00950542001-06-06 20:29:01 +0000320
Chris Lattnere62dbe92002-07-23 17:56:16 +0000321
Chris Lattner00950542001-06-06 20:29:01 +0000322#---------------------------------------------------------
Chris Lattnera8abc222002-09-18 03:22:27 +0000323# Handle the DIRS and PARALLEL_DIRS options
Chris Lattner00950542001-06-06 20:29:01 +0000324#---------------------------------------------------------
325
Anand Shukla7c7a07e2002-09-18 04:29:30 +0000326ifdef DIRS
Chris Lattnerdc95ade2003-01-16 20:02:30 +0000327all install clean test ::
Chris Lattner16d1f732002-09-17 23:45:34 +0000328 $(VERB) for dir in ${DIRS}; do \
Chris Lattnerf1ffd992002-09-17 23:35:02 +0000329 (cd $$dir; $(MAKE) $@) || exit 1; \
330 done
Anand Shukla7c7a07e2002-09-18 04:29:30 +0000331endif
Chris Lattnera8abc222002-09-18 03:22:27 +0000332
333# Handle PARALLEL_DIRS
334ifdef PARALLEL_DIRS
335all :: $(addsuffix /.makeall , $(PARALLEL_DIRS))
336install :: $(addsuffix /.makeinstall, $(PARALLEL_DIRS))
337clean :: $(addsuffix /.makeclean , $(PARALLEL_DIRS))
Chris Lattnerdc95ade2003-01-16 20:02:30 +0000338test :: $(addsuffix /.maketest , $(PARALLEL_DIRS))
Chris Lattnera8abc222002-09-18 03:22:27 +0000339
Chris Lattnerdc95ade2003-01-16 20:02:30 +0000340%/.makeall %/.makeinstall %/.makeclean %/.maketest:
Chris Lattnera8abc222002-09-18 03:22:27 +0000341 $(VERB) cd $(@D); $(MAKE) $(subst $(@D)/.make,,$@)
Chris Lattner00950542001-06-06 20:29:01 +0000342endif
343
John Criswell2a6530f2003-06-27 16:58:44 +0000344ifdef OPTIONAL_DIRS
345all install clean test ::
346 $(VERB) for dir in ${OPTIONAL_DIRS}; do \
347 if [ -d $$dir ]; \
348 then\
349 (cd $$dir; $(MAKE) $@) || exit 1; \
350 fi \
351 done
352endif
353
Chris Lattner00950542001-06-06 20:29:01 +0000354#---------------------------------------------------------
355# Handle the LIBRARYNAME option - used when building libs...
356#---------------------------------------------------------
Chris Lattnere62dbe92002-07-23 17:56:16 +0000357#
358# When libraries are built, they are allowed to optionally define the
359# DONT_BUILD_RELINKED make variable, which, when defined, prevents a .o file
360# from being built for the library. This .o files may then be linked to by a
361# tool if the tool does not need (or want) the semantics a .a file provides
362# (linking in only object files that are "needed"). If a library is never to
363# be used in this way, it is better to define DONT_BUILD_RELINKED, and define
364# BUILD_ARCHIVE instead.
365#
366# Some libraries must be built as .a files (libscalar for example) because if
Chris Lattner1917e952002-07-31 21:32:05 +0000367# it's built as a .o file, then all of the constituent .o files in it will be
Chris Lattnere62dbe92002-07-23 17:56:16 +0000368# linked into tools (for example gccas) even if they only use one of the parts
369# of it. For this reason, sometimes it's useful to use libraries as .a files.
Chris Lattner00950542001-06-06 20:29:01 +0000370
371ifdef LIBRARYNAME
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000372
Chris Lattner2a548c52002-09-16 22:36:42 +0000373# Make sure there isn't any extranous whitespace on the LIBRARYNAME option
Chris Lattnerccb4ebd2002-09-16 22:34:56 +0000374LIBRARYNAME := $(strip $(LIBRARYNAME))
375
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000376LIBNAME_O := $(DESTLIBRELEASE)/lib$(LIBRARYNAME).so
377LIBNAME_P := $(DESTLIBPROFILE)/lib$(LIBRARYNAME).so
378LIBNAME_G := $(DESTLIBDEBUG)/lib$(LIBRARYNAME).so
379LIBNAME_AO := $(DESTLIBRELEASE)/lib$(LIBRARYNAME).a
380LIBNAME_AP := $(DESTLIBPROFILE)/lib$(LIBRARYNAME).a
381LIBNAME_AG := $(DESTLIBDEBUG)/lib$(LIBRARYNAME).a
382LIBNAME_OBJO := $(DESTLIBRELEASE)/$(LIBRARYNAME).o
383LIBNAME_OBJP := $(DESTLIBPROFILE)/$(LIBRARYNAME).o
384LIBNAME_OBJG := $(DESTLIBDEBUG)/$(LIBRARYNAME).o
Chris Lattner00950542001-06-06 20:29:01 +0000385
Chris Lattner760da062003-03-14 20:25:22 +0000386# dynamic target builds a shared object version of the library...
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000387dynamic:: $(DESTLIBCURRENT)/lib$(LIBRARYNAME).so
Vikram S. Adve60f56062002-08-02 18:34:12 +0000388
Chris Lattner760da062003-03-14 20:25:22 +0000389# Does the library want a .o version built?
Chris Lattnere62dbe92002-07-23 17:56:16 +0000390ifndef DONT_BUILD_RELINKED
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000391all:: $(DESTLIBCURRENT)/$(LIBRARYNAME).o
Chris Lattnere62dbe92002-07-23 17:56:16 +0000392endif
Chris Lattner760da062003-03-14 20:25:22 +0000393
394# Does the library want an archive version built?
Chris Lattnere62dbe92002-07-23 17:56:16 +0000395ifdef BUILD_ARCHIVE
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000396all:: $(DESTLIBCURRENT)/lib$(LIBRARYNAME).a
Chris Lattnere62dbe92002-07-23 17:56:16 +0000397endif
Chris Lattnere62dbe92002-07-23 17:56:16 +0000398
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000399$(LIBNAME_O): $(ObjectsO) $(LibSubDirs) $(DESTLIBRELEASE)/.dir
Chris Lattner00950542001-06-06 20:29:01 +0000400 @echo ======= Linking $(LIBRARYNAME) release library =======
Misha Brukmanb5f096f2002-09-12 16:05:39 +0000401 $(VERB) $(MakeSOO) -o $@ $(ObjectsO) $(LibSubDirs) $(LibLinkOpts)
Chris Lattner00950542001-06-06 20:29:01 +0000402
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000403$(LIBNAME_P): $(ObjectsP) $(LibSubDirs) $(DESTLIBPROFILE)/.dir
Vikram S. Adve41e78912002-09-20 14:03:13 +0000404 @echo ======= Linking $(LIBRARYNAME) profile library =======
405 $(VERB) $(MakeSOP) -o $@ $(ObjectsP) $(LibSubDirs) $(LibLinkOpts)
406
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000407$(LIBNAME_G): $(ObjectsG) $(LibSubDirs) $(DESTLIBDEBUG)/.dir
Chris Lattner00950542001-06-06 20:29:01 +0000408 @echo ======= Linking $(LIBRARYNAME) debug library =======
Misha Brukmanb5f096f2002-09-12 16:05:39 +0000409 $(VERB) $(MakeSO) -g -o $@ $(ObjectsG) $(LibSubDirs) $(LibLinkOpts)
Chris Lattner00950542001-06-06 20:29:01 +0000410
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000411$(LIBNAME_AO): $(ObjectsO) $(LibSubDirs) $(DESTLIBRELEASE)/.dir
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000412 @echo ======= Linking $(LIBRARYNAME) release library =======
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000413 @rm -f $@
Misha Brukmanb5f096f2002-09-12 16:05:39 +0000414 $(VERB) $(AR) $@ $(ObjectsO) $(LibSubDirs)
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000415
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000416$(LIBNAME_AP): $(ObjectsP) $(LibSubDirs) $(DESTLIBPROFILE)/.dir
Vikram S. Adve41e78912002-09-20 14:03:13 +0000417 @echo ======= Linking $(LIBRARYNAME) profile library =======
418 @rm -f $@
419 $(VERB) $(AR) $@ $(ObjectsP) $(LibSubDirs)
420
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000421$(LIBNAME_AG): $(ObjectsG) $(LibSubDirs) $(DESTLIBDEBUG)/.dir
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000422 @echo ======= Linking $(LIBRARYNAME) debug library =======
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000423 @rm -f $@
Misha Brukmanb5f096f2002-09-12 16:05:39 +0000424 $(VERB) $(AR) $@ $(ObjectsG) $(LibSubDirs)
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000425
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000426$(LIBNAME_OBJO): $(ObjectsO) $(LibSubDirs) $(DESTLIBRELEASE)/.dir
Misha Brukmanb5f096f2002-09-12 16:05:39 +0000427 @echo "Linking $@"
428 $(VERB) $(Relink) -o $@ $(ObjectsO) $(LibSubDirs)
Chris Lattnere62dbe92002-07-23 17:56:16 +0000429
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000430$(LIBNAME_OBJP): $(ObjectsP) $(LibSubDirs) $(DESTLIBPROFILE)/.dir
Vikram S. Adve41e78912002-09-20 14:03:13 +0000431 @echo "Linking $@"
432 $(VERB) $(Relink) -o $@ $(ObjectsP) $(LibSubDirs)
433
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000434$(LIBNAME_OBJG): $(ObjectsG) $(LibSubDirs) $(DESTLIBDEBUG)/.dir
Chris Lattner9e398162002-09-25 17:15:22 +0000435 @echo "Linking $@"
Misha Brukmanb5f096f2002-09-12 16:05:39 +0000436 $(VERB) $(Relink) -o $@ $(ObjectsG) $(LibSubDirs)
Chris Lattnere62dbe92002-07-23 17:56:16 +0000437
Chris Lattner00950542001-06-06 20:29:01 +0000438endif
439
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000440#------------------------------------------------------------------------
Vikram S. Adve0193d5e2001-10-10 22:35:00 +0000441# Create a TAGS database for emacs
442#------------------------------------------------------------------------
443
Vikram S. Adve022d06c2001-10-13 12:26:59 +0000444ifeq ($(LEVEL), .)
Vikram S. Adve022d06c2001-10-13 12:26:59 +0000445tags:
Chris Lattner18f47012002-05-10 18:51:54 +0000446 etags -l c++ `find include lib tools -name '*.cpp' -o -name '*.h'`
Vikram S. Adve022d06c2001-10-13 12:26:59 +0000447all:: tags
Vikram S. Adve022d06c2001-10-13 12:26:59 +0000448endif
Vikram S. Adve0193d5e2001-10-10 22:35:00 +0000449
450#------------------------------------------------------------------------
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000451# Handle the TOOLNAME option - used when building tool executables...
452#------------------------------------------------------------------------
453#
454# The TOOLNAME option should be used with a USEDLIBS variable that tells the
Chris Lattnere62dbe92002-07-23 17:56:16 +0000455# libraries (and the order of the libs) that should be linked to the
456# tool. USEDLIBS should contain a list of library names (some with .a extension)
457# that are automatically linked in as .o files unless the .a suffix is added.
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000458#
459ifdef TOOLNAME
460
461# TOOLEXENAME* - These compute the output filenames to generate...
John Criswell8bff5092003-06-11 13:55:44 +0000462TOOLEXENAME_G := $(DESTTOOLDEBUG)/$(TOOLNAME)
463TOOLEXENAME_O := $(DESTTOOLRELEASE)/$(TOOLNAME)
464TOOLEXENAME_P := $(DESTTOOLPROFILE)/$(TOOLNAME)
465TOOLEXENAMES := $(DESTTOOLCURRENT)/$(TOOLNAME)
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000466
467# USED_LIBS_OPTIONS - Compute the options line that add -llib1 -llib2, etc.
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000468PROJ_LIBS_OPTIONS := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS)))
469PROJ_LIBS_OPTIONS_G := $(patsubst %.o, $(PROJLIBDEBUGSOURCE)/%.o, $(PROJ_LIBS_OPTIONS))
470PROJ_LIBS_OPTIONS_O := $(patsubst %.o, $(PROJLIBRELEASESOURCE)/%.o,$(PROJ_LIBS_OPTIONS))
471PROJ_LIBS_OPTIONS_P := $(patsubst %.o, $(PROJLIBPROFILESOURCE)/%.o,$(PROJ_LIBS_OPTIONS))
472
473LLVM_LIBS_OPTIONS := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS)))
474LLVM_LIBS_OPTIONS_G := $(patsubst %.o, $(LLVMLIBDEBUGSOURCE)/%.o, $(LLVM_LIBS_OPTIONS))
475LLVM_LIBS_OPTIONS_O := $(patsubst %.o, $(LLVMLIBRELEASESOURCE)/%.o,$(LLVM_LIBS_OPTIONS))
476LLVM_LIBS_OPTIONS_P := $(patsubst %.o, $(LLVMLIBPROFILESOURCE)/%.o,$(LLVM_LIBS_OPTIONS))
477
478LIB_OPTS_G := $(LLVM_LIBS_OPTIONS_G) $(PROJ_LIBS_OPTIONS_G)
Chris Lattnere3ba95e2003-06-20 15:41:57 +0000479LIB_OPTS_O := $(LLVM_LIBS_OPTIONS_O) $(PROJ_LIBS_OPTIONS_O)
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000480LIB_OPTS_P := $(LLVM_LIBS_OPTIONS_P) $(PROJ_LIBS_OPTIONS_P)
481
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000482# USED_LIB_PATHS - Compute the path of the libraries used so that tools are
Chris Lattnere62dbe92002-07-23 17:56:16 +0000483# rebuilt if libraries change. This has to make sure to handle .a/.so and .o
484# files seperately.
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000485#
Chris Lattnere62dbe92002-07-23 17:56:16 +0000486STATICUSEDLIBS := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS)))
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000487USED_LIB_PATHS_G := $(addprefix $(DESTLIBDEBUG)/, $(STATICUSEDLIBS))
488USED_LIB_PATHS_O := $(addprefix $(DESTLIBRELEASE)/, $(STATICUSEDLIBS))
489USED_LIB_PATHS_P := $(addprefix $(DESTLIBPROFILE)/, $(STATICUSEDLIBS))
Chris Lattner1c588502002-11-04 20:50:33 +0000490LINK_OPTS := $(TOOLLINKOPTS) $(PLATFORMLINKOPTS)
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000491
Chris Lattner8d7dfb32003-01-22 16:13:31 +0000492
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000493
494
495
496
Chris Lattner8d7dfb32003-01-22 16:13:31 +0000497# Tell make that we need to rebuild subdirectories before we can link the tool.
498# This affects things like LLI which has library subdirectories.
499$(USED_LIB_PATHS_G) $(USED_LIB_PATHS_O) $(USED_LIB_PATHS_P): \
500 $(addsuffix /.makeall, $(PARALLEL_DIRS))
501
Chris Lattner669bd7c2001-10-13 05:10:29 +0000502all:: $(TOOLEXENAMES)
John Criswell2a6530f2003-06-27 16:58:44 +0000503
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000504clean::
Misha Brukmanb5f096f2002-09-12 16:05:39 +0000505 $(VERB) rm -f $(TOOLEXENAMES)
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000506
John Criswell8bff5092003-06-11 13:55:44 +0000507$(TOOLEXENAME_G): $(ObjectsG) $(USED_LIB_PATHS_G) $(DESTTOOLDEBUG)/.dir
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000508 @echo ======= Linking $(TOOLNAME) debug executable $(STRIP_WARN_MSG)=======
509 $(VERB) $(LinkG) -o $@ $(ObjectsG) $(LIB_OPTS_G) $(LINK_OPTS)
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000510
John Criswell8bff5092003-06-11 13:55:44 +0000511$(TOOLEXENAME_O): $(ObjectsO) $(USED_LIB_PATHS_O) $(DESTTOOLRELEASE)/.dir
Chris Lattner287d4432002-09-12 17:02:40 +0000512 @echo ======= Linking $(TOOLNAME) release executable =======
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000513 $(VERB) $(LinkO) -o $@ $(ObjectsO) $(LIB_OPTS_O) $(LINK_OPTS)
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000514
John Criswell8bff5092003-06-11 13:55:44 +0000515$(TOOLEXENAME_P): $(ObjectsP) $(USED_LIB_PATHS_P) $(DESTTOOLPROFILE)/.dir
Vikram S. Adve41e78912002-09-20 14:03:13 +0000516 @echo ======= Linking $(TOOLNAME) profile executable =======
Dinakar Dhurjatiffb55cd2003-05-29 16:18:20 +0000517 $(VERB) $(LinkP) -o $@ $(ObjectsP) $(LIB_OPTS_P) $(LINK_OPTS)
Vikram S. Adve41e78912002-09-20 14:03:13 +0000518
Chris Lattner1cbc29f2001-09-07 22:57:58 +0000519endif
520
521
Chris Lattner00950542001-06-06 20:29:01 +0000522
523#---------------------------------------------------------
John Criswell8bff5092003-06-11 13:55:44 +0000524.PRECIOUS: $(BUILD_OBJ_DIR)/Depend/.dir
525.PRECIOUS: $(BUILD_OBJ_DIR)/Debug/.dir $(BUILD_OBJ_DIR)/Release/.dir
Chris Lattner00950542001-06-06 20:29:01 +0000526
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000527# Create .o files in the ObjectFiles directory from the .cpp and .c files...
John Criswell8bff5092003-06-11 13:55:44 +0000528$(BUILD_OBJ_DIR)/Release/%.o: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Release/.dir
Misha Brukmanb5f096f2002-09-12 16:05:39 +0000529 @echo "Compiling $<"
530 $(VERB) $(CompileO) $< -o $@
Chris Lattner00950542001-06-06 20:29:01 +0000531
John Criswell8bff5092003-06-11 13:55:44 +0000532$(BUILD_OBJ_DIR)/Release/%.o: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Release/.dir
Chris Lattner1eeac662002-10-22 23:28:23 +0000533 $(VERB) $(CompileCO) $< -o $@
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000534
John Criswell8bff5092003-06-11 13:55:44 +0000535$(BUILD_OBJ_DIR)/Profile/%.o: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Profile/.dir
Vikram S. Adve41e78912002-09-20 14:03:13 +0000536 @echo "Compiling $<"
537 $(VERB) $(CompileP) $< -o $@
538
John Criswell8bff5092003-06-11 13:55:44 +0000539$(BUILD_OBJ_DIR)/Profile/%.o: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Profile/.dir
Chris Lattner172b6482002-09-22 02:47:15 +0000540 @echo "Compiling $<"
541 $(VERB) $(CompileCP) $< -o $@
542
John Criswell8bff5092003-06-11 13:55:44 +0000543$(BUILD_OBJ_DIR)/Debug/%.o: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Debug/.dir
Misha Brukmanb5f096f2002-09-12 16:05:39 +0000544 @echo "Compiling $<"
545 $(VERB) $(CompileG) $< -o $@
Chris Lattner00950542001-06-06 20:29:01 +0000546
John Criswell8bff5092003-06-11 13:55:44 +0000547$(BUILD_OBJ_DIR)/Debug/%.o: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Debug/.dir
Chris Lattner172b6482002-09-22 02:47:15 +0000548 $(VERB) $(CompileCG) $< -o $@
Vikram S. Adve112a72c2001-07-15 13:16:47 +0000549
Chris Lattnere8996782003-01-16 22:44:19 +0000550#
551# Rules for building lex/yacc files
552#
553LEX_FILES = $(filter %.l, $(Source))
554LEX_OUTPUT = $(LEX_FILES:%.l=%.cpp)
555YACC_FILES = $(filter %.y, $(Source))
556YACC_OUTPUT = $(addprefix $(YACC_FILES:%.y=%), .h .cpp .output)
557.PRECIOUS: $(LEX_OUTPUT) $(YACC_OUTPUT)
558
Chris Lattner00950542001-06-06 20:29:01 +0000559# Create a .cpp source file from a flex input file... this uses sed to cut down
560# on the warnings emited by GCC...
Chris Lattner6d131b42003-01-23 16:33:10 +0000561#
562# The last line is a gross hack to work around flex aparently not being able to
563# resize the buffer on a large token input. Currently, for uninitialized string
564# buffers in LLVM we can generate very long tokens, so this is a hack around it.
565# FIXME. (f.e. char Buffer[10000]; )
566#
Chris Lattner00950542001-06-06 20:29:01 +0000567%.cpp: %.l
John Criswell65aa59342003-05-29 18:52:10 +0000568 $(FLEX) -t $< | sed '/^find_rule/d' | \
Chris Lattner6d131b42003-01-23 16:33:10 +0000569 sed 's/void yyunput/inline void yyunput/' | \
570 sed 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
571 sed 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' > $@
Chris Lattner00950542001-06-06 20:29:01 +0000572
573# Rule for building the bison parsers...
Chris Lattner694c5df2003-05-15 21:28:55 +0000574%.c: %.y # Cancel built-in rules for yacc
575%.h: %.y # Cancel built-in rules for yacc
Chris Lattner00950542001-06-06 20:29:01 +0000576%.cpp %.h : %.y
Chris Lattner694c5df2003-05-15 21:28:55 +0000577 @echo Bison\'ing $<...
Chris Lattnere8996782003-01-16 22:44:19 +0000578 $(VERB) $(BISON) -v -d -p $(<:%Parser.y=%) $*.y
579 $(VERB) mv -f $*.tab.c $*.cpp
580 $(VERB) mv -f $*.tab.h $*.h
Chris Lattner00950542001-06-06 20:29:01 +0000581
582# To create the directories...
583%/.dir:
Chris Lattnere8996782003-01-16 22:44:19 +0000584 $(VERB) mkdir -p $*
Chris Lattner00950542001-06-06 20:29:01 +0000585 @date > $@
586
Chris Lattner30440c62003-01-16 21:06:18 +0000587# To create postscript files from dot files...
588%.ps: %.dot
589 dot -Tps < $< > $@
590
Chris Lattner172b6482002-09-22 02:47:15 +0000591# 'make clean' nukes the tree
Chris Lattner00950542001-06-06 20:29:01 +0000592clean::
John Criswell8bff5092003-06-11 13:55:44 +0000593 $(VERB) rm -rf $(BUILD_OBJ_DIR)/Debug $(BUILD_OBJ_DIR)/Release $(BUILD_OBJ_DIR)/Profile $(BUILD_OBJ_DIR)/Depend
Misha Brukmanab6d2932002-12-04 17:08:15 +0000594 $(VERB) rm -f core core.[0-9][0-9]* *.o *.d *.so *~ *.flc
Chris Lattnere8996782003-01-16 22:44:19 +0000595 $(VERB) rm -f $(LEX_OUTPUT) $(YACC_OUTPUT)
Chris Lattner00950542001-06-06 20:29:01 +0000596
Chris Lattner694c5df2003-05-15 21:28:55 +0000597# If dependencies were generated for the file that included this file,
Chris Lattner00950542001-06-06 20:29:01 +0000598# include the dependancies now...
599#
Chris Lattner694c5df2003-05-15 21:28:55 +0000600SourceBaseNames := $(basename $(notdir $(filter-out Debug/%, $(Source))))
John Criswell8bff5092003-06-11 13:55:44 +0000601SourceDepend := $(SourceBaseNames:%=$(BUILD_OBJ_DIR)/Depend/%.d)
Chris Lattner694c5df2003-05-15 21:28:55 +0000602
603# Create dependencies for the *.cpp files...
604#$(SourceDepend): \x
John Criswell8bff5092003-06-11 13:55:44 +0000605$(BUILD_OBJ_DIR)/Depend/%.d: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Depend/.dir
606 $(VERB) $(Depend) $< | sed 's|$*\.o *|$(BUILD_OBJ_DIR)/Release/& $(BUILD_OBJ_DIR)/Profile/& $(BUILD_OBJ_DIR)/Debug/& $(BUILD_OBJ_DIR)/Depend/$(@F)|g' > $@
Chris Lattner694c5df2003-05-15 21:28:55 +0000607
608# Create dependencies for the *.c files...
609#$(SourceDepend): \x
John Criswell8bff5092003-06-11 13:55:44 +0000610$(BUILD_OBJ_DIR)/Depend/%.d: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Depend/.dir
Chris Lattner694c5df2003-05-15 21:28:55 +0000611 $(VERB) $(DependC) $< | sed 's|$*\.o *|Release/& Profile/& Debug/& Depend/$(@F)|g' > $@
612
Chris Lattner00950542001-06-06 20:29:01 +0000613ifneq ($(SourceDepend),)
Chris Lattnered03bc92002-10-25 14:32:42 +0000614-include $(SourceDepend)
Chris Lattner00950542001-06-06 20:29:01 +0000615endif