llvm.org GIT mirror llvm / 481cc7c
Implement BYTECODE_LIBRARY support git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7855 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 16 years ago
2 changed file(s) with 124 addition(s) and 20 deletion(s). Raw diff Collapse all Expand all
118118 # It is typically the root directory of what we're compiling now.
119119 #
120120 ifndef LLVM_SRC_ROOT
121 LLVM_SRC_ROOT = $(BUILD_SRC_ROOT)
121 LLVM_SRC_ROOT := $(BUILD_SRC_ROOT)
122122 endif
123123
124124 #
125125 # Set the LLVM object directory.
126126 #
127127 ifndef LLVM_OBJ_ROOT
128 LLVM_OBJ_ROOT = $(BUILD_OBJ_ROOT)
128 LLVM_OBJ_ROOT := $(BUILD_OBJ_ROOT)
129129 endif
130130
131131 ###########################################################################
142142 ifdef BYTECODE_LIBRARY
143143 # if BYTECODE_LIBRARY is specified, the default is to build the bytecode lib
144144 all:: bytecodelib
145 install:: bytecodelib-install
145146 endif
146147
147148 # Default Rule: Make sure it's also a :: rule
171172 # slightly since GNU Make will not try to find implicit rules for targets
172173 # which are marked as Phony.
173174 #
174 .PHONY: all dynamic bytecodelib clean distclean install test bytecode prdirs
175 .PHONY: all dynamic bytecodelib bytecodelib-install
176 .PHONY: clean distclean install test bytecode prdirs
175177
176178 ###########################################################################
177179 # Miscellaneous paths and commands:
226228 DESTLIBDEBUG := $(BUILD_OBJ_ROOT)/lib/Debug
227229 DESTLIBRELEASE := $(BUILD_OBJ_ROOT)/lib/Release
228230 DESTLIBPROFILE := $(BUILD_OBJ_ROOT)/lib/Profile
231 DESTLIBBYTECODE := $(BUILD_OBJ_ROOT)/lib/Bytecode
229232 DESTLIBCURRENT := $(BUILD_OBJ_ROOT)/lib/$(CONFIGURATION)
230233
231234 # LLVM libraries used for linking
299302 ###########################################################################
300303
301304 #--------------------------------------------------------------------------
302 # Special tools used while building the LLVM tree. Burg is built as part
303 # of the utils directory.
304 #--------------------------------------------------------------------------
305 # Utilities used while building the LLVM tree, which live in the utils dir
306 #
305307 BURG := $(LLVMTOOLCURRENT)/burg
306308 RunBurg := $(BURG) $(BURG_OPTS)
307
308309 TBLGEN := $(LLVMTOOLCURRENT)/tblgen
310
311 #--------------------------------------------------------------------------
312 # The LLVM GCC front-end in C and C++ flavors
313 #
314 LLVMGCC := $(LLVMGCCDIR)/bin/gcc
315 LCC1 := $(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH)/cc1
316 LLVMGXX := $(LLVMGCCDIR)/bin/g++
317 LCC1XX := $(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH)/cc1plus
318
319 #--------------------------------------------------------------------------
320 # Some of the compiled LLVM tools which are used for compilation of runtime
321 # libraries.
322 #
323 LLVMAS := $(LLVMTOOLCURRENT)/as
309324
310325
311326 ###########################################################################
398413 #
399414 # Libtool Objects
400415 #
401 Objs := $(sort $(patsubst Debug/%.lo, %.lo, $(addsuffix .lo,$(notdir $(basename $(Source))))))
416 Srcs := $(sort $(notdir $(basename $(Source))))
417 Objs := $(addsuffix .lo, $(Srcs))
402418 ObjectsO := $(addprefix $(BUILD_OBJ_DIR)/Release/,$(Objs))
403419 ObjectsP := $(addprefix $(BUILD_OBJ_DIR)/Profile/,$(Objs))
404420 ObjectsG := $(addprefix $(BUILD_OBJ_DIR)/Debug/,$(Objs))
421 ObjectsBC := $(addprefix $(BUILD_OBJ_DIR)/Bytecode/,$(addsuffix .bc, $(Srcs)))
405422
406423 #
407424 # The real objects underlying the libtool objects
480497 LIBNAME_OBJO := $(DESTLIBRELEASE)/$(LIBRARYNAME).o
481498 LIBNAME_OBJP := $(DESTLIBPROFILE)/$(LIBRARYNAME).o
482499 LIBNAME_OBJG := $(DESTLIBDEBUG)/$(LIBRARYNAME).o
500 LIBNAME_BC := $(DESTLIBBYTECODE)/lib$(LIBRARYNAME).bc
483501
484502 #--------------------------------------------------------------------
485503 # Library Targets
488506
489507 # dynamic target builds a shared object version of the library...
490508 dynamic:: $(DESTLIBCURRENT)/lib$(LIBRARYNAME).so
509 bytecodelib:: $(LIBNAME_BC)
510 bytecodelib-install:: $(LLVMGCCDIR)/bytecode-libs/lib$(LIBRARYNAME).bc
511
512 $(LLVMGCCDIR)/bytecode-libs/lib$(LIBRARYNAME).bc: $(LIBNAME_BC)
513 @echo ======= Installing $(LIBRARYNAME) bytecode library =======
514 cp $< $@
491515
492516 # Does the library want a .o version built?
493517 ifndef DONT_BUILD_RELINKED
503527 # Rules for building libraries
504528 #--------------------------------------------------------------------
505529
530 LinkBCLib := $(LLVMGCC) -shared
531 ifdef EXPORTED_SYMBOL_LIST
532 LinkBCLib += -Xlinker -internalize-public-api-list=$(EXPORTED_SYMBOL_LIST)
533 else
534 LinkBCLib += -Xlinker -disable-internalize
535 endif
536
537
538 # Rule for building bytecode libraries.
539 $(LIBNAME_BC): $(ObjectsBC) $(LibSubDirs)
540 @echo ======= Linking $(LIBRARYNAME) bytecode library =======
541 $(VERB) $(LinkBCLib) -o $@ $(ObjectsBC) $(LibSubDirs) $(LibLinkOpts)
506542 #
507543 # Rules for building dynamically linked libraries.
508544 #
538574 @echo ======= Linking $(LIBRARYNAME) archive debug library =======
539575 @$(RM) -f $@
540576 $(VERB) $(Link) -g $(STRIP) -o $@ $(ObjectsG) $(LibSubDirs) -static
577
541578
542579 #
543580 # Rules for building .o libraries.
662699
663700
664701 #---------------------------------------------------------
665 .PRECIOUS: $(BUILD_OBJ_DIR)/Depend/.dir
702 .PRECIOUS: $(BUILD_OBJ_DIR)/Depend/.dir $(BUILD_OBJ_DIR)/Bytecode/.dir
666703 .PRECIOUS: $(BUILD_OBJ_DIR)/Debug/.dir $(BUILD_OBJ_DIR)/Release/.dir
667704
668705 # Create .lo files in the ObjectFiles directory from the .cpp and .c files...
689726 $(BUILD_OBJ_DIR)/Debug/%.lo: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Debug/.dir
690727 @echo "Compiling $<"
691728 $(VERB) $(CompileCG) $< -o $@
729
730 $(BUILD_OBJ_DIR)/Bytecode/%.bc: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Bytecode/.dir $(LCC1XX)
731 @echo "Compiling $< to bytecode"
732 $(VERB) $(LLVMGXX) $(CPPFLAGS) -c $< -o $@
733
734 $(BUILD_OBJ_DIR)/Bytecode/%.bc: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Bytecode/.dir $(LCC1)
735 @echo "Compiling $< to bytecode"
736 $(VERB) $(LLVMGCC) $(CPPFLAGS) -c $< -o $@
737
738 $(BUILD_OBJ_DIR)/Bytecode/%.bc: $(SourceDir)%.ll $(BUILD_OBJ_DIR)/Bytecode/.dir $(LCC1)
739 @echo "Compiling $< to bytecode"
740 $(VERB) $(LLVMAS) $< -f -o $@
741
692742
693743 #
694744 # Rules for building lex/yacc files
746796
747797 # 'make clean' nukes the tree
748798 clean::
749 $(VERB) $(RM) -rf $(BUILD_OBJ_DIR)/Debug $(BUILD_OBJ_DIR)/Release $(BUILD_OBJ_DIR)/Profile $(BUILD_OBJ_DIR)/Depend
799 $(VERB) $(RM) -rf $(BUILD_OBJ_DIR)/Debug $(BUILD_OBJ_DIR)/Release
800 $(VERB) $(RM) -rf $(BUILD_OBJ_DIR)/Profile $(BUILD_OBJ_DIR)/Depend
801 $(VERB) $(RM) -rf $(BUILD_OBJ_DIR)/Bytecode
750802 $(VERB) $(RM) -f core core.[0-9][0-9]* *.o *.d *.so *~ *.flc
751803 $(VERB) $(RM) -f $(LEX_OUTPUT) $(YACC_OUTPUT)
752804
118118 # It is typically the root directory of what we're compiling now.
119119 #
120120 ifndef LLVM_SRC_ROOT
121 LLVM_SRC_ROOT = $(BUILD_SRC_ROOT)
121 LLVM_SRC_ROOT := $(BUILD_SRC_ROOT)
122122 endif
123123
124124 #
125125 # Set the LLVM object directory.
126126 #
127127 ifndef LLVM_OBJ_ROOT
128 LLVM_OBJ_ROOT = $(BUILD_OBJ_ROOT)
128 LLVM_OBJ_ROOT := $(BUILD_OBJ_ROOT)
129129 endif
130130
131131 ###########################################################################
142142 ifdef BYTECODE_LIBRARY
143143 # if BYTECODE_LIBRARY is specified, the default is to build the bytecode lib
144144 all:: bytecodelib
145 install:: bytecodelib-install
145146 endif
146147
147148 # Default Rule: Make sure it's also a :: rule
171172 # slightly since GNU Make will not try to find implicit rules for targets
172173 # which are marked as Phony.
173174 #
174 .PHONY: all dynamic bytecodelib clean distclean install test bytecode prdirs
175 .PHONY: all dynamic bytecodelib bytecodelib-install
176 .PHONY: clean distclean install test bytecode prdirs
175177
176178 ###########################################################################
177179 # Miscellaneous paths and commands:
226228 DESTLIBDEBUG := $(BUILD_OBJ_ROOT)/lib/Debug
227229 DESTLIBRELEASE := $(BUILD_OBJ_ROOT)/lib/Release
228230 DESTLIBPROFILE := $(BUILD_OBJ_ROOT)/lib/Profile
231 DESTLIBBYTECODE := $(BUILD_OBJ_ROOT)/lib/Bytecode
229232 DESTLIBCURRENT := $(BUILD_OBJ_ROOT)/lib/$(CONFIGURATION)
230233
231234 # LLVM libraries used for linking
299302 ###########################################################################
300303
301304 #--------------------------------------------------------------------------
302 # Special tools used while building the LLVM tree. Burg is built as part
303 # of the utils directory.
304 #--------------------------------------------------------------------------
305 # Utilities used while building the LLVM tree, which live in the utils dir
306 #
305307 BURG := $(LLVMTOOLCURRENT)/burg
306308 RunBurg := $(BURG) $(BURG_OPTS)
307
308309 TBLGEN := $(LLVMTOOLCURRENT)/tblgen
310
311 #--------------------------------------------------------------------------
312 # The LLVM GCC front-end in C and C++ flavors
313 #
314 LLVMGCC := $(LLVMGCCDIR)/bin/gcc
315 LCC1 := $(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH)/cc1
316 LLVMGXX := $(LLVMGCCDIR)/bin/g++
317 LCC1XX := $(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH)/cc1plus
318
319 #--------------------------------------------------------------------------
320 # Some of the compiled LLVM tools which are used for compilation of runtime
321 # libraries.
322 #
323 LLVMAS := $(LLVMTOOLCURRENT)/as
309324
310325
311326 ###########################################################################
398413 #
399414 # Libtool Objects
400415 #
401 Objs := $(sort $(patsubst Debug/%.lo, %.lo, $(addsuffix .lo,$(notdir $(basename $(Source))))))
416 Srcs := $(sort $(notdir $(basename $(Source))))
417 Objs := $(addsuffix .lo, $(Srcs))
402418 ObjectsO := $(addprefix $(BUILD_OBJ_DIR)/Release/,$(Objs))
403419 ObjectsP := $(addprefix $(BUILD_OBJ_DIR)/Profile/,$(Objs))
404420 ObjectsG := $(addprefix $(BUILD_OBJ_DIR)/Debug/,$(Objs))
421 ObjectsBC := $(addprefix $(BUILD_OBJ_DIR)/Bytecode/,$(addsuffix .bc, $(Srcs)))
405422
406423 #
407424 # The real objects underlying the libtool objects
480497 LIBNAME_OBJO := $(DESTLIBRELEASE)/$(LIBRARYNAME).o
481498 LIBNAME_OBJP := $(DESTLIBPROFILE)/$(LIBRARYNAME).o
482499 LIBNAME_OBJG := $(DESTLIBDEBUG)/$(LIBRARYNAME).o
500 LIBNAME_BC := $(DESTLIBBYTECODE)/lib$(LIBRARYNAME).bc
483501
484502 #--------------------------------------------------------------------
485503 # Library Targets
488506
489507 # dynamic target builds a shared object version of the library...
490508 dynamic:: $(DESTLIBCURRENT)/lib$(LIBRARYNAME).so
509 bytecodelib:: $(LIBNAME_BC)
510 bytecodelib-install:: $(LLVMGCCDIR)/bytecode-libs/lib$(LIBRARYNAME).bc
511
512 $(LLVMGCCDIR)/bytecode-libs/lib$(LIBRARYNAME).bc: $(LIBNAME_BC)
513 @echo ======= Installing $(LIBRARYNAME) bytecode library =======
514 cp $< $@
491515
492516 # Does the library want a .o version built?
493517 ifndef DONT_BUILD_RELINKED
503527 # Rules for building libraries
504528 #--------------------------------------------------------------------
505529
530 LinkBCLib := $(LLVMGCC) -shared
531 ifdef EXPORTED_SYMBOL_LIST
532 LinkBCLib += -Xlinker -internalize-public-api-list=$(EXPORTED_SYMBOL_LIST)
533 else
534 LinkBCLib += -Xlinker -disable-internalize
535 endif
536
537
538 # Rule for building bytecode libraries.
539 $(LIBNAME_BC): $(ObjectsBC) $(LibSubDirs)
540 @echo ======= Linking $(LIBRARYNAME) bytecode library =======
541 $(VERB) $(LinkBCLib) -o $@ $(ObjectsBC) $(LibSubDirs) $(LibLinkOpts)
506542 #
507543 # Rules for building dynamically linked libraries.
508544 #
538574 @echo ======= Linking $(LIBRARYNAME) archive debug library =======
539575 @$(RM) -f $@
540576 $(VERB) $(Link) -g $(STRIP) -o $@ $(ObjectsG) $(LibSubDirs) -static
577
541578
542579 #
543580 # Rules for building .o libraries.
662699
663700
664701 #---------------------------------------------------------
665 .PRECIOUS: $(BUILD_OBJ_DIR)/Depend/.dir
702 .PRECIOUS: $(BUILD_OBJ_DIR)/Depend/.dir $(BUILD_OBJ_DIR)/Bytecode/.dir
666703 .PRECIOUS: $(BUILD_OBJ_DIR)/Debug/.dir $(BUILD_OBJ_DIR)/Release/.dir
667704
668705 # Create .lo files in the ObjectFiles directory from the .cpp and .c files...
689726 $(BUILD_OBJ_DIR)/Debug/%.lo: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Debug/.dir
690727 @echo "Compiling $<"
691728 $(VERB) $(CompileCG) $< -o $@
729
730 $(BUILD_OBJ_DIR)/Bytecode/%.bc: $(SourceDir)%.cpp $(BUILD_OBJ_DIR)/Bytecode/.dir $(LCC1XX)
731 @echo "Compiling $< to bytecode"
732 $(VERB) $(LLVMGXX) $(CPPFLAGS) -c $< -o $@
733
734 $(BUILD_OBJ_DIR)/Bytecode/%.bc: $(SourceDir)%.c $(BUILD_OBJ_DIR)/Bytecode/.dir $(LCC1)
735 @echo "Compiling $< to bytecode"
736 $(VERB) $(LLVMGCC) $(CPPFLAGS) -c $< -o $@
737
738 $(BUILD_OBJ_DIR)/Bytecode/%.bc: $(SourceDir)%.ll $(BUILD_OBJ_DIR)/Bytecode/.dir $(LCC1)
739 @echo "Compiling $< to bytecode"
740 $(VERB) $(LLVMAS) $< -f -o $@
741
692742
693743 #
694744 # Rules for building lex/yacc files
746796
747797 # 'make clean' nukes the tree
748798 clean::
749 $(VERB) $(RM) -rf $(BUILD_OBJ_DIR)/Debug $(BUILD_OBJ_DIR)/Release $(BUILD_OBJ_DIR)/Profile $(BUILD_OBJ_DIR)/Depend
799 $(VERB) $(RM) -rf $(BUILD_OBJ_DIR)/Debug $(BUILD_OBJ_DIR)/Release
800 $(VERB) $(RM) -rf $(BUILD_OBJ_DIR)/Profile $(BUILD_OBJ_DIR)/Depend
801 $(VERB) $(RM) -rf $(BUILD_OBJ_DIR)/Bytecode
750802 $(VERB) $(RM) -f core core.[0-9][0-9]* *.o *.d *.so *~ *.flc
751803 $(VERB) $(RM) -f $(LEX_OUTPUT) $(YACC_OUTPUT)
752804