Reid Spencer | 3d771cb | 2004-10-10 22:16:37 +0000 | [diff] [blame] | 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 | # Options for all makefiles |
| 11 | ACLOCAL_AMFLAGS = -I autoconf -I autoconf/m4 --output=autoconf/aclocal.m4 |
| 12 | AUTOMAKE_OPTIONS = foreign dejagnu dist-zip nostdinc |
| 13 | |
| 14 | # |
| 15 | # Install Directories as local makefile variables |
| 16 | # |
| 17 | LLVM_PREFIX := @LLVM_PREFIX@ |
| 18 | LLVM_BINDIR := @LLVM_BINDIR@ |
| 19 | LLVM_LIBDIR := @LLVM_LIBDIR@ |
| 20 | LLVM_DATADIR := @LLVM_DATADIR@ |
| 21 | LLVM_DOCSDIR := @LLVM_DOCSDIR@ |
| 22 | LLVM_ETCDIR := @LLVM_ETCDIR@ |
| 23 | LLVM_INCLUDEDIR:= @LLVM_INCLUDEDIR@ |
| 24 | LLVM_INFODIR := @LLVM_INFODIR@ |
| 25 | LLVM_MANDIR := @LLVM_MANDIR@ |
| 26 | |
| 27 | # |
| 28 | # LLVM Specific C/C++ compiler flags |
| 29 | # |
| 30 | LLVM_COMMONFLAGS := -Wall -W -Wwrite-strings -Wno-unused -Wcast-align |
| 31 | LLVM_CXXFLAGS := |
| 32 | LLVM_CFLAGS := |
| 33 | LLVM_CPPFLAGS := \ |
| 34 | -I. \ |
| 35 | -I$(srcdir) \ |
| 36 | -I$(top_srcdir)/include \ |
| 37 | -I$(top_builddir)/include \ |
| 38 | -D_RENTRANT -D_GNU_SOURCE -D__STDC_LIMIT_MACROS |
| 39 | |
| 40 | if ENABLE_PROFILED |
| 41 | LLVM_CPPFLAGS += -DNDEBUG |
| 42 | LLVM_CXXFLAGS += -pg -O3 -finline-functions -felide-constructors |
| 43 | LLVM_CXXFLAGS += -pg -O3 -finline-functions |
| 44 | LLVM_CFLAGS += -pg |
| 45 | endif |
| 46 | |
| 47 | if ENABLE_OPTIMIZED |
| 48 | LLVM_CPPFLAGS += -DNDEBUG |
| 49 | LLVM_CXXFLAGS += -O3 -finline-functions -fomit-frame-pointer -felide-constructors |
| 50 | else |
| 51 | LLVM_CPPFLAGS += -D_DEBUG |
| 52 | endif |
| 53 | |
| 54 | # Required tool definitions as macros so they can be overridden |
| 55 | VERB := @ |
| 56 | SED := sed |
| 57 | RM := rm |
| 58 | CMP := cmp |
| 59 | MV := mv |
| 60 | ECHO := echo |
| 61 | IGNORE := true |
| 62 | LINKLIB := ${LIBTOOL} --tag=CXX --mode=link $(CXX) -o |
| 63 | |
| 64 | BURG := $(top_builddir)/utils/Burg/burg$(EXEEXT) |
| 65 | RunBurg := $(BURG) -I |
| 66 | TBLGEN := $(top_builddir)/utils/TableGen/TableGen$(EXEEXT) |
| 67 | LGCCLDPROG := $(top_builddir)/tools/gccld/gccld$(EXEEXT) |
| 68 | |
| 69 | |
| 70 | # Set up the standard automake variables |
| 71 | # |
| 72 | AM_CPPFLAGS = $(LLVM_CPPFLAGS) |
| 73 | AM_CXXFLAGS = $(LLVM_COMMONFLAGS) $(LLVM_CXXFLAGS) |
| 74 | AM_CFLAGS = $(LLVM_COMMONFLAGS) $(LLVM_CFLAGS) |
| 75 | |
| 76 | # LLVM GMake Function macros |
| 77 | FIXOBJ = $(top_builddir)/lib/$(2)/LLVM$(1).o |
| 78 | FIXLIB = $(top_builddir)/lib/$(2)/libLLVM$(1).a |
Reid Spencer | f8f3305 | 2004-10-10 22:54:46 +0000 | [diff] [blame] | 79 | FINDPATH = $(if $(findstring Core,$(1)),VMCore,$(strip \ |
| 80 | $(if $(findstring Support,$(1)),Support,$(strip \ |
Reid Spencer | 3d771cb | 2004-10-10 22:16:37 +0000 | [diff] [blame] | 81 | $(if $(findstring System,$(1)),System,$(strip \ |
Reid Spencer | f8f3305 | 2004-10-10 22:54:46 +0000 | [diff] [blame] | 82 | $(if $(findstring BCReader,$(1)),Bytecode/Reader,$(strip \ |
| 83 | $(if $(findstring BCWriter,$(1)),Bytecode/Writer,$(strip \ |
| 84 | $(if $(findstring AsmParser,$(1)),AsmParser,$(strip \ |
| 85 | $(if $(findstring Analysis,$(1)),Analysis,$(strip \ |
| 86 | $(if $(findstring Target,$(1)),Target,$(strip \ |
| 87 | $(if $(findstring Transforms,$(1)),Transforms,$(strip \ |
Reid Spencer | 3d771cb | 2004-10-10 22:16:37 +0000 | [diff] [blame] | 88 | $(if $(findstring IPA,$(1)),Analysis/IPA,$(strip \ |
| 89 | $(if $(findstring DataStructure,$(1)),Analysis/DataStructure,$(strip \ |
Reid Spencer | 3d771cb | 2004-10-10 22:16:37 +0000 | [diff] [blame] | 90 | $(if $(findstring IPO,$(1)),Transforms/IPO,$(strip \ |
| 91 | $(if $(findstring Instrument,$(1)),Transforms/Instrumentation,$(strip \ |
| 92 | $(if $(findstring ScalarOpts,$(1)),Transforms/Scalar,$(strip \ |
| 93 | $(if $(findstring TransformUtils,$(1)),Transforms/Utils,$(strip \ |
Reid Spencer | 3d771cb | 2004-10-10 22:16:37 +0000 | [diff] [blame] | 94 | $(if $(findstring ModuloScheduling,$(1)),CodeGen/ModuloScheduling,$(strip \ |
| 95 | $(if $(findstring SelectionDAG,$(1)),CodeGen/SelectionDAG,$(strip \ |
Reid Spencer | f8f3305 | 2004-10-10 22:54:46 +0000 | [diff] [blame] | 96 | $(if $(findstring ProfilePaths,$(1)),Transforms/Instrumentation/ProfilePaths,$(strip \ |
Reid Spencer | 3d771cb | 2004-10-10 22:16:37 +0000 | [diff] [blame] | 97 | $(if $(findstring CodeGen,$(1)),CodeGen,$(strip \ |
Reid Spencer | f8f3305 | 2004-10-10 22:54:46 +0000 | [diff] [blame] | 98 | $(if $(findstring CWriter,$(1)),Target/CBackend,$(strip \ |
| 99 | $(if $(findstring PowerPC,$(1)),Target/PowerPC,$(strip \ |
| 100 | $(if $(findstring Skeleton,$(1)),Target/Skeleton,$(strip \ |
| 101 | $(if $(findstring SparcV9InstrSched,$(1)),Target/SparcV9/InstrSched,$(strip \ |
| 102 | $(if $(findstring SparcV9LiveVar,$(1)),Target/SparcV9/LiveVar,$(strip \ |
| 103 | $(if $(findstring SparcV9RegAlloc,$(1)),Target/SparcV9/RegAlloc,$(strip \ |
| 104 | $(if $(findstring SparcV9,$(1)),Target/SparcV9,$(strip \ |
| 105 | $(if $(findstring X86,$(1)),Target/X86,$(strip \ |
Reid Spencer | 3d771cb | 2004-10-10 22:16:37 +0000 | [diff] [blame] | 106 | $(if $(findstring Debugger,$(1)),Debugger,$(strip \ |
| 107 | $(if $(findstring Interpreter,$(1)),ExecutionEngine/Interpreter,$(strip \ |
| 108 | $(if $(findstring JIT,$(1)),ExecutionEngine/JIT,$(strip \ |
| 109 | $(if $(findstring ExecutionEngine,$(1)),ExecutionEngine,$(strip \ |
Reid Spencer | 3d771cb | 2004-10-10 22:16:37 +0000 | [diff] [blame] | 110 | $(if $(findstring Hello,$(1)),Transforms/Hello,$strip \ |
| 111 | PATH_TO_UNKNOWN_OBJECT))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) |
| 112 | |
| 113 | GETOBJ = $(call FIXOBJ,$(1),$(call FINDPATH,$(1))) |
| 114 | GETLIB = $(call FIXLIB,$(1),$(call FINDPATH,$(1))) |
| 115 | GETOBJS = $(foreach I,$(1) $(2) $(3) $(4) $(5) $(6) $(7) $(8) $(9) $(10),$(call GETOBJ,$(I))) |
| 116 | GETLIBS = $(foreach I,$(1) $(2) $(3) $(4) $(5) $(6) $(7) $(8) $(9) $(10),$(call GETLIB,$(I))) |
| 117 | |
| 118 | # LLVM Rules |
| 119 | |
| 120 | %.cpp: %.l |
| 121 | @${ECHO} Flexing $< |
| 122 | $(VERB) $(FLEX) -t $< | \ |
| 123 | $(SED) '/^find_rule/d' | \ |
| 124 | $(SED) 's/void yyunput/inline void yyunput/' | \ |
| 125 | $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \ |
| 126 | $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' > $@.tmp |
| 127 | $(VERB) $(CMP) -s $@ $@.tmp > /dev/null || ${MV} -f $@.tmp $@ |
| 128 | @# remove the output of flex if it didn't get moved over... |
| 129 | @$(RM) -f $@.tmp |
| 130 | |
| 131 | SUFFIXES = .td |
| 132 | |
| 133 | %.c: %.y # Cancel built-in rules for yacc |
| 134 | |
| 135 | %.h: %.y # Cancel built-in rules for yacc |
| 136 | |
| 137 | %.cpp %.h : %.y |
| 138 | @${ECHO} "Bisoning `basename $<`" |
| 139 | $(VERB) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $< |
| 140 | $(VERB) $(CMP) -s $*.tab.c $*.cpp > /dev/null || ${MV} -f $*.tab.c $*.cpp |
| 141 | $(VERB) $(CMP) -s $*.tab.h $*.h > /dev/null || ${MV} -f $*.tab.h $*.h |
| 142 | @# If the files were not updated, don't leave them lying around... |
| 143 | @$(RM) -f $*.tab.c $*.tab.h |
| 144 | |
| 145 | |
| 146 | %GenRegisterNames.inc : %.td |
| 147 | @echo "Building $< register names with tblgen" |
| 148 | $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-register-enums -o $@ |
| 149 | |
| 150 | %GenRegisterInfo.h.inc : %.td |
| 151 | @echo "Building $< register information header with tblgen" |
| 152 | $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-register-desc-header -o $@ |
| 153 | |
| 154 | %GenRegisterInfo.inc : %.td |
| 155 | @echo "Building $< register info implementation with tblgen" |
| 156 | $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-register-desc -o $@ |
| 157 | |
| 158 | %GenInstrNames.inc : %.td |
| 159 | @echo "Building $< instruction names with tblgen" |
| 160 | $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-instr-enums -o $@ |
| 161 | |
| 162 | %GenInstrInfo.inc : %.td |
| 163 | @echo "Building $< instruction information with tblgen" |
| 164 | $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-instr-desc -o $@ |
| 165 | |
| 166 | %GenAsmWriter.inc : %.td |
| 167 | @echo "Building $< assembly writer with tblgen" |
| 168 | $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-asm-writer -o $@ |
| 169 | |
| 170 | %GenATTAsmWriter.inc : %.td |
| 171 | @echo "Building $< AT&T assembly writer with tblgen" |
| 172 | $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-asm-writer -o $@ |
| 173 | |
| 174 | %GenIntelAsmWriter.inc : %.td |
| 175 | @echo "Building $< Intel assembly writer with tblgen" |
| 176 | $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-asm-writer -asmwriternum=1 -o $@ |
| 177 | |
| 178 | %GenInstrSelector.inc: %.td |
| 179 | @echo "Building $< instruction selector with tblgen" |
| 180 | $(VERB) $(TBLGEN) -I $(srcdir) $< -gen-instr-selector -o $@ |
| 181 | |
| 182 | TDFILES = $(wildcard $(srcdir)/*.td ) $(srcdir)/../Target.td |