Makefile revision 05dee5064f691d6e1f5c141a7b9862fa345dcb54
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 llvm-config.in.in find-cycles.pl
13
14include $(LEVEL)/Makefile.common
15
16# Combine preprocessor flags (except for -I) and CXX flags.
17SUB_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.
22SUB_LDFLAGS = 
23
24FinalLibDeps = $(PROJ_SRC_DIR)/FinalLibDeps.txt
25ifdef HAVE_PERL
26ifeq ($(HAVE_PERL),1)
27LibDeps = $(PROJ_SRC_DIR)/LibDeps.txt
28GenLibDeps = $(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 > $@
41endif
42endif
43
44# Rerun our configure substitutions as needed.
45ConfigInIn = $(PROJ_SRC_DIR)/llvm-config.in.in
46llvm-config.in: $(ConfigInIn) $(ConfigStatusScript)
47	$(Verb) cd $(PROJ_OBJ_ROOT) ; \
48		$(ConfigStatusScript) tools/llvm-config/llvm-config.in
49
50# Build our final script.
51llvm-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.
62all-local:: llvm-config
63clean-local::
64	$(Verb) $(RM) -f llvm-config llvm-config.in
65install-local:: all-local
66	$(Echo) Installing llvm-config
67	$(Verb) $(MKDIR) $(PROJ_bindir)
68	$(Verb) $(ScriptInstall) llvm-config $(PROJ_bindir)
69