Makefile revision dee05112a63cdd440dfb27db12ef541b7afd0a6d
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
10LEVEL = ../..
11
12EXTRA_DIST = LibDeps.txt FinalLibDeps.txt llvm-config.in.in find-cycles.pl
13
14include $(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.
19ifeq ($(HAVE_PERL),1)
20
21# Combine preprocessor flags (except for -I) and CXX flags.
22SUB_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.
27SUB_LDFLAGS = 
28
29FinalLibDeps = $(PROJ_OBJ_DIR)/FinalLibDeps.txt
30LibDeps = $(PROJ_OBJ_DIR)/LibDeps.txt
31GenLibDeps = $(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.
46ConfigInIn = $(PROJ_SRC_DIR)/llvm-config.in.in
47llvm-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$(ToolDir)/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
62else
63# We don't have perl, just generate a dummy llvm-config
64$(ToolDir)/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
69endif
70# Hook into the standard Makefile rules.
71all-local:: $(ToolDir)/llvm-config
72clean-local::
73	$(Verb) $(RM) -f $(ToolDir)/llvm-config llvm-config.in $(FinalLibDeps) \
74	  $(LibDeps) GenLibDeps.out
75install-local:: all-local
76	$(Echo) Installing llvm-config
77	$(Verb) $(MKDIR) $(PROJ_bindir)
78	$(Verb) $(ScriptInstall) $(ToolDir)/llvm-config $(PROJ_bindir)
79
80