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