1 ##===- tools/llvm-config/Makefile --------------------------*- Makefile -*-===##
3 # The LLVM Compiler Infrastructure
5 # This file was developed by Reid Spencer and Eric Kidd and is distributed under
6 # the University of Illinois Open Source 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_CXXFLAGS = ${CPP.BaseFlags} ${CXX.Flags}
25 # This is blank for now. We need to be careful about adding stuff here:
26 # LDFLAGS tend not to be portable, and we don't currently require the
27 # user to use libtool when linking against LLVM.
30 FinalLibDeps = $(PROJ_OBJ_DIR)/FinalLibDeps.txt
31 LibDeps = $(PROJ_OBJ_DIR)/LibDeps.txt
32 LibDepsTemp = $(PROJ_OBJ_DIR)/LibDeps.txt.tmp
33 GenLibDeps = $(PROJ_SRC_ROOT)/utils/GenLibDeps.pl
35 $(LibDepsTemp): $(GenLibDeps) $(LibDir) $(wildcard $(LibDir)/*.a $(LibDir)/*.o)
36 $(Echo) "Regenerating LibDeps.txt.tmp"
37 $(Verb) $(GenLibDeps) -flat $(LibDir) $(NM_PATH) > $(LibDepsTemp)
39 $(LibDeps): $(LibDepsTemp)
40 $(Verb) $(CMP) -s $@ $< || ( $(CP) $< $@ && \
41 $(EchoCmd) Updated LibDeps.txt because dependencies changes )
43 # Find all the cyclic dependencies between various LLVM libraries, so we
44 # don't have to process them at runtime.
45 $(FinalLibDeps): find-cycles.pl $(LibDeps)
46 $(Echo) "Checking for cyclic dependencies between LLVM libraries."
47 $(Verb) $(PERL) $< < $(LibDeps) > $@ || rm -f $@
49 # Rerun our configure substitutions as needed.
50 ConfigInIn = $(PROJ_SRC_DIR)/llvm-config.in.in
51 llvm-config.in: $(ConfigInIn) $(ConfigStatusScript)
52 $(Verb) cd $(PROJ_OBJ_ROOT) ; \
53 $(ConfigStatusScript) tools/llvm-config/llvm-config.in
55 # Build our final script.
56 $(ToolDir)/llvm-config: llvm-config.in $(FinalLibDeps)
57 $(Echo) "Building llvm-config script."
58 $(Verb) $(ECHO) 's,@LLVM_CXXFLAGS@,$(SUB_CXXFLAGS),' > temp.sed
59 $(Verb) $(ECHO) 's,@LLVM_LDFLAGS@,$(SUB_LDFLAGS),' >> temp.sed
60 $(Verb) $(ECHO) 's,@LLVM_BUILDMODE@,$(BuildMode),' >> temp.sed
61 $(Verb) $(SED) -f temp.sed < $< > $@
62 $(Verb) $(RM) temp.sed
63 $(Verb) cat $(FinalLibDeps) >> $@
67 # We don't have perl, just generate a dummy llvm-config
68 $(ToolDir)/llvm-config:
69 $(Echo) "Building place holder llvm-config script."
70 $(Verb) $(ECHO) 'echo llvm-config: Perl not found so llvm-config could not be generated' >> $@
74 # Hook into the standard Makefile rules.
75 all-local:: $(ToolDir)/llvm-config
77 $(Verb) $(RM) -f $(ToolDir)/llvm-config llvm-config.in $(FinalLibDeps) \
78 $(LibDeps) GenLibDeps.out
79 install-local:: all-local
80 $(Echo) Installing llvm-config
81 $(Verb) $(MKDIR) $(PROJ_bindir)
82 $(Verb) $(ScriptInstall) $(ToolDir)/llvm-config $(PROJ_bindir)