[Wasm] Fix memory override in mono_wasm_add_assembly
[mono-project.git] / mcs / build / executable.make
blob29abac599a5668c06de7b7782bee3ae25711be00
1 # -*- makefile -*-
3 # The rules for building a program.
5 base_prog = $(notdir $(PROGRAM))
6 ifndef sourcefile
7 sourcefile := $(base_prog).sources
8 endif
9 base_prog_config := $(wildcard $(base_prog).config.$(PROFILE))
10 ifndef base_prog_config
11 base_prog_config := $(wildcard $(base_prog).config)
12 endif
14 ifeq (cat,$(PLATFORM_CHANGE_SEPARATOR_CMD))
15 response = $(sourcefile)
16 else
17 response = $(depsdir)/$(sourcefile).response
18 executable_CLEAN_FILES += $(response)
19 endif
21 ifndef the_libdir
22 the_libdir = $(topdir)/class/lib/$(PROFILE_DIRECTORY)/
23 ifdef PROGRAM_USE_INTERMEDIATE_FILE
24 build_libdir = $(the_libdir)tmp/
25 else
26 build_libdir = $(the_libdir)
27 endif
28 endif
30 ifdef base_prog_config
31 PROGRAM_config := $(build_libdir)$(PROGRAM).config
32 endif
34 sn = $(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)/sn.exe
35 SN = MONO_PATH="$(topdir)/class/lib/$(BUILD_TOOLS_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(RUNTIME_FLAGS) $(sn) -q
37 the_lib = $(the_libdir)$(base_prog)
38 build_lib = $(build_libdir)$(base_prog)
40 executable_CLEAN_FILES += $(the_lib) $(the_lib).so $(the_lib).mdb $(the_lib:.exe=.pdb)
41 executable_CLEAN_FILES += $(build_lib) $(build_lib).so $(build_lib).mdb $(build_lib:.exe=.pdb)
43 makefrag = $(depsdir)/$(PROFILE)_$(base_prog).makefrag
45 LIB_REFS_ALL = $(DEFAULT_REFERENCES) $(LIB_REFS)
47 ifdef TARGET_NET_REFERENCE
48 # System*, mscorlib references come from the TARGET_NET_REFERENCE dir, others from the profile dir
49 LIB_REFS_MONO = $(call _FILTER_OUT,System,$(call _FILTER_OUT,mscorlib,$(LIB_REFS_ALL)))
50 LIB_REFS_SYSTEM = $(filter-out $(LIB_REFS_MONO),$(LIB_REFS_ALL))
52 MCS_REFERENCES = $(patsubst %,-r:$(topdir)/../external/binary-reference-assemblies/$(TARGET_NET_REFERENCE)/%.dll,$(LIB_REFS_SYSTEM))
53 MCS_REFERENCES += $(patsubst %,-r:$(topdir)/class/lib/$(PROFILE_DIRECTORY)/%.dll,$(LIB_REFS_MONO))
54 else
55 MCS_REFERENCES = $(patsubst %,-r:$(topdir)/class/lib/$(PROFILE_DIRECTORY)/%.dll,$(LIB_REFS_ALL))
56 endif
58 ifdef KEYFILE
59 LIB_MCS_FLAGS += /keyfile:$(KEYFILE)
60 endif
62 ifndef NO_BUILD
63 all-local: $(the_lib) $(PROGRAM_config)
64 endif
66 install-local: all-local
67 test-local: all-local
68 uninstall-local:
70 ifdef NO_INSTALL
71 install-local uninstall-local:
73 else
75 ifndef PROGRAM_INSTALL_DIR
76 PROGRAM_INSTALL_DIR = $(mono_libdir)/mono/$(FRAMEWORK_VERSION)
77 endif
79 install-local:
80 $(MKINSTALLDIRS) $(DESTDIR)$(PROGRAM_INSTALL_DIR)
81 $(INSTALL_BIN) $(the_lib) $(DESTDIR)$(PROGRAM_INSTALL_DIR)
82 test ! -f $(the_lib).mdb || $(INSTALL_BIN) $(the_lib).mdb $(DESTDIR)$(PROGRAM_INSTALL_DIR)
83 test ! -f $(the_lib:.exe=.pdb) || $(INSTALL_BIN) $(the_lib:.exe=.pdb) $(DESTDIR)$(PROGRAM_INSTALL_DIR)
84 ifdef PROGRAM_config
85 $(INSTALL_DATA) $(PROGRAM_config) $(DESTDIR)$(PROGRAM_INSTALL_DIR)
86 endif
87 ifdef PLATFORM_AOT_SUFFIX
88 test ! -f $(PROGRAM)$(PLATFORM_AOT_SUFFIX) || $(INSTALL_LIB) $(PROGRAM)$(PLATFORM_AOT_SUFFIX) $(DESTDIR)$(PROGRAM_INSTALL_DIR)
89 endif
91 uninstall-local:
92 -rm -f $(DESTDIR)$(PROGRAM_INSTALL_DIR)/$(base_prog) $(DESTDIR)$(PROGRAM_INSTALL_DIR)/$(base_prog).mdb \
93 $(DESTDIR)$(PROGRAM_INSTALL_DIR)/$(base_prog:.exe=.pdb) $(DESTDIR)$(PROGRAM_INSTALL_DIR)/$(base_prog).config
94 endif
96 clean-local:
97 -rm -f $(executable_CLEAN_FILES) $(CLEAN_FILES) $(tests_CLEAN_FILES)
99 test-local:
101 run-test-local:
103 run-test-ondotnet-local:
106 DISTFILES = $(sourcefile) $(base_prog_config) $(EXTRA_DISTFILES)
108 ifdef HAS_NUNIT_TEST
109 ASSEMBLY = $(PROGRAM)
110 ASSEMBLY_EXT = .exe
111 the_assembly = $(PROGRAM)
112 include $(topdir)/build/tests.make
113 endif
115 ifdef HAVE_CS_TESTS
116 DISTFILES += $(test_sourcefile)
117 endif
119 dist-local: dist-default
120 for f in `cat $(sourcefile)` ; do \
121 case $$f in \
122 ../*) : ;; \
123 *) dest=`dirname "$$f"` ; \
124 case $$subs in *" $$dest "*) : ;; *) subs=" $$dest$$subs" ; $(MKINSTALLDIRS) $(distdir)/$$dest ;; esac ; \
125 cp -p "$$f" $(distdir)/$$dest || exit 1 ;; \
126 esac ; done ; \
127 for d in . $$subs ; do \
128 case $$d in .) : ;; *) test ! -f $$d/ChangeLog || cp -p $$d/ChangeLog $(distdir)/$$d ;; esac ; done
130 ifndef PROGRAM_COMPILE
131 PROGRAM_COMPILE = $(CSCOMPILE)
132 endif
134 $(the_lib): $(the_libdir)/.stamp $(if $(PROFILE_PLATFORM),$(if $(filter $(HOST_PLATFORM),$(BUILD_PLATFORM)),$(topdir)/class/lib/$(PROFILE)/.stamp))
136 ifdef PROFILE_PLATFORM
137 $(topdir)/class/lib/$(PROFILE)/.stamp: | $(topdir)/class/lib/$(PROFILE)-$(HOST_PLATFORM)/.stamp
138 $(if $(filter $(HOST_PLATFORM),$(BUILD_PLATFORM)),$(if $(filter $(BUILD_PLATFORM),win32),CYGWIN=winsymlinks:nativestrict) ln -s $(abspath $(topdir)/class/lib/$(PROFILE)-$(BUILD_PLATFORM)) $(abspath $(topdir)/class/lib/$(PROFILE)))
139 endif
141 $(build_lib): $(BUILT_SOURCES) $(EXTRA_SOURCES) $(response) $(build_libdir:=/.stamp)
142 $(PROGRAM_COMPILE) $(MCS_REFERENCES) -target:exe -out:$@ $(BUILT_SOURCES) $(EXTRA_SOURCES) @$(response)
143 ifdef PROGRAM_SNK
144 $(Q) $(SN) -R $@ $(PROGRAM_SNK)
145 endif
147 ifdef PROGRAM_USE_INTERMEDIATE_FILE
148 $(the_lib): $(build_lib)
149 $(Q) cp $(build_lib) $@
150 $(Q) test ! -f $(build_lib).mdb || mv $(build_lib).mdb $@.mdb
151 $(Q) test ! -f $(build_lib:.exe=.pdb) || mv $(build_lib:.exe=.pdb) $(the_lib:.exe=.pdb)
152 endif
154 ifdef PROGRAM_config
155 ifneq ($(base_prog_config),$(PROGRAM_config))
156 executable_CLEAN_FILES += $(PROGRAM_config)
157 $(PROGRAM_config): $(base_prog_config) $(dir $(PROGRAM_config))/.stamp
158 cp $(base_prog_config) $(PROGRAM_config)
159 endif
160 endif
162 $(makefrag): $(sourcefile)
163 # @echo Creating $@ ...
164 @sed 's,^,$(build_lib): ,' $< >$@
165 @if test ! -f $(sourcefile).makefrag; then :; else \
166 cat $(sourcefile).makefrag >> $@ ; \
167 echo '$@: $(sourcefile).makefrag' >> $@; \
168 echo '$(sourcefile).makefrag:' >> $@; fi
170 ifneq ($(response),$(sourcefile))
171 $(response): $(sourcefile)
172 @echo Converting $(sourcefile) to $@ ...
173 @cat $(sourcefile) | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
174 endif
176 -include $(makefrag)
178 all-local: $(makefrag) $(extra_targets)
180 ifdef BUILT_SOURCES
181 library_CLEAN_FILES += $(BUILT_SOURCES)
182 ifeq (cat, $(PLATFORM_CHANGE_SEPARATOR_CMD))
183 BUILT_SOURCES_cmdline = $(BUILT_SOURCES)
184 else
185 BUILT_SOURCES_cmdline = `echo $(BUILT_SOURCES) | $(PLATFORM_CHANGE_SEPARATOR_CMD)`
186 endif
187 endif
189 csproj-local:
190 config_file=`basename $(PROGRAM) .exe`-$(PROFILE).input; \
191 echo $(thisdir):$$config_file >> $(topdir)/../msvc/scripts/order; \
192 (echo $(is_boot); \
193 echo $(USE_MCS_FLAGS) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) $(patsubst %,-r:%,$(LIB_REFS)); \
194 echo $(sourcefile); \
195 echo $(PROGRAM); \
196 echo $(BUILT_SOURCES_cmdline); \
197 echo $(build_lib); \
198 echo $(FRAMEWORK_VERSION); \
199 echo $(PROFILE); \
200 echo $(RESOURCE_DEFS); \
201 echo $(response)) > $(topdir)/../msvc/scripts/inputs/$$config_file
204 ifneq ($(response),$(sourcefile))
205 $(response): $(topdir)/build/executable.make $(depsdir)/.stamp
206 endif
207 $(makefrag): $(topdir)/build/executable.make $(depsdir)/.stamp
209 doc-update-local:
212 # Need to be here so it comes after the definition of DEP_DIRS/DEP_LIBS
213 gen-deps:
214 @echo "$(DEPS_TARGET_DIR): $(DEP_DIRS) $(DEP_LIBS)" >> $(DEPS_FILE)