2009-09-02 Jb Evain <jbevain@novell.com>
[mcs.git] / build / library.make
blobb9e859d85996a4dd0562922b8ccb3f887197552a
1 # -*- makefile -*-
3 # The rules for building our class libraries.
5 # The NO_TEST stuff is not too pleasant but whatcha
6 # gonna do.
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.
11 sourcefile = $(LIBRARY).sources
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
24 PLATFORM_excludes := $(wildcard $(LIBRARY).$(PLATFORM)-excludes)
26 ifndef PLATFORM_excludes
27 ifeq (cat,$(PLATFORM_CHANGE_SEPARATOR_CMD))
28 response = $(sourcefile)
29 endif
30 endif
32 ifndef response
33 response = $(depsdir)/$(PROFILE)_$(LIBRARY).response
34 library_CLEAN_FILES += $(response) $(LIBRARY).mdb $(BUILT_SOURCES)
35 endif
37 ifndef LIBRARY_NAME
38 LIBRARY_NAME = $(LIBRARY)
39 endif
41 ifdef LIBRARY_COMPAT
42 lib_dir = compat
43 else
44 lib_dir = lib
45 endif
47 makefrag = $(depsdir)/$(PROFILE)_$(LIBRARY).makefrag
48 the_libdir = $(topdir)/class/$(lib_dir)/$(PROFILE)/
49 the_lib = $(the_libdir)$(LIBRARY_NAME)
50 the_pdb = $(the_lib:.dll=.pdb)
51 the_mdb = $(the_lib).mdb
52 library_CLEAN_FILES += $(makefrag) $(the_lib) $(the_lib).so $(the_pdb) $(the_mdb)
54 ifdef LIBRARY_NEEDS_POSTPROCESSING
55 build_libdir = fixup/$(PROFILE)/
56 else
57 ifdef LIBRARY_USE_INTERMEDIATE_FILE
58 build_libdir = $(the_libdir)tmp/
59 else
60 build_libdir = $(the_libdir)
61 endif
62 endif
64 build_lib = $(build_libdir)$(LIBRARY_NAME)
65 library_CLEAN_FILES += $(build_lib) $(build_lib:.dll=.pdb)
67 ifdef NO_SIGN_ASSEMBLY
68 SN = :
69 else
70 sn = $(topdir)/class/lib/net_1_1_bootstrap/sn.exe
71 SN = $(Q) MONO_PATH="$(topdir)/class/lib/net_1_1_bootstrap$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(RUNTIME_FLAGS) $(sn)
72 SNFLAGS = -q
73 endif
75 ifeq ($(PLATFORM), win32)
76 GACDIR = `cygpath -w $(mono_libdir)`
77 GACROOT = `cygpath -w $(DESTDIR)$(mono_libdir)`
78 test_flags += -d:WINDOWS
79 else
80 GACDIR = $(mono_libdir)
81 GACROOT = $(DESTDIR)$(mono_libdir)
82 endif
84 all-local: $(the_lib) $(extra_targets)
86 ifeq ($(LIBRARY_COMPILE),$(BOOT_COMPILE))
87 is_boot=true
88 else
89 is_boot=false
90 endif
92 csproj-local:
93 config_file=`basename $(LIBRARY_NAME) .dll`-$(PROFILE).input; \
94 echo $(thisdir):$$config_file >> $(topdir)/../mono/msvc/scripts/order; \
95 (echo $(is_boot); \
96 echo $(MCS); \
97 echo $(USE_MCS_FLAGS) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS); \
98 echo $(LIBRARY_NAME); \
99 echo $(BUILT_SOURCES_cmdline); \
100 echo $(build_lib); \
101 echo $(response)) > $(topdir)/../mono/msvc/scripts/inputs/$$config_file
104 install-local: all-local
105 test-local: all-local
106 uninstall-local:
108 ifdef NO_INSTALL
109 install-local uninstall-local:
112 else
114 ifdef LIBRARY_INSTALL_DIR
115 install-local:
116 $(MKINSTALLDIRS) $(DESTDIR)$(LIBRARY_INSTALL_DIR)
117 $(INSTALL_LIB) $(the_lib) $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME)
118 test ! -f $(the_lib).mdb || $(INSTALL_LIB) $(the_lib).mdb $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME).mdb
120 uninstall-local:
121 -rm -f $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME) $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME).mdb
123 else
125 # If RUNTIME_HAS_CONSISTENT_GACDIR is set, it implies that the internal GACDIR
126 # of the runtime is the same as the GACDIR we want. So, we don't need to pass it
127 # to gacutil. Note that the GACDIR we want may not be the same as the value of
128 # GACDIR set above, since the user could have overridden the value of $(prefix).
130 # This makes a difference only when we're building from the mono/ tree, since we
131 # have to ensure that the internal GACDIR of the in-tree runtime matches where we
132 # install the DLLs.
134 ifndef RUNTIME_HAS_CONSISTENT_GACDIR
135 gacdir_flag = /gacdir $(GACDIR)
136 endif
138 ifndef LIBRARY_PACKAGE
139 ifdef LIBRARY_COMPAT
140 LIBRARY_PACKAGE = compat-$(FRAMEWORK_VERSION)
141 else
142 LIBRARY_PACKAGE = $(FRAMEWORK_VERSION)
143 endif
144 endif
146 ifneq (none, $(LIBRARY_PACKAGE))
147 package_flag = /package $(LIBRARY_PACKAGE)
148 endif
150 install-local: $(gacutil)
151 $(GACUTIL) /i $(the_lib) /f $(gacdir_flag) /root $(GACROOT) $(package_flag)
153 uninstall-local: $(gacutil)
154 -$(GACUTIL) /u $(LIBRARY_NAME:.dll=) $(gacdir_flag) /root $(GACROOT) $(package_flag)
156 endif # LIBRARY_INSTALL_DIR
157 endif # NO_INSTALL
159 clean-local:
160 -rm -f $(tests_CLEAN_FILES) $(library_CLEAN_FILES) $(CLEAN_FILES)
162 test-local run-test-local run-test-ondotnet-local:
165 DISTFILES = $(wildcard *$(LIBRARY)*.sources) $(EXTRA_DISTFILES)
167 ASSEMBLY = $(LIBRARY)
168 ASSEMBLY_EXT = .dll
169 the_assembly = $(the_lib)
170 include $(topdir)/build/tests.make
172 ifdef HAVE_CS_TESTS
173 DISTFILES += $(test_sourcefile)
174 endif
176 # make dist will collect files in .sources files from all profiles
177 dist-local: dist-default
178 subs=' ' ; \
179 for f in `$(topdir)/tools/removecomments.sh $(wildcard *$(LIBRARY).sources)` $(TEST_FILES) ; do \
180 case $$f in \
181 ../*) : ;; \
182 *) dest=`dirname $$f` ; \
183 case $$subs in *" $$dest "*) : ;; *) subs=" $$dest$$subs" ; $(MKINSTALLDIRS) $(distdir)/$$dest ;; esac ; \
184 cp -p $$f $(distdir)/$$dest || exit 1 ;; \
185 esac ; done ; \
186 for d in . $$subs ; do \
187 case $$d in .) : ;; *) test ! -f $$d/ChangeLog || cp -p $$d/ChangeLog $(distdir)/$$d ;; esac ; done
189 ifdef LIBRARY_NEEDS_POSTPROCESSING
190 dist-local: dist-fixup
191 FIXUP_PROFILES = default net_2_0
192 dist-fixup:
193 $(MKINSTALLDIRS) $(distdir)/fixup $(FIXUP_PROFILES:%=$(distdir)/fixup/%)
194 endif
196 ifndef LIBRARY_COMPILE
197 LIBRARY_COMPILE = $(CSCOMPILE)
198 endif
200 ifndef LIBRARY_SNK
201 LIBRARY_SNK = $(topdir)/class/mono.snk
202 endif
204 ifdef gacutil
205 $(gacutil):
206 cd $(topdir) && $(MAKE) PROFILE=net_1_1_bootstrap
207 endif
209 ifdef sn
210 $(sn):
211 cd $(topdir) && $(MAKE) PROFILE=net_1_1_bootstrap
212 endif
214 ifdef BUILT_SOURCES
215 ifeq (cat, $(PLATFORM_CHANGE_SEPARATOR_CMD))
216 BUILT_SOURCES_cmdline = $(BUILT_SOURCES)
217 else
218 BUILT_SOURCES_cmdline = `echo $(BUILT_SOURCES) | $(PLATFORM_CHANGE_SEPARATOR_CMD)`
219 endif
220 endif
222 # The library
224 $(the_lib): $(the_libdir)/.stamp
226 $(build_lib): $(response) $(sn) $(BUILT_SOURCES) $(build_libdir:=/.stamp)
227 $(LIBRARY_COMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) -target:library -out:$@ $(BUILT_SOURCES_cmdline) @$(response)
228 $(SN) $(SNFLAGS) -R $@ $(LIBRARY_SNK)
230 ifdef LIBRARY_USE_INTERMEDIATE_FILE
231 $(the_lib): $(build_lib)
232 $(Q) cp $(build_lib) $@
233 $(SN) $(SNFLAGS) -v $@
234 $(Q) test ! -f $(build_lib).mdb || mv $(build_lib).mdb $@.mdb
235 $(Q) test ! -f $(build_lib:.dll=.pdb) || mv $(build_lib:.dll=.pdb) $(the_lib:.dll=.pdb)
236 endif
238 ifdef PLATFORM_AOT_SUFFIX
239 Q_AOT=$(if $(V),,@echo "AOT [$(PROFILE)] $(notdir $(@))";)
240 $(the_lib)$(PLATFORM_AOT_SUFFIX): $(the_lib)
241 $(Q_AOT) MONO_PATH='$(the_libdir)' > $(PROFILE)_aot.log 2>&1 $(RUNTIME) --aot=bind-to-runtime-version $(the_lib)
242 endif
244 ifdef ENABLE_AOT
245 ifneq (,$(filter $(AOT_IN_PROFILES), $(PROFILE)))
247 all-local: $(the_lib)$(PLATFORM_AOT_SUFFIX)
249 endif
250 endif
252 $(makefrag): $(sourcefile)
253 @echo Creating $@ ...
254 @sed 's,^,$(build_lib): ,' $< >$@
256 ifneq ($(response),$(sourcefile))
257 $(response): $(sourcefile) $(PLATFORM_excludes)
258 @echo Creating $@ ...
259 @sort $(sourcefile) $(PLATFORM_excludes) | uniq -u | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
260 endif
262 -include $(makefrag)
264 # for now, don't give any /lib flags or set MONO_PATH, since we
265 # give a full path to the assembly.
267 ## Include corcompare stuff
268 include $(topdir)/build/corcompare.make
270 all-local: $(makefrag) $(test_makefrag) $(btest_makefrag)
271 ifneq ($(response),$(sourcefile))
272 $(response): $(topdir)/build/library.make $(depsdir)/.stamp
273 endif
274 $(makefrag) $(test_response) $(test_makefrag) $(btest_response) $(btest_makefrag): $(topdir)/build/library.make $(depsdir)/.stamp
276 ## Documentation stuff
278 Q_MDOC_UP=$(if $(V),,@echo "MDOC-UP [$(PROFILE)] $(notdir $(@))";)
279 MDOC_UP =$(Q_MDOC_UP) \
280 if `echo $(PROFILE) | grep ^net_1_ > /dev/null 2>/dev/null` ; then \
281 $(RUNTIME) $(topdir)/tools/mdoc/monodocer1.exe \
282 -path:Documentation/en -assembly:$(the_lib) ; \
283 else \
284 $(RUNTIME) $(topdir)/tools/mdoc/mdoc.exe update --delete \
285 -o Documentation/en $(the_lib) ; \
288 doc-update-local: $(the_libdir)/.doc-stamp
290 $(the_libdir)/.doc-stamp: $(the_lib)
291 $(MDOC_UP)
292 @echo "doc-stamp" > $@