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@/$(subst /,\/,$(SUB_CPPFLAGS))/' \
62 $(Verb
) $(ECHO
) 's/@LLVM_CFLAGS@/$(subst /,\/,$(SUB_CFLAGS))/' \
64 $(Verb
) $(ECHO
) 's/@LLVM_CXXFLAGS@/$(subst /,\/,$(SUB_CXXFLAGS))/' \
66 $(Verb
) $(ECHO
) 's/@LLVM_LDFLAGS@/$(subst /,\/,$(SUB_LDFLAGS))/' \
68 $(Verb
) $(ECHO
) 's/@LLVM_BUILDMODE@/$(subst /,\/,$(BuildMode))/' \
70 $(Verb
) $(SED
) -f temp.sed
< $< > $@
71 $(Verb
) $(RM
) temp.sed
72 $(Verb
) cat
$(FinalLibDeps
) >> $@
76 # We don't have perl, just generate a dummy llvm-config
77 $(ToolDir
)/llvm-config
:
78 $(Echo
) "Building place holder llvm-config script."
79 $(Verb
) $(ECHO
) 'echo llvm-config: Perl not found so llvm-config could not be generated' >> $@
83 # Hook into the standard Makefile rules.
84 all-local
:: $(ToolDir
)/llvm-config
86 $(Verb
) $(RM
) -f
$(ToolDir
)/llvm-config llvm-config.in
$(FinalLibDeps
) \
87 $(LibDeps
) GenLibDeps.out
88 install-local
:: all-local
89 $(Echo
) Installing llvm-config
90 $(Verb
) $(MKDIR
) $(PROJ_bindir
)
91 $(Verb
) $(ScriptInstall
) $(ToolDir
)/llvm-config
$(PROJ_bindir
)