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
10LEVEL := ../..
11TOOLNAME := llvm-config
12USEDLIBS := LLVMSupport.a
13
14# We generate sources in the build directory, make sure it is in the include
15# paths.
16INCLUDE_BUILD_DIR := 1
17
18# This tool has no plugins, optimize startup time.
19TOOL_NO_EXPORTS := 1
20
21# Note that we have to use lazy expansion here.
22BUILDVARIABLES_SRCPATH = $(PROJ_SRC_ROOT)/tools/$(TOOLNAME)/BuildVariables.inc.in
23BUILDVARIABLES_OBJPATH = $(ObjDir)/BuildVariables.inc
24BUILT_SOURCES = $(BUILDVARIABLES_OBJPATH)
25
26include $(LEVEL)/Makefile.common
27
28# Combine preprocessor flags (except for -I) and CXX flags.
29SUB_CPPFLAGS := ${CPP.BaseFlags}
30SUB_CFLAGS   := ${CPP.BaseFlags} ${C.Flags}
31SUB_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.
35ifneq ($(TARGET_LIBS), )
36  LLVM_SYSTEM_LIBS := $(TARGET_LIBS)
37else
38  LLVM_SYSTEM_LIBS := $(LIBS)
39endif
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.
44SUB_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_LIBDIR_SUFFIX@//' \
63	  >> temp.sed
64	$(Verb) $(ECHO) 's/@LLVM_SYSTEM_LIBS@/$(subst /,\/,$(LLVM_SYSTEM_LIBS))/' \
65	  >> temp.sed
66	$(Verb) $(ECHO) 's/@LLVM_TARGETS_BUILT@/$(subst /,\/,$(TARGETS_TO_BUILD))/' \
67	  >> temp.sed
68	$(Verb) $(SED) -f temp.sed < $< > $@
69	$(Verb) $(RM) temp.sed
70
71# When cross-compiling, install a version of llvm-config that runs on the host.
72ifeq ($(LLVM_CROSS_COMPILING),1)
73install:: $(DESTDIR)$(PROJ_bindir)
74	$(Echo) Installing llvm-config-host
75	$(Verb) $(ProgInstall) $(BuildLLVMToolDir)/llvm-config \
76	  $(DESTDIR)$(PROJ_bindir)/$(program_prefix)llvm-config-host
77endif
78