Reid Spencer | 05dee50 | 2006-04-20 21:13:58 +0000 | [diff] [blame] | 1 | ##===- tools/llvm-config/Makefile --------------------------*- Makefile -*-===## |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 2 | # |
Reid Spencer | 0fab2b1 | 2006-03-19 22:10:53 +0000 | [diff] [blame] | 3 | # The LLVM Compiler Infrastructure |
| 4 | # |
Chris Lattner | 5116784 | 2007-12-29 20:07:17 +0000 | [diff] [blame] | 5 | # This file is distributed under the University of Illinois Open Source |
| 6 | # License. See LICENSE.TXT for details. |
Reid Spencer | 0fab2b1 | 2006-03-19 22:10:53 +0000 | [diff] [blame] | 7 | # |
| 8 | ##===----------------------------------------------------------------------===## |
| 9 | |
| 10 | LEVEL = ../.. |
| 11 | |
Reid Spencer | b3bd5ca | 2006-05-03 17:49:50 +0000 | [diff] [blame] | 12 | EXTRA_DIST = LibDeps.txt FinalLibDeps.txt llvm-config.in.in find-cycles.pl |
Chris Lattner | 0465fa9 | 2006-07-07 00:46:19 +0000 | [diff] [blame] | 13 | REQUIRES_EH := 1 |
Reid Spencer | 0fab2b1 | 2006-03-19 22:10:53 +0000 | [diff] [blame] | 14 | |
| 15 | include $(LEVEL)/Makefile.common |
| 16 | |
Reid Spencer | b3bd5ca | 2006-05-03 17:49:50 +0000 | [diff] [blame] | 17 | # 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. |
| 20 | ifeq ($(HAVE_PERL),1) |
| 21 | |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 22 | # Combine preprocessor flags (except for -I) and CXX flags. |
Reid Spencer | 4a2c083 | 2007-07-10 07:21:34 +0000 | [diff] [blame] | 23 | SUB_CPPFLAGS = ${CPP.BaseFlags} |
| 24 | SUB_CFLAGS = ${CPP.BaseFlags} ${C.Flags} |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 25 | SUB_CXXFLAGS = ${CPP.BaseFlags} ${CXX.Flags} |
| 26 | |
| 27 | # This is blank for now. We need to be careful about adding stuff here: |
| 28 | # LDFLAGS tend not to be portable, and we don't currently require the |
| 29 | # user to use libtool when linking against LLVM. |
| 30 | SUB_LDFLAGS = |
| 31 | |
Reid Spencer | b3bd5ca | 2006-05-03 17:49:50 +0000 | [diff] [blame] | 32 | FinalLibDeps = $(PROJ_OBJ_DIR)/FinalLibDeps.txt |
Chris Lattner | 73ebd09 | 2006-06-06 17:43:03 +0000 | [diff] [blame] | 33 | LibDeps = $(PROJ_OBJ_DIR)/LibDeps.txt |
Reid Spencer | 4fbcdf6 | 2006-12-12 00:43:38 +0000 | [diff] [blame] | 34 | LibDepsTemp = $(PROJ_OBJ_DIR)/LibDeps.txt.tmp |
Chris Lattner | 73ebd09 | 2006-06-06 17:43:03 +0000 | [diff] [blame] | 35 | GenLibDeps = $(PROJ_SRC_ROOT)/utils/GenLibDeps.pl |
| 36 | |
Reid Spencer | 4fbcdf6 | 2006-12-12 00:43:38 +0000 | [diff] [blame] | 37 | $(LibDepsTemp): $(GenLibDeps) $(LibDir) $(wildcard $(LibDir)/*.a $(LibDir)/*.o) |
| 38 | $(Echo) "Regenerating LibDeps.txt.tmp" |
Ted Kremenek | f248f0d | 2007-11-27 17:53:54 +0000 | [diff] [blame] | 39 | $(Verb) $(PERL) $(GenLibDeps) -flat $(LibDir) "$(NM_PATH)" > $(LibDepsTemp) |
Reid Spencer | 4fbcdf6 | 2006-12-12 00:43:38 +0000 | [diff] [blame] | 40 | |
| 41 | $(LibDeps): $(LibDepsTemp) |
| 42 | $(Verb) $(CMP) -s $@ $< || ( $(CP) $< $@ && \ |
Reid Spencer | d7fc4f6 | 2007-02-04 22:08:16 +0000 | [diff] [blame] | 43 | $(EchoCmd) Updated LibDeps.txt because dependencies changed ) |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 44 | |
| 45 | # Find all the cyclic dependencies between various LLVM libraries, so we |
| 46 | # don't have to process them at runtime. |
Reid Spencer | 05dee50 | 2006-04-20 21:13:58 +0000 | [diff] [blame] | 47 | $(FinalLibDeps): find-cycles.pl $(LibDeps) |
Chris Lattner | c6c3843 | 2006-12-06 05:39:18 +0000 | [diff] [blame] | 48 | $(Echo) "Checking for cyclic dependencies between LLVM libraries." |
Chris Lattner | 80930eb | 2006-09-04 01:49:10 +0000 | [diff] [blame] | 49 | $(Verb) $(PERL) $< < $(LibDeps) > $@ || rm -f $@ |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 50 | |
| 51 | # Rerun our configure substitutions as needed. |
Reid Spencer | 05dee50 | 2006-04-20 21:13:58 +0000 | [diff] [blame] | 52 | ConfigInIn = $(PROJ_SRC_DIR)/llvm-config.in.in |
| 53 | llvm-config.in: $(ConfigInIn) $(ConfigStatusScript) |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 54 | $(Verb) cd $(PROJ_OBJ_ROOT) ; \ |
Reid Spencer | 05dee50 | 2006-04-20 21:13:58 +0000 | [diff] [blame] | 55 | $(ConfigStatusScript) tools/llvm-config/llvm-config.in |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 56 | |
| 57 | # Build our final script. |
Reid Spencer | dee0511 | 2006-06-01 01:52:49 +0000 | [diff] [blame] | 58 | $(ToolDir)/llvm-config: llvm-config.in $(FinalLibDeps) |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 59 | $(Echo) "Building llvm-config script." |
David Greene | a696d24 | 2007-06-28 19:36:08 +0000 | [diff] [blame] | 60 | $(Verb) $(ECHO) 's,@LLVM_CPPFLAGS@,$(SUB_CPPFLAGS),' > temp.sed |
| 61 | $(Verb) $(ECHO) 's,@LLVM_CFLAGS@,$(SUB_CFLAGS),' >> temp.sed |
Chandler Carruth | d5ee896 | 2007-01-09 02:38:29 +0000 | [diff] [blame] | 62 | $(Verb) $(ECHO) 's,@LLVM_CXXFLAGS@,$(SUB_CXXFLAGS),' >> temp.sed |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 63 | $(Verb) $(ECHO) 's,@LLVM_LDFLAGS@,$(SUB_LDFLAGS),' >> temp.sed |
Chris Lattner | abdbae7 | 2006-06-02 19:13:29 +0000 | [diff] [blame] | 64 | $(Verb) $(ECHO) 's,@LLVM_BUILDMODE@,$(BuildMode),' >> temp.sed |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 65 | $(Verb) $(SED) -f temp.sed < $< > $@ |
| 66 | $(Verb) $(RM) temp.sed |
Reid Spencer | 05dee50 | 2006-04-20 21:13:58 +0000 | [diff] [blame] | 67 | $(Verb) cat $(FinalLibDeps) >> $@ |
Reid Spencer | b3bd5ca | 2006-05-03 17:49:50 +0000 | [diff] [blame] | 68 | $(Verb) chmod +x $@ |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 69 | |
Reid Spencer | b3bd5ca | 2006-05-03 17:49:50 +0000 | [diff] [blame] | 70 | else |
| 71 | # We don't have perl, just generate a dummy llvm-config |
Reid Spencer | dee0511 | 2006-06-01 01:52:49 +0000 | [diff] [blame] | 72 | $(ToolDir)/llvm-config: |
Reid Spencer | b3bd5ca | 2006-05-03 17:49:50 +0000 | [diff] [blame] | 73 | $(Echo) "Building place holder llvm-config script." |
| 74 | $(Verb) $(ECHO) 'echo llvm-config: Perl not found so llvm-config could not be generated' >> $@ |
| 75 | $(Verb) chmod +x $@ |
| 76 | |
| 77 | endif |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 78 | # Hook into the standard Makefile rules. |
Reid Spencer | dee0511 | 2006-06-01 01:52:49 +0000 | [diff] [blame] | 79 | all-local:: $(ToolDir)/llvm-config |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 80 | clean-local:: |
Reid Spencer | dee0511 | 2006-06-01 01:52:49 +0000 | [diff] [blame] | 81 | $(Verb) $(RM) -f $(ToolDir)/llvm-config llvm-config.in $(FinalLibDeps) \ |
| 82 | $(LibDeps) GenLibDeps.out |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 83 | install-local:: all-local |
| 84 | $(Echo) Installing llvm-config |
| 85 | $(Verb) $(MKDIR) $(PROJ_bindir) |
Reid Spencer | dee0511 | 2006-06-01 01:52:49 +0000 | [diff] [blame] | 86 | $(Verb) $(ScriptInstall) $(ToolDir)/llvm-config $(PROJ_bindir) |
Reid Spencer | b3bd5ca | 2006-05-03 17:49:50 +0000 | [diff] [blame] | 87 | |