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 ##===----------------------------------------------------------------------===##
12 EXTRA_DIST = LibDeps.txt FinalLibDeps.txt llvm-config.in.in find-cycles.pl
14 include $(LEVEL)/Makefile.common
16 # If we don't have Perl, we can't generate the library dependencies upon which
17 # llvm-config depends. Therefore, only if we detect perl will we do anything
21 # Combine preprocessor flags (except for -I) and CXX flags.
22 SUB_CPPFLAGS = ${CPP.BaseFlags}
23 SUB_CFLAGS = ${CPP.BaseFlags} ${C.Flags}
24 SUB_CXXFLAGS = ${CPP.BaseFlags} ${CXX.Flags}
26 # This is blank for now. We need to be careful about adding stuff here:
27 # LDFLAGS tend not to be portable, and we don't currently require the
28 # user to use libtool when linking against LLVM.
31 FinalLibDeps = $(PROJ_OBJ_DIR)/FinalLibDeps.txt
32 LibDeps = $(PROJ_OBJ_DIR)/LibDeps.txt
33 LibDepsTemp = $(PROJ_OBJ_DIR)/LibDeps.txt.tmp
34 GenLibDeps = $(PROJ_SRC_ROOT)/utils/GenLibDeps.pl
36 $(LibDepsTemp): $(GenLibDeps) $(LibDir) $(wildcard $(LibDir)/*.a $(LibDir)/*.o)
37 $(Echo) "Regenerating LibDeps.txt.tmp"
38 $(Verb) $(PERL) $(GenLibDeps) -flat $(LibDir) "$(NM_PATH)" > $(LibDepsTemp)
40 $(LibDeps): $(LibDepsTemp)
41 $(Verb) $(CMP) -s $@ $< || ( $(CP) $< $@ && \
42 $(EchoCmd) Updated LibDeps.txt because dependencies changed )
44 # Find all the cyclic dependencies between various LLVM libraries, so we
45 # don't have to process them at runtime.
46 $(FinalLibDeps): find-cycles.pl $(LibDeps)
47 $(Echo) "Checking for cyclic dependencies between LLVM libraries."
48 $(Verb) $(PERL) $< < $(LibDeps) > $@ || rm -f $@
50 # Rerun our configure substitutions as needed.
51 ConfigInIn = $(PROJ_SRC_DIR)/llvm-config.in.in
52 llvm-config.in: $(ConfigInIn) $(ConfigStatusScript)
53 $(Verb) cd $(PROJ_OBJ_ROOT) ; \
54 $(ConfigStatusScript) tools/llvm-config/llvm-config.in
56 # Build our final script.
57 $(ToolDir)/llvm-config: llvm-config.in $(FinalLibDeps)
58 $(Echo) "Building llvm-config script."
59 $(Verb) $(ECHO) 's/@LLVM_CPPFLAGS@/$(subst /,\/,$(SUB_CPPFLAGS))/' \
61 $(Verb) $(ECHO) 's/@LLVM_CFLAGS@/$(subst /,\/,$(SUB_CFLAGS))/' \
63 $(Verb) $(ECHO) 's/@LLVM_CXXFLAGS@/$(subst /,\/,$(SUB_CXXFLAGS))/' \
65 $(Verb) $(ECHO) 's/@LLVM_LDFLAGS@/$(subst /,\/,$(SUB_LDFLAGS))/' \
67 $(Verb) $(ECHO) 's/@LLVM_BUILDMODE@/$(subst /,\/,$(BuildMode))/' \
69 $(Verb) $(ECHO) 's/@LLVM_OBJ_SUFFIX@/$(subst /,\/,/$(BuildMode))/' \
71 $(Verb) $(SED) -f temp.sed < $< > $@
72 $(Verb) $(RM) temp.sed
73 $(Verb) cat $(FinalLibDeps) >> $@
77 # We don't have perl, just generate a dummy llvm-config
78 $(ToolDir)/llvm-config:
79 $(Echo) "Building place holder llvm-config script."
80 $(Verb) $(ECHO) 'echo llvm-config: Perl not found so llvm-config could not be generated' >> $@
84 # Hook into the standard Makefile rules.
85 all-local:: $(ToolDir)/llvm-config
87 $(Verb) $(RM) -f $(ToolDir)/llvm-config llvm-config.in $(FinalLibDeps) \
88 $(LibDeps) GenLibDeps.out
89 install-local:: all-local
90 $(Echo) Installing llvm-config
91 $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_bindir)
92 $(Verb) $(ScriptInstall) $(ToolDir)/llvm-config $(DESTDIR)$(PROJ_bindir)