Home | History | Annotate | Download | only in llvm-config
      1 ##===- tools/llvm-config/Makefile---------------------------*- Makefile -*-===##
      2 # 
      3 #                     The LLVM Compiler Infrastructure
      4 #
      5 # This file is distributed under the University of Illinois Open Source
      6 # License. See LICENSE.TXT for details.
      7 # 
      8 ##===----------------------------------------------------------------------===##
      9 
     10 LEVEL := ../..
     11 TOOLNAME := llvm-config
     12 USEDLIBS := LLVMSupport.a
     13 
     14 # We generate sources in the build directory, make sure it is in the include
     15 # paths.
     16 INCLUDE_BUILD_DIR := 1
     17 
     18 # This tool has no plugins, optimize startup time.
     19 TOOL_NO_EXPORTS := 1
     20 
     21 # Note that we have to use lazy expansion here.
     22 BUILDVARIABLES_SRCPATH = $(PROJ_SRC_ROOT)/tools/$(TOOLNAME)/BuildVariables.inc.in
     23 BUILDVARIABLES_OBJPATH = $(ObjDir)/BuildVariables.inc
     24 BUILT_SOURCES = $(BUILDVARIABLES_OBJPATH)
     25 
     26 include $(LEVEL)/Makefile.common
     27 
     28 # Combine preprocessor flags (except for -I) and CXX flags.
     29 SUB_CPPFLAGS := ${CPP.BaseFlags}
     30 SUB_CFLAGS   := ${CPP.BaseFlags} ${C.Flags}
     31 SUB_CXXFLAGS := ${CPP.BaseFlags} ${CXX.Flags}
     32 
     33 # Override LIBS with TARGET's LIBS for cross compilation.
     34 # FIXME: Host's llvm-config is not generated. It's for target's.
     35 ifneq ($(TARGET_LIBS), )
     36   LLVM_SYSTEM_LIBS := $(TARGET_LIBS)
     37 else
     38   LLVM_SYSTEM_LIBS := $(LIBS)
     39 endif
     40 
     41 ifneq ($(REQUIRES_RTTI), 1)
     42   LLVM_HAS_RTTI := NO
     43 else
     44   LLVM_HAS_RTTI := YES
     45 endif
     46 
     47 # This is blank for now.  We need to be careful about adding stuff here:
     48 # LDFLAGS tend not to be portable, and we don't currently require the
     49 # user to use libtool when linking against LLVM.
     50 SUB_LDFLAGS :=
     51 
     52 $(ObjDir)/BuildVariables.inc: $(BUILDVARIABLES_SRCPATH) Makefile $(ObjDir)/.dir
     53 	$(Echo) "Building llvm-config BuildVariables.inc file."
     54 	$(Verb) $(ECHO) 's/@LLVM_SRC_ROOT@/$(subst /,\/,$(LLVM_SRC_ROOT))/' \
     55 	  > temp.sed
     56 	$(Verb) $(ECHO) 's/@LLVM_OBJ_ROOT@/$(subst /,\/,$(LLVM_OBJ_ROOT))/' \
     57 	  >> temp.sed
     58 	$(Verb) $(ECHO) 's/@LLVM_CPPFLAGS@/$(subst /,\/,$(SUB_CPPFLAGS))/' \
     59 	  >> temp.sed
     60 	$(Verb) $(ECHO) 's/@LLVM_CFLAGS@/$(subst /,\/,$(SUB_CFLAGS))/' \
     61 	  >> temp.sed
     62 	$(Verb) $(ECHO) 's/@LLVM_CXXFLAGS@/$(subst /,\/,$(SUB_CXXFLAGS))/' \
     63 	  >> temp.sed
     64 	$(Verb) $(ECHO) 's/@LLVM_LDFLAGS@/$(subst /,\/,$(SUB_LDFLAGS))/' \
     65 	  >> temp.sed
     66 	$(Verb) $(ECHO) 's/@LLVM_BUILDMODE@/$(subst /,\/,$(BuildMode))/' \
     67 	  >> temp.sed
     68 	$(Verb) $(ECHO) 's/@LLVM_LIBDIR_SUFFIX@//' \
     69 	  >> temp.sed
     70 	$(Verb) $(ECHO) 's/@LLVM_SYSTEM_LIBS@/$(subst /,\/,$(LLVM_SYSTEM_LIBS))/' \
     71 	  >> temp.sed
     72 	$(Verb) $(ECHO) 's/@LLVM_TARGETS_BUILT@/$(subst /,\/,$(TARGETS_TO_BUILD))/' \
     73 	  >> temp.sed
     74 	$(if $(filter-out $(ENABLE_SHARED),0),\
     75 	  $(Verb) $(ECHO) 's/@LLVM_BUILD_LLVM_DYLIB@/ON/',\
     76 	  $(Verb) $(ECHO) 's/@LLVM_BUILD_LLVM_DYLIB@/OFF/') \
     77 	  >> temp.sed
     78 	$(Verb) $(ECHO) 's/@LLVM_ENABLE_SHARED@/OFF/' \
     79 	  >> temp.sed
     80 	$(Verb) $(ECHO) 's/@LLVM_DYLIB_COMPONENTS@/all/' \
     81 	  >> temp.sed
     82 	$(Verb) $(ECHO) 's/@LLVM_BUILD_SYSTEM@/autoconf/' \
     83 	  >> temp.sed
     84 	$(Verb) $(ECHO) 's/@LLVM_HAS_RTTI@/$(LLVM_HAS_RTTI)/' \
     85 	  >> temp.sed
     86 	$(Verb) $(SED) -f temp.sed < $< > $@
     87 	$(Verb) $(RM) temp.sed
     88 
     89 # When cross-compiling, install a version of llvm-config that runs on the host.
     90 ifeq ($(LLVM_CROSS_COMPILING),1)
     91 install:: $(DESTDIR)$(PROJ_bindir)
     92 	$(Echo) Installing llvm-config-host
     93 	$(Verb) $(ProgInstall) $(BuildLLVMToolDir)/llvm-config \
     94 	  $(DESTDIR)$(PROJ_bindir)/$(program_prefix)llvm-config-host
     95 endif
     96