blob: 354723ab2bbc72af50da10a887b3ccc77b16c118 [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
32GenLibDeps = $(PROJ_SRC_ROOT)/utils/GenLibDeps.pl
33
34$(LibDeps): $(GenLibDeps) $(LibDir) $(wildcard $(LibDir)/*.a $(LibDir)/*.o)
Reid Spencer025213e2006-03-23 22:42:50 +000035 $(Echo) "Regenerating LibDeps.txt"
Anton Korobeynikov3acbb9b2006-08-04 22:55:53 +000036 $(Verb) $(GenLibDeps) -flat $(LibDir) $(NM_PATH) > $(LibDeps)
Reid Spencerf2722ca2006-03-22 15:59:55 +000037
38# Find all the cyclic dependencies between various LLVM libraries, so we
39# don't have to process them at runtime.
Reid Spencer05dee502006-04-20 21:13:58 +000040$(FinalLibDeps): find-cycles.pl $(LibDeps)
Chris Lattnerc6c38432006-12-06 05:39:18 +000041 $(Echo) "Checking for cyclic dependencies between LLVM libraries."
Chris Lattner80930eb2006-09-04 01:49:10 +000042 $(Verb) $(PERL) $< < $(LibDeps) > $@ || rm -f $@
Reid Spencerf2722ca2006-03-22 15:59:55 +000043
44# Rerun our configure substitutions as needed.
Reid Spencer05dee502006-04-20 21:13:58 +000045ConfigInIn = $(PROJ_SRC_DIR)/llvm-config.in.in
46llvm-config.in: $(ConfigInIn) $(ConfigStatusScript)
Reid Spencerf2722ca2006-03-22 15:59:55 +000047 $(Verb) cd $(PROJ_OBJ_ROOT) ; \
Reid Spencer05dee502006-04-20 21:13:58 +000048 $(ConfigStatusScript) tools/llvm-config/llvm-config.in
Reid Spencerf2722ca2006-03-22 15:59:55 +000049
50# Build our final script.
Reid Spencerdee05112006-06-01 01:52:49 +000051$(ToolDir)/llvm-config: llvm-config.in $(FinalLibDeps)
Reid Spencerf2722ca2006-03-22 15:59:55 +000052 $(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
Chris Lattnerabdbae72006-06-02 19:13:29 +000055 $(Verb) $(ECHO) 's,@LLVM_BUILDMODE@,$(BuildMode),' >> 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