X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=Makefile.rules;h=39c741a8838c196a294dbe5529bf000c352fe815;hb=dbd38d7f64697b72364387e25dd062c5ce276466;hp=de9f24ef2ad73c2901712e5055b71a989f27a2d9;hpb=e0acb769f4e11f3b7cc263a36e686581e3e38c18;p=oota-llvm.git diff --git a/Makefile.rules b/Makefile.rules index de9f24ef2ad..39c741a8838 100644 --- a/Makefile.rules +++ b/Makefile.rules @@ -77,7 +77,7 @@ ifneq ($(MakefileConfigIn),) PreConditions += $(MakefileConfig) endif -preconditions : $(PreConditions) +preconditions: $(PreConditions) #------------------------------------------------------------------------ # Make sure the BUILT_SOURCES are built first @@ -108,6 +108,9 @@ spotless: else \ $(EchoCmd) "make spotless" can only be run from $(PROJ_OBJ_ROOT); \ fi +else +spotless: + $(EchoCmd) "spotless target not supported for objdir == srcdir" endif $(BUILT_SOURCES) : $(ObjMakefiles) @@ -343,6 +346,10 @@ endif CompileCommonOpts := -Wall -W -Wwrite-strings -Wno-unused +ifeq ($(OS),HP-UX) + CompileCommonOpts += -D_REENTRANT -D_HPUX_SOURCE +endif + LD.Flags += -L$(LibDir) -L$(LLVMLibDir) CPP.Flags += -I$(PROJ_OBJ_DIR) -I$(PROJ_SRC_DIR) \ -I$(PROJ_OBJ_ROOT)/include \ @@ -355,10 +362,13 @@ Compile.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags) LTCompile.C = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C) BCCompile.C = $(LLVMGCCWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \ $(C.Flags) -c +Preprocess.C = $(CC) $(CPP.Flags) $(CompileCommonOpts) -E $(C.Flags) + Compile.CXX = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX) BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \ $(CXX.Flags) -c +Preprocess.CXX= $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -E Link = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \ $(CompileCommonOpts) $(LD.Flags) $(Strip) Relink = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \ @@ -419,17 +429,10 @@ endif # in the file so they get built before dependencies #--------------------------------------------------------- -$(PROJ_bindir): - $(Verb) $(MKDIR) $(PROJ_bindir) - -$(PROJ_libdir): - $(Verb) $(MKDIR) $(PROJ_libdir) - -$(PROJ_includedir): - $(Verb) $(MKDIR) $(PROJ_includedir) - -$(PROJ_etcdir): - $(Verb) $(MKDIR) $(PROJ_etcdir) +$(PROJ_bindir): $(PROJ_bindir)/.dir +$(PROJ_libdir): $(PROJ_libdir)/.dir +$(PROJ_includedir): $(PROJ_includedir)/.dir +$(PROJ_etcdir): $(PROJ_etcdir)/.dir # To create other directories, as needed, and timestamp their creation %/.dir: @@ -475,9 +478,9 @@ $(RecursiveTargets):: done endif -#--------------------------------------------------------- +#----------------------------------------------------------- # Handle the PARALLEL_DIRS options for parallel construction -#--------------------------------------------------------- +#----------------------------------------------------------- ifdef PARALLEL_DIRS SubDirs += $(PARALLEL_DIRS) @@ -549,6 +552,100 @@ uninstall-local:: endif +############################################################################### +# Set up variables for building libararies +############################################################################### + +#--------------------------------------------------------- +# Handle the special "JIT" value for LLVM_LIBS which is a +# shorthand for a bunch of libraries that get the correct +# JIT support for a library or a tool that runs JIT. +#--------------------------------------------------------- +ifeq ($(LLVMLIBS),JIT) + +# Make sure we can get our own symbols in the tool +Link += -dlopen self + +# Generic JIT libraries +JIT_LIBS := LLVMInterpreter LLVMJIT LLVMCodeGen LLVMExecutionEngine + +# You can enable the X86 JIT on a non-X86 host by setting the flag +# ENABLE_X86_JIT on the make command line. If not, it will still be +# enabled automagically on an X86 host. +ifeq ($(ARCH), x86) + ENABLE_X86_JIT = 1 +endif + +# What the X86 JIT requires +ifdef ENABLE_X86_JIT + JIT_LIBS += LLVMX86 LLVMSelectionDAG +endif + +# You can enable the SparcV9 JIT on a non-SparcV9 host by setting the flag +# ENABLE_SPARCV9_JIT on the make command line. If not, it will still be +# enabled automagically on an SparcV9 host. +ifeq ($(ARCH), Sparc) + ENABLE_SPARCV9_JIT = 1 +endif + +# What the Sparc JIT requires +ifdef ENABLE_SPARCV9_JIT + JIT_LIBS += LLVMSparcV9 LLVMSparcV9ModuloSched LLVMSparcV9InstrSched \ + LLVMSparcV9LiveVar LLVMInstrumentation.a \ + LLVMBCWriter LLVMTransforms.a LLVMipo.a LLVMipa.a \ + LLVMDataStructure LLVMSparcV9RegAlloc +endif + +# You can enable the PowerPC JIT on a non-PowerPC host by setting the flag +# ENABLE_PPC_JIT on the make command line. If not, it will still be +# enabled automagically on an PowerPC host. +ifeq ($(ARCH), PowerPC) + ENABLE_PPC_JIT = 1 +endif + +# What the PowerPC JIT requires +ifdef ENABLE_PPC_JIT + JIT_LIBS += LLVMPowerPC LLVMSelectionDAG +endif + +# You can enable the Alpha JIT on a non-Alpha host by setting the flag +# ENABLE_ALPHA_JIT on the make command line. If not, it will still be +# enabled automagically on an Alpha host. +ifeq ($(ARCH), Alpha) + ENABLE_ALPHA_JIT = 1 +endif + +# What the Alpha JIT requires +ifdef ENABLE_ALPHA_JIT + JIT_LIBS += LLVMAlpha LLVMSelectionDAG +endif + +LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts.a LLVMTransformUtils.a LLVMAnalysis.a \ + LLVMBCReader LLVMCore LLVMSupport.a LLVMTarget.a LLVMbzip2 \ + LLVMSystem.a $(PLATFORMLIBDL) +endif + +#--------------------------------------------------------- +# Define various command line options pertaining to the +# libraries needed when linking. There are "Proj" libs +# (defined by the user's project) and "LLVM" libs (defined +# by the # LLVM project). +#--------------------------------------------------------- +# Some versions of gcc on Alpha produce too many symbols, so use a .a file +ifeq ($(ARCH),Alpha) +USEDLIBS := $(subst LLVMCore, LLVMCore.a, $(USEDLIBS)) +LLVMLIBS := $(subst LLVMCore, LLVMCore.a, $(LLVMLIBS)) +endif + +ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS))) +ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions)) +LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS))) +LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions)) +ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS))) +LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS))) +ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs)) +LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs)) + ############################################################################### # Library Build Rules: Four ways to build a library ############################################################################### @@ -563,7 +660,7 @@ endif ifdef MODULE_NAME ifeq ($(strip $(LLVMGCC)),) -$(warning Modules require llvm-gcc but no llvm-gcc is available) +$(warning Modules require llvm-gcc but no llvm-gcc is available ****) else Module := $(LibDir)/$(MODULE_NAME).bc @@ -574,7 +671,7 @@ LinkModule += -Xlinker -internalize-public-api-file=$(EXPORTED_SYMBOL_FILE) endif $(Module): $(BUILT_SOURCES) $(ObjectsBC) $(LibDir)/.dir $(GCCLD) - $(Echo) Building $(BuildMOde) Bytecode Module $(notdir $@) + $(Echo) Building $(BuildMode) Bytecode Module $(notdir $@) $(Verb) $(LinkModule) -o $@ $(ObjectsBC) all-local:: $(Module) @@ -630,10 +727,18 @@ ifdef SHARED_LIBRARY all-local:: $(LibName.LA) +ifdef LINK_LIBS_IN_SHARED +$(LibName.LA): $(ObjectsLO) $(LibDir)/.dir + $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT) + $(Verb) $(Link) -o $@ $(ObjectsLO) \ + $(ProjLibsOptions) $(LLVMLibsOptions) + $(Verb) $(LTInstall) $@ $(LibDir) +else $(LibName.LA): $(ObjectsLO) $(LibDir)/.dir $(Echo) Linking $(BuildMode) Shared Library $(LIBRARYNAME)$(SHLIBEXT) $(Verb) $(Link) -o $@ $(ObjectsLO) $(Verb) $(LTInstall) $@ $(LibDir) +endif clean-local:: ifneq ($(strip $(LibName.LA)),) @@ -663,12 +768,14 @@ endif #--------------------------------------------------------- ifdef BYTECODE_LIBRARY ifeq ($(strip $(LLVMGCC)),) -$(warning Bytecode libraries require llvm-gcc which could not be found) +$(warning Bytecode libraries require llvm-gcc which could not be found ****) else # make the C and C++ compilers strip debug info out of bytecode libraries. +ifndef DEBUG_RUNTIME BCCompile.C += -Wa,-strip-debug BCCompile.CXX += -Wa,-strip-debug +endif all-local:: $(LibName.BCA) @@ -722,10 +829,18 @@ endif #--------------------------------------------------------- # ReLinked Library Targets: -# If the user didn't explicitly forbid building a -# relinked then we provide targets for building them. +# If the user explicitly requests a relinked library with +# BUILD_RELINKED, provide it. Otherwise, if they specify +# neither of BUILD_ARCHIVE or DONT_BUILD_RELINKED, give +# them one. #--------------------------------------------------------- +ifndef BUILD_ARCHIVE ifndef DONT_BUILD_RELINKED +BUILD_RELINKED = 1 +endif +endif + +ifdef BUILD_RELINKED all-local:: $(LibName.O) @@ -796,79 +911,14 @@ endif ifdef TOOLNAME -#--------------------------------------------------------- -# Handle the special "JIT" value for LLVM_LIBS which is a -# shorthand for a bunch of libraries that get the correct -# JIT support for a tool that runs JIT. -#--------------------------------------------------------- -ifeq ($(LLVMLIBS),JIT) - -# Make sure we can get our own symbols in the tool -Link += -dlopen self - -# Generic JIT libraries -JIT_LIBS := LLVMInterpreter LLVMJIT LLVMCodeGen LLVMExecutionEngine - -# You can enable the X86 JIT on a non-X86 host by setting the flag -# ENABLE_X86_JIT on the make command line. If not, it will still be -# enabled automagically on an X86 host. -ifeq ($(ARCH), x86) - ENABLE_X86_JIT = 1 -endif - -# What the X86 JIT requires -ifdef ENABLE_X86_JIT - JIT_LIBS += LLVMX86 LLVMSelectionDAG -endif - -# You can enable the SparcV9 JIT on a non-SparcV9 host by setting the flag -# ENABLE_SPARCV9_JIT on the make command line. If not, it will still be -# enabled automagically on an SparcV9 host. -ifeq ($(ARCH), Sparc) - ENABLE_SPARCV9_JIT = 1 -endif - -# What the Sparc JIT requires -ifdef ENABLE_SPARCV9_JIT - JIT_LIBS += LLVMSparcV9 LLVMSparcV9ModuloSched LLVMSparcV9InstrSched \ - LLVMSparcV9LiveVar LLVMInstrumentation.a LLVMProfilePaths \ - LLVMBCWriter LLVMTransforms.a LLVMipo.a LLVMipa.a \ - LLVMDataStructure.a LLVMSparcV9RegAlloc -endif - -# You can enable the PowerPC JIT on a non-PowerPC host by setting the flag -# ENABLE_PPC_JIT on the make command line. If not, it will still be -# enabled automagically on an PowerPC host. -ifeq ($(ARCH), PowerPC) - ENABLE_PPC_JIT = 1 -endif - -# What the PowerPC JIT requires -ifdef ENABLE_PPC_JIT - JIT_LIBS += LLVMPowerPC -endif - -LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts LLVMAnalysis.a LLVMTransformUtils.a \ - LLVMBCReader LLVMCore LLVMSupport.a LLVMTarget.a LLVMbzip2 \ - LLVMSystem.a $(PLATFORMLIBDL) -endif - #--------------------------------------------------------- # Set up variables for building a tool. #--------------------------------------------------------- ifdef EXAMPLE_TOOL -ToolBuildPath := $(ExmplDir)/$(TOOLNAME)$(EXEEXT) +ToolBuildPath := $(ExmplDir)/$(strip $(TOOLNAME))$(EXEEXT) else -ToolBuildPath := $(ToolDir)/$(TOOLNAME)$(EXEEXT) +ToolBuildPath := $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT) endif -ProjLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(USEDLIBS))) -ProjLibsOptions := $(patsubst %.o, $(LibDir)/%.o, $(ProjLibsOptions)) -LLVMLibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(LLVMLIBS))) -LLVMLibsOptions := $(patsubst %.o, $(LLVMLibDir)/%.o, $(LLVMLibsOptions)) -ProjUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(USEDLIBS))) -LLVMUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(LLVMLIBS))) -ProjLibsPaths := $(addprefix $(LibDir)/,$(ProjUsedLibs)) -LLVMLibsPaths := $(addprefix $(LLVMLibDir)/,$(LLVMUsedLibs)) #--------------------------------------------------------- # Tell make that we need to rebuild subdirectories before @@ -968,6 +1018,20 @@ $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES) endif +## Rules for building preprocessed (.i/.ii) outputs. +$(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES) + $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file" + $(Verb) $(Preprocess.CXX) $< -o $@ + +$(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES) + $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file" + $(Verb) $(Preprocess.CXX) $< -o $@ + + $(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES) + $(Echo) "Compiling $*.c for $(BuildMode) build to .i file" + $(Verb) $(Preprocess.C) $< -o $@ + + #--------------------------------------------------------- # Create .bc files in the ObjDir directory from .cpp .cc and .c files... #--------------------------------------------------------- @@ -1049,7 +1113,7 @@ $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS) ifdef TARGET -TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td) +TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td $(LLVM_SRC_ROOT)/lib/Target/TargetSelectionDAG.td) INCFiles := $(filter %.inc,$(BUILT_SOURCES)) INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp) .PRECIOUS: $(INCTMPFiles) $(INCFiles) @@ -1106,6 +1170,16 @@ $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir $(Echo) "Building $( $@ + > $(PROJ_SRC_DIR)/$*.cpp + $(Echo) "*** DON'T FORGET TO CHECK IN $*.cpp (generated file)" + +LexObjs := $(patsubst %.l,$(ObjDir)/%.o,$(LexFiles)) +$(LexObjs): $(ObjDir)/%.o : $(PROJ_SRC_DIR)/%.cpp clean-local:: -$(Verb) $(RM) -f $(LexOutput) - $(Verb) $(RM) -f $(LexOutput) endif @@ -1155,7 +1232,6 @@ endif YaccFiles := $(filter %.y,$(Sources)) ifneq ($(YaccFiles),) -YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.h .cpp .output) .PRECIOUS: $(YaccOutput) @@ -1164,16 +1240,21 @@ YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.h .cpp .output) %.cpp: %.y %.h: %.y -# Rule for building the bison parsers... -%.cpp %.h : %.y +# Rule for building the bison based parsers... +$(PROJ_SRC_DIR)/%.cpp $(PROJ_SRC_DIR)/%.h : $(PROJ_SRC_DIR)/%.y $(Echo) "Bisoning $*.y" - $(Verb) $(BISON) -v -d -p $(