Make mcs.exe .net4 application
[mono.git] / mcs / build / library.make
index 2a541a1273f4a7ee2477565f77fe311b7fc83eb2..4b14c26391692d34d2c2a548cfac28a4fe17765d 100644 (file)
 sourcefile = $(LIBRARY).sources
 
 # If the directory contains the per profile include file, generate list file.
-PROFILE_sources = $(PROFILE)_$(LIBRARY).sources
-ifeq ($(wildcard $(PROFILE_sources)), $(PROFILE_sources))
+PROFILE_sources := $(wildcard $(PROFILE)_$(LIBRARY).sources)
+ifdef PROFILE_sources
 PROFILE_excludes = $(wildcard $(PROFILE)_$(LIBRARY).exclude.sources)
-COMMON_sourcefile := $(sourcefile)
 sourcefile = $(depsdir)/$(PROFILE)_$(LIBRARY).sources
-$(sourcefile): $(PROFILE_sources) $(PROFILE_excludes) $(COMMON_sourcefile)
+library_CLEAN_FILES += $(sourcefile)
+
+# Note, gensources.sh can create a $(sourcefile).makefrag if it sees any '#include's
+# We don't include it in the dependencies since it isn't always created
+$(sourcefile): $(PROFILE_sources) $(PROFILE_excludes) $(topdir)/build/gensources.sh
        @echo Creating the per profile list $@ ...
-       $(topdir)/tools/gensources.sh $(PROFILE_sources) $(PROFILE_excludes) > $@
+       $(SHELL) $(topdir)/build/gensources.sh $@ $(PROFILE_sources) $(PROFILE_excludes)
 endif
 
 PLATFORM_excludes := $(wildcard $(LIBRARY).$(PLATFORM)-excludes)
@@ -31,7 +34,7 @@ endif
 
 ifndef response
 response = $(depsdir)/$(PROFILE)_$(LIBRARY).response
-library_CLEAN_FILES += $(response) $(LIBRARY).mdb $(BUILT_SOURCES)
+library_CLEAN_FILES += $(response)
 endif
 
 ifndef LIBRARY_NAME
@@ -44,65 +47,28 @@ else
 lib_dir = lib
 endif
 
-makefrag = $(depsdir)/$(PROFILE)_$(LIBRARY).makefrag
 the_libdir = $(topdir)/class/$(lib_dir)/$(PROFILE)/
-the_lib = $(the_libdir)$(LIBRARY_NAME)
-the_pdb = $(the_lib:.dll=.pdb)
-the_mdb = $(the_lib).mdb
-library_CLEAN_FILES += $(makefrag) $(the_lib) $(the_pdb) $(the_mdb)
-
 ifdef LIBRARY_NEEDS_POSTPROCESSING
 build_libdir = fixup/$(PROFILE)/
-build_lib = $(build_libdir)$(LIBRARY_NAME)
-library_CLEAN_FILES += $(build_lib) $(build_lib:.dll=.pdb)
 else
-build_lib = $(the_lib)
-endif
-
-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
-
-test_lib = $(LIBRARY:.dll=_test_$(PROFILE).dll)
-test_sourcefile = $(LIBRARY:.dll=_test.dll.sources)
-test_pdb = $(test_lib:.dll=.pdb)
-test_response = $(depsdir)/$(test_lib).response
-test_makefrag = $(depsdir)/$(test_lib).makefrag
-test_flags = -r:$(the_lib) $(test_nunit_ref) $(TEST_MCS_FLAGS)
-library_CLEAN_FILES += $(LIBRARY:.dll=_test*.dll) $(LIBRARY:.dll=_test*.pdb) $(test_response) $(test_makefrag)
-
-btest_lib = $(LIBRARY:.dll=_btest_$(PROFILE).dll)
-btest_sourcefile = $(LIBRARY:.dll=_btest.dll.sources)
-btest_pdb = $(btest_lib:.dll=.pdb)
-btest_response = $(depsdir)/$(btest_lib).response
-btest_makefrag = $(depsdir)/$(btest_lib).makefrag
-btest_flags = -r:$(the_lib) $(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))
+ifdef LIBRARY_USE_INTERMEDIATE_FILE
+build_libdir = $(the_libdir)tmp/
+else
+build_libdir = $(the_libdir)
 endif
-ifndef HAVE_VB_TESTS
-HAVE_VB_TESTS := $(wildcard $(btest_sourcefile))
 endif
 
-endif
-
-ifdef NO_INSTALL
-GACUTIL = :
-else
-gacutil = $(topdir)/class/lib/net_1_1_bootstrap/gacutil.exe
-GACUTIL = MONO_PATH="$(topdir)/class/lib/net_1_1_bootstrap$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(RUNTIME_FLAGS) $(gacutil)
-endif
+the_lib   = $(the_libdir)$(LIBRARY_NAME)
+build_lib = $(build_libdir)$(LIBRARY_NAME)
+library_CLEAN_FILES += $(the_lib)   $(the_lib).so   $(the_lib).mdb   $(the_lib:.dll=.pdb)
+library_CLEAN_FILES += $(build_lib) $(build_lib).so $(build_lib).mdb $(build_lib:.dll=.pdb)
 
 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) $(RUNTIME_FLAGS) $(sn)
-SNFLAGS = -q -R
+sn = $(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)/sn.exe
+SN = $(Q) MONO_PATH="$(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(RUNTIME_FLAGS) $(sn)
+SNFLAGS = -q
 endif
 
 ifeq ($(PLATFORM), win32)
@@ -114,7 +80,27 @@ GACDIR = $(mono_libdir)
 GACROOT = $(DESTDIR)$(mono_libdir)
 endif
 
-all-local: $(the_lib)
+ifndef NO_BUILD
+all-local: $(the_lib) $(extra_targets)
+endif
+
+ifeq ($(LIBRARY_COMPILE),$(BOOT_COMPILE))
+is_boot=true
+else
+is_boot=false
+endif
+
+csproj-local: 
+       config_file=`basename $(LIBRARY) .dll`-$(PROFILE).input; \
+       echo $(thisdir):$$config_file >> $(topdir)/../mono/msvc/scripts/order; \
+       (echo $(is_boot); \
+       echo $(MCS);    \
+       echo $(USE_MCS_FLAGS) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS); \
+       echo $(LIBRARY_NAME); \
+       echo $(BUILT_SOURCES_cmdline); \
+       echo $(build_lib); \
+       echo $(response)) > $(topdir)/../mono/msvc/scripts/inputs/$$config_file
+
 
 install-local: all-local
 test-local: all-local
@@ -126,11 +112,17 @@ install-local uninstall-local:
 
 else
 
+aot_lib = $(the_lib)$(PLATFORM_AOT_SUFFIX)
+aot_libname = $(LIBRARY_NAME)$(PLATFORM_AOT_SUFFIX)
+
 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
+ifdef PLATFORM_AOT_SUFFIX
+       test ! -f $(aot_lib) || $(INSTALL_LIB) $(aot_lib) $(DESTDIR)$(LIBRARY_INSTALL_DIR)
+endif
 
 uninstall-local:
        -rm -f $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME) $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME).mdb
@@ -168,87 +160,35 @@ install-local: $(gacutil)
 uninstall-local: $(gacutil)
        -$(GACUTIL) /u $(LIBRARY_NAME:.dll=) $(gacdir_flag) /root $(GACROOT) $(package_flag)
 
-endif
-endif
+endif # LIBRARY_INSTALL_DIR
+endif # NO_INSTALL
 
 clean-local:
-       -rm -f $(library_CLEAN_FILES) $(CLEAN_FILES)
+       -rm -f $(tests_CLEAN_FILES) $(library_CLEAN_FILES) $(CLEAN_FILES)
 
 test-local run-test-local run-test-ondotnet-local:
        @:
 
-ifndef NO_TEST
-$(test_nunit_dep): $(topdir)/build/deps/nunit-$(PROFILE).stamp
-       @if test -f $@; then :; else rm -f $<; $(MAKE) $<; fi
-$(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
-
-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
-
-TEST_HARNESS_EXCLUDES = /exclude:NotWorking,ValueAdd,CAS,InetAccess
-TEST_HARNESS_EXCLUDES_ONDOTNET = /exclude:NotDotNet,CAS
+DISTFILES = $(wildcard *$(LIBRARY)*.sources) $(EXTRA_DISTFILES)
 
-ifdef TEST_HARNESS_VERBOSE
-TEST_HARNESS_OUTPUT = /labels
-TEST_HARNESS_OUTPUT_ONDOTNET = /labels
-TEST_HARNESS_POSTPROC = :
-TEST_HARNESS_POSTPROC_ONDOTNET = :
-else
-TEST_HARNESS_OUTPUT = /output:TestResult-$(PROFILE).log
-TEST_HARNESS_OUTPUT_ONDOTNET = /output:TestResult-ondotnet-$(PROFILE).log
-TEST_HARNESS_POSTPROC = (echo ''; cat TestResult-$(PROFILE).log) | sed '1,/^Tests run: /d'
-TEST_HARNESS_POSTPROC_ONDOTNET = (echo ''; cat TestResult-ondotnet-$(PROFILE).log) | sed '1,/^Tests run: /d'
-endif
-
-## FIXME: i18n problem in the 'sed' command below
-run-test-lib: test-local
-       ok=:; \
-       MONO_REGISTRY_PATH="$(HOME)/.mono/registry" $(TEST_RUNTIME) $(RUNTIME_FLAGS) $(TEST_HARNESS) $(TEST_HARNESS_FLAGS) $(LOCAL_TEST_HARNESS_FLAGS) $(TEST_HARNESS_EXCLUDES) $(TEST_HARNESS_OUTPUT) /xml:TestResult-$(PROFILE).xml $(test_assemblies) || ok=false; \
-       $(TEST_HARNESS_POSTPROC) ; $$ok
-
-run-test-ondotnet-lib: test-local
-       ok=:; \
-       $(TEST_HARNESS) $(TEST_HARNESS_FLAGS) $(LOCAL_TEST_HARNESS_ONDOTNET_FLAGS) $(TEST_HARNESS_EXCLUDES_ONDOTNET) $(TEST_HARNESS_OUTPUT_ONDOTNET) /xml:TestResult-ondotnet-$(PROFILE).xml $(test_assemblies) || ok=false; \
-       $(TEST_HARNESS_POSTPROC_ONDOTNET) ; $$ok
-endif
-
-DISTFILES = $(sourcefile) $(EXTRA_DISTFILES)
-
-TEST_FILES =
+ASSEMBLY      = $(LIBRARY)
+ASSEMBLY_EXT  = .dll
+the_assembly  = $(the_lib)
+include $(topdir)/build/tests.make
 
 ifdef HAVE_CS_TESTS
-TEST_FILES += `sed -e '/^$$/d' -e 's,^,Test/,' $(test_sourcefile)`
 DISTFILES += $(test_sourcefile)
 endif
-ifdef HAVE_VB_TESTS
-TEST_FILES += `sed -e '/^$$/d' -e 's,^,Test/,' $(btest_sourcefile)`
-DISTFILES += $(btest_sourcefile)
-endif
 
+# make dist will collect files in .sources files from all profiles
 dist-local: dist-default
        subs=' ' ; \
-       for f in `cat $(sourcefile)` $(TEST_FILES) ; do \
+       for f in `$(topdir)/tools/removecomments.sh $(wildcard *$(LIBRARY).sources)` $(TEST_FILES) ; do \
          case $$f in \
          ../*) : ;; \
-         *) dest=`dirname $$f` ; \
+         *) dest=`dirname "$$f"` ; \
             case $$subs in *" $$dest "*) : ;; *) subs=" $$dest$$subs" ; $(MKINSTALLDIRS) $(distdir)/$$dest ;; esac ; \
-            cp -p $$f $(distdir)/$$dest || exit 1 ;; \
+            cp -p "$$f" $(distdir)/$$dest || exit 1 ;; \
          esac ; done ; \
        for d in . $$subs ; do \
          case $$d in .) : ;; *) test ! -f $$d/ChangeLog || cp -p $$d/ChangeLog $(distdir)/$$d ;; esac ; done
@@ -264,29 +204,12 @@ ifndef LIBRARY_COMPILE
 LIBRARY_COMPILE = $(CSCOMPILE)
 endif
 
-ifndef TEST_COMPILE
-TEST_COMPILE = $(CSCOMPILE)
-endif
-
-ifndef BTEST_COMPILE
-BTEST_COMPILE = $(BASCOMPILE)
-endif
-
 ifndef LIBRARY_SNK
 LIBRARY_SNK = $(topdir)/class/mono.snk
 endif
 
-ifdef gacutil
-$(gacutil):
-       cd $(topdir) && $(MAKE) PROFILE=net_1_1_bootstrap
-endif
-
-ifdef sn
-$(sn):
-       cd $(topdir) && $(MAKE) PROFILE=net_1_1_bootstrap
-endif
-
 ifdef BUILT_SOURCES
+library_CLEAN_FILES += $(BUILT_SOURCES)
 ifeq (cat, $(PLATFORM_CHANGE_SEPARATOR_CMD))
 BUILT_SOURCES_cmdline = $(BUILT_SOURCES)
 else
@@ -296,72 +219,64 @@ endif
 
 # The library
 
-$(the_libdir)/.stamp $(build_libdir:=/.stamp):
-       $(MKINSTALLDIRS) $(@D)
-       touch $@
-
 $(the_lib): $(the_libdir)/.stamp
 
 $(build_lib): $(response) $(sn) $(BUILT_SOURCES) $(build_libdir:=/.stamp)
-ifdef LIBRARY_USE_INTERMEDIATE_FILE
-       $(LIBRARY_COMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) -target:library -out:$(LIBRARY_NAME) $(BUILT_SOURCES_cmdline) @$(response)
-       $(SN) $(SNFLAGS) $(LIBRARY_NAME) $(LIBRARY_SNK)
-       mv $(LIBRARY_NAME) $@
-       test ! -f $(LIBRARY_NAME).mdb || mv $(LIBRARY_NAME).mdb $@.mdb
-       test ! -f $(LIBRARY_NAME:.dll=.pdb) || mv $(LIBRARY_NAME:.dll=.pdb) $(dir $@)$(LIBRARY_NAME:.dll=.pdb)
-else
        $(LIBRARY_COMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) -target:library -out:$@ $(BUILT_SOURCES_cmdline) @$(response)
-       $(SN) $(SNFLAGS) $@ $(LIBRARY_SNK)
-endif
-
-$(makefrag): $(sourcefile)
-       @echo Creating $@ ...
-       @sed 's,^,$(build_lib): ,' $< >$@
+       $(SN) $(SNFLAGS) -R $@ $(LIBRARY_SNK)
 
-ifneq ($(response),$(sourcefile))
-$(response): $(sourcefile) $(PLATFORM_excludes)
-       @echo Creating $@ ...
-       @sort $(sourcefile) $(PLATFORM_excludes) | uniq -u | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
+ifdef LIBRARY_USE_INTERMEDIATE_FILE
+$(the_lib): $(build_lib)
+       $(Q) cp $(build_lib) $@
+       $(SN) $(SNFLAGS) -v $@
+       $(Q) test ! -f $(build_lib).mdb || mv $(build_lib).mdb $@.mdb
+       $(Q) test ! -f $(build_lib:.dll=.pdb) || mv $(build_lib:.dll=.pdb) $(the_lib:.dll=.pdb)
 endif
 
--include $(makefrag)
-
-# for now, don't give any /lib flags or set MONO_PATH, since we
-# give a full path to the assembly.
-
-ifdef HAVE_CS_TESTS
+library_CLEAN_FILES += $(PROFILE)_aot.log
 
-$(test_lib): $(the_lib) $(test_response) $(test_nunit_dep)
-       $(TEST_COMPILE) -target:library -out:$@ $(test_flags) @$(test_response)
-
-$(test_response): $(test_sourcefile)
-       @echo Creating $@ ...
-       @sed -e '/^$$/d' -e 's,^,Test/,' $(test_sourcefile) | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
+ifdef PLATFORM_AOT_SUFFIX
+Q_AOT=$(if $(V),,@echo "AOT [$(PROFILE)] $(notdir $(@))";)
+$(the_lib)$(PLATFORM_AOT_SUFFIX): $(the_lib)
+       $(Q_AOT) MONO_PATH='$(the_libdir)' > $(PROFILE)_aot.log 2>&1 $(RUNTIME) --aot=bind-to-runtime-version --debug $(the_lib)
+endif
 
-$(test_makefrag): $(test_response)
-       @echo Creating $@ ...
-       @sed 's,^,$(test_lib): ,' $< >$@
+ifdef ENABLE_AOT
+ifneq (,$(filter $(AOT_IN_PROFILES), $(PROFILE)))
 
--include $(test_makefrag)
+all-local: $(the_lib)$(PLATFORM_AOT_SUFFIX)
 
+endif
 endif
 
-ifdef HAVE_VB_TESTS
+makefrag = $(depsdir)/$(PROFILE)_$(LIBRARY).makefrag
+library_CLEAN_FILES += $(makefrag)
+$(makefrag): $(sourcefile)
+#      @echo Creating $@ ...
+       @sed 's,^,$(build_lib): ,' $< >$@
+       @if test ! -f $(sourcefile).makefrag; then :; else \
+          cat $(sourcefile).makefrag >> $@ ; \
+          echo '$@: $(sourcefile).makefrag' >> $@; \
+          echo '$(sourcefile).makefrag:' >> $@; fi
 
-$(btest_lib): $(the_lib) $(btest_response) $(test_nunit_dep)
-       $(BTEST_COMPILE) -target:library -out:$@ $(btest_flags) @$(btest_response)
+ifneq ($(response),$(sourcefile))
 
-$(btest_response): $(btest_sourcefile)
-       @echo Creating $@ ...
-       @sed -e '/^$$/d' -e 's,^,Test/,' $(btest_sourcefile) | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
+ifdef PLATFORM_excludes
+$(response): $(sourcefile) $(PLATFORM_excludes)
+       @echo Filtering $(sourcefile) to $@ ...
+       @sort $(sourcefile) $(PLATFORM_excludes) | uniq -u | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
+else
+$(response): $(sourcefile)
+       @echo Converting $(sourcefile) to $@ ...
+       @cat $(sourcefile) | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
+endif
 
-$(btest_makefrag): $(btest_response)
-       @echo Creating $@ ...
-       @sed 's,^,$(btest_lib): ,' $< >$@
+endif
 
--include $(btest_makefrag)
+-include $(makefrag)
 
-endif
+# for now, don't give any /lib flags or set MONO_PATH, since we
+# give a full path to the assembly.
 
 ## Include corcompare stuff
 include $(topdir)/build/corcompare.make
@@ -371,3 +286,18 @@ ifneq ($(response),$(sourcefile))
 $(response): $(topdir)/build/library.make $(depsdir)/.stamp
 endif
 $(makefrag) $(test_response) $(test_makefrag) $(btest_response) $(btest_makefrag): $(topdir)/build/library.make $(depsdir)/.stamp
+
+## Documentation stuff
+
+Q_MDOC_UP=$(if $(V),,@echo "MDOC-UP [$(PROFILE)] $(notdir $(@))";)
+MDOC_UP  =$(Q_MDOC_UP) \
+               MONO_PATH="$(topdir)/class/lib/net_4_0$(PLATFORM_PATH_SEPARATOR)$(topdir)/class/lib/net_2_0$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" \
+               $(RUNTIME) $(topdir)/tools/mdoc/mdoc.exe update --delete            \
+                       -o Documentation/en $(the_lib)
+
+doc-update-local: $(the_libdir)/.doc-stamp
+
+$(the_libdir)/.doc-stamp: $(the_lib)
+       $(MDOC_UP)
+       @echo "doc-stamp" > $@
+