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 GenLibDeps = $(PROJ_SRC_ROOT)/utils/GenLibDeps.pl
34 $(LibDeps): $(GenLibDeps) $(LibDir) $(wildcard $(LibDir)/*.a $(LibDir)/*.o)
35 $(Echo) "Regenerating LibDeps.txt"
36 $(Verb) $(GenLibDeps) -flat $(LibDir) $(NM_PATH) | sort > $(LibDeps)
38 # Find all the cyclic dependencies between various LLVM libraries, so we
39 # don't have to process them at runtime.
40 $(FinalLibDeps): find-cycles.pl $(LibDeps)
41 $(Echo) "Finding cyclic dependencies between LLVM libraries."
42 -$(Verb) $(PERL) $< < $(LibDeps) > $@
44 # Rerun our configure substitutions as needed.
45 ConfigInIn = $(PROJ_SRC_DIR)/llvm-config.in.in
46 llvm-config.in: $(ConfigInIn) $(ConfigStatusScript)
47 $(Verb) cd $(PROJ_OBJ_ROOT) ; \
48 $(ConfigStatusScript) tools/llvm-config/llvm-config.in
50 # Build our final script.
51 $(ToolDir)/llvm-config: llvm-config.in $(FinalLibDeps)
52 $(Echo) "Building llvm-config script."
53 $(Verb) $(ECHO) 's,@LLVM_CXXFLAGS@,$(SUB_CXXFLAGS),' > temp.sed
54 $(Verb) $(ECHO) 's,@LLVM_LDFLAGS@,$(SUB_LDFLAGS),' >> temp.sed
55 $(Verb) $(ECHO) 's,@LLVM_BUILDMODE@,$(BuildMode),' >> temp.sed
56 $(Verb) $(SED) -f temp.sed < $< > $@
57 $(Verb) $(RM) temp.sed
58 $(Verb) cat $(FinalLibDeps) >> $@
62 # We don't have perl, just generate a dummy llvm-config
63 $(ToolDir)/llvm-config:
64 $(Echo) "Building place holder llvm-config script."
65 $(Verb) $(ECHO) 'echo llvm-config: Perl not found so llvm-config could not be generated' >> $@
69 # Hook into the standard Makefile rules.
70 all-local:: $(ToolDir)/llvm-config
72 $(Verb) $(RM) -f $(ToolDir)/llvm-config llvm-config.in $(FinalLibDeps) \
73 $(LibDeps) GenLibDeps.out
74 install-local:: all-local
75 $(Echo) Installing llvm-config
76 $(Verb) $(MKDIR) $(PROJ_bindir)
77 $(Verb) $(ScriptInstall) $(ToolDir)/llvm-config $(PROJ_bindir)