Several Changes To Support Building llvm-config:
[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 llvm-config.in.in find-cycles.pl
13
14 include $(LEVEL)/Makefile.common
15
16 # Combine preprocessor flags (except for -I) and CXX flags.
17 SUB_CXXFLAGS = ${CPP.BaseFlags} ${CXX.Flags}
18
19 # This is blank for now.  We need to be careful about adding stuff here:
20 # LDFLAGS tend not to be portable, and we don't currently require the
21 # user to use libtool when linking against LLVM.
22 SUB_LDFLAGS = 
23
24 FinalLibDeps = $(PROJ_SRC_DIR)/FinalLibDeps.txt
25 ifdef HAVE_PERL
26 ifeq ($(HAVE_PERL),1)
27 LibDeps = $(PROJ_SRC_DIR)/LibDeps.txt
28 GenLibDeps = $(PROJ_SRC_ROOT)/utils/GenLibDeps.pl
29 # MANUAL USE ONLY!  GenLibDeps.pl is very non-portable, so LibDeps.txt
30 # should only be re-built manually.  No other rule in this file should
31 # depend on LibDeps.txt.
32 $(LibDeps): $(GenLibDeps) $(LibDir)
33         $(Echo) "Regenerating LibDeps.txt"
34         $(Verb) $(GenLibDeps) -flat $(LibDir) | sort > $(LibDeps)
35
36 # Find all the cyclic dependencies between various LLVM libraries, so we
37 # don't have to process them at runtime.
38 $(FinalLibDeps): find-cycles.pl $(LibDeps)
39         $(Echo) "Finding cyclic dependencies between LLVM libraries."
40         $(Verb) $(PERL) $< < $(PROJ_SRC_DIR)/LibDeps.txt > $@
41 endif
42 endif
43
44 # Rerun our configure substitutions as needed.
45 ConfigInIn = $(PROJ_SRC_DIR)/llvm-config.in.in
46 llvm-config.in: $(ConfigInIn) $(ConfigStatusScript)
47         $(Verb) cd $(PROJ_OBJ_ROOT) ; \
48                 $(ConfigStatusScript) tools/llvm-config/llvm-config.in
49
50 # Build our final script.
51 llvm-config: llvm-config.in $(FinalLibDeps)
52         $(Echo) "Building llvm-config script."
53         $(Verb) $(ECHO) 's,@LLVM_CXXFLAGS@,$(SUB_CXXFLAGS),' > temp.sed
54         $(Verb) $(ECHO) 's,@LLVM_LDFLAGS@,$(SUB_LDFLAGS),' >> temp.sed
55         $(Verb) $(ECHO) 's,@CORE_IS_ARCHIVE@,$(CORE_IS_ARCHIVE),' >> temp.sed
56         $(Verb) $(SED) -f temp.sed < $< > $@
57         $(Verb) $(RM) temp.sed
58         $(Verb) cat $(FinalLibDeps) >> $@
59         $(Verb) chmod +x llvm-config
60
61 # Hook into the standard Makefile rules.
62 all-local:: llvm-config
63 clean-local::
64         $(Verb) $(RM) -f llvm-config llvm-config.in
65 install-local:: all-local
66         $(Echo) Installing llvm-config
67         $(Verb) $(MKDIR) $(PROJ_bindir)
68         $(Verb) $(ScriptInstall) llvm-config $(PROJ_bindir)