1 ##===- tools/llvm-config/Makefile---------------------------*- Makefile -*-===##
3 # The LLVM Compiler Infrastructure
5 # This file is distributed under the University of Illinois Open Source
6 # License. See LICENSE.TXT for details.
8 ##===----------------------------------------------------------------------===##
11 TOOLNAME := llvm-config
12 USEDLIBS := LLVMSupport.a
14 # We generate sources in the build directory, make sure it is in the include
16 INCLUDE_BUILD_DIR := 1
18 # This tool has no plugins, optimize startup time.
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)
26 include $(LEVEL)/Makefile.common
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}
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)
38 LLVM_SYSTEM_LIBS := $(LIBS)
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.
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))/' \
50 $(Verb) $(ECHO) 's/@LLVM_OBJ_ROOT@/$(subst /,\/,$(LLVM_OBJ_ROOT))/' \
52 $(Verb) $(ECHO) 's/@LLVM_CPPFLAGS@/$(subst /,\/,$(SUB_CPPFLAGS))/' \
54 $(Verb) $(ECHO) 's/@LLVM_CFLAGS@/$(subst /,\/,$(SUB_CFLAGS))/' \
56 $(Verb) $(ECHO) 's/@LLVM_CXXFLAGS@/$(subst /,\/,$(SUB_CXXFLAGS))/' \
58 $(Verb) $(ECHO) 's/@LLVM_LDFLAGS@/$(subst /,\/,$(SUB_LDFLAGS))/' \
60 $(Verb) $(ECHO) 's/@LLVM_BUILDMODE@/$(subst /,\/,$(BuildMode))/' \
62 $(Verb) $(ECHO) 's/@LLVM_SYSTEM_LIBS@/$(subst /,\/,$(LLVM_SYSTEM_LIBS))/' \
64 $(Verb) $(ECHO) 's/@LLVM_TARGETS_BUILT@/$(subst /,\/,$(TARGETS_TO_BUILD))/' \
66 $(Verb) $(SED) -f temp.sed < $< > $@
67 $(Verb) $(RM) temp.sed
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