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 llvm-config-perobj
: llvm-config.in
$(GenLibDeps
) $(LibDir
) $(wildcard $(LibDir
)/*.a
)
57 $(Echo
) "Generating llvm-config-perobj"
58 $(Verb
) $(PERL
) $(GenLibDeps
) -perobj
-flat
$(LibDir
) "$(NM_PATH)" >PerobjDeps.txt
59 $(Echo
) "Checking for cyclic dependencies between LLVM objects."
60 $(Verb
) $(PERL
) $(PROJ_SRC_DIR
)/find-cycles.pl
< PerobjDepsIncl.txt
> PerobjDepsInclFinal.txt ||
rm -f
$@
61 $(Verb
) $(ECHO
) 's/@LLVM_CPPFLAGS@/$(subst /,\/,$(SUB_CPPFLAGS))/' \
63 $(Verb
) $(ECHO
) 's/@LLVM_CFLAGS@/$(subst /,\/,$(SUB_CFLAGS))/' \
65 $(Verb
) $(ECHO
) 's/@LLVM_CXXFLAGS@/$(subst /,\/,$(SUB_CXXFLAGS))/' \
67 $(Verb
) $(ECHO
) 's/@LLVM_LDFLAGS@/$(subst /,\/,$(SUB_LDFLAGS))/' \
69 $(Verb
) $(ECHO
) 's/@LLVM_BUILDMODE@/$(subst /,\/,$(BuildMode))/' \
71 $(Verb
) $(SED
) -f temp.sed
< $< > $@
72 $(Verb
) $(RM
) temp.sed
73 $(Verb
) cat PerobjDepsFinal.txt
>> $@
76 llvm-config-perobjincl
: llvm-config.in
$(GenLibDeps
) $(LibDir
) $(wildcard $(LibDir
)/*.a
)
77 $(Echo
) "Generating llvm-config-perobjincl"
78 $(Verb
) $(PERL
) $(GenLibDeps
) -perobj
-perobjincl
-flat
$(LibDir
) "$(NM_PATH)" >PerobjDepsIncl.txt
79 $(Echo
) "Checking for cyclic dependencies between LLVM objects."
80 $(Verb
) $(PERL
) $(PROJ_SRC_DIR
)/find-cycles.pl
< PerobjDepsIncl.txt
> PerobjDepsInclFinal.txt
81 $(Verb
) $(ECHO
) 's/@LLVM_CPPFLAGS@/$(subst /,\/,$(SUB_CPPFLAGS))/' \
83 $(Verb
) $(ECHO
) 's/@LLVM_CFLAGS@/$(subst /,\/,$(SUB_CFLAGS))/' \
85 $(Verb
) $(ECHO
) 's/@LLVM_CXXFLAGS@/$(subst /,\/,$(SUB_CXXFLAGS))/' \
87 $(Verb
) $(ECHO
) 's/@LLVM_LDFLAGS@/$(subst /,\/,$(SUB_LDFLAGS))/' \
89 $(Verb
) $(ECHO
) 's/@LLVM_BUILDMODE@/$(subst /,\/,$(BuildMode))/' \
91 $(Verb
) $(SED
) -f temp.sed
< $< > $@
92 $(Verb
) $(RM
) temp.sed
93 $(Verb
) cat PerobjDepsInclFinal.txt
>> $@
96 # Build our final script.
97 $(ToolDir
)/llvm-config
: llvm-config.in
$(FinalLibDeps
)
98 $(Echo
) "Building llvm-config script."
99 $(Verb
) $(ECHO
) 's/@LLVM_CPPFLAGS@/$(subst /,\/,$(SUB_CPPFLAGS))/' \
101 $(Verb
) $(ECHO
) 's/@LLVM_CFLAGS@/$(subst /,\/,$(SUB_CFLAGS))/' \
103 $(Verb
) $(ECHO
) 's/@LLVM_CXXFLAGS@/$(subst /,\/,$(SUB_CXXFLAGS))/' \
105 $(Verb
) $(ECHO
) 's/@LLVM_LDFLAGS@/$(subst /,\/,$(SUB_LDFLAGS))/' \
107 $(Verb
) $(ECHO
) 's/@LLVM_BUILDMODE@/$(subst /,\/,$(BuildMode))/' \
109 $(Verb
) $(SED
) -f temp.sed
< $< > $@
110 $(Verb
) $(RM
) temp.sed
111 $(Verb
) cat
$(FinalLibDeps
) >> $@
115 # We don't have perl, just generate a dummy llvm-config
116 $(ToolDir
)/llvm-config
:
117 $(Echo
) "Building place holder llvm-config script."
118 $(Verb
) $(ECHO
) 'echo llvm-config: Perl not found so llvm-config could not be generated' >> $@
122 # Hook into the standard Makefile rules.
123 all-local
:: $(ToolDir
)/llvm-config
125 $(Verb
) $(RM
) -f
$(ToolDir
)/llvm-config llvm-config.in
$(FinalLibDeps
) \
126 $(LibDeps
) GenLibDeps.out
127 install-local
:: all-local
128 $(Echo
) Installing llvm-config
129 $(Verb
) $(MKDIR
) $(DESTDIR
)$(PROJ_bindir
)
130 $(Verb
) $(ScriptInstall
) $(ToolDir
)/llvm-config
$(DESTDIR
)$(PROJ_bindir
)