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 |
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 | f72538e | 2007-01-06 02:48:03 +0000 | [diff] [blame] | 23 | SUB_CFLAGS = ${CPP.BaseFlags} ${C.Flags} |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 24 | SUB_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. |
| 29 | SUB_LDFLAGS = |
| 30 | |
Reid Spencer | b3bd5ca | 2006-05-03 17:49:50 +0000 | [diff] [blame] | 31 | FinalLibDeps = $(PROJ_OBJ_DIR)/FinalLibDeps.txt |
Chris Lattner | 73ebd09 | 2006-06-06 17:43:03 +0000 | [diff] [blame] | 32 | LibDeps = $(PROJ_OBJ_DIR)/LibDeps.txt |
Reid Spencer | 4fbcdf6 | 2006-12-12 00:43:38 +0000 | [diff] [blame] | 33 | LibDepsTemp = $(PROJ_OBJ_DIR)/LibDeps.txt.tmp |
Chris Lattner | 73ebd09 | 2006-06-06 17:43:03 +0000 | [diff] [blame] | 34 | GenLibDeps = $(PROJ_SRC_ROOT)/utils/GenLibDeps.pl |
| 35 | |
Reid Spencer | 4fbcdf6 | 2006-12-12 00:43:38 +0000 | [diff] [blame] | 36 | $(LibDepsTemp): $(GenLibDeps) $(LibDir) $(wildcard $(LibDir)/*.a $(LibDir)/*.o) |
| 37 | $(Echo) "Regenerating LibDeps.txt.tmp" |
| 38 | $(Verb) $(GenLibDeps) -flat $(LibDir) $(NM_PATH) > $(LibDepsTemp) |
| 39 | |
| 40 | $(LibDeps): $(LibDepsTemp) |
| 41 | $(Verb) $(CMP) -s $@ $< || ( $(CP) $< $@ && \ |
| 42 | $(EchoCmd) Updated LibDeps.txt because dependencies changes ) |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 43 | |
| 44 | # Find all the cyclic dependencies between various LLVM libraries, so we |
| 45 | # don't have to process them at runtime. |
Reid Spencer | 05dee50 | 2006-04-20 21:13:58 +0000 | [diff] [blame] | 46 | $(FinalLibDeps): find-cycles.pl $(LibDeps) |
Chris Lattner | c6c3843 | 2006-12-06 05:39:18 +0000 | [diff] [blame] | 47 | $(Echo) "Checking for cyclic dependencies between LLVM libraries." |
Chris Lattner | 80930eb | 2006-09-04 01:49:10 +0000 | [diff] [blame] | 48 | $(Verb) $(PERL) $< < $(LibDeps) > $@ || rm -f $@ |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 49 | |
| 50 | # Rerun our configure substitutions as needed. |
Reid Spencer | 05dee50 | 2006-04-20 21:13:58 +0000 | [diff] [blame] | 51 | ConfigInIn = $(PROJ_SRC_DIR)/llvm-config.in.in |
| 52 | llvm-config.in: $(ConfigInIn) $(ConfigStatusScript) |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 53 | $(Verb) cd $(PROJ_OBJ_ROOT) ; \ |
Reid Spencer | 05dee50 | 2006-04-20 21:13:58 +0000 | [diff] [blame] | 54 | $(ConfigStatusScript) tools/llvm-config/llvm-config.in |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 55 | |
| 56 | # Build our final script. |
Reid Spencer | dee0511 | 2006-06-01 01:52:49 +0000 | [diff] [blame] | 57 | $(ToolDir)/llvm-config: llvm-config.in $(FinalLibDeps) |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 58 | $(Echo) "Building llvm-config script." |
Reid Spencer | f72538e | 2007-01-06 02:48:03 +0000 | [diff] [blame] | 59 | $(Verb) $(ECHO) 's,@LLVM_CFLAGS@,$(SUB_CFLAGS),' > temp.sed |
Chandler Carruth | d5ee896 | 2007-01-09 02:38:29 +0000 | [diff] [blame^] | 60 | $(Verb) $(ECHO) 's,@LLVM_CXXFLAGS@,$(SUB_CXXFLAGS),' >> temp.sed |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 61 | $(Verb) $(ECHO) 's,@LLVM_LDFLAGS@,$(SUB_LDFLAGS),' >> temp.sed |
Chris Lattner | abdbae7 | 2006-06-02 19:13:29 +0000 | [diff] [blame] | 62 | $(Verb) $(ECHO) 's,@LLVM_BUILDMODE@,$(BuildMode),' >> temp.sed |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 63 | $(Verb) $(SED) -f temp.sed < $< > $@ |
| 64 | $(Verb) $(RM) temp.sed |
Reid Spencer | 05dee50 | 2006-04-20 21:13:58 +0000 | [diff] [blame] | 65 | $(Verb) cat $(FinalLibDeps) >> $@ |
Reid Spencer | b3bd5ca | 2006-05-03 17:49:50 +0000 | [diff] [blame] | 66 | $(Verb) chmod +x $@ |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 67 | |
Reid Spencer | b3bd5ca | 2006-05-03 17:49:50 +0000 | [diff] [blame] | 68 | else |
| 69 | # We don't have perl, just generate a dummy llvm-config |
Reid Spencer | dee0511 | 2006-06-01 01:52:49 +0000 | [diff] [blame] | 70 | $(ToolDir)/llvm-config: |
Reid Spencer | b3bd5ca | 2006-05-03 17:49:50 +0000 | [diff] [blame] | 71 | $(Echo) "Building place holder llvm-config script." |
| 72 | $(Verb) $(ECHO) 'echo llvm-config: Perl not found so llvm-config could not be generated' >> $@ |
| 73 | $(Verb) chmod +x $@ |
| 74 | |
| 75 | endif |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 76 | # Hook into the standard Makefile rules. |
Reid Spencer | dee0511 | 2006-06-01 01:52:49 +0000 | [diff] [blame] | 77 | all-local:: $(ToolDir)/llvm-config |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 78 | clean-local:: |
Reid Spencer | dee0511 | 2006-06-01 01:52:49 +0000 | [diff] [blame] | 79 | $(Verb) $(RM) -f $(ToolDir)/llvm-config llvm-config.in $(FinalLibDeps) \ |
| 80 | $(LibDeps) GenLibDeps.out |
Reid Spencer | f2722ca | 2006-03-22 15:59:55 +0000 | [diff] [blame] | 81 | install-local:: all-local |
| 82 | $(Echo) Installing llvm-config |
| 83 | $(Verb) $(MKDIR) $(PROJ_bindir) |
Reid Spencer | dee0511 | 2006-06-01 01:52:49 +0000 | [diff] [blame] | 84 | $(Verb) $(ScriptInstall) $(ToolDir)/llvm-config $(PROJ_bindir) |
Reid Spencer | b3bd5ca | 2006-05-03 17:49:50 +0000 | [diff] [blame] | 85 | |