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 | # |
| 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 | |
| 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 |
Reid Spencer | 0fab2b1 | 2006-03-19 22:10:53 +0000 | [diff] [blame] | 13 | |
| 14 | include $(LEVEL)/Makefile.common |
| 15 | |
Reid Spencer | b3bd5ca | 2006-05-03 17:49:50 +0000 | [diff] [blame] | 16 | # 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. |
| 19 | ifeq ($(HAVE_PERL),1) |
| 20 | |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 21 | # Combine preprocessor flags (except for -I) and CXX flags. |
| 22 | SUB_CXXFLAGS = ${CPP.BaseFlags} ${CXX.Flags} |
| 23 | |
| 24 | # This is blank for now. We need to be careful about adding stuff here: |
| 25 | # LDFLAGS tend not to be portable, and we don't currently require the |
| 26 | # user to use libtool when linking against LLVM. |
| 27 | SUB_LDFLAGS = |
| 28 | |
Reid Spencer | b3bd5ca | 2006-05-03 17:49:50 +0000 | [diff] [blame] | 29 | FinalLibDeps = $(PROJ_OBJ_DIR)/FinalLibDeps.txt |
| 30 | LibDeps = $(PROJ_OBJ_DIR)/LibDeps.txt |
Reid Spencer | 05dee50 | 2006-04-20 21:13:58 +0000 | [diff] [blame] | 31 | GenLibDeps = $(PROJ_SRC_ROOT)/utils/GenLibDeps.pl |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 32 | # MANUAL USE ONLY! GenLibDeps.pl is very non-portable, so LibDeps.txt |
| 33 | # should only be re-built manually. No other rule in this file should |
| 34 | # depend on LibDeps.txt. |
Reid Spencer | 05dee50 | 2006-04-20 21:13:58 +0000 | [diff] [blame] | 35 | $(LibDeps): $(GenLibDeps) $(LibDir) |
Reid Spencer | 025213e | 2006-03-23 22:42:50 +0000 | [diff] [blame] | 36 | $(Echo) "Regenerating LibDeps.txt" |
Reid Spencer | 05dee50 | 2006-04-20 21:13:58 +0000 | [diff] [blame] | 37 | $(Verb) $(GenLibDeps) -flat $(LibDir) | sort > $(LibDeps) |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 38 | |
| 39 | # Find all the cyclic dependencies between various LLVM libraries, so we |
| 40 | # don't have to process them at runtime. |
Reid Spencer | 05dee50 | 2006-04-20 21:13:58 +0000 | [diff] [blame] | 41 | $(FinalLibDeps): find-cycles.pl $(LibDeps) |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 42 | $(Echo) "Finding cyclic dependencies between LLVM libraries." |
Reid Spencer | b3bd5ca | 2006-05-03 17:49:50 +0000 | [diff] [blame] | 43 | $(Verb) $(PERL) $< < $(LibDeps) > $@ |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 44 | |
| 45 | # Rerun our configure substitutions as needed. |
Reid Spencer | 05dee50 | 2006-04-20 21:13:58 +0000 | [diff] [blame] | 46 | ConfigInIn = $(PROJ_SRC_DIR)/llvm-config.in.in |
| 47 | llvm-config.in: $(ConfigInIn) $(ConfigStatusScript) |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 48 | $(Verb) cd $(PROJ_OBJ_ROOT) ; \ |
Reid Spencer | 05dee50 | 2006-04-20 21:13:58 +0000 | [diff] [blame] | 49 | $(ConfigStatusScript) tools/llvm-config/llvm-config.in |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 50 | |
| 51 | # Build our final script. |
Reid Spencer | dee0511 | 2006-06-01 01:52:49 +0000 | [diff] [blame] | 52 | $(ToolDir)/llvm-config: llvm-config.in $(FinalLibDeps) |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 53 | $(Echo) "Building llvm-config script." |
| 54 | $(Verb) $(ECHO) 's,@LLVM_CXXFLAGS@,$(SUB_CXXFLAGS),' > temp.sed |
| 55 | $(Verb) $(ECHO) 's,@LLVM_LDFLAGS@,$(SUB_LDFLAGS),' >> temp.sed |
Chris Lattner | abdbae7 | 2006-06-02 19:13:29 +0000 | [diff] [blame^] | 56 | $(Verb) $(ECHO) 's,@LLVM_BUILDMODE@,$(BuildMode),' >> temp.sed |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 57 | $(Verb) $(SED) -f temp.sed < $< > $@ |
| 58 | $(Verb) $(RM) temp.sed |
Reid Spencer | 05dee50 | 2006-04-20 21:13:58 +0000 | [diff] [blame] | 59 | $(Verb) cat $(FinalLibDeps) >> $@ |
Reid Spencer | b3bd5ca | 2006-05-03 17:49:50 +0000 | [diff] [blame] | 60 | $(Verb) chmod +x $@ |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 61 | |
Reid Spencer | b3bd5ca | 2006-05-03 17:49:50 +0000 | [diff] [blame] | 62 | else |
| 63 | # We don't have perl, just generate a dummy llvm-config |
Reid Spencer | dee0511 | 2006-06-01 01:52:49 +0000 | [diff] [blame] | 64 | $(ToolDir)/llvm-config: |
Reid Spencer | b3bd5ca | 2006-05-03 17:49:50 +0000 | [diff] [blame] | 65 | $(Echo) "Building place holder llvm-config script." |
| 66 | $(Verb) $(ECHO) 'echo llvm-config: Perl not found so llvm-config could not be generated' >> $@ |
| 67 | $(Verb) chmod +x $@ |
| 68 | |
| 69 | endif |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 70 | # Hook into the standard Makefile rules. |
Reid Spencer | dee0511 | 2006-06-01 01:52:49 +0000 | [diff] [blame] | 71 | all-local:: $(ToolDir)/llvm-config |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 72 | clean-local:: |
Reid Spencer | dee0511 | 2006-06-01 01:52:49 +0000 | [diff] [blame] | 73 | $(Verb) $(RM) -f $(ToolDir)/llvm-config llvm-config.in $(FinalLibDeps) \ |
| 74 | $(LibDeps) GenLibDeps.out |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 75 | install-local:: all-local |
| 76 | $(Echo) Installing llvm-config |
| 77 | $(Verb) $(MKDIR) $(PROJ_bindir) |
Reid Spencer | dee0511 | 2006-06-01 01:52:49 +0000 | [diff] [blame] | 78 | $(Verb) $(ScriptInstall) $(ToolDir)/llvm-config $(PROJ_bindir) |
Reid Spencer | b3bd5ca | 2006-05-03 17:49:50 +0000 | [diff] [blame] | 79 | |