For PR764:
[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
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_CXXFLAGS = ${CPP.BaseFlags} ${CXX.Flags}
23
24 # This is blank for now.  We need to be careful about adding stuff here:
25 # LDFLAGS tend not to be portable, and we don't currently require the
26 # user to use libtool when linking against LLVM.
27 SUB_LDFLAGS = 
28
29 FinalLibDeps = $(PROJ_OBJ_DIR)/FinalLibDeps.txt
30 LibDeps = $(PROJ_OBJ_DIR)/LibDeps.txt
31 GenLibDeps = $(PROJ_SRC_ROOT)/utils/GenLibDeps.pl
32 # MANUAL USE ONLY!  GenLibDeps.pl is very non-portable, so LibDeps.txt
33 # should only be re-built manually.  No other rule in this file should
34 # depend on LibDeps.txt.
35 $(LibDeps): $(GenLibDeps) $(LibDir)
36         $(Echo) "Regenerating LibDeps.txt"
37         $(Verb) $(GenLibDeps) -flat $(LibDir) | sort > $(LibDeps)
38
39 # Find all the cyclic dependencies between various LLVM libraries, so we
40 # don't have to process them at runtime.
41 $(FinalLibDeps): find-cycles.pl $(LibDeps)
42         $(Echo) "Finding cyclic dependencies between LLVM libraries."
43         $(Verb) $(PERL) $< < $(LibDeps) > $@
44
45 # Rerun our configure substitutions as needed.
46 ConfigInIn = $(PROJ_SRC_DIR)/llvm-config.in.in
47 llvm-config.in: $(ConfigInIn) $(ConfigStatusScript)
48         $(Verb) cd $(PROJ_OBJ_ROOT) ; \
49                 $(ConfigStatusScript) tools/llvm-config/llvm-config.in
50
51 # Build our final script.
52 llvm-config: llvm-config.in $(FinalLibDeps)
53         $(Echo) "Building llvm-config script."
54         $(Verb) $(ECHO) 's,@LLVM_CXXFLAGS@,$(SUB_CXXFLAGS),' > temp.sed
55         $(Verb) $(ECHO) 's,@LLVM_LDFLAGS@,$(SUB_LDFLAGS),' >> temp.sed
56         $(Verb) $(ECHO) 's,@CORE_IS_ARCHIVE@,$(CORE_IS_ARCHIVE),' >> temp.sed
57         $(Verb) $(SED) -f temp.sed < $< > $@
58         $(Verb) $(RM) temp.sed
59         $(Verb) cat $(FinalLibDeps) >> $@
60         $(Verb) chmod +x $@
61
62 else
63 # We don't have perl, just generate a dummy llvm-config
64 llvm-config:
65         $(Echo) "Building place holder llvm-config script."
66         $(Verb) $(ECHO) 'echo llvm-config: Perl not found so llvm-config could not be generated' >> $@
67         $(Verb) chmod +x $@
68
69 endif
70 # Hook into the standard Makefile rules.
71 all-local:: llvm-config
72 clean-local::
73         $(Verb) $(RM) -f llvm-config llvm-config.in $(FinalLibDeps) $(LibDeps) \
74           GenLibDeps.out
75 install-local:: all-local
76         $(Echo) Installing llvm-config
77         $(Verb) $(MKDIR) $(PROJ_bindir)
78         $(Verb) $(ScriptInstall) llvm-config $(PROJ_bindir)
79