blob: e5bdc04063f92770bdb0dd8c39fb40dedcd6d5a8 [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#
Chris Lattner51167842007-12-29 20:07:17 +00005# This file is distributed under the University of Illinois Open Source
6# License. See LICENSE.TXT for details.
Reid Spencer0fab2b12006-03-19 22:10:53 +00007#
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.
Reid Spencer4a2c0832007-07-10 07:21:34 +000022SUB_CPPFLAGS = ${CPP.BaseFlags}
23SUB_CFLAGS = ${CPP.BaseFlags} ${C.Flags}
Reid Spencerf2722ca2006-03-22 15:59:55 +000024SUB_CXXFLAGS = ${CPP.BaseFlags} ${CXX.Flags}
25
26# This is blank for now. We need to be careful about adding stuff here:
27# LDFLAGS tend not to be portable, and we don't currently require the
28# user to use libtool when linking against LLVM.
29SUB_LDFLAGS =
30
Reid Spencerb3bd5ca2006-05-03 17:49:50 +000031FinalLibDeps = $(PROJ_OBJ_DIR)/FinalLibDeps.txt
Chris Lattner73ebd092006-06-06 17:43:03 +000032LibDeps = $(PROJ_OBJ_DIR)/LibDeps.txt
Reid Spencer4fbcdf62006-12-12 00:43:38 +000033LibDepsTemp = $(PROJ_OBJ_DIR)/LibDeps.txt.tmp
Chris Lattner73ebd092006-06-06 17:43:03 +000034GenLibDeps = $(PROJ_SRC_ROOT)/utils/GenLibDeps.pl
35
Reid Spencer4fbcdf62006-12-12 00:43:38 +000036$(LibDepsTemp): $(GenLibDeps) $(LibDir) $(wildcard $(LibDir)/*.a $(LibDir)/*.o)
37 $(Echo) "Regenerating LibDeps.txt.tmp"
Ted Kremenekf248f0d2007-11-27 17:53:54 +000038 $(Verb) $(PERL) $(GenLibDeps) -flat $(LibDir) "$(NM_PATH)" > $(LibDepsTemp)
Reid Spencer4fbcdf62006-12-12 00:43:38 +000039
40$(LibDeps): $(LibDepsTemp)
41 $(Verb) $(CMP) -s $@ $< || ( $(CP) $< $@ && \
Reid Spencerd7fc4f62007-02-04 22:08:16 +000042 $(EchoCmd) Updated LibDeps.txt because dependencies changed )
Reid Spencerf2722ca2006-03-22 15:59:55 +000043
44# Find all the cyclic dependencies between various LLVM libraries, so we
45# don't have to process them at runtime.
Reid Spencer05dee502006-04-20 21:13:58 +000046$(FinalLibDeps): find-cycles.pl $(LibDeps)
Chris Lattnerc6c38432006-12-06 05:39:18 +000047 $(Echo) "Checking for cyclic dependencies between LLVM libraries."
Chris Lattner80930eb2006-09-04 01:49:10 +000048 $(Verb) $(PERL) $< < $(LibDeps) > $@ || rm -f $@
Reid Spencerf2722ca2006-03-22 15:59:55 +000049
50# Rerun our configure substitutions as needed.
Reid Spencer05dee502006-04-20 21:13:58 +000051ConfigInIn = $(PROJ_SRC_DIR)/llvm-config.in.in
52llvm-config.in: $(ConfigInIn) $(ConfigStatusScript)
Reid Spencerf2722ca2006-03-22 15:59:55 +000053 $(Verb) cd $(PROJ_OBJ_ROOT) ; \
Reid Spencer05dee502006-04-20 21:13:58 +000054 $(ConfigStatusScript) tools/llvm-config/llvm-config.in
Reid Spencerf2722ca2006-03-22 15:59:55 +000055
56# Build our final script.
Reid Spencerdee05112006-06-01 01:52:49 +000057$(ToolDir)/llvm-config: llvm-config.in $(FinalLibDeps)
Reid Spencerf2722ca2006-03-22 15:59:55 +000058 $(Echo) "Building llvm-config script."
Dan Gohman4832f882009-03-10 19:01:23 +000059 $(Verb) $(ECHO) 's/@LLVM_CPPFLAGS@/$(subst /,\/,$(SUB_CPPFLAGS))/' \
60 > temp.sed
61 $(Verb) $(ECHO) 's/@LLVM_CFLAGS@/$(subst /,\/,$(SUB_CFLAGS))/' \
62 >> temp.sed
63 $(Verb) $(ECHO) 's/@LLVM_CXXFLAGS@/$(subst /,\/,$(SUB_CXXFLAGS))/' \
64 >> temp.sed
65 $(Verb) $(ECHO) 's/@LLVM_LDFLAGS@/$(subst /,\/,$(SUB_LDFLAGS))/' \
66 >> temp.sed
67 $(Verb) $(ECHO) 's/@LLVM_BUILDMODE@/$(subst /,\/,$(BuildMode))/' \
68 >> temp.sed
Reid Spencerf2722ca2006-03-22 15:59:55 +000069 $(Verb) $(SED) -f temp.sed < $< > $@
70 $(Verb) $(RM) temp.sed
Reid Spencer05dee502006-04-20 21:13:58 +000071 $(Verb) cat $(FinalLibDeps) >> $@
Reid Spencerb3bd5ca2006-05-03 17:49:50 +000072 $(Verb) chmod +x $@
Reid Spencerf2722ca2006-03-22 15:59:55 +000073
Reid Spencerb3bd5ca2006-05-03 17:49:50 +000074else
75# We don't have perl, just generate a dummy llvm-config
Reid Spencerdee05112006-06-01 01:52:49 +000076$(ToolDir)/llvm-config:
Reid Spencerb3bd5ca2006-05-03 17:49:50 +000077 $(Echo) "Building place holder llvm-config script."
78 $(Verb) $(ECHO) 'echo llvm-config: Perl not found so llvm-config could not be generated' >> $@
79 $(Verb) chmod +x $@
80
81endif
Reid Spencerf2722ca2006-03-22 15:59:55 +000082# Hook into the standard Makefile rules.
Reid Spencerdee05112006-06-01 01:52:49 +000083all-local:: $(ToolDir)/llvm-config
Reid Spencerf2722ca2006-03-22 15:59:55 +000084clean-local::
Reid Spencerdee05112006-06-01 01:52:49 +000085 $(Verb) $(RM) -f $(ToolDir)/llvm-config llvm-config.in $(FinalLibDeps) \
86 $(LibDeps) GenLibDeps.out
Reid Spencerf2722ca2006-03-22 15:59:55 +000087install-local:: all-local
88 $(Echo) Installing llvm-config
89 $(Verb) $(MKDIR) $(PROJ_bindir)
Reid Spencerdee05112006-06-01 01:52:49 +000090 $(Verb) $(ScriptInstall) $(ToolDir)/llvm-config $(PROJ_bindir)
Reid Spencerb3bd5ca2006-05-03 17:49:50 +000091