blob: d777e812e14189ea9236972ca54669fc4cbaba9b [file] [log] [blame]
Reid Spencer05dee502006-04-20 21:13:58 +00001##===- tools/llvm-config/Makefile --------------------------*- Makefile -*-===##
Reid Spencerf2722ca2006-03-22 15:59:55 +00002#
Reid Spencer0fab2b12006-03-19 22:10:53 +00003# 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
Reid Spencerb3bd5ca2006-05-03 17:49:50 +000012EXTRA_DIST = LibDeps.txt FinalLibDeps.txt llvm-config.in.in find-cycles.pl
Reid Spencer0fab2b12006-03-19 22:10:53 +000013
14include $(LEVEL)/Makefile.common
15
Reid Spencerb3bd5ca2006-05-03 17:49:50 +000016# 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
Reid Spencerf2722ca2006-03-22 15:59:55 +000021# 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
Reid Spencerb3bd5ca2006-05-03 17:49:50 +000029FinalLibDeps = $(PROJ_OBJ_DIR)/FinalLibDeps.txt
30LibDeps = $(PROJ_OBJ_DIR)/LibDeps.txt
Reid Spencer05dee502006-04-20 21:13:58 +000031GenLibDeps = $(PROJ_SRC_ROOT)/utils/GenLibDeps.pl
Reid Spencerf2722ca2006-03-22 15:59:55 +000032# 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.
Reid Spencer05dee502006-04-20 21:13:58 +000035$(LibDeps): $(GenLibDeps) $(LibDir)
Reid Spencer025213e2006-03-23 22:42:50 +000036 $(Echo) "Regenerating LibDeps.txt"
Reid Spencer05dee502006-04-20 21:13:58 +000037 $(Verb) $(GenLibDeps) -flat $(LibDir) | sort > $(LibDeps)
Reid Spencerf2722ca2006-03-22 15:59:55 +000038
39# Find all the cyclic dependencies between various LLVM libraries, so we
40# don't have to process them at runtime.
Reid Spencer05dee502006-04-20 21:13:58 +000041$(FinalLibDeps): find-cycles.pl $(LibDeps)
Reid Spencerf2722ca2006-03-22 15:59:55 +000042 $(Echo) "Finding cyclic dependencies between LLVM libraries."
Reid Spencerb3bd5ca2006-05-03 17:49:50 +000043 $(Verb) $(PERL) $< < $(LibDeps) > $@
Reid Spencerf2722ca2006-03-22 15:59:55 +000044
45# Rerun our configure substitutions as needed.
Reid Spencer05dee502006-04-20 21:13:58 +000046ConfigInIn = $(PROJ_SRC_DIR)/llvm-config.in.in
47llvm-config.in: $(ConfigInIn) $(ConfigStatusScript)
Reid Spencerf2722ca2006-03-22 15:59:55 +000048 $(Verb) cd $(PROJ_OBJ_ROOT) ; \
Reid Spencer05dee502006-04-20 21:13:58 +000049 $(ConfigStatusScript) tools/llvm-config/llvm-config.in
Reid Spencerf2722ca2006-03-22 15:59:55 +000050
51# Build our final script.
Reid Spencerdee05112006-06-01 01:52:49 +000052$(ToolDir)/llvm-config: llvm-config.in $(FinalLibDeps)
Reid Spencerf2722ca2006-03-22 15:59:55 +000053 $(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
Reid Spencerf2722ca2006-03-22 15:59:55 +000056 $(Verb) $(SED) -f temp.sed < $< > $@
57 $(Verb) $(RM) temp.sed
Reid Spencer05dee502006-04-20 21:13:58 +000058 $(Verb) cat $(FinalLibDeps) >> $@
Reid Spencerb3bd5ca2006-05-03 17:49:50 +000059 $(Verb) chmod +x $@
Reid Spencerf2722ca2006-03-22 15:59:55 +000060
Reid Spencerb3bd5ca2006-05-03 17:49:50 +000061else
62# We don't have perl, just generate a dummy llvm-config
Reid Spencerdee05112006-06-01 01:52:49 +000063$(ToolDir)/llvm-config:
Reid Spencerb3bd5ca2006-05-03 17:49:50 +000064 $(Echo) "Building place holder llvm-config script."
65 $(Verb) $(ECHO) 'echo llvm-config: Perl not found so llvm-config could not be generated' >> $@
66 $(Verb) chmod +x $@
67
68endif
Reid Spencerf2722ca2006-03-22 15:59:55 +000069# Hook into the standard Makefile rules.
Reid Spencerdee05112006-06-01 01:52:49 +000070all-local:: $(ToolDir)/llvm-config
Reid Spencerf2722ca2006-03-22 15:59:55 +000071clean-local::
Reid Spencerdee05112006-06-01 01:52:49 +000072 $(Verb) $(RM) -f $(ToolDir)/llvm-config llvm-config.in $(FinalLibDeps) \
73 $(LibDeps) GenLibDeps.out
Reid Spencerf2722ca2006-03-22 15:59:55 +000074install-local:: all-local
75 $(Echo) Installing llvm-config
76 $(Verb) $(MKDIR) $(PROJ_bindir)
Reid Spencerdee05112006-06-01 01:52:49 +000077 $(Verb) $(ScriptInstall) $(ToolDir)/llvm-config $(PROJ_bindir)
Reid Spencerb3bd5ca2006-05-03 17:49:50 +000078