blob: de89d290353a1406d51540a17efae3fc6a28bac4 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001##===- tools/llvm-config/Makefile --------------------------*- Makefile -*-===##
2#
3# The LLVM Compiler Infrastructure
4#
Chris Lattnere692fc82007-12-29 20:07:17 +00005# This file is distributed under the University of Illinois Open Source
6# License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007#
8##===----------------------------------------------------------------------===##
9
10LEVEL = ../..
11
12EXTRA_DIST = LibDeps.txt FinalLibDeps.txt llvm-config.in.in find-cycles.pl
13REQUIRES_EH := 1
14
15include $(LEVEL)/Makefile.common
16
17# If we don't have Perl, we can't generate the library dependencies upon which
18# llvm-config depends. Therefore, only if we detect perl will we do anything
19# useful.
20ifeq ($(HAVE_PERL),1)
21
22# Combine preprocessor flags (except for -I) and CXX flags.
23SUB_CPPFLAGS = ${CPP.BaseFlags}
24SUB_CFLAGS = ${CPP.BaseFlags} ${C.Flags}
25SUB_CXXFLAGS = ${CPP.BaseFlags} ${CXX.Flags}
26
27# This is blank for now. We need to be careful about adding stuff here:
28# LDFLAGS tend not to be portable, and we don't currently require the
29# user to use libtool when linking against LLVM.
30SUB_LDFLAGS =
31
32FinalLibDeps = $(PROJ_OBJ_DIR)/FinalLibDeps.txt
33LibDeps = $(PROJ_OBJ_DIR)/LibDeps.txt
34LibDepsTemp = $(PROJ_OBJ_DIR)/LibDeps.txt.tmp
35GenLibDeps = $(PROJ_SRC_ROOT)/utils/GenLibDeps.pl
36
37$(LibDepsTemp): $(GenLibDeps) $(LibDir) $(wildcard $(LibDir)/*.a $(LibDir)/*.o)
38 $(Echo) "Regenerating LibDeps.txt.tmp"
Ted Kremenek4b07b9c2007-11-27 17:53:54 +000039 $(Verb) $(PERL) $(GenLibDeps) -flat $(LibDir) "$(NM_PATH)" > $(LibDepsTemp)
Dan Gohmanf17a25c2007-07-18 16:29:46 +000040
41$(LibDeps): $(LibDepsTemp)
42 $(Verb) $(CMP) -s $@ $< || ( $(CP) $< $@ && \
43 $(EchoCmd) Updated LibDeps.txt because dependencies changed )
44
45# Find all the cyclic dependencies between various LLVM libraries, so we
46# don't have to process them at runtime.
47$(FinalLibDeps): find-cycles.pl $(LibDeps)
48 $(Echo) "Checking for cyclic dependencies between LLVM libraries."
49 $(Verb) $(PERL) $< < $(LibDeps) > $@ || rm -f $@
50
51# Rerun our configure substitutions as needed.
52ConfigInIn = $(PROJ_SRC_DIR)/llvm-config.in.in
53llvm-config.in: $(ConfigInIn) $(ConfigStatusScript)
54 $(Verb) cd $(PROJ_OBJ_ROOT) ; \
55 $(ConfigStatusScript) tools/llvm-config/llvm-config.in
56
57# Build our final script.
58$(ToolDir)/llvm-config: llvm-config.in $(FinalLibDeps)
59 $(Echo) "Building llvm-config script."
60 $(Verb) $(ECHO) 's,@LLVM_CPPFLAGS@,$(SUB_CPPFLAGS),' > temp.sed
61 $(Verb) $(ECHO) 's,@LLVM_CFLAGS@,$(SUB_CFLAGS),' >> temp.sed
62 $(Verb) $(ECHO) 's,@LLVM_CXXFLAGS@,$(SUB_CXXFLAGS),' >> temp.sed
63 $(Verb) $(ECHO) 's,@LLVM_LDFLAGS@,$(SUB_LDFLAGS),' >> temp.sed
64 $(Verb) $(ECHO) 's,@LLVM_BUILDMODE@,$(BuildMode),' >> temp.sed
65 $(Verb) $(SED) -f temp.sed < $< > $@
66 $(Verb) $(RM) temp.sed
67 $(Verb) cat $(FinalLibDeps) >> $@
68 $(Verb) chmod +x $@
69
70else
71# We don't have perl, just generate a dummy llvm-config
72$(ToolDir)/llvm-config:
73 $(Echo) "Building place holder llvm-config script."
74 $(Verb) $(ECHO) 'echo llvm-config: Perl not found so llvm-config could not be generated' >> $@
75 $(Verb) chmod +x $@
76
77endif
78# Hook into the standard Makefile rules.
79all-local:: $(ToolDir)/llvm-config
80clean-local::
81 $(Verb) $(RM) -f $(ToolDir)/llvm-config llvm-config.in $(FinalLibDeps) \
82 $(LibDeps) GenLibDeps.out
83install-local:: all-local
84 $(Echo) Installing llvm-config
85 $(Verb) $(MKDIR) $(PROJ_bindir)
86 $(Verb) $(ScriptInstall) $(ToolDir)/llvm-config $(PROJ_bindir)
87