Add this for backwards compatibility
[mono.git] / mcs / build / library.make
1 # -*- makefile -*-
2 #
3 # The rules for building our class libraries.
4 #
5 # The NO_TEST stuff is not too pleasant but whatcha
6 # gonna do.
7
8 # All the dep files now land in the same directory so we
9 # munge in the library name to keep the files from clashing.
10
11 sourcefile = $(LIBRARY).sources
12
13 # If the directory contains the per profile include file, generate list file.
14 PROFILE_sources = $(PROFILE)_$(LIBRARY).sources
15 ifeq ($(wildcard $(PROFILE_sources)), $(PROFILE_sources))
16 PROFILE_excludes = $(wildcard $(PROFILE)_$(LIBRARY).exclude.sources)
17 COMMON_sourcefile := $(sourcefile)
18 sourcefile = $(depsdir)/$(PROFILE)_$(LIBRARY).sources
19 $(sourcefile): $(PROFILE_sources) $(PROFILE_excludes) $(COMMON_sourcefile)
20         @echo Creating the per profile list $@ ...
21         $(topdir)/tools/gensources.sh $(PROFILE_sources) $(PROFILE_excludes) > $@
22 endif
23
24 PLATFORM_excludes := $(wildcard $(LIBRARY).$(PLATFORM)-excludes)
25
26 ifndef PLATFORM_excludes
27 ifeq (cat,$(PLATFORM_CHANGE_SEPARATOR_CMD))
28 response = $(sourcefile)
29 endif
30 endif
31
32 ifndef response
33 response = $(depsdir)/$(PROFILE)_$(LIBRARY).response
34 library_CLEAN_FILES += $(response) $(LIBRARY).mdb $(BUILT_SOURCES)
35 endif
36
37 ifndef LIBRARY_NAME
38 LIBRARY_NAME = $(LIBRARY)
39 endif
40
41 makefrag = $(depsdir)/$(PROFILE)_$(LIBRARY).makefrag
42 the_lib = $(topdir)/class/lib/$(PROFILE)/$(LIBRARY_NAME)
43 the_pdb = $(the_lib:.dll=.pdb)
44 the_mdb = $(the_lib).mdb
45 library_CLEAN_FILES += $(makefrag) $(the_lib) $(the_pdb) $(the_mdb)
46
47 ifdef LIBRARY_NEEDS_POSTPROCESSING
48 build_lib = fixup/$(PROFILE)/$(LIBRARY_NAME)
49 library_CLEAN_FILES += $(build_lib) $(build_lib:.dll=.pdb)
50 else
51 build_lib = $(the_lib)
52 endif
53
54 ifndef NO_TEST
55 test_nunit_lib = nunit.framework.dll nunit.core.dll nunit.util.dll
56 test_nunit_dep = $(test_nunit_lib:%=$(topdir)/class/lib/$(PROFILE)/%)
57 test_nunit_ref = $(test_nunit_dep:%=-r:%)
58 library_CLEAN_FILES += TestResult*.xml
59
60 ifndef test_against
61 test_against = $(the_lib)
62 test_dep = $(the_lib)
63 endif
64
65 ifndef test_lib
66 test_lib = $(LIBRARY:.dll=_test_$(PROFILE).dll)
67 test_sourcefile = $(LIBRARY:.dll=_test.dll.sources)
68 else
69 test_sourcefile = $(test_lib).sources
70 endif
71 test_pdb = $(test_lib:.dll=.pdb)
72 test_response = $(depsdir)/$(test_lib).response
73 test_makefrag = $(depsdir)/$(test_lib).makefrag
74 test_flags = -r:$(test_against) $(test_nunit_ref) $(TEST_MCS_FLAGS)
75 library_CLEAN_FILES += $(LIBRARY:.dll=_test*.dll) $(LIBRARY:.dll=_test*.pdb) $(test_response) $(test_makefrag)
76
77 ifndef btest_lib
78 btest_lib = $(LIBRARY:.dll=_btest_$(PROFILE).dll)
79 btest_sourcefile = $(LIBRARY:.dll=_btest.dll.sources)
80 else
81 btest_sourcefile = $(btest_lib).sources
82 endif
83 btest_pdb = $(btest_lib:.dll=.pdb)
84 btest_response = $(depsdir)/$(btest_lib).response
85 btest_makefrag = $(depsdir)/$(btest_lib).makefrag
86 btest_flags = -r:$(test_against) $(test_nunit_ref) $(TEST_MBAS_FLAGS)
87 library_CLEAN_FILES += $(LIBRARY:.dll=_btest*.dll) $(LIBRARY:.dll=_btest*.pdb) $(btest_response) $(btest_makefrag)
88
89 ifndef HAVE_CS_TESTS
90 HAVE_CS_TESTS := $(wildcard $(test_sourcefile))
91 endif
92 ifndef HAVE_VB_TESTS
93 HAVE_VB_TESTS := $(wildcard $(btest_sourcefile))
94 endif
95
96 endif
97
98 ifdef NO_INSTALL
99 GACUTIL = :
100 else
101 gacutil = $(topdir)/class/lib/net_1_1_bootstrap/gacutil.exe
102 GACUTIL = MONO_PATH="$(topdir)/class/lib/net_1_1_bootstrap$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(RUNTIME_FLAGS) $(gacutil)
103 endif
104
105 ifdef NO_SIGN_ASSEMBLY
106 SN = :
107 else
108 sn = $(topdir)/class/lib/net_1_1_bootstrap/sn.exe
109 SN = MONO_PATH="$(topdir)/class/lib/net_1_1_bootstrap$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(RUNTIME_FLAGS) $(sn)
110 SNFLAGS = -q -R
111 endif
112
113 ifeq ($(PLATFORM), win32)
114 GACDIR = `cygpath -w $(mono_libdir)`
115 GACROOT = `cygpath -w $(DESTDIR)$(mono_libdir)`
116 test_flags += -d:WINDOWS
117 else
118 GACDIR = $(mono_libdir)
119 GACROOT = $(DESTDIR)$(mono_libdir)
120 endif
121
122 all-local: $(the_lib)
123
124 install-local: all-local
125 test-local: all-local
126 uninstall-local:
127
128 ifdef NO_INSTALL
129 install-local uninstall-local:
130         @:
131
132 else
133
134 ifdef LIBRARY_INSTALL_DIR
135 install-local:
136         $(MKINSTALLDIRS) $(DESTDIR)$(LIBRARY_INSTALL_DIR)
137         $(INSTALL_LIB) $(the_lib) $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME)
138         test ! -f $(the_lib).mdb || $(INSTALL_LIB) $(the_lib).mdb $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME).mdb
139
140 uninstall-local:
141         -rm -f $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME) $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME).mdb
142
143 else
144
145 # If RUNTIME_HAS_CONSISTENT_GACDIR is set, it implies that the internal GACDIR
146 # of the runtime is the same as the GACDIR we want.  So, we don't need to pass it
147 # to gacutil.  Note that the GACDIR we want may not be the same as the value of
148 # GACDIR set above, since the user could have overridden the value of $(prefix).
149 #
150 # This makes a difference only when we're building from the mono/ tree, since we
151 # have to ensure that the internal GACDIR of the in-tree runtime matches where we
152 # install the DLLs.
153
154 ifndef RUNTIME_HAS_CONSISTENT_GACDIR
155 gacdir_flag = /gacdir $(GACDIR)
156 endif
157
158 install-local: $(gacutil)
159         $(GACUTIL) /i $(the_lib) /f $(gacdir_flag) /root $(GACROOT) /package $(FRAMEWORK_VERSION)
160
161 uninstall-local: $(gacutil)
162         -$(GACUTIL) /u $(LIBRARY_NAME:.dll=) $(gacdir_flag) /root $(GACROOT) /package $(FRAMEWORK_VERSION)
163
164 endif
165 endif
166
167 clean-local:
168         -rm -f $(library_CLEAN_FILES) $(CLEAN_FILES)
169
170 test-local run-test-local run-test-ondotnet-local:
171         @:
172
173 ifndef NO_TEST
174 $(test_nunit_dep): $(topdir)/build/deps/nunit-$(PROFILE).stamp
175         @if test -f $@; then :; else rm -f $<; $(MAKE) $<; fi
176 $(topdir)/build/deps/nunit-$(PROFILE).stamp:
177         cd ${topdir}/nunit20 && $(MAKE)
178         echo "stamp" >$@
179 library_CLEAN_FILES += $(topdir)/build/deps/nunit-$(PROFILE).stamp
180 endif
181
182 test_assemblies :=
183
184 ifdef HAVE_CS_TESTS
185 test_assemblies += $(test_lib)
186 endif
187
188 ifdef HAVE_VB_TESTS
189 test_assemblies += $(btest_lib)
190 endif
191
192 ifdef test_assemblies
193 test-local: $(test_assemblies)
194 run-test-local: run-test-lib
195 run-test-ondotnet-local: run-test-ondotnet-lib
196
197 ## FIXME: i18n problem in the 'sed' command below
198 run-test-lib: test-local
199         ok=:; \
200         $(TEST_RUNTIME) $(TEST_HARNESS) $(TEST_HARNESS_FLAGS) $(LOCAL_TEST_HARNESS_FLAGS) /output:TestResult-$(PROFILE).log /exclude:NotWorking,ValueAdd,CAS,InetAccess /xml:TestResult-$(PROFILE).xml $(test_assemblies) || ok=false; \
201         sed '1,/^Tests run: /d' TestResult-$(PROFILE).log; \
202         $$ok
203
204 run-test-ondotnet-lib: test-local
205         ok=:; \
206         $(TEST_HARNESS) $(TEST_HARNESS_FLAGS) $(LOCAL_TEST_HARNESS_ONDOTNET_FLAGS) /exclude=NotDotNet,CAS /output:TestResult-ondotnet-$(PROFILE).log /xml:TestResult-ondotnet-$(PROFILE).xml $(test_assemblies) || ok=false; \
207         sed '1,/^Tests run: /d' TestResult-ondotnet-$(PROFILE).log; \
208         $$ok
209 endif
210
211 DISTFILES = $(sourcefile) $(EXTRA_DISTFILES)
212
213 TEST_FILES =
214
215 ifdef HAVE_CS_TESTS
216 TEST_FILES += `sed -e '/^$$/d' -e 's,^,Test/,' $(test_sourcefile)`
217 DISTFILES += $(test_sourcefile)
218 endif
219 ifdef HAVE_VB_TESTS
220 TEST_FILES += `sed -e '/^$$/d' -e 's,^,Test/,' $(btest_sourcefile)`
221 DISTFILES += $(btest_sourcefile)
222 endif
223
224 dist-local: dist-default
225         subs=' ' ; \
226         for f in `cat $(sourcefile)` $(TEST_FILES) ; do \
227           case $$f in \
228           ../*) : ;; \
229           *) dest=`dirname $$f` ; \
230              case $$subs in *" $$dest "*) : ;; *) subs=" $$dest$$subs" ; $(MKINSTALLDIRS) $(distdir)/$$dest ;; esac ; \
231              cp -p $$f $(distdir)/$$dest || exit 1 ;; \
232           esac ; done ; \
233         for d in . $$subs ; do \
234           case $$d in .) : ;; *) test ! -f $$d/ChangeLog || cp -p $$d/ChangeLog $(distdir)/$$d ;; esac ; done
235
236 ifdef LIBRARY_NEEDS_POSTPROCESSING
237 dist-local: dist-fixup
238 FIXUP_PROFILES = default net_2_0
239 dist-fixup:
240         $(MKINSTALLDIRS) $(distdir)/fixup $(FIXUP_PROFILES:%=$(distdir)/fixup/%)
241 endif
242
243 ifndef LIBRARY_COMPILE
244 LIBRARY_COMPILE = $(CSCOMPILE)
245 endif
246
247 ifndef TEST_COMPILE
248 TEST_COMPILE = $(CSCOMPILE)
249 endif
250
251 ifndef BTEST_COMPILE
252 BTEST_COMPILE = $(BASCOMPILE)
253 endif
254
255 ifndef LIBRARY_SNK
256 LIBRARY_SNK = $(topdir)/class/mono.snk
257 endif
258
259 ifdef gacutil
260 $(gacutil):
261         cd $(topdir) && $(MAKE) PROFILE=net_1_1_bootstrap
262 endif
263
264 ifdef sn
265 $(sn):
266         cd $(topdir) && $(MAKE) PROFILE=net_1_1_bootstrap
267 endif
268
269 ifdef BUILT_SOURCES
270 ifeq (cat, $(PLATFORM_CHANGE_SEPARATOR_CMD))
271 BUILT_SOURCES_cmdline = $(BUILT_SOURCES)
272 else
273 BUILT_SOURCES_cmdline = `echo $(BUILT_SOURCES) | $(PLATFORM_CHANGE_SEPARATOR_CMD)`
274 endif
275 endif
276
277 # The library
278
279 $(build_lib): $(response) $(sn) $(BUILT_SOURCES)
280 ifdef LIBRARY_USE_INTERMEDIATE_FILE
281         $(LIBRARY_COMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) -target:library -out:$(LIBRARY_NAME) $(BUILT_SOURCES_cmdline) @$(response)
282         $(SN) $(SNFLAGS) $(LIBRARY_NAME) $(LIBRARY_SNK)
283         mv $(LIBRARY_NAME) $@
284         test ! -f $(LIBRARY_NAME).mdb || mv $(LIBRARY_NAME).mdb $@.mdb
285         test ! -f $(LIBRARY_NAME:.dll=.pdb) || mv $(LIBRARY_NAME:.dll=.pdb) $(dir $@)$(LIBRARY_NAME:.dll=.pdb)
286 else
287         $(LIBRARY_COMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) -target:library -out:$@ $(BUILT_SOURCES_cmdline) @$(response)
288         $(SN) $(SNFLAGS) $@ $(LIBRARY_SNK)
289 endif
290
291 $(makefrag): $(sourcefile)
292         @echo Creating $@ ...
293         @sed 's,^,$(build_lib): ,' $< >$@
294
295 ifneq ($(response),$(sourcefile))
296 $(response): $(sourcefile) $(PLATFORM_excludes)
297         @echo Creating $@ ...
298         @sort $(sourcefile) $(PLATFORM_excludes) | uniq -u | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
299 endif
300
301 -include $(makefrag)
302
303 # for now, don't give any /lib flags or set MONO_PATH, since we
304 # give a full path to the assembly.
305
306 ifdef HAVE_CS_TESTS
307
308 $(test_lib): $(test_dep) $(test_response) $(test_nunit_dep)
309         $(TEST_COMPILE) -target:library -out:$@ $(test_flags) @$(test_response)
310
311 $(test_response): $(test_sourcefile)
312         @echo Creating $@ ...
313         @sed -e '/^$$/d' -e 's,^,Test/,' $(test_sourcefile) | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
314
315 $(test_makefrag): $(test_response)
316         @echo Creating $@ ...
317         @sed 's,^,$(test_lib): ,' $< >$@
318
319 -include $(test_makefrag)
320
321 endif
322
323 ifdef HAVE_VB_TESTS
324
325 $(btest_lib): $(test_dep) $(btest_response) $(test_nunit_dep)
326         $(BTEST_COMPILE) -target:library -out:$@ $(btest_flags) @$(btest_response)
327
328 $(btest_response): $(btest_sourcefile)
329         @echo Creating $@ ...
330         @sed -e '/^$$/d' -e 's,^,Test/,' $(btest_sourcefile) | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
331
332 $(btest_makefrag): $(btest_response)
333         @echo Creating $@ ...
334         @sed 's,^,$(btest_lib): ,' $< >$@
335
336 -include $(btest_makefrag)
337
338 endif
339
340 all-local: $(makefrag) $(test_makefrag) $(btest_makefrag)
341 $(makefrag) $(test_makefrag) $(btest_makefrag): $(topdir)/build/library.make