1 #,===-- Makefile.rules.am - Common make rules for LLVM ------*- Makefile -*--===#
3 # The LLVM Compiler Infrastructure
5 # This file was developed by Reid Spencer and is distributed under the
6 # University of Illinois Open Source License. See LICENSE.TXT for details.
8 #===------------------------------------------------------------------------===#
11 # LLVM Specific C/C++ compiler flags
13 # Locations of built programs/libraries
14 LDIR := $(top_builddir)/$(BUILDMODE)/lib
15 BDIR := $(top_builddir)/$(BUILDMODE)/bin
16 DDIR := $(top_builddir)/$(BUILDMODE)/data
17 EDIR := $(top_builddir)/$(BUILDMODE)/etc
18 BCDIR := $(top_builddir)/$(BUILDMODE)/bclib
23 LLVM_COMMONFLAGS := -Wall -W -Wwrite-strings -Wno-unused -Wcast-align
24 LLVM_CXXFLAGS := $(LLVM_COMMONFLAGS)
25 LLVM_CFLAGS := $(LLVM_COMMONFLAGS)
26 LLVM_CPPFLAGS := -I. -I$(srcdir) -I$(top_srcdir)/include \
27 -I$(top_builddir)/include -D_RENTRANT -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
29 ifeq ($(BUILDMODE),Profile)
30 LLVM_CPPFLAGS += -DNDEBUG
31 LLVM_CXXFLAGS += -pg -O3 -finline-functions -felide-constructors
34 ifeq ($(BUILDMODE),Release)
35 LLVM_CPPFLAGS += -DNDEBUG
36 LLVM_CXXFLAGS += -O3 -finline-functions -fomit-frame-pointer -felide-constructors
39 LLVM_CPPFLAGS += -D_DEBUG
45 # Set up the standard automake variables
47 AM_CPPFLAGS = $(LLVM_CPPFLAGS)
48 AM_CXXFLAGS = $(LLVM_COMMONFLAGS) $(LLVM_CXXFLAGS)
49 AM_CFLAGS = $(LLVM_COMMONFLAGS) $(LLVM_CFLAGS)
50 AM_LDFLAGS = -L$(LDIR)
52 # Required tool definitions as macros so they can be overridden
53 LINKLIB := ${LIBTOOL} --tag=CXX --mode=link $(CXX) -o
55 BURG := $(top_builddir)/utils/Burg/burg$(EXEEXT)
57 TBLGEN := $(top_builddir)/utils/TableGen/TableGen$(EXEEXT)
59 LLVMGCC := PATH=$(BDIR):$(PATH) $(LLVMGCCDIR)/bin/gcc
60 LLVMGXX := PATH=$(BDIR):$(PATH) $(LLVMGCCDIR)/bin/g++
61 LLVMAS := $(BDIR)/llvm-as$(EXEEXT)
62 LLVMGCCLD := $(BDIR)/gccld$(EXEEXT)
64 # LLVM GNU Make Function macros
65 GETOBJ = $(patsubst %,$(LDIR)/LLVM%.o,$(1))
66 GETLIB = $(patsubst %,-lLLVM%,$(1))
67 GETOBJS = $(foreach I,$(1) $(2) $(3) $(4) $(5) $(6) $(7) $(8) $(9) $(10),$(call GETOBJ,$(I)))
68 GETLIBS = $(foreach I,$(1) $(2) $(3) $(4) $(5) $(6) $(7) $(8) $(9) $(10),$(call GETLIB,$(I)))
73 lib_LINKS_TO_MAKE = $(foreach L,$(lib_LIBRARIES),$(patsubst lib%.a,$(LDIR)/lib%.a,$(L)))
74 all-am : $(lib_LINKS_TO_MAKE)
76 $(LDIR)/lib%.a : $(LDIR) lib%.a
77 cwd=`pwd` ; cd $(LDIR) ; $(RM) -f lib$*.a ; $(LN) -s $${cwd}/lib$*.a .
84 bin_LINKS_TO_MAKE = $(foreach P,$(bin_PROGRAMS),$(patsubst %,$(BDIR)/%,$(P)))
86 all-am : $(bin_LINKS_TO_MAKE)
89 cwd=`pwd` ; cd $(BDIR) ; $(RM) -f $* ; $(LN) -s $${cwd}/$* .
97 PRELINK_LIB_NAME = $(LDIR)/$(patsubst lib%.a,%.o,$(PRELINK))
98 PRELINK_VAR_NAME = $(patsubst lib%.a,lib%_a,$(PRELINK))_OBJECTS
99 PRELINK_OBJECTS = $($(PRELINK_VAR_NAME))
101 all-am: $(PRELINK_LIB_NAME)
103 $(PRELINK_LIB_NAME) : $(PRELINK_OBJECTS)
104 $(LIBTOOL) --mode=link $(CXX) -o $(PRELINK_LIB_NAME) $(PRELINK_OBJECTS)
106 clean-am: clean-relink
109 $(RM) -f $(PRELINK_LIB_NAME)
111 install-am: install-prelink
114 @${ECHO} ======= Installing $(PRELINK) library =======
115 $(INSTALL_DATA) '$(PRELINK_LIB_NAME)' $(DESTDIR)$(libdir)
119 ifdef BYTECODE_LIBRARY
120 BCL_LIB_NAME = $(BCDIR)/$(patsubst lib%.a,%.bc,$(BYTECODE_LIBRARY))
121 BCL_VAR_NAME = $(patsubst lib%.a,lib%_a,$(BYTECODE_LIBRARY))_OBJECTS
122 BCL_OBJECTS = $(patsubst %.o,%.bc,$($(BCL_VAR_NAME)))
124 LinkBCLib := $(LLVMGCC) -shared -nostdlib
125 ifdef EXPORTED_SYMBOL_LIST
126 LinkBCLib += -Xlinker -internalize-public-api-list=$(EXPORTED_SYMBOL_LIST)
128 LinkBCLib += -Xlinker -disable-internalize
131 all-am: $(BCDIR) $(BCL_LIB_NAME)
133 $(BCL_LIB_NAME) : $(BCL_OBJECTS)
134 $(LinkBCLib) -o $@ $(BCL_OBJECTS) $(LibSubDirs) $(LibLinkOpts)
142 $(RM) -f $(BCL_LIB_NAME) *.bc
144 install-am: install-bcl
146 $(INSTALL_DATA) '$(BCL_LIB_NAME)' $(DESTDIR)$(libdir)
152 $(VERB) $(FLEX) -t $< | \
153 $(SED) '/^find_rule/d' | \
154 $(SED) 's/void yyunput/inline void yyunput/' | \
155 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
156 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' > $@.tmp
157 $(VERB) $(CMP) -s $@ $@.tmp > /dev/null || ${MV} -f $@.tmp $@
158 @# remove the output of flex if it didn't get moved over...
163 %.c: %.y # Cancel built-in rules for yacc
165 %.h: %.y # Cancel built-in rules for yacc
168 @${ECHO} "Bisoning `basename $<`"
169 $(VERB) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
170 $(VERB) $(CMP) -s $*.tab.c $*.cpp > /dev/null || ${MV} -f $*.tab.c $*.cpp
171 $(VERB) $(CMP) -s $*.tab.h $*.h > /dev/null || ${MV} -f $*.tab.h $*.h
172 @# If the files were not updated, don't leave them lying around...
173 @$(RM) -f $*.tab.c $*.tab.h
176 @${ECHO} "Compiling $*.cpp to bytecode"
177 $(VERB) $(LLVMGXX) $(AM_CPPFLAGS) $(AM_CXXFLAGS) -c $< -o $@
180 @${ECHO} "Compiling $*.c to bytecode"
181 $(VERB) $(LLVMGCC) $(AM_CPPFLAGS) $(AM_CFLAGS) -c $< -o $@
184 @${ECHO} "Compiling $*.ll to bytecode"
185 $(VERB) $(LLVMAS) $< -f -o $@
187 %GenRegisterNames.inc : %.td
188 @echo "Building $< register names with tblgen"
189 $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-register-enums -o $@
191 %GenRegisterInfo.h.inc : %.td
192 @echo "Building $< register information header with tblgen"
193 $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-register-desc-header -o $@
195 %GenRegisterInfo.inc : %.td
196 @echo "Building $< register info implementation with tblgen"
197 $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-register-desc -o $@
199 %GenInstrNames.inc : %.td
200 @echo "Building $< instruction names with tblgen"
201 $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-instr-enums -o $@
203 %GenInstrInfo.inc : %.td
204 @echo "Building $< instruction information with tblgen"
205 $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-instr-desc -o $@
207 %GenAsmWriter.inc : %.td
208 @echo "Building $< assembly writer with tblgen"
209 $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-asm-writer -o $@
211 %GenATTAsmWriter.inc : %.td
212 @echo "Building $< AT&T assembly writer with tblgen"
213 $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-asm-writer -o $@
215 %GenIntelAsmWriter.inc : %.td
216 @echo "Building $< Intel assembly writer with tblgen"
217 $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-asm-writer -asmwriternum=1 -o $@
219 %GenInstrSelector.inc: %.td
220 @echo "Building $< instruction selector with tblgen"
221 $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-instr-selector -o $@
223 %GenCodeEmitter.inc:: %.td $(TDFILES) $(TBLGEN)
224 @echo "Building $< code emitter with tblgen"
225 $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-emitter -o $@
227 TDFILES = $(wildcard $(srcdir)/*.td ) $(srcdir)/../Target.td