blob: 410808b1f269ed3ed99e94fc977ec2551b21b130 [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
Chris Lattner0465fa92006-07-07 00:46:19 +000013REQUIRES_EH := 1
Reid Spencer0fab2b12006-03-19 22:10:53 +000014
15include $(LEVEL)/Makefile.common
16
Reid Spencerb3bd5ca2006-05-03 17:49:50 +000017# If we don't have Perl, we can't generate the library dependencies upon which
18# llvm-config depends. Therefore, only if we detect perl will we do anything
19# useful.
20ifeq ($(HAVE_PERL),1)
21
Reid Spencerf2722ca2006-03-22 15:59:55 +000022# Combine preprocessor flags (except for -I) and CXX flags.
23SUB_CXXFLAGS = ${CPP.BaseFlags} ${CXX.Flags}
24
25# This is blank for now. We need to be careful about adding stuff here:
26# LDFLAGS tend not to be portable, and we don't currently require the
27# user to use libtool when linking against LLVM.
28SUB_LDFLAGS =
29
Reid Spencerb3bd5ca2006-05-03 17:49:50 +000030FinalLibDeps = $(PROJ_OBJ_DIR)/FinalLibDeps.txt
Chris Lattner73ebd092006-06-06 17:43:03 +000031LibDeps = $(PROJ_OBJ_DIR)/LibDeps.txt
Reid Spencer4fbcdf62006-12-12 00:43:38 +000032LibDepsTemp = $(PROJ_OBJ_DIR)/LibDeps.txt.tmp
Chris Lattner73ebd092006-06-06 17:43:03 +000033GenLibDeps = $(PROJ_SRC_ROOT)/utils/GenLibDeps.pl
34
Reid Spencer4fbcdf62006-12-12 00:43:38 +000035$(LibDepsTemp): $(GenLibDeps) $(LibDir) $(wildcard $(LibDir)/*.a $(LibDir)/*.o)
36 $(Echo) "Regenerating LibDeps.txt.tmp"
37 $(Verb) $(GenLibDeps) -flat $(LibDir) $(NM_PATH) > $(LibDepsTemp)
38
39$(LibDeps): $(LibDepsTemp)
40 $(Verb) $(CMP) -s $@ $< || ( $(CP) $< $@ && \
41 $(EchoCmd) Updated LibDeps.txt because dependencies changes )
Reid Spencerf2722ca2006-03-22 15:59:55 +000042
43# Find all the cyclic dependencies between various LLVM libraries, so we
44# don't have to process them at runtime.
Reid Spencer05dee502006-04-20 21:13:58 +000045$(FinalLibDeps): find-cycles.pl $(LibDeps)
Chris Lattnerc6c38432006-12-06 05:39:18 +000046 $(Echo) "Checking for cyclic dependencies between LLVM libraries."
Chris Lattner80930eb2006-09-04 01:49:10 +000047 $(Verb) $(PERL) $< < $(LibDeps) > $@ || rm -f $@
Reid Spencerf2722ca2006-03-22 15:59:55 +000048
49# Rerun our configure substitutions as needed.
Reid Spencer05dee502006-04-20 21:13:58 +000050ConfigInIn = $(PROJ_SRC_DIR)/llvm-config.in.in
51llvm-config.in: $(ConfigInIn) $(ConfigStatusScript)
Reid Spencerf2722ca2006-03-22 15:59:55 +000052 $(Verb) cd $(PROJ_OBJ_ROOT) ; \
Reid Spencer05dee502006-04-20 21:13:58 +000053 $(ConfigStatusScript) tools/llvm-config/llvm-config.in
Reid Spencerf2722ca2006-03-22 15:59:55 +000054
55# Build our final script.
Reid Spencerdee05112006-06-01 01:52:49 +000056$(ToolDir)/llvm-config: llvm-config.in $(FinalLibDeps)
Reid Spencerf2722ca2006-03-22 15:59:55 +000057 $(Echo) "Building llvm-config script."
58 $(Verb) $(ECHO) 's,@LLVM_CXXFLAGS@,$(SUB_CXXFLAGS),' > temp.sed
59 $(Verb) $(ECHO) 's,@LLVM_LDFLAGS@,$(SUB_LDFLAGS),' >> temp.sed
Chris Lattnerabdbae72006-06-02 19:13:29 +000060 $(Verb) $(ECHO) 's,@LLVM_BUILDMODE@,$(BuildMode),' >> temp.sed
Reid Spencerf2722ca2006-03-22 15:59:55 +000061 $(Verb) $(SED) -f temp.sed < $< > $@
62 $(Verb) $(RM) temp.sed
Reid Spencer05dee502006-04-20 21:13:58 +000063 $(Verb) cat $(FinalLibDeps) >> $@
Reid Spencerb3bd5ca2006-05-03 17:49:50 +000064 $(Verb) chmod +x $@
Reid Spencerf2722ca2006-03-22 15:59:55 +000065
Reid Spencerb3bd5ca2006-05-03 17:49:50 +000066else
67# We don't have perl, just generate a dummy llvm-config
Reid Spencerdee05112006-06-01 01:52:49 +000068$(ToolDir)/llvm-config:
Reid Spencerb3bd5ca2006-05-03 17:49:50 +000069 $(Echo) "Building place holder llvm-config script."
70 $(Verb) $(ECHO) 'echo llvm-config: Perl not found so llvm-config could not be generated' >> $@
71 $(Verb) chmod +x $@
72
73endif
Reid Spencerf2722ca2006-03-22 15:59:55 +000074# Hook into the standard Makefile rules.
Reid Spencerdee05112006-06-01 01:52:49 +000075all-local:: $(ToolDir)/llvm-config
Reid Spencerf2722ca2006-03-22 15:59:55 +000076clean-local::
Reid Spencerdee05112006-06-01 01:52:49 +000077 $(Verb) $(RM) -f $(ToolDir)/llvm-config llvm-config.in $(FinalLibDeps) \
78 $(LibDeps) GenLibDeps.out
Reid Spencerf2722ca2006-03-22 15:59:55 +000079install-local:: all-local
80 $(Echo) Installing llvm-config
81 $(Verb) $(MKDIR) $(PROJ_bindir)
Reid Spencerdee05112006-06-01 01:52:49 +000082 $(Verb) $(ScriptInstall) $(ToolDir)/llvm-config $(PROJ_bindir)
Reid Spencerb3bd5ca2006-05-03 17:49:50 +000083