blob: c7f7b3234d64b6633f3ae2c6c2b8cabbc6e01dbf [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
Torok Edwin18743f42010-02-04 09:31:35 +000056llvm-config-perobj: llvm-config.in $(GenLibDeps) $(LibDir) $(wildcard $(LibDir)/*.a)
57 $(Echo) "Generating llvm-config-perobj"
58 $(Verb) $(PERL) $(GenLibDeps) -perobj -flat $(LibDir) "$(NM_PATH)" >PerobjDeps.txt
59 $(Echo) "Checking for cyclic dependencies between LLVM objects."
60 $(Verb) $(PERL) $(PROJ_SRC_DIR)/find-cycles.pl < PerobjDepsIncl.txt > PerobjDepsInclFinal.txt || rm -f $@
61 $(Verb) $(ECHO) 's/@LLVM_CPPFLAGS@/$(subst /,\/,$(SUB_CPPFLAGS))/' \
62 > temp.sed
63 $(Verb) $(ECHO) 's/@LLVM_CFLAGS@/$(subst /,\/,$(SUB_CFLAGS))/' \
64 >> temp.sed
65 $(Verb) $(ECHO) 's/@LLVM_CXXFLAGS@/$(subst /,\/,$(SUB_CXXFLAGS))/' \
66 >> temp.sed
67 $(Verb) $(ECHO) 's/@LLVM_LDFLAGS@/$(subst /,\/,$(SUB_LDFLAGS))/' \
68 >> temp.sed
69 $(Verb) $(ECHO) 's/@LLVM_BUILDMODE@/$(subst /,\/,$(BuildMode))/' \
70 >> temp.sed
71 $(Verb) $(SED) -f temp.sed < $< > $@
72 $(Verb) $(RM) temp.sed
73 $(Verb) cat PerobjDepsFinal.txt >> $@
74 $(Verb) chmod +x $@
75
76llvm-config-perobjincl: llvm-config.in $(GenLibDeps) $(LibDir) $(wildcard $(LibDir)/*.a)
77 $(Echo) "Generating llvm-config-perobjincl"
78 $(Verb) $(PERL) $(GenLibDeps) -perobj -perobjincl -flat $(LibDir) "$(NM_PATH)" >PerobjDepsIncl.txt
79 $(Echo) "Checking for cyclic dependencies between LLVM objects."
80 $(Verb) $(PERL) $(PROJ_SRC_DIR)/find-cycles.pl < PerobjDepsIncl.txt > PerobjDepsInclFinal.txt
81 $(Verb) $(ECHO) 's/@LLVM_CPPFLAGS@/$(subst /,\/,$(SUB_CPPFLAGS))/' \
82 > temp.sed
83 $(Verb) $(ECHO) 's/@LLVM_CFLAGS@/$(subst /,\/,$(SUB_CFLAGS))/' \
84 >> temp.sed
85 $(Verb) $(ECHO) 's/@LLVM_CXXFLAGS@/$(subst /,\/,$(SUB_CXXFLAGS))/' \
86 >> temp.sed
87 $(Verb) $(ECHO) 's/@LLVM_LDFLAGS@/$(subst /,\/,$(SUB_LDFLAGS))/' \
88 >> temp.sed
89 $(Verb) $(ECHO) 's/@LLVM_BUILDMODE@/$(subst /,\/,$(BuildMode))/' \
90 >> temp.sed
91 $(Verb) $(SED) -f temp.sed < $< > $@
92 $(Verb) $(RM) temp.sed
93 $(Verb) cat PerobjDepsInclFinal.txt >> $@
94 $(Verb) chmod +x $@
95
Reid Spencerf2722ca2006-03-22 15:59:55 +000096# Build our final script.
Reid Spencerdee05112006-06-01 01:52:49 +000097$(ToolDir)/llvm-config: llvm-config.in $(FinalLibDeps)
Reid Spencerf2722ca2006-03-22 15:59:55 +000098 $(Echo) "Building llvm-config script."
Dan Gohman4832f882009-03-10 19:01:23 +000099 $(Verb) $(ECHO) 's/@LLVM_CPPFLAGS@/$(subst /,\/,$(SUB_CPPFLAGS))/' \
100 > temp.sed
101 $(Verb) $(ECHO) 's/@LLVM_CFLAGS@/$(subst /,\/,$(SUB_CFLAGS))/' \
102 >> temp.sed
103 $(Verb) $(ECHO) 's/@LLVM_CXXFLAGS@/$(subst /,\/,$(SUB_CXXFLAGS))/' \
104 >> temp.sed
105 $(Verb) $(ECHO) 's/@LLVM_LDFLAGS@/$(subst /,\/,$(SUB_LDFLAGS))/' \
106 >> temp.sed
107 $(Verb) $(ECHO) 's/@LLVM_BUILDMODE@/$(subst /,\/,$(BuildMode))/' \
108 >> temp.sed
Reid Spencerf2722ca2006-03-22 15:59:55 +0000109 $(Verb) $(SED) -f temp.sed < $< > $@
110 $(Verb) $(RM) temp.sed
Reid Spencer05dee502006-04-20 21:13:58 +0000111 $(Verb) cat $(FinalLibDeps) >> $@
Reid Spencerb3bd5ca2006-05-03 17:49:50 +0000112 $(Verb) chmod +x $@
Reid Spencerf2722ca2006-03-22 15:59:55 +0000113
Reid Spencerb3bd5ca2006-05-03 17:49:50 +0000114else
115# We don't have perl, just generate a dummy llvm-config
Reid Spencerdee05112006-06-01 01:52:49 +0000116$(ToolDir)/llvm-config:
Reid Spencerb3bd5ca2006-05-03 17:49:50 +0000117 $(Echo) "Building place holder llvm-config script."
118 $(Verb) $(ECHO) 'echo llvm-config: Perl not found so llvm-config could not be generated' >> $@
119 $(Verb) chmod +x $@
120
121endif
Reid Spencerf2722ca2006-03-22 15:59:55 +0000122# Hook into the standard Makefile rules.
Reid Spencerdee05112006-06-01 01:52:49 +0000123all-local:: $(ToolDir)/llvm-config
Reid Spencerf2722ca2006-03-22 15:59:55 +0000124clean-local::
Reid Spencerdee05112006-06-01 01:52:49 +0000125 $(Verb) $(RM) -f $(ToolDir)/llvm-config llvm-config.in $(FinalLibDeps) \
126 $(LibDeps) GenLibDeps.out
Reid Spencerf2722ca2006-03-22 15:59:55 +0000127install-local:: all-local
128 $(Echo) Installing llvm-config
Erick Tryzelaard4076cf2010-03-04 20:56:19 +0000129 $(Verb) $(MKDIR) $(DESTDIR)$(PROJ_bindir)
130 $(Verb) $(ScriptInstall) $(ToolDir)/llvm-config $(DESTDIR)$(PROJ_bindir)
Reid Spencerb3bd5ca2006-05-03 17:49:50 +0000131