Revert commit 145449 (ddunbar) since it is breaking the dragonegg buildbots.
[oota-llvm.git] / tools / llvm-config / Makefile
1 ##===- tools/llvm-config/Makefile --------------------------*- Makefile -*-===##
2 #
3 #                     The LLVM Compiler Infrastructure
4 #
5 # This file is distributed under the University of Illinois Open Source
6 # License. See LICENSE.TXT for details.
7
8 ##===----------------------------------------------------------------------===##
9
10 LEVEL = ../..
11
12 EXTRA_DIST = LibDeps.txt FinalLibDeps.txt llvm-config.in.in find-cycles.pl
13
14 include $(LEVEL)/Makefile.common
15
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
18 # useful.
19 ifeq ($(HAVE_PERL),1)
20
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}
25
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.
29 SUB_LDFLAGS = 
30
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
35
36 $(LibDepsTemp): $(GenLibDeps) $(LibDir) $(wildcard $(LibDir)/*.a $(LibDir)/*.o)
37         $(Echo) "Regenerating LibDeps.txt.tmp"
38         $(Verb) $(PERL) $(GenLibDeps) -flat $(LibDir) "$(NM_PATH)" > $(LibDepsTemp)
39
40 $(LibDeps): $(LibDepsTemp)
41         $(Verb) $(CMP) -s $@ $< || ( $(CP) $< $@ && \
42           $(EchoCmd) Updated LibDeps.txt because dependencies changed )
43
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 $@
49
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
55
56 # Build our final script.
57 $(ToolDir)/llvm-config: llvm-config.in $(FinalLibDeps)
58         $(Echo) "Building llvm-config script."
59         $(Verb) $(ECHO) 's/@LLVM_CPPFLAGS@/$(subst /,\/,$(SUB_CPPFLAGS))/' \
60           > temp.sed
61         $(Verb) $(ECHO) 's/@LLVM_CFLAGS@/$(subst /,\/,$(SUB_CFLAGS))/' \
62           >> temp.sed
63         $(Verb) $(ECHO) 's/@LLVM_CXXFLAGS@/$(subst /,\/,$(SUB_CXXFLAGS))/' \
64           >> temp.sed
65         $(Verb) $(ECHO) 's/@LLVM_LDFLAGS@/$(subst /,\/,$(SUB_LDFLAGS))/' \
66           >> temp.sed
67         $(Verb) $(ECHO) 's/@LLVM_BUILDMODE@/$(subst /,\/,$(BuildMode))/' \
68           >> temp.sed
69         $(Verb) $(ECHO) 's/@LLVM_OBJ_SUFFIX@/$(subst /,\/,/$(BuildMode))/' \
70           >> temp.sed
71         $(Verb) $(SED) -f temp.sed < $< > $@
72         $(Verb) $(RM) temp.sed
73         $(Verb) cat $(FinalLibDeps) >> $@
74         $(Verb) chmod +x $@
75
76 else
77 # We don't have perl, just generate a dummy llvm-config
78 $(ToolDir)/llvm-config:
79         $(Echo) "Building place holder llvm-config script."
80         $(Verb) $(ECHO) 'echo llvm-config: Perl not found so llvm-config could not be generated' >> $@
81         $(Verb) chmod +x $@
82
83 endif
84 # Hook into the standard Makefile rules.
85 all-local:: $(ToolDir)/llvm-config
86 clean-local::
87         $(Verb) $(RM) -f $(ToolDir)/llvm-config llvm-config.in $(FinalLibDeps) \
88           $(LibDeps) GenLibDeps.out
89 install-local:: all-local
90         $(Echo) Installing llvm-config
91         $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_bindir)
92         $(Verb) $(ScriptInstall) $(ToolDir)/llvm-config $(DESTDIR)$(PROJ_bindir)
93