* platforms/linux.make (PLATFORM_CHANGE_SEPARATOR_CMD): Define to 'cat'.
[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 PLATFORM_excludes := $(wildcard $(LIBRARY).$(PLATFORM)-excludes)
13
14 ifndef PLATFORM_excludes
15 ifeq (cat,$(PLATFORM_CHANGE_SEPARATOR_CMD))
16 response = $(sourcefile)
17 endif
18 endif
19
20 ifndef response
21 response = $(depsdir)/$(PROFILE)_$(LIBRARY).response
22 library_CLEAN_FILES += $(response)
23 endif
24
25 ifndef LIBRARY_NAME
26 LIBRARY_NAME = $(LIBRARY)
27 endif
28
29 makefrag = $(depsdir)/$(PROFILE)_$(LIBRARY).makefrag
30 the_lib = $(topdir)/class/lib/$(PROFILE)/$(LIBRARY_NAME)
31 the_pdb = $(the_lib:.dll=.pdb)
32 library_CLEAN_FILES += $(makefrag) $(the_lib) $(the_pdb)
33
34 ifndef NO_TEST
35 test_nunit_lib = nunit.framework.dll nunit.core.dll nunit.util.dll
36 test_nunit_dep = $(test_nunit_lib:%=$(topdir)/class/lib/$(PROFILE)/%)
37 test_nunit_ref = $(test_nunit_dep:%=-r:%)
38 library_CLEAN_FILES += TestResult.xml
39
40 ifndef test_against
41 test_against = $(the_lib)
42 test_dep = $(the_lib)
43 endif
44
45 ifndef test_lib
46 test_lib = $(LIBRARY:.dll=_test.dll)
47 endif
48 test_pdb = $(test_lib:.dll=.pdb)
49 test_sourcefile = $(test_lib).sources
50 test_response = $(depsdir)/$(PROFILE)_$(test_lib).response
51 test_makefrag = $(depsdir)/$(PROFILE)_$(test_lib).makefrag
52 test_flags = /r:$(test_against) $(test_nunit_ref) $(TEST_MCS_FLAGS)
53 library_CLEAN_FILES += $(test_lib) $(test_pdb) $(test_response) $(test_makefrag)
54
55 ifndef btest_lib
56 btest_lib = $(LIBRARY:.dll=_btest.dll)
57 endif
58 btest_pdb = $(btest_lib:.dll=.pdb)
59 btest_sourcefile = $(btest_lib).sources
60 btest_response = $(depsdir)/$(btest_lib).response
61 btest_makefrag = $(depsdir)/$(btest_lib).makefrag
62 btest_flags = /r:$(test_against) $(test_nunit_ref) $(TEST_MBAS_FLAGS)
63 library_CLEAN_FILES += $(btest_lib) $(btest_pdb) $(btest_response) $(btest_makefrag)
64
65 ifndef HAVE_CS_TESTS
66 HAVE_CS_TESTS := $(wildcard $(test_sourcefile))
67 endif
68 ifndef HAVE_VB_TESTS
69 HAVE_VB_TESTS := $(wildcard $(btest_sourcefile))
70 endif
71
72 endif
73
74 gacutil = $(topdir)/tools/gacutil/gacutil.exe
75 sn = $(topdir)/tools/security/sn.exe
76
77 PACKAGE = 1.0
78
79 ifeq ($(PROFILE), net_2_0)
80 PACKAGE = 2.0
81 endif
82
83 all-local: $(the_lib)
84
85 install-local: $(the_lib) maybe-sign-lib
86
87 ifdef LIBRARY_INSTALL_DIR
88 install-local:
89         $(MKINSTALLDIRS) $(DESTDIR)$(LIBRARY_INSTALL_DIR)
90         $(INSTALL_LIB) $(the_lib) $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME)
91
92 uninstall-local:
93         -rm -f $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME)
94
95 else
96
97 install-local: $(gacutil)
98         $(RUNTIME) $(gacutil) /i $(the_lib) /f /root $(DESTDIR)$(prefix)/lib /package $(PACKAGE)
99
100 uninstall-local: $(gacutil)
101         $(RUNTIME) $(gacutil) /u $(LIBRARY_NAME:.dll=)
102
103 $(gacutil):
104         cd $(topdir)/tools/gacutil && $(MAKE)
105
106 endif
107
108 maybe-sign-lib:
109 ifndef NO_SIGN_ASSEMBLY
110 maybe-sign-lib: $(sn)
111         $(RUNTIME) $(sn) -q -R $(the_lib) $(topdir)/class/mono.snk
112 endif
113
114 $(sn):
115         cd $(topdir)/tools/security && $(MAKE) sn.exe
116
117 clean-local:
118         -rm -f $(library_CLEAN_FILES) $(CLEAN_FILES)
119
120 test-local: $(the_lib)
121         @:
122 run-test-local:
123         @:
124 run-test-ondotnet-local:
125         @:
126
127 ifndef NO_TEST
128 $(test_nunit_dep): $(topdir)/build/deps/nunit.stamp
129         @if test -f $@; then :; else rm -f $<; $(MAKE) $<; fi
130 $(topdir)/build/deps/nunit.stamp:
131         cd ${topdir}/nunit20 && $(MAKE)
132         echo "stamp" >$@
133 endif
134
135 ifdef HAVE_CS_TESTS
136
137 test-local: $(test_lib)
138
139 run-test-local: run-test-lib
140
141 run-test-lib: test-local
142         $(TEST_RUNTIME) $(TEST_HARNESS) $(test_lib)
143
144 run-test-ondotnet-local: run-test-ondotnet-lib
145
146 run-test-ondotnet-lib: test-local
147         $(TEST_HARNESS) $(test_lib)
148 endif
149
150 ifdef HAVE_VB_TESTS
151
152 test-local: $(btest_lib)
153
154 run-test-local: run-btest-lib
155
156 run-btest-lib: test-local
157         $(TEST_RUNTIME) $(TEST_HARNESS) $(btest_lib)
158
159 run-test-ondotnet-local: run-btest-ondotnet-lib
160
161 run-btest-ondotnet-lib: test-local
162         $(TEST_HARNESS) $(btest_lib)
163
164 endif
165
166 DISTFILES = $(sourcefile) $(test_sourcefile) $(EXTRA_DISTFILES)
167
168 TEST_FILES = 
169
170 ifdef HAVE_CS_TESTS
171 TEST_FILES += `sed 's,^,Test/,' $(test_sourcefile)`
172 endif
173 ifdef HAVE_VB_TESTS
174 TEST_FILES += `sed 's,^,Test/,' $(btest_sourcefile)`
175 endif
176
177 dist-local: dist-default
178         for f in `cat $(sourcefile)` $(TEST_FILES) ; do \
179             dest=`dirname $(distdir)/$$f` ; \
180             $(MKINSTALLDIRS) $$dest && cp $$f $$dest || exit 1 ; \
181         done
182
183 ifndef LIBRARY_COMPILE
184 LIBRARY_COMPILE = $(CSCOMPILE)
185 endif
186
187 ifndef TEST_COMPILE
188 TEST_COMPILE = $(CSCOMPILE)
189 endif
190
191 ifndef BTEST_COMPILE
192 BTEST_COMPILE = $(BASCOMPILE)
193 endif
194
195 # Fun with dependency tracking
196
197 $(the_lib): $(makefrag) $(response)
198         $(LIBRARY_COMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) /target:library /out:$@ @$(response)
199
200 $(makefrag): $(sourcefile)
201         @echo Creating $@ ...
202         @sed 's,^,$(the_lib): ,' $< >$@
203
204 ifneq ($(response),$(sourcefile))
205 $(response): $(sourcefile) $(PLATFORM_excludes)
206         @echo Creating $@ ...
207         @sort $(sourcefile) $(PLATFORM_excludes) | uniq -u | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
208 endif
209
210 -include $(makefrag)
211
212 # for now, don't give any /lib flags or set MONO_PATH, since we
213 # give a full path to the assembly.
214
215 ifdef HAVE_CS_TESTS
216
217 $(test_lib): $(test_makefrag) $(test_dep) $(test_response) $(test_nunit_dep)
218         $(TEST_COMPILE) /target:library /out:$@ $(test_flags) @$(test_response)
219
220 $(test_response): $(test_sourcefile)
221         @echo Creating $@ ...
222         @sed 's,^,Test/,' $(test_sourcefile) | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
223
224 $(test_makefrag): $(test_response)
225         @echo Creating $@ ...
226         @sed 's,^,$(test_lib): ,' $< >$@
227
228 -include $(test_makefrag)
229
230 endif
231
232 ifdef HAVE_VB_TESTS
233
234 $(btest_lib): $(btest_makefrag) $(test_dep) $(btest_response) $(test_nunit_dep)
235         $(BTEST_COMPILE) /target:library /out:$@ $(btest_flags) @$(btest_response)
236
237 $(btest_response): $(btest_sourcefile)
238         @echo Creating $@ ...
239         @sed 's,^,Test/,' $(btest_sourcefile) | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
240
241 $(btest_makefrag): $(btest_response)
242         @echo Creating $@ ...
243         @sed 's,^,$(btest_lib): ,' $< >$@
244
245 -include $(btest_makefrag)
246
247 endif