2005-01-16 Nick Drochak <ndrochak@ieee.org>
[mono.git] / mcs / build / library.make
index bf0ed9c794df1a42d94069f96eb8b9cbdf60cdf1..55774dc6132c06db7c03ef35e9be9fa60e2c2133 100644 (file)
@@ -19,7 +19,7 @@ endif
 
 ifndef response
 response = $(depsdir)/$(PROFILE)_$(LIBRARY).response
-library_CLEAN_FILES += $(response)
+library_CLEAN_FILES += $(response) $(LIBRARY).mdb $(BUILT_SOURCES)
 endif
 
 ifndef LIBRARY_NAME
@@ -28,15 +28,15 @@ endif
 
 makefrag = $(depsdir)/$(PROFILE)_$(LIBRARY).makefrag
 the_lib = $(topdir)/class/lib/$(PROFILE)/$(LIBRARY_NAME)
-the_lib_signature_stamp = $(makefrag:.makefrag=.was_signed)
 the_pdb = $(the_lib:.dll=.pdb)
-library_CLEAN_FILES += $(makefrag) $(the_lib) $(the_pdb) $(the_lib_signature_stamp)
+the_mdb = $(the_lib).mdb
+library_CLEAN_FILES += $(makefrag) $(the_lib) $(the_pdb) $(the_mdb)
 
 ifndef NO_TEST
 test_nunit_lib = nunit.framework.dll nunit.core.dll nunit.util.dll
 test_nunit_dep = $(test_nunit_lib:%=$(topdir)/class/lib/$(PROFILE)/%)
 test_nunit_ref = $(test_nunit_dep:%=-r:%)
-library_CLEAN_FILES += TestResult.xml
+library_CLEAN_FILES += TestResult*.xml
 
 ifndef test_against
 test_against = $(the_lib)
@@ -44,24 +44,28 @@ test_dep = $(the_lib)
 endif
 
 ifndef test_lib
-test_lib = $(LIBRARY:.dll=_test.dll)
+test_lib = $(LIBRARY:.dll=_test_$(PROFILE).dll)
+test_sourcefile = $(LIBRARY:.dll=_test.dll.sources)
+else
+test_sourcefile = $(test_lib).sources
 endif
 test_pdb = $(test_lib:.dll=.pdb)
-test_sourcefile = $(test_lib).sources
-test_response = $(depsdir)/$(PROFILE)_$(test_lib).response
-test_makefrag = $(depsdir)/$(PROFILE)_$(test_lib).makefrag
+test_response = $(depsdir)/$(test_lib).response
+test_makefrag = $(depsdir)/$(test_lib).makefrag
 test_flags = /r:$(test_against) $(test_nunit_ref) $(TEST_MCS_FLAGS)
-library_CLEAN_FILES += $(test_lib) $(test_pdb) $(test_response) $(test_makefrag)
+library_CLEAN_FILES += $(LIBRARY:.dll=_test*.dll) $(LIBRARY:.dll=_test*.pdb) $(test_response) $(test_makefrag)
 
 ifndef btest_lib
-btest_lib = $(LIBRARY:.dll=_btest.dll)
+btest_lib = $(LIBRARY:.dll=_btest_$(PROFILE).dll)
+btest_sourcefile = $(LIBRARY:.dll=_btest.dll.sources)
+else
+btest_sourcefile = $(btest_lib).sources
 endif
 btest_pdb = $(btest_lib:.dll=.pdb)
-btest_sourcefile = $(btest_lib).sources
 btest_response = $(depsdir)/$(btest_lib).response
 btest_makefrag = $(depsdir)/$(btest_lib).makefrag
 btest_flags = /r:$(test_against) $(test_nunit_ref) $(TEST_MBAS_FLAGS)
-library_CLEAN_FILES += $(btest_lib) $(btest_pdb) $(btest_response) $(btest_makefrag)
+library_CLEAN_FILES += $(LIBRARY:.dll=_btest*.dll) $(LIBRARY:.dll=_btest*.pdb) $(btest_response) $(btest_makefrag)
 
 ifndef HAVE_CS_TESTS
 HAVE_CS_TESTS := $(wildcard $(test_sourcefile))
@@ -73,107 +77,102 @@ endif
 endif
 
 gacutil = $(topdir)/tools/gacutil/gacutil.exe
-sn = $(topdir)/tools/security/sn.exe
+GACUTIL = MONO_PATH="$(topdir)/class/lib/default$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(gacutil)
 
-PACKAGE = 1.0
-
-ifeq ($(PROFILE), net_2_0)
-PACKAGE = 2.0
+ifdef NO_SIGN_ASSEMBLY
+SN = :
+else
+sn = $(topdir)/class/lib/net_1_1_bootstrap/sn.exe
+SN = MONO_PATH="$(topdir)/class/lib/net_1_1_bootstrap/$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(sn)
+SNFLAGS = -q -R
 endif
 
+libdir = $(prefix)/lib
+
 ifeq ($(PLATFORM), win32)
-GACDIR = `cygpath -w $(DESTDIR)$(prefix)/lib`
+GACDIR = `cygpath -w $(libdir)`
+GACROOT = `cygpath -w $(DESTDIR)$(libdir)`
 else
-GACDIR = $(DESTDIR)$(prefix)/lib
+GACDIR = $(libdir)
+GACROOT = $(DESTDIR)$(libdir)
 endif
 
-all-local: $(the_lib)
+all-local install-local test-local: $(the_lib)
+
+ifdef NO_INSTALL
+install-local uninstall-local:
+       @:
 
-install-local: $(the_lib) 
+else
 
 ifdef LIBRARY_INSTALL_DIR
 install-local:
        $(MKINSTALLDIRS) $(DESTDIR)$(LIBRARY_INSTALL_DIR)
        $(INSTALL_LIB) $(the_lib) $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME)
+       test ! -f $(the_lib).mdb || $(INSTALL_LIB) $(the_lib).mdb $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME).mdb
 
 uninstall-local:
-       -rm -f $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME)
+       -rm -f $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME) $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME).mdb
 
 else
 
-install-local: $(gacutil)
-       MONO_PATH="$(topdir)/class/lib/$(PROFILE):$$MONO_PATH" $(RUNTIME) $(gacutil) /i $(the_lib) /f /root $(GACDIR) /package $(PACKAGE)
-
-uninstall-local: $(gacutil)
-       MONO_PATH="$(topdir)/class/lib/$(PROFILE):$$MONO_PATH" $(RUNTIME) $(gacutil) /u $(LIBRARY_NAME:.dll=)
-
-$(gacutil):
-       cd $(topdir)/tools/gacutil && $(MAKE)
+# If RUNTIME_HAS_CONSISTENT_GACDIR is set, it implies that the internal GACDIR
+# of the runtime is the same as the GACDIR we want.  So, we don't need to pass it
+# to gacutil.  Note that the GACDIR we want may not be the same as the value of 
+# GACDIR set above, since the user could have overridden the value of $(prefix).
+#
+# This makes a difference only when we're building from the mono/ tree, since we
+# have to ensure that the internal GACDIR of the in-tree runtime matches where we 
+# install the DLLs.
 
+ifndef RUNTIME_HAS_CONSISTENT_GACDIR
+gacdir_flag = /gacdir $(GACDIR)
 endif
 
-ifndef NO_SIGN_ASSEMBLY
-install-local: $(the_lib_signature_stamp)
+install-local: $(gacutil)
+       $(GACUTIL) /i $(the_lib) /f $(gacdir_flag) /root $(GACROOT) /package $(FRAMEWORK_VERSION)
 
-ifndef LIBRARY_SNK
-LIBRARY_SNK = $(topdir)/class/mono.snk
-endif
+uninstall-local: $(gacutil)
+       -$(GACUTIL) /u $(LIBRARY_NAME:.dll=) $(gacdir_flag) /root $(GACROOT) /package $(FRAMEWORK_VERSION)
 
-$(the_lib_signature_stamp): $(the_lib) $(sn)
-       MONO_PATH="$(topdir)/class/lib/$(PROFILE):$$MONO_PATH" $(RUNTIME) $(sn) -q -R $(the_lib) $(LIBRARY_SNK)
-       echo stamp > $@
 endif
-
-$(sn):
-       cd $(topdir)/tools/security && $(MAKE) sn.exe
+endif
 
 clean-local:
        -rm -f $(library_CLEAN_FILES) $(CLEAN_FILES)
 
-test-local: $(the_lib)
-       @:
-run-test-local:
-       @:
-run-test-ondotnet-local:
+test-local run-test-local run-test-ondotnet-local:
        @:
 
 ifndef NO_TEST
-$(test_nunit_dep): $(topdir)/build/deps/nunit.stamp
+$(test_nunit_dep): $(topdir)/build/deps/nunit-$(PROFILE).stamp
        @if test -f $@; then :; else rm -f $<; $(MAKE) $<; fi
-$(topdir)/build/deps/nunit.stamp:
+$(topdir)/build/deps/nunit-$(PROFILE).stamp:
        cd ${topdir}/nunit20 && $(MAKE)
        echo "stamp" >$@
+library_CLEAN_FILES += $(topdir)/build/deps/nunit-$(PROFILE).stamp
 endif
 
+test_assemblies :=
+
 ifdef HAVE_CS_TESTS
+test_assemblies += $(test_lib)
+endif
 
-test-local: $(test_lib)
+ifdef HAVE_VB_TESTS
+test_assemblies += $(btest_lib)
+endif
 
+ifdef test_assemblies
+test-local: $(test_assemblies)
 run-test-local: run-test-lib
+run-test-ondotnet-local: run-test-ondotnet-lib
 
 run-test-lib: test-local
-       $(TEST_RUNTIME) $(TEST_HARNESS) $(test_lib)
-
-run-test-ondotnet-local: run-test-ondotnet-lib
+       $(TEST_RUNTIME) $(TEST_HARNESS) $(TEST_HARNESS_FLAGS) /output:TestResult-$(PROFILE).log /exclude:NotWorking,ValueAdd /xml:TestResult-$(PROFILE).xml $(test_assemblies)
 
 run-test-ondotnet-lib: test-local
-       $(TEST_HARNESS) $(test_lib)
-endif
-
-ifdef HAVE_VB_TESTS
-
-test-local: $(btest_lib)
-
-run-test-local: run-btest-lib
-
-run-btest-lib: test-local
-       $(TEST_RUNTIME) $(TEST_HARNESS) $(btest_lib)
-
-run-test-ondotnet-local: run-btest-ondotnet-lib
-
-run-btest-ondotnet-lib: test-local
-       $(TEST_HARNESS) $(btest_lib)
-
+       $(TEST_HARNESS) $(TEST_HARNESS_FLAGS) /exclude=NotDotNet /output:TestResult-ondotnet-$(PROFILE).log /xml:TestResult-ondotnet-$(PROFILE).xml $(test_assemblies)
 endif
 
 DISTFILES = $(sourcefile) $(test_sourcefile) $(EXTRA_DISTFILES)
@@ -189,9 +188,10 @@ endif
 
 dist-local: dist-default
        for f in `cat $(sourcefile)` $(TEST_FILES) ; do \
-           dest=`dirname $(distdir)/$$f` ; \
-           $(MKINSTALLDIRS) $$dest && cp $$f $$dest || exit 1 ; \
-       done
+         case $$f in \
+         ../*) : ;; \
+         *) dest=`dirname $(distdir)/$$f` ; $(MKINSTALLDIRS) $$dest && cp -p $$f $$dest || exit 1 ;; \
+         esac ; done
 
 ifndef LIBRARY_COMPILE
 LIBRARY_COMPILE = $(CSCOMPILE)
@@ -205,10 +205,36 @@ ifndef BTEST_COMPILE
 BTEST_COMPILE = $(BASCOMPILE)
 endif
 
-# Fun with dependency tracking
+ifndef LIBRARY_SNK
+LIBRARY_SNK = $(topdir)/class/mono.snk
+endif
+
+$(gacutil):
+       cd $(topdir)/tools/gacutil && $(MAKE) PROFILE=default
+
+ifdef sn
+$(sn):
+       cd $(topdir) && $(MAKE) PROFILE=net_1_1_bootstrap
+endif
+
+ifeq (cat, $(PLATFORM_CHANGE_SEPARATOR_CMD))
+BUILT_SOURCES_cmdline = $(BUILT_SOURCES)
+else
+BUILT_SOURCES_cmdline = `echo $(BUILT_SOURCES) | $(PLATFORM_CHANGE_SEPARATOR_CMD)`
+endif
 
-$(the_lib): $(response)
-       $(LIBRARY_COMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) /target:library /out:$@ @$(response)
+# The library
+
+$(the_lib): $(response) $(sn) $(BUILT_SOURCES)
+ifdef LIBRARY_USE_INTERMEDIATE_FILE
+       $(LIBRARY_COMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) /target:library /out:$(@F) $(BUILT_SOURCES_cmdline) @$(response)
+       $(SN) $(SNFLAGS) $(@F) $(LIBRARY_SNK)
+       mv $(@F) $@
+       test ! -f $(@F).mdb || mv $(@F).mdb $@.mdb
+else
+       $(LIBRARY_COMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) /target:library /out:$@ $(BUILT_SOURCES_cmdline) @$(response)
+       $(SN) $(SNFLAGS) $@ $(LIBRARY_SNK)
+endif
 
 $(makefrag): $(sourcefile)
        @echo Creating $@ ...