Home | History | Annotate | Download | only in llvm-config
      1 ##===- tools/llvm-config/Makefile --------------------------*- Makefile -*-===##
      2 #
      3 #                     The LLVM Compiler Infrastructure
      4 #
      5 # This file is distributed under the University of Illinois Open Source
      6 # License. See LICENSE.TXT for details.
      7 # 
      8 ##===----------------------------------------------------------------------===##
      9 
     10 LEVEL = ../..
     11 
     12 EXTRA_DIST = LibDeps.txt FinalLibDeps.txt llvm-config.in.in find-cycles.pl
     13 
     14 include $(LEVEL)/Makefile.common
     15 
     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 
     21 # Combine preprocessor flags (except for -I) and CXX flags.
     22 SUB_CPPFLAGS = ${CPP.BaseFlags}
     23 SUB_CFLAGS   = ${CPP.BaseFlags} ${C.Flags}
     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 
     31 FinalLibDeps = $(PROJ_OBJ_DIR)/FinalLibDeps.txt
     32 LibDeps      = $(PROJ_OBJ_DIR)/LibDeps.txt
     33 LibDepsTemp  = $(PROJ_OBJ_DIR)/LibDeps.txt.tmp
     34 GenLibDeps   = $(PROJ_SRC_ROOT)/utils/GenLibDeps.pl
     35 
     36 $(LibDepsTemp): $(GenLibDeps) $(LibDir) $(wildcard $(LibDir)/*.a $(LibDir)/*.o)
     37 	$(Echo) "Regenerating LibDeps.txt.tmp"
     38 	$(Verb) $(PERL) $(GenLibDeps) -flat $(LibDir) "$(NM_PATH)" > $(LibDepsTemp)
     39 
     40 $(LibDeps): $(LibDepsTemp)
     41 	$(Verb) $(CMP) -s $@ $< || ( $(CP) $< $@ && \
     42 	  $(EchoCmd) Updated LibDeps.txt because dependencies changed )
     43 
     44 # Find all the cyclic dependencies between various LLVM libraries, so we
     45 # don't have to process them at runtime.
     46 $(FinalLibDeps): find-cycles.pl $(LibDeps)
     47 	$(Echo) "Checking for cyclic dependencies between LLVM libraries."
     48 	$(Verb) $(PERL) $< < $(LibDeps) > $@ || rm -f $@
     49 
     50 # Rerun our configure substitutions as needed.
     51 ConfigInIn = $(PROJ_SRC_DIR)/llvm-config.in.in
     52 llvm-config.in: $(ConfigInIn) $(ConfigStatusScript)
     53 	$(Verb) cd $(PROJ_OBJ_ROOT) ; \
     54 		$(ConfigStatusScript) tools/llvm-config/llvm-config.in
     55 
     56 llvm-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 
     76 llvm-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 
     96 # Build our final script.
     97 $(ToolDir)/llvm-config: llvm-config.in $(FinalLibDeps)
     98 	$(Echo) "Building llvm-config script."
     99 	$(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
    109 	$(Verb) $(SED) -f temp.sed < $< > $@
    110 	$(Verb) $(RM) temp.sed
    111 	$(Verb) cat $(FinalLibDeps) >> $@
    112 	$(Verb) chmod +x $@
    113 
    114 else
    115 # We don't have perl, just generate a dummy llvm-config
    116 $(ToolDir)/llvm-config:
    117 	$(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 
    121 endif
    122 # Hook into the standard Makefile rules.
    123 all-local:: $(ToolDir)/llvm-config
    124 clean-local::
    125 	$(Verb) $(RM) -f $(ToolDir)/llvm-config llvm-config.in $(FinalLibDeps) \
    126 	  $(LibDeps) GenLibDeps.out
    127 install-local:: all-local
    128 	$(Echo) Installing llvm-config
    129 	$(Verb) $(MKDIR) $(DESTDIR)$(PROJ_bindir)
    130 	$(Verb) $(ScriptInstall) $(ToolDir)/llvm-config $(DESTDIR)$(PROJ_bindir)
    131 
    132