Rewrite emitCastOperation, refactoring parts of it into emitIntegerCast, and
[oota-llvm.git] / Makefile_rules
1 #,===-- Makefile.rules.am - Common make rules for LLVM ------*- Makefile -*--===#
2 #
3 #                     The LLVM Compiler Infrastructure
4 #
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.
7
8 #===------------------------------------------------------------------------===#
9
10 #
11 # LLVM Specific C/C++ compiler flags
12
13 LLVM_COMMONFLAGS := -Wall -W -Wwrite-strings -Wno-unused -Wcast-align
14 LLVM_CXXFLAGS    := 
15 LLVM_CFLAGS      :=
16 LLVM_CPPFLAGS    := \
17   -I. \
18   -I$(srcdir) \
19   -I$(top_srcdir)/include \
20   -I$(top_builddir)/include \
21   -D_RENTRANT -D_GNU_SOURCE -D__STDC_LIMIT_MACROS
22
23 ifeq ($(BUILDMODE),Profile)
24   LLVM_CPPFLAGS  += -DNDEBUG
25   LLVM_CXXFLAGS  += -pg -O3 -finline-functions -felide-constructors
26   LLVM_CFLAGS    += -pg
27 else
28   ifeq ($(BUILDMODE),Release)
29     LLVM_CPPFLAGS  += -DNDEBUG
30     LLVM_CXXFLAGS  += -O3 -finline-functions -fomit-frame-pointer -felide-constructors
31     LLVM_CFLAGS    += -O3
32   else
33     LLVM_CPPFLAGS  += -D_DEBUG
34     LLVM_CXXFLAGS  += -O1
35     LLVM_CFLAGS    += -O1
36   endif
37 endif
38
39 LDIR = $(top_builddir)/$(BUILDMODE)/lib
40 BDIR = $(top_builddir)/$(BUILDMODE)/bin
41 DDIR = $(top_builddir)/$(BUILDMODE)/data
42 EDIR = $(top_builddir)/$(BUILDMODE)/etc
43
44 # Required tool definitions as macros so they can be overridden
45 LINKLIB    := ${LIBTOOL} --tag=CXX --mode=link $(CXX) -o
46
47 BURG       := $(top_builddir)/utils/Burg/burg$(EXEEXT)
48 RunBurg    := $(BURG) -I
49 TBLGEN     := $(top_builddir)/utils/TableGen/TableGen$(EXEEXT)
50 LGCCLDPROG := $(top_builddir)/tools/gccld/gccld$(EXEEXT)
51
52 # Set up the standard automake variables
53 #
54 AM_CPPFLAGS  = $(LLVM_CPPFLAGS) 
55 AM_CXXFLAGS  = $(LLVM_COMMONFLAGS) $(LLVM_CXXFLAGS)
56 AM_CFLAGS    = $(LLVM_COMMONFLAGS) $(LLVM_CFLAGS)
57 AM_LDFLAGS   = -L$(LDIR)
58
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)))
64
65 # LLVM Rules
66
67 ifdef lib_LIBRARIES
68 lib_LINKS_TO_MAKE = $(foreach L,$(lib_LIBRARIES),$(patsubst lib%.a,$(LDIR)/lib%.a,$(L)))
69 all-am : $(lib_LINKS_TO_MAKE)
70
71 $(LDIR)/lib%.a : lib%.a
72         cwd=`pwd` ; cd $(LDIR) ; $(LN) -s $${cwd}/$* .
73 endif
74
75 ifdef bin_PROGRAMS
76 bin_LINKS_TO_MAKE = $(foreach P,$(bin_PROGRAMS),$(patsubst %,$(BDIR)/%,$(P)))
77
78 all-am : $(bin_LINKS_TO_MAKE)
79
80 $(BDIR)/% : %
81         cwd=`pwd` ; cd $(BDIR) ; $(LN) -s $${cwd}/$* .
82 endif
83
84 ifdef PRELINK
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))
88
89 all-am: $(PRELINK_LIB_NAME)
90
91 $(PRELINK_LIB_NAME) : $(PRELINK_OBJECTS)
92         $(LIBTOOL) --mode=link $(CXX) -o $(PRELINK_LIB_NAME) $(PRELINK_OBJECTS)
93
94         
95 clean-am: clean-relink
96
97 clean-relink:
98         $(RM) -f $(PRELINK_LIB_NAME)
99 endif
100
101 %.cpp: %.l
102         @${ECHO} Flexing $<
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...
110         @$(RM) -f $@.tmp
111
112 SUFFIXES = .td
113
114 %.c: %.y     # Cancel built-in rules for yacc
115
116 %.h: %.y     # Cancel built-in rules for yacc
117
118 %.cpp %.h : %.y
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
125
126
127 %GenRegisterNames.inc : %.td 
128         @echo "Building $< register names with tblgen"
129         $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-register-enums -o $@
130
131 %GenRegisterInfo.h.inc : %.td 
132         @echo "Building $< register information header with tblgen"
133         $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-register-desc-header -o $@
134
135 %GenRegisterInfo.inc : %.td 
136         @echo "Building $< register info implementation with tblgen"
137         $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-register-desc -o $@
138
139 %GenInstrNames.inc : %.td
140         @echo "Building $< instruction names with tblgen"
141         $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-instr-enums -o $@
142
143 %GenInstrInfo.inc : %.td
144         @echo "Building $< instruction information with tblgen"
145         $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-instr-desc -o $@
146
147 %GenAsmWriter.inc : %.td
148         @echo "Building $< assembly writer with tblgen"
149         $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-asm-writer -o $@
150
151 %GenATTAsmWriter.inc : %.td
152         @echo "Building $< AT&T assembly writer with tblgen"
153         $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-asm-writer -o $@
154
155 %GenIntelAsmWriter.inc : %.td
156         @echo "Building $< Intel assembly writer with tblgen"
157         $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-asm-writer -asmwriternum=1 -o $@
158
159 %GenInstrSelector.inc: %.td
160         @echo "Building $< instruction selector with tblgen"
161         $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-instr-selector -o $@
162
163 TDFILES = $(wildcard $(srcdir)/*.td ) $(srcdir)/../Target.td