Make use of the LLVMGCCStdCXXLibDir variable to link objects
[oota-llvm.git] / runtime / GCCLibraries / crtend / Makefile
index a7f2c7a9d77fdcb1866ba1ab6a61038c8460dcee..be7b93e5a058e242a71c46a15ef3c03826eb41bf 100644 (file)
 # This directory contains the C and C++ runtime libraries for the LLVM GCC
 # front-ends.  See the README.txt file for more details.
 #
-# Since this archive has strange requirements, we use almost all custom rules
-# for building it.
+# Since this archive has strange requirements, we use some custom rules for 
+# building it.
 #
 ##===----------------------------------------------------------------------===##
 
 LEVEL = ../../..
-DONT_BUILD_RELINKED=1
+DONT_BUILD_RELINKED = 1
+BYTECODE_LIBRARY = 1
+LIBRARYNAME = crtend
+
+# Note: We're using FAKE_SOURCES because the comp_*.c don't really exists. 
+# However this makefile builds comp_*.bc and that's what we want in the library.
+# The FAKE_SOURCES variable supports this kind of construction. It uses the
+# FAKE_SOURCES to determine a list of things to build, but doesn't use 
+# FAKE_SOURCES for dependencies, distribution, etc. It is assumed the makefile
+# will know how to build the objects eventhough the sources don't exist.
+
+FAKE_SOURCES := comp_main.c comp_genericeh.c comp_sjljeh.c
 
 MainSrc      := crtend.c listend.ll
 GenericEHSrc := Exception.cpp
 SJLJEHSrc    := SJLJ-Exception.cpp
-CXXEHSrc     := C++-Exception.cpp
-Source       := $(MainSrc) $(GenericEHSrc) $(SJLJEHSrc) $(CXXEHSrc)
-
-include $(LEVEL)/Makefile.common
-
-# CRTEND_A - The result of making 'all' - the final archive file.
-CRTEND_A   = $(DESTLIBBYTECODE)/crtend.a
-all:: $(CRTEND_A)
-
-# Installation simply requires copying the archive to it's new home.
-$(LLVMGCCDIR)/bytecode-libs/crtend.a: $(CRTEND_A)
-       cp $< $@
-
-install:: $(LLVMGCCDIR)/bytecode-libs/crtend.a
 
+EXTRA_DIST   := $(MainSrc) $(GenericEHSrc) $(SJLJEHSrc) \
+                comp_main.lst comp_genericeh.lst comp_sjljeh.lst
 
-# The four components described in the README
-Components := main genericeh sjljeh cxxeh
-ComponentLibs := $(Components:%=$(BUILD_OBJ_DIR)/BytecodeObj/comp_%.bc)
-
-
-# We build crtend.a from the four components described in the README.
-$(CRTEND_A) : $(ComponentLibs)
-       @echo Building final crtend.a file from components
-       $(VERB) $(AR) $@ $(ComponentLibs)
+include $(LEVEL)/Makefile.common
 
-MainObj      := $(BUILD_OBJ_DIR)/BytecodeObj/crtend.bc \
-                $(BUILD_OBJ_DIR)/BytecodeObj/listend.bc
-GenericEHObj := $(BUILD_OBJ_DIR)/BytecodeObj/Exception.bc
-SJLJEHObj    := $(BUILD_OBJ_DIR)/BytecodeObj/SJLJ-Exception.bc
-CXXEHObj     := $(BUILD_OBJ_DIR)/BytecodeObj/C++-Exception.bc
+MainObj      := $(ObjDir)/crtend.bc $(ObjDir)/listend.bc
+GenericEHObj := $(ObjDir)/Exception.bc
+SJLJEHObj    := $(ObjDir)/SJLJ-Exception.bc
 
 # __main and ctor/dtor support component
-$(BUILD_OBJ_DIR)/BytecodeObj/comp_main.bc: $(MainObj)
-       @echo Linking $(notdir $@) component...
-       $(VERB) $(LGCCLDPROG) -link-as-library -internalize-public-api-file=$(BUILD_SRC_DIR)/comp_main.lst $(MainObj) -o $@
+$(ObjDir)/comp_main.bc: $(MainObj)
+       $(Echo) Linking $(notdir $@) component...
+       $(Verb) $(GCCLD) -link-as-library \
+       -internalize-public-api-file=$(BUILD_SRC_DIR)/comp_main.lst \
+       $(MainObj) -o $@ -L$(LLVMGCCStdCXXLibDir)
 
 # Generic exception handling support runtime.
-$(BUILD_OBJ_DIR)/BytecodeObj/comp_genericeh.bc: $(GenericEHObj)
-       @echo Linking $(notdir $@) component...
-       $(VERB) $(LGCCLDPROG) -link-as-library -internalize-public-api-file=$(BUILD_SRC_DIR)/comp_genericeh.lst $(GenericEHObj) -o $@
+$(ObjDir)/comp_genericeh.bc: $(GenericEHObj)
+       $(Echo) Linking $(notdir $@) component...
+       $(Verb) $(GCCLD) -link-as-library \
+       -internalize-public-api-file=$(BUILD_SRC_DIR)/comp_genericeh.lst \
+       $(GenericEHObj) -o $@ -L$(LLVMGCCStdCXXLibDir)
 
 # setjmp/longjmp exception handling support runtime.
-$(BUILD_OBJ_DIR)/BytecodeObj/comp_sjljeh.bc: $(SJLJEHObj)
-       @echo Linking $(notdir $@) component...
-       $(VERB) $(LGCCLDPROG) -link-as-library -internalize-public-api-file=$(BUILD_SRC_DIR)/comp_sjljeh.lst $(SJLJEHObj) -o $@
-
-# C++ exception handling support runtime.
-$(BUILD_OBJ_DIR)/BytecodeObj/comp_cxxeh.bc: $(CXXEHObj)
-       @echo Linking $(notdir $@) component...
-       $(VERB) $(LGCCLDPROG) -link-as-library -internalize-public-api-file=$(BUILD_SRC_DIR)/comp_cxxeh.lst $(CXXEHObj) -o $@
-
-
+$(ObjDir)/comp_sjljeh.bc: $(SJLJEHObj)
+       $(Echo) Linking $(notdir $@) component...
+       $(Verb) $(GCCLD) -link-as-library \
+       -internalize-public-api-file=$(BUILD_SRC_DIR)/comp_sjljeh.lst \
+       $(SJLJEHObj) -o $@ -L$(LLVMGCCStdCXXLibDir)