Merge pull request #3012 from marek-safar/rs-Net
[mono.git] / mcs / build / executable.make
1 # -*- makefile -*-
2 #
3 # The rules for building a program.
4
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
13
14 ifeq (cat,$(PLATFORM_CHANGE_SEPARATOR_CMD))
15 response = $(sourcefile)
16 else
17 response = $(depsdir)/$(sourcefile).response
18 executable_CLEAN_FILES += $(response)
19 endif
20
21 ifndef the_libdir
22 the_libdir = $(topdir)/class/lib/$(PROFILE)/
23 ifdef PROGRAM_USE_INTERMEDIATE_FILE
24 build_libdir = $(the_libdir)tmp/
25 else
26 build_libdir = $(the_libdir)
27 endif
28 endif
29
30 ifdef base_prog_config
31 PROGRAM_config := $(build_libdir)$(PROGRAM).config
32 endif
33
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
36
37 the_lib = $(the_libdir)$(base_prog)
38 build_lib = $(build_libdir)$(base_prog)
39
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)
42
43 makefrag = $(depsdir)/$(PROFILE)_$(base_prog).makefrag
44
45 all-local: $(the_lib) $(PROGRAM_config)
46
47 install-local: all-local
48 test-local: all-local
49 uninstall-local:
50
51 ifdef NO_INSTALL
52 install-local uninstall-local:
53         @:
54 else
55
56 ifndef PROGRAM_INSTALL_DIR
57 PROGRAM_INSTALL_DIR = $(mono_libdir)/mono/$(FRAMEWORK_VERSION)
58 endif
59
60 install-local:
61         $(MKINSTALLDIRS) $(DESTDIR)$(PROGRAM_INSTALL_DIR)
62         $(INSTALL_BIN) $(the_lib) $(DESTDIR)$(PROGRAM_INSTALL_DIR)
63         test ! -f $(the_lib).mdb || $(INSTALL_BIN) $(the_lib).mdb $(DESTDIR)$(PROGRAM_INSTALL_DIR)
64 ifdef PROGRAM_config
65         $(INSTALL_DATA) $(PROGRAM_config) $(DESTDIR)$(PROGRAM_INSTALL_DIR)
66 endif
67 ifdef PLATFORM_AOT_SUFFIX
68         test ! -f $(PROGRAM)$(PLATFORM_AOT_SUFFIX) || $(INSTALL_LIB) $(PROGRAM)$(PLATFORM_AOT_SUFFIX) $(DESTDIR)$(PROGRAM_INSTALL_DIR)
69 endif
70
71 uninstall-local:
72         -rm -f $(DESTDIR)$(PROGRAM_INSTALL_DIR)/$(base_prog) $(DESTDIR)$(PROGRAM_INSTALL_DIR)/$(base_prog).mdb $(DESTDIR)$(PROGRAM_INSTALL_DIR)/$(base_prog).config
73 endif
74
75 clean-local:
76         -rm -f $(executable_CLEAN_FILES) $(CLEAN_FILES) $(tests_CLEAN_FILES)
77
78 test-local:
79         @:
80 run-test-local:
81         @:
82 run-test-ondotnet-local:
83         @:
84
85 DISTFILES = $(sourcefile) $(base_prog_config) $(EXTRA_DISTFILES)
86
87 ifdef HAS_NUNIT_TEST
88 ASSEMBLY      = $(PROGRAM)
89 ASSEMBLY_EXT  = .exe
90 the_assembly  = $(PROGRAM)
91 include $(topdir)/build/tests.make
92 endif
93
94 ifdef HAVE_CS_TESTS
95 DISTFILES += $(test_sourcefile)
96 endif
97
98 dist-local: dist-default
99         for f in `cat $(sourcefile)` ; do \
100           case $$f in \
101           ../*) : ;; \
102           *) dest=`dirname "$$f"` ; \
103              case $$subs in *" $$dest "*) : ;; *) subs=" $$dest$$subs" ; $(MKINSTALLDIRS) $(distdir)/$$dest ;; esac ; \
104              cp -p "$$f" $(distdir)/$$dest || exit 1 ;; \
105           esac ; done ; \
106         for d in . $$subs ; do \
107           case $$d in .) : ;; *) test ! -f $$d/ChangeLog || cp -p $$d/ChangeLog $(distdir)/$$d ;; esac ; done
108
109 ifndef PROGRAM_COMPILE
110 PROGRAM_COMPILE = $(CSCOMPILE)
111 endif
112
113 $(the_lib): $(the_libdir)/.stamp
114
115 $(build_lib): $(BUILT_SOURCES) $(EXTRA_SOURCES) $(response) $(build_libdir:=/.stamp)
116         $(PROGRAM_COMPILE) $(MCS_REFERENCES) -target:exe -out:$@ $(BUILT_SOURCES) $(EXTRA_SOURCES) @$(response)
117 ifdef PROGRAM_SNK
118         $(Q) $(SN) -R $@ $(PROGRAM_SNK)
119 endif
120
121 ifdef PROGRAM_USE_INTERMEDIATE_FILE
122 $(the_lib): $(build_lib)
123         $(Q) cp $(build_lib) $@
124         $(Q) test ! -f $(build_lib).mdb || mv $(build_lib).mdb $@.mdb
125         $(Q) test ! -f $(build_lib:.exe=.pdb) || mv $(build_lib:.exe=.pdb) $(the_lib:.exe=.pdb)
126 endif
127
128 ifdef PROGRAM_config
129 ifneq ($(base_prog_config),$(PROGRAM_config))
130 executable_CLEAN_FILES += $(PROGRAM_config)
131 $(PROGRAM_config): $(base_prog_config) $(dir $(PROGRAM_config))/.stamp
132         cp $(base_prog_config) $(PROGRAM_config)
133 endif
134 endif
135
136 $(makefrag): $(sourcefile)
137 #       @echo Creating $@ ...
138         @sed 's,^,$(build_lib): ,' $< >$@
139         @if test ! -f $(sourcefile).makefrag; then :; else \
140            cat $(sourcefile).makefrag >> $@ ; \
141            echo '$@: $(sourcefile).makefrag' >> $@; \
142            echo '$(sourcefile).makefrag:' >> $@; fi
143
144 ifneq ($(response),$(sourcefile))
145 $(response): $(sourcefile)
146         @echo Converting $(sourcefile) to $@ ...
147         @cat $(sourcefile) | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
148 endif
149
150 -include $(makefrag)
151
152 MCS_REFERENCES = $(patsubst %,-r:$(topdir)/class/lib/$(PROFILE)/%.dll,$(LIB_REFS))
153 MCS_REFERENCES += $(patsubst %,-r:$(topdir)/class/lib/$(PROFILE)/%.exe,$(EXE_REFS))
154
155 all-local: $(makefrag) $(extra_targets)
156
157 ifdef BUILT_SOURCES
158 library_CLEAN_FILES += $(BUILT_SOURCES)
159 ifeq (cat, $(PLATFORM_CHANGE_SEPARATOR_CMD))
160 BUILT_SOURCES_cmdline = $(BUILT_SOURCES)
161 else
162 BUILT_SOURCES_cmdline = `echo $(BUILT_SOURCES) | $(PLATFORM_CHANGE_SEPARATOR_CMD)`
163 endif
164 endif
165
166 csproj-local:
167         config_file=`basename $(PROGRAM) .exe`-$(PROFILE).input; \
168         echo $(thisdir):$$config_file >> $(topdir)/../msvc/scripts/order; \
169         (echo $(is_boot); \
170         echo $(USE_MCS_FLAGS) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) $(patsubst %,-r:%,$(LIB_REFS)); \
171         echo $(PROGRAM); \
172         echo $(BUILT_SOURCES_cmdline); \
173         echo $(build_lib); \
174         echo $(FRAMEWORK_VERSION); \
175         echo $(PROFILE); \
176         echo $(response)) > $(topdir)/../msvc/scripts/inputs/$$config_file
177
178
179 ifneq ($(response),$(sourcefile))
180 $(response): $(topdir)/build/executable.make $(depsdir)/.stamp
181 endif
182 $(makefrag): $(topdir)/build/executable.make $(depsdir)/.stamp
183
184 doc-update-local:
185         @:
186
187 # Need to be here so it comes after the definition of DEP_DIRS/DEP_LIBS
188 gen-deps:
189         @echo "$(DEPS_TARGET_DIR): $(DEP_DIRS) $(DEP_LIBS)" >> $(DEPS_FILE)