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
15 include $(LEVEL)/Makefile.common
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
22 # Combine preprocessor flags (except for -I) and CXX flags.
23 SUB_CPPFLAGS = ${CPP.BaseFlags}
24 SUB_CFLAGS = ${CPP.BaseFlags} ${C.Flags}
25 SUB_CXXFLAGS = ${CPP.BaseFlags} ${CXX.Flags}
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.
32 FinalLibDeps = $(PROJ_OBJ_DIR)/FinalLibDeps.txt
33 LibDeps = $(PROJ_OBJ_DIR)/LibDeps.txt
34 LibDepsTemp = $(PROJ_OBJ_DIR)/LibDeps.txt.tmp
35 GenLibDeps = $(PROJ_SRC_ROOT)/utils/GenLibDeps.pl
37 $(LibDepsTemp): $(GenLibDeps) $(LibDir) $(wildcard $(LibDir)/*.a $(LibDir)/*.o)
38 $(Echo) "Regenerating LibDeps.txt.tmp"
39 $(Verb) $(PERL) $(GenLibDeps) -flat $(LibDir) "$(NM_PATH)" > $(LibDepsTemp)
41 $(LibDeps): $(LibDepsTemp)
42 $(Verb) $(CMP) -s $@ $< || ( $(CP) $< $@ && \
43 $(EchoCmd) Updated LibDeps.txt because dependencies changed )
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 $@
51 # Rerun our configure substitutions as needed.
52 ConfigInIn = $(PROJ_SRC_DIR)/llvm-config.in.in
53 llvm-config.in: $(ConfigInIn) $(ConfigStatusScript)
54 $(Verb) cd $(PROJ_OBJ_ROOT) ; \
55 $(ConfigStatusScript) tools/llvm-config/llvm-config.in
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) >> $@
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' >> $@
78 # Hook into the standard Makefile rules.
79 all-local:: $(ToolDir)/llvm-config
81 $(Verb) $(RM) -f $(ToolDir)/llvm-config llvm-config.in $(FinalLibDeps) \
82 $(LibDeps) GenLibDeps.out
83 install-local:: all-local
84 $(Echo) Installing llvm-config
85 $(Verb) $(MKDIR) $(PROJ_bindir)
86 $(Verb) $(ScriptInstall) $(ToolDir)/llvm-config $(PROJ_bindir)