(run-test-lib, run-btest-lib): Unify. Give profile-specific name
[mono.git] / mcs / build / library.make
index b9ee8aba15ce1fc1730a2d6ff03207391567095c..7d7807ba11f276ac8a568e16396a9727a293dc3b 100644 (file)
@@ -8,21 +8,18 @@
 # All the dep files now land in the same directory so we
 # munge in the library name to keep the files from clashing.
 
-core_sourcefile = $(LIBRARY).sources
+sourcefile = $(LIBRARY).sources
 PLATFORM_excludes := $(wildcard $(LIBRARY).$(PLATFORM)-excludes)
 
-ifdef PLATFORM_excludes
-sourcefile = $(depsdir)/$(LIBRARY).$(PLATFORM)-sources
-$(sourcefile): $(core_sourcefile) $(PLATFORM_excludes)
-       cat $(core_sourcefile) $(PLATFORM_excludes) | sort | uniq -u >$@
-else
-sourcefile = $(core_sourcefile)
+ifndef PLATFORM_excludes
+ifeq (cat,$(PLATFORM_CHANGE_SEPARATOR_CMD))
+response = $(sourcefile)
+endif
 endif
 
-ifdef PLATFORM_CHANGE_SEPARATOR_CMD
+ifndef response
 response = $(depsdir)/$(PROFILE)_$(LIBRARY).response
-else
-response = $(sourcefile)
+library_CLEAN_FILES += $(response) $(LIBRARY).mdb
 endif
 
 ifndef LIBRARY_NAME
@@ -31,14 +28,17 @@ endif
 
 makefrag = $(depsdir)/$(PROFILE)_$(LIBRARY).makefrag
 the_lib = $(topdir)/class/lib/$(PROFILE)/$(LIBRARY_NAME)
-the_pdb = $(patsubst %.dll,%.pdb,$(the_lib))
+the_lib_signature_stamp = $(makefrag:.makefrag=.was_signed)
+the_pdb = $(the_lib:.dll=.pdb)
+the_mdb = $(the_lib:.dll=.mdb)
+library_CLEAN_FILES += $(makefrag) $(the_lib) $(the_pdb) \
+                       $(the_mdb) $(the_lib_signature_stamp)
 
 ifndef NO_TEST
-test_nunitfw = $(topdir)/class/lib/$(PROFILE)/nunit.framework.dll 
-test_nunitcore = $(topdir)/class/lib/$(PROFILE)/nunit.core.dll 
-test_nunitutil = $(topdir)/class/lib/$(PROFILE)/nunit.util.dll 
-test_nunit_dep = $(test_nunitfw) $(test_nunitcore) $(test_nunitutil)
-test_nunit_ref = -r:$(test_nunitfw) -r:$(test_nunitcore) -r:$(test_nunitutil)
+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
 
 ifndef test_against
 test_against = $(the_lib)
@@ -46,22 +46,28 @@ test_dep = $(the_lib)
 endif
 
 ifndef test_lib
-test_lib = $(patsubst %.dll,%_test.dll,$(LIBRARY))
-endif
-test_pdb = $(patsubst %.dll,%.pdb,$(test_lib))
+test_lib = $(LIBRARY:.dll=_test_$(PROFILE).dll)
+test_sourcefile = $(LIBRARY:.dll=_test.dll.sources)
+else
 test_sourcefile = $(test_lib).sources
-test_response = $(depsdir)/$(PROFILE)_$(test_lib).response
-test_makefrag = $(depsdir)/$(PROFILE)_$(test_lib).makefrag
+endif
+test_pdb = $(test_lib:.dll=.pdb)
+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 += $(LIBRARY:.dll=_test*.dll) $(LIBRARY:.dll=_test*.pdb) $(test_response) $(test_makefrag)
 
 ifndef btest_lib
-btest_lib = $(patsubst %.dll,%_btest.dll,$(LIBRARY))
-endif
-btest_pdb = $(patsubst %.dll,%.pdb,$(btest_lib))
+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_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 += $(LIBRARY:.dll=_btest*.dll) $(LIBRARY:.dll=_btest*.pdb) $(btest_response) $(btest_makefrag)
 
 ifndef HAVE_CS_TESTS
 HAVE_CS_TESTS := $(wildcard $(test_sourcefile))
@@ -81,58 +87,49 @@ ifeq ($(PROFILE), net_2_0)
 PACKAGE = 2.0
 endif
 
-all-local: $(the_lib)
+ifeq ($(PLATFORM), win32)
+GACDIR = `cygpath -w $(DESTDIR)$(prefix)/lib`
+else
+GACDIR = $(DESTDIR)$(prefix)/lib
+endif
 
-install-local: $(the_lib) maybe-sign-lib
+all-local install-local test-local: $(the_lib)
 
 ifdef LIBRARY_INSTALL_DIR
 install-local:
        $(MKINSTALLDIRS) $(DESTDIR)$(LIBRARY_INSTALL_DIR)
        $(INSTALL_LIB) $(the_lib) $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME)
+       -$(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)
-       $(RUNTIME) $(gacutil) /i $(the_lib) /f /root $(DESTDIR)$(prefix)/lib /package $(PACKAGE)
+       MONO_PATH="$(topdir)/class/lib/$(PROFILE):$$MONO_PATH" $(RUNTIME) $(gacutil) /i $(the_lib) /f /root $(GACDIR) /package $(PACKAGE)
 
 uninstall-local: $(gacutil)
-       $(RUNTIME) $(gacutil) /u `echo $(LIBRARY_NAME) | sed 's,.dll$,,'`
-
-$(gacutil):
-       cd $(topdir)/tools/gacutil && $(MAKE)
+       MONO_PATH="$(topdir)/class/lib/$(PROFILE):$$MONO_PATH" $(RUNTIME) $(gacutil) /u $(LIBRARY_NAME:.dll=)
 
 endif
 
-maybe-sign-lib:
 ifndef NO_SIGN_ASSEMBLY
-maybe-sign-lib: $(sn)
-       $(RUNTIME) $(sn) -q -R $(the_lib) $(topdir)/class/mono.snk
-endif
+all-local install-local: $(the_lib_signature_stamp)
 
-$(sn):
-       cd $(topdir)/tools/security && $(MAKE) sn.exe
-
-clean-local:
-       -rm -f $(the_lib) $(makefrag) $(test_lib) \
-              $(test_makefrag) $(test_response) \
-              $(the_pdb) $(test_pdb) $(CLEAN_FILES) \
-              TestResult.xml
-ifdef PLATFORM_excludes
-       -rm -rf $(sourcefile)
+ifndef LIBRARY_SNK
+LIBRARY_SNK = $(topdir)/class/mono.snk
 endif
-ifdef PLATFORM_CHANGE_SEPARATOR_CMD
-       -rm -rf $(response)
+
+$(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
 
+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
@@ -143,38 +140,29 @@ $(topdir)/build/deps/nunit.stamp:
        echo "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) /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) /xml:TestResult-ondotnet-$(PROFILE).xml $(test_assemblies)
 endif
 
-DISTFILES = $(core_sourcefile) $(test_sourcefile) $(EXTRA_DISTFILES)
+DISTFILES = $(sourcefile) $(test_sourcefile) $(EXTRA_DISTFILES)
 
 TEST_FILES = 
 
@@ -186,10 +174,11 @@ TEST_FILES += `sed 's,^,Test/,' $(btest_sourcefile)`
 endif
 
 dist-local: dist-default
-       for f in `cat $(core_sourcefile)` $(TEST_FILES) ; do \
-           dest=`dirname $(distdir)/$$f` ; \
-           $(MKINSTALLDIRS) $$dest && cp $$f $$dest || exit 1 ; \
-       done
+       for f in `cat $(sourcefile)` $(TEST_FILES) ; do \
+         case $$f in \
+         ../*) : ;; \
+         *) dest=`dirname $(distdir)/$$f` ; $(MKINSTALLDIRS) $$dest && cp $$f $$dest || exit 1 ;; \
+         esac ; done
 
 ifndef LIBRARY_COMPILE
 LIBRARY_COMPILE = $(CSCOMPILE)
@@ -203,19 +192,28 @@ ifndef BTEST_COMPILE
 BTEST_COMPILE = $(BASCOMPILE)
 endif
 
-# Fun with dependency tracking
+$(gacutil) $(sn):
+       cd $(@D) && $(MAKE) $(@F)
 
-$(the_lib): $(makefrag) $(response)
+# The library
+
+$(the_lib): $(response)
+ifdef LIBRARY_USE_INTERMEDIATE_FILE
+       $(LIBRARY_COMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) /target:library /out:$(@F) @$(response)
+       mv $(@F) $@
+       -mv $(@F).mdb $@.mdb
+else
        $(LIBRARY_COMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) /target:library /out:$@ @$(response)
+endif
 
 $(makefrag): $(sourcefile)
        @echo Creating $@ ...
        @sed 's,^,$(the_lib): ,' $< >$@
 
-ifdef PLATFORM_CHANGE_SEPARATOR_CMD
-$(response): $(sourcefile)
+ifneq ($(response),$(sourcefile))
+$(response): $(sourcefile) $(PLATFORM_excludes)
        @echo Creating $@ ...
-       @cat $(sourcefile) | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
+       @sort $(sourcefile) $(PLATFORM_excludes) | uniq -u | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
 endif
 
 -include $(makefrag)
@@ -225,16 +223,12 @@ endif
 
 ifdef HAVE_CS_TESTS
 
-$(test_lib): $(test_makefrag) $(test_dep) $(test_response) $(test_nunit_dep)
+$(test_lib): $(test_dep) $(test_response) $(test_nunit_dep)
        $(TEST_COMPILE) /target:library /out:$@ $(test_flags) @$(test_response)
 
 $(test_response): $(test_sourcefile)
        @echo Creating $@ ...
-ifdef PLATFORM_CHANGE_SEPARATOR_CMD
-       @sed 's,^,Test/,' $< |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
-else
-       @sed 's,^,Test/,' $< >$@
-endif
+       @sed 's,^,Test/,' $(test_sourcefile) | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
 
 $(test_makefrag): $(test_response)
        @echo Creating $@ ...
@@ -246,16 +240,12 @@ endif
 
 ifdef HAVE_VB_TESTS
 
-$(btest_lib): $(btest_makefrag) $(test_dep) $(btest_response) $(test_nunit_dep)
+$(btest_lib): $(test_dep) $(btest_response) $(test_nunit_dep)
        $(BTEST_COMPILE) /target:library /out:$@ $(btest_flags) @$(btest_response)
 
 $(btest_response): $(btest_sourcefile)
        @echo Creating $@ ...
-ifdef PLATFORM_CHANGE_SEPARATOR_CMD
-       @sed 's,^,Test/,' $< |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
-else
-       @sed 's,^,Test/,' $< >$@
-endif
+       @sed 's,^,Test/,' $(btest_sourcefile) | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
 
 $(btest_makefrag): $(btest_response)
        @echo Creating $@ ...
@@ -264,3 +254,6 @@ $(btest_makefrag): $(btest_response)
 -include $(btest_makefrag)
 
 endif
+
+all-local: $(makefrag) $(test_makefrag) $(btest_makefrag)
+$(makefrag) $(test_makefrag) $(btest_makefrag): $(topdir)/build/library.make