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 # This is blank for now.  We need to be careful about adding stuff here:
     34 # LDFLAGS tend not to be portable, and we don't currently require the
     35 # user to use libtool when linking against LLVM.
     36 SUB_LDFLAGS :=
     37 
     38 $(ObjDir)/BuildVariables.inc: $(BUILDVARIABLES_SRCPATH) Makefile $(ObjDir)/.dir
     39 	$(Echo) "Building llvm-config BuildVariables.inc file."
     40 	$(Verb) $(ECHO) 's/@LLVM_SRC_ROOT@/$(subst /,\/,$(LLVM_SRC_ROOT))/' \
     41 	  > temp.sed
     42 	$(Verb) $(ECHO) 's/@LLVM_OBJ_ROOT@/$(subst /,\/,$(LLVM_OBJ_ROOT))/' \
     43 	  >> temp.sed
     44 	$(Verb) $(ECHO) 's/@LLVM_CPPFLAGS@/$(subst /,\/,$(SUB_CPPFLAGS))/' \
     45 	  >> temp.sed
     46 	$(Verb) $(ECHO) 's/@LLVM_CFLAGS@/$(subst /,\/,$(SUB_CFLAGS))/' \
     47 	  >> temp.sed
     48 	$(Verb) $(ECHO) 's/@LLVM_CXXFLAGS@/$(subst /,\/,$(SUB_CXXFLAGS))/' \
     49 	  >> temp.sed
     50 	$(Verb) $(ECHO) 's/@LLVM_LDFLAGS@/$(subst /,\/,$(SUB_LDFLAGS))/' \
     51 	  >> temp.sed
     52 	$(Verb) $(ECHO) 's/@LLVM_BUILDMODE@/$(subst /,\/,$(BuildMode))/' \
     53 	  >> temp.sed
     54 	$(Verb) $(ECHO) 's/@LLVM_SYSTEM_LIBS@/$(subst /,\/,$(LIBS))/' \
     55 	  >> temp.sed
     56 	$(Verb) $(ECHO) 's/@LLVM_TARGETS_BUILT@/$(subst /,\/,$(TARGETS_TO_BUILD))/' \
     57 	  >> temp.sed
     58 	$(Verb) $(SED) -f temp.sed < $< > $@
     59 	$(Verb) $(RM) temp.sed
     60 
     61 # When cross-compiling, install a version of llvm-config that runs on the host.
     62 ifeq ($(LLVM_CROSS_COMPILING),1)
     63 install:: $(DESTDIR)$(PROJ_bindir)
     64 	$(Echo) Installing llvm-config-host
     65 	$(Verb) $(ProgInstall) $(BuildLLVMToolDir)/llvm-config \
     66 	  $(DESTDIR)$(PROJ_bindir)/$(program_prefix)llvm-config-host
     67 endif
     68