Add support for building with _GLIBCXX_DEBUG. New configure option
[oota-llvm.git] / tools / llvm-config / Makefile
1 ##===- tools/llvm-config/Makefile --------------------------*- Makefile -*-===##
2 #
3 #                     The LLVM Compiler Infrastructure
4 #
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.
7
8 ##===----------------------------------------------------------------------===##
9
10 LEVEL = ../..
11
12 EXTRA_DIST = LibDeps.txt FinalLibDeps.txt llvm-config.in.in find-cycles.pl
13 REQUIRES_EH := 1
14
15 include $(LEVEL)/Makefile.common
16
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
19 # useful.
20 ifeq ($(HAVE_PERL),1)
21
22 # Combine preprocessor flags (except for -I) and CXX flags.
23 SUB_CPPFLAGS = ${CPP.Defines}
24 SUB_CFLAGS = ${CPP.BaseFlags} ${C.Flags}
25 SUB_CXXFLAGS = ${CPP.BaseFlags} ${CXX.Flags}
26
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.
30 SUB_LDFLAGS = 
31
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
36
37 $(LibDepsTemp): $(GenLibDeps) $(LibDir) $(wildcard $(LibDir)/*.a $(LibDir)/*.o)
38         $(Echo) "Regenerating LibDeps.txt.tmp"
39         $(Verb) $(PERL) $(GenLibDeps) -flat $(LibDir) $(NM_PATH) > $(LibDepsTemp)
40
41 $(LibDeps): $(LibDepsTemp)
42         $(Verb) $(CMP) -s $@ $< || ( $(CP) $< $@ && \
43           $(EchoCmd) Updated LibDeps.txt because dependencies changed )
44
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 $@
50
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
56
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@,$(SUB_CPPFLAGS),' > temp.sed
61         $(Verb) $(ECHO) 's,@LLVM_CFLAGS@,$(SUB_CFLAGS),' >> temp.sed
62         $(Verb) $(ECHO) 's,@LLVM_CXXFLAGS@,$(SUB_CXXFLAGS),' >> temp.sed
63         $(Verb) $(ECHO) 's,@LLVM_LDFLAGS@,$(SUB_LDFLAGS),' >> temp.sed
64         $(Verb) $(ECHO) 's,@LLVM_BUILDMODE@,$(BuildMode),' >> temp.sed
65         $(Verb) $(SED) -f temp.sed < $< > $@
66         $(Verb) $(RM) temp.sed
67         $(Verb) cat $(FinalLibDeps) >> $@
68         $(Verb) chmod +x $@
69
70 else
71 # We don't have perl, just generate a dummy llvm-config
72 $(ToolDir)/llvm-config:
73         $(Echo) "Building place holder llvm-config script."
74         $(Verb) $(ECHO) 'echo llvm-config: Perl not found so llvm-config could not be generated' >> $@
75         $(Verb) chmod +x $@
76
77 endif
78 # Hook into the standard Makefile rules.
79 all-local:: $(ToolDir)/llvm-config
80 clean-local::
81         $(Verb) $(RM) -f $(ToolDir)/llvm-config llvm-config.in $(FinalLibDeps) \
82           $(LibDeps) GenLibDeps.out
83 install-local:: all-local
84         $(Echo) Installing llvm-config
85         $(Verb) $(MKDIR) $(PROJ_bindir)
86         $(Verb) $(ScriptInstall) $(ToolDir)/llvm-config $(PROJ_bindir)
87