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 LLVM_COMMONFLAGS := -Wall -W -Wwrite-strings -Wno-unused -Wcast-align
19 -I$(top_srcdir)/include \
20 -I$(top_builddir)/include \
21 -D_RENTRANT -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
23 ifeq ($(BUILDMODE),Profile)
24 LLVM_CPPFLAGS += -DNDEBUG
25 LLVM_CXXFLAGS += -pg -O3 -finline-functions -felide-constructors
28 ifeq ($(BUILDMODE),Release)
29 LLVM_CPPFLAGS += -DNDEBUG
30 LLVM_CXXFLAGS += -O3 -finline-functions -fomit-frame-pointer -felide-constructors
33 LLVM_CPPFLAGS += -D_DEBUG
39 LDIR = $(top_builddir)/$(BUILDMODE)/lib
40 BDIR = $(top_builddir)/$(BUILDMODE)/bin
41 DDIR = $(top_builddir)/$(BUILDMODE)/data
42 EDIR = $(top_builddir)/$(BUILDMODE)/etc
44 # Required tool definitions as macros so they can be overridden
45 LINKLIB := ${LIBTOOL} --tag=CXX --mode=link $(CXX) -o
47 BURG := $(top_builddir)/utils/Burg/burg$(EXEEXT)
49 TBLGEN := $(top_builddir)/utils/TableGen/TableGen$(EXEEXT)
50 LGCCLDPROG := $(top_builddir)/tools/gccld/gccld$(EXEEXT)
52 # Set up the standard automake variables
54 AM_CPPFLAGS = $(LLVM_CPPFLAGS)
55 AM_CXXFLAGS = $(LLVM_COMMONFLAGS) $(LLVM_CXXFLAGS)
56 AM_CFLAGS = $(LLVM_COMMONFLAGS) $(LLVM_CFLAGS)
57 AM_LDFLAGS = -L$(LDIR)
59 # LLVM GNU Make Function macros
60 GETOBJ = $(patsubst %,$(LDIR)/LLVM%.o,$(1))
61 GETLIB = $(patsubst %,-lLLVM%,$(1))
62 GETOBJS = $(foreach I,$(1) $(2) $(3) $(4) $(5) $(6) $(7) $(8) $(9) $(10),$(call GETOBJ,$(I)))
63 GETLIBS = $(foreach I,$(1) $(2) $(3) $(4) $(5) $(6) $(7) $(8) $(9) $(10),$(call GETLIB,$(I)))
68 lib_LINKS_TO_MAKE = $(foreach L,$(lib_LIBRARIES),$(patsubst lib%.a,$(LDIR)/lib%.a,$(L)))
69 all-am : $(lib_LINKS_TO_MAKE)
71 $(LDIR)/lib%.a : lib%.a
72 cwd=`pwd` ; cd $(LDIR) ; $(LN) -s $${cwd}/$* .
76 bin_LINKS_TO_MAKE = $(foreach P,$(bin_PROGRAMS),$(patsubst %,$(BDIR)/%,$(P)))
78 all-am : $(bin_LINKS_TO_MAKE)
81 cwd=`pwd` ; cd $(BDIR) ; $(LN) -s $${cwd}/$* .
85 PRELINK_LIB_NAME = $(LDIR)/$(patsubst lib%.a,%.o,$(PRELINK))
86 PRELINK_VAR_NAME = $(patsubst lib%.a,lib%_a,$(PRELINK))_OBJECTS
87 PRELINK_OBJECTS = $($(PRELINK_VAR_NAME))
89 all-am: $(PRELINK_LIB_NAME)
91 $(PRELINK_LIB_NAME) : $(PRELINK_OBJECTS)
92 $(LIBTOOL) --mode=link $(CXX) -o $(PRELINK_LIB_NAME) $(PRELINK_OBJECTS)
95 clean-am: clean-relink
98 $(RM) -f $(PRELINK_LIB_NAME)
103 $(VERB) $(FLEX) -t $< | \
104 $(SED) '/^find_rule/d' | \
105 $(SED) 's/void yyunput/inline void yyunput/' | \
106 $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
107 $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' > $@.tmp
108 $(VERB) $(CMP) -s $@ $@.tmp > /dev/null || ${MV} -f $@.tmp $@
109 @# remove the output of flex if it didn't get moved over...
114 %.c: %.y # Cancel built-in rules for yacc
116 %.h: %.y # Cancel built-in rules for yacc
119 @${ECHO} "Bisoning `basename $<`"
120 $(VERB) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
121 $(VERB) $(CMP) -s $*.tab.c $*.cpp > /dev/null || ${MV} -f $*.tab.c $*.cpp
122 $(VERB) $(CMP) -s $*.tab.h $*.h > /dev/null || ${MV} -f $*.tab.h $*.h
123 @# If the files were not updated, don't leave them lying around...
124 @$(RM) -f $*.tab.c $*.tab.h
127 %GenRegisterNames.inc : %.td
128 @echo "Building $< register names with tblgen"
129 $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-register-enums -o $@
131 %GenRegisterInfo.h.inc : %.td
132 @echo "Building $< register information header with tblgen"
133 $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-register-desc-header -o $@
135 %GenRegisterInfo.inc : %.td
136 @echo "Building $< register info implementation with tblgen"
137 $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-register-desc -o $@
139 %GenInstrNames.inc : %.td
140 @echo "Building $< instruction names with tblgen"
141 $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-instr-enums -o $@
143 %GenInstrInfo.inc : %.td
144 @echo "Building $< instruction information with tblgen"
145 $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-instr-desc -o $@
147 %GenAsmWriter.inc : %.td
148 @echo "Building $< assembly writer with tblgen"
149 $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-asm-writer -o $@
151 %GenATTAsmWriter.inc : %.td
152 @echo "Building $< AT&T assembly writer with tblgen"
153 $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-asm-writer -o $@
155 %GenIntelAsmWriter.inc : %.td
156 @echo "Building $< Intel assembly writer with tblgen"
157 $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-asm-writer -asmwriternum=1 -o $@
159 %GenInstrSelector.inc: %.td
160 @echo "Building $< instruction selector with tblgen"
161 $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-instr-selector -o $@
163 TDFILES = $(wildcard $(srcdir)/*.td ) $(srcdir)/../Target.td