blob: 413fd0a53a310de13339e215f8b66dfdfdeb64b8 [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
Chris Lattner73ebd092006-06-06 17:43:03 +000030LibDeps = $(PROJ_OBJ_DIR)/LibDeps.txt
31GenLibDeps = $(PROJ_SRC_ROOT)/utils/GenLibDeps.pl
32
33$(LibDeps): $(GenLibDeps) $(LibDir) $(wildcard $(LibDir)/*.a $(LibDir)/*.o)
Reid Spencer025213e2006-03-23 22:42:50 +000034 $(Echo) "Regenerating LibDeps.txt"
Reid Spencer05dee502006-04-20 21:13:58 +000035 $(Verb) $(GenLibDeps) -flat $(LibDir) | sort > $(LibDeps)
Reid Spencerf2722ca2006-03-22 15:59:55 +000036
37# Find all the cyclic dependencies between various LLVM libraries, so we
38# don't have to process them at runtime.
Reid Spencer05dee502006-04-20 21:13:58 +000039$(FinalLibDeps): find-cycles.pl $(LibDeps)
Reid Spencerf2722ca2006-03-22 15:59:55 +000040 $(Echo) "Finding cyclic dependencies between LLVM libraries."
Reid Spencerb3bd5ca2006-05-03 17:49:50 +000041 $(Verb) $(PERL) $< < $(LibDeps) > $@
Reid Spencerf2722ca2006-03-22 15:59:55 +000042
43# Rerun our configure substitutions as needed.
Reid Spencer05dee502006-04-20 21:13:58 +000044ConfigInIn = $(PROJ_SRC_DIR)/llvm-config.in.in
45llvm-config.in: $(ConfigInIn) $(ConfigStatusScript)
Reid Spencerf2722ca2006-03-22 15:59:55 +000046 $(Verb) cd $(PROJ_OBJ_ROOT) ; \
Reid Spencer05dee502006-04-20 21:13:58 +000047 $(ConfigStatusScript) tools/llvm-config/llvm-config.in
Reid Spencerf2722ca2006-03-22 15:59:55 +000048
49# Build our final script.
Reid Spencerdee05112006-06-01 01:52:49 +000050$(ToolDir)/llvm-config: llvm-config.in $(FinalLibDeps)
Reid Spencerf2722ca2006-03-22 15:59:55 +000051 $(Echo) "Building llvm-config script."
52 $(Verb) $(ECHO) 's,@LLVM_CXXFLAGS@,$(SUB_CXXFLAGS),' > temp.sed
53 $(Verb) $(ECHO) 's,@LLVM_LDFLAGS@,$(SUB_LDFLAGS),' >> temp.sed
Chris Lattnerabdbae72006-06-02 19:13:29 +000054 $(Verb) $(ECHO) 's,@LLVM_BUILDMODE@,$(BuildMode),' >> temp.sed
Reid Spencerf2722ca2006-03-22 15:59:55 +000055 $(Verb) $(SED) -f temp.sed < $< > $@
56 $(Verb) $(RM) temp.sed
Reid Spencer05dee502006-04-20 21:13:58 +000057 $(Verb) cat $(FinalLibDeps) >> $@
Reid Spencerb3bd5ca2006-05-03 17:49:50 +000058 $(Verb) chmod +x $@
Reid Spencerf2722ca2006-03-22 15:59:55 +000059
Reid Spencerb3bd5ca2006-05-03 17:49:50 +000060else
61# We don't have perl, just generate a dummy llvm-config
Reid Spencerdee05112006-06-01 01:52:49 +000062$(ToolDir)/llvm-config:
Reid Spencerb3bd5ca2006-05-03 17:49:50 +000063 $(Echo) "Building place holder llvm-config script."
64 $(Verb) $(ECHO) 'echo llvm-config: Perl not found so llvm-config could not be generated' >> $@
65 $(Verb) chmod +x $@
66
67endif
Reid Spencerf2722ca2006-03-22 15:59:55 +000068# Hook into the standard Makefile rules.
Reid Spencerdee05112006-06-01 01:52:49 +000069all-local:: $(ToolDir)/llvm-config
Reid Spencerf2722ca2006-03-22 15:59:55 +000070clean-local::
Reid Spencerdee05112006-06-01 01:52:49 +000071 $(Verb) $(RM) -f $(ToolDir)/llvm-config llvm-config.in $(FinalLibDeps) \
72 $(LibDeps) GenLibDeps.out
Reid Spencerf2722ca2006-03-22 15:59:55 +000073install-local:: all-local
74 $(Echo) Installing llvm-config
75 $(Verb) $(MKDIR) $(PROJ_bindir)
Reid Spencerdee05112006-06-01 01:52:49 +000076 $(Verb) $(ScriptInstall) $(ToolDir)/llvm-config $(PROJ_bindir)
Reid Spencerb3bd5ca2006-05-03 17:49:50 +000077