Merge pull request #495 from nicolas-raoul/fix-for-issue2907-with-no-formatting-changes
[mono.git] / mcs / build / library.make
index 2be22379527ca1720fe006832f85b8dc3b2ac2ff..768149e9d1066b1ba99eab7e122d86dfef6181d7 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,13 +47,7 @@ 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_lib).so $(the_pdb) $(the_mdb)
-
 ifdef LIBRARY_NEEDS_POSTPROCESSING
 build_libdir = fixup/$(PROFILE)/
 else
@@ -61,15 +58,18 @@ build_libdir = $(the_libdir)
 endif
 endif
 
+the_lib   = $(the_libdir)$(LIBRARY_NAME)
 build_lib = $(build_libdir)$(LIBRARY_NAME)
-library_CLEAN_FILES += $(build_lib) $(build_lib:.dll=.pdb)
+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 = $(Q) MONO_PATH="$(topdir)/class/lib/net_1_1_bootstrap$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(RUNTIME_FLAGS) $(sn)
-SNFLAGS = -q -R
+ifeq ("$(SN)","")
+sn = $(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)/sn.exe
+SN = MONO_PATH="$(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(RUNTIME_FLAGS) $(sn) -q
+endif
 endif
 
 ifeq ($(PLATFORM), win32)
@@ -81,7 +81,9 @@ GACDIR = $(mono_libdir)
 GACROOT = $(DESTDIR)$(mono_libdir)
 endif
 
+ifndef NO_BUILD
 all-local: $(the_lib) $(extra_targets)
+endif
 
 ifeq ($(LIBRARY_COMPILE),$(BOOT_COMPILE))
 is_boot=true
@@ -89,17 +91,21 @@ else
 is_boot=false
 endif
 
-csproj-local: 
-       config_file=`basename $(LIBRARY_NAME) .dll`-$(PROFILE).input; \
-       echo $(thisdir):$$config_file >> $(topdir)/../mono/msvc/scripts/order; \
+csproj-local: csproj-library csproj-test
+
+csproj-library:
+       config_file=`basename $(LIBRARY) .dll`-$(PROFILE).input; \
+       echo $(thisdir):$$config_file >> $(topdir)/../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
+       echo $(FRAMEWORK_VERSION); \
+       echo $(response)) > $(topdir)/../msvc/scripts/inputs/$$config_file
 
+csproj-test:
 
 install-local: all-local
 test-local: all-local
@@ -111,11 +117,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
@@ -171,6 +183,19 @@ include $(topdir)/build/tests.make
 
 ifdef HAVE_CS_TESTS
 DISTFILES += $(test_sourcefile)
+
+csproj-test:
+       config_file=`basename $(LIBRARY) .dll`-tests-$(PROFILE).input; \
+       echo $(thisdir):$$config_file >> $(topdir)/../msvc/scripts/order; \
+       (echo false; \
+       echo $(MCS);    \
+       echo $(USE_MCS_FLAGS) -r:$(the_assembly) $(TEST_MCS_FLAGS); \
+       echo $(test_lib); \
+       echo $(BUILT_SOURCES_cmdline); \
+       echo $(test_lib); \
+       echo $(FRAMEWORK_VERSION); \
+       echo $(test_response)) > $(topdir)/../msvc/scripts/inputs/$$config_file
+
 endif
 
 # make dist will collect files in .sources files from all profiles
@@ -179,9 +204,9 @@ dist-local: dist-default
        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
@@ -201,17 +226,8 @@ 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
@@ -225,20 +241,22 @@ $(the_lib): $(the_libdir)/.stamp
 
 $(build_lib): $(response) $(sn) $(BUILT_SOURCES) $(build_libdir:=/.stamp)
        $(LIBRARY_COMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) -target:library -out:$@ $(BUILT_SOURCES_cmdline) @$(response)
-       $(SN) $(SNFLAGS) $@ $(LIBRARY_SNK)
+       $(Q) $(SN) -R $@ $(LIBRARY_SNK)
 
 ifdef LIBRARY_USE_INTERMEDIATE_FILE
 $(the_lib): $(build_lib)
-       $(SN) $(SNFLAGS) $(build_lib) $(LIBRARY_SNK)
        $(Q) cp $(build_lib) $@
+       $(Q) $(SN) -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
 
+library_CLEAN_FILES += $(PROFILE)_aot.log
+
 ifdef PLATFORM_AOT_SUFFIX
-Q_AOT=$(if $(V),,@echo "AOT [$(PROFILE)] $(notdir $(@))";)
+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 $(the_lib)
+       $(Q_AOT) MONO_PATH='$(the_libdir)' > $(PROFILE)_aot.log 2>&1 $(RUNTIME) --aot=bind-to-runtime-version --debug $(the_lib)
 endif
 
 ifdef ENABLE_AOT
@@ -249,14 +267,28 @@ all-local: $(the_lib)$(PLATFORM_AOT_SUFFIX)
 endif
 endif
 
+makefrag = $(depsdir)/$(PROFILE)_$(LIBRARY).makefrag
+library_CLEAN_FILES += $(makefrag)
 $(makefrag): $(sourcefile)
-       @echo Creating $@ ...
+#      @echo Creating $@ ...
        @sed 's,^,$(build_lib): ,' $< >$@
+       @if test ! -f $(sourcefile).makefrag; then :; else \
+          cat $(sourcefile).makefrag >> $@ ; \
+          echo '$@: $(sourcefile).makefrag' >> $@; \
+          echo '$(sourcefile).makefrag:' >> $@; fi
 
 ifneq ($(response),$(sourcefile))
+
+ifdef PLATFORM_excludes
 $(response): $(sourcefile) $(PLATFORM_excludes)
-       @echo Creating $@ ...
+       @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
+
 endif
 
 -include $(makefrag)
@@ -276,14 +308,10 @@ $(makefrag) $(test_response) $(test_makefrag) $(btest_response) $(btest_makefrag
 ## Documentation stuff
 
 Q_MDOC_UP=$(if $(V),,@echo "MDOC-UP [$(PROFILE)] $(notdir $(@))";)
+# net_2_0 is needed because monodoc is only compiled in that profile
 MDOC_UP  =$(Q_MDOC_UP) \
-       if `echo $(PROFILE) | grep ^net_1_ > /dev/null 2>/dev/null` ; then    \
-               $(RUNTIME) $(topdir)/tools/mdoc/monodocer1.exe                      \
-                       -path:Documentation/en -assembly:$(the_lib) ;                     \
-       else                                                                  \
-               $(RUNTIME) $(topdir)/tools/mdoc/mdoc.exe update --delete            \
-                       -o Documentation/en $(the_lib) ;                                  \
-       fi
+               MONO_PATH="$(topdir)/class/lib/$(DEFAULT_PROFILE)$(PLATFORM_PATH_SEPARATOR)$(topdir)/class/lib/net_2_0$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(topdir)/class/lib/$(DEFAULT_PROFILE)/mdoc.exe \
+               update --delete -o Documentation/en $(the_lib)
 
 doc-update-local: $(the_libdir)/.doc-stamp