2010-05-25 Jb Evain <jbevain@novell.com>
[mcs.git] / build / library.make
blob7bf697ed1c7d09b90f46b735edb2ef41b1c5fc07
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 := $(wildcard $(PROFILE)_$(LIBRARY).sources)
15 ifdef PROFILE_sources
16 PROFILE_excludes = $(wildcard $(PROFILE)_$(LIBRARY).exclude.sources)
17 sourcefile = $(depsdir)/$(PROFILE)_$(LIBRARY).sources
18 library_CLEAN_FILES += $(sourcefile)
20 # Note, gensources.sh can create a $(sourcefile).makefrag if it sees any '#include's
21 # We don't include it in the dependencies since it isn't always created
22 $(sourcefile): $(PROFILE_sources) $(PROFILE_excludes) $(topdir)/build/gensources.sh
23 @echo Creating the per profile list $@ ...
24 $(SHELL) $(topdir)/build/gensources.sh $@ $(PROFILE_sources) $(PROFILE_excludes)
25 endif
27 PLATFORM_excludes := $(wildcard $(LIBRARY).$(PLATFORM)-excludes)
29 ifndef PLATFORM_excludes
30 ifeq (cat,$(PLATFORM_CHANGE_SEPARATOR_CMD))
31 response = $(sourcefile)
32 endif
33 endif
35 ifndef response
36 response = $(depsdir)/$(PROFILE)_$(LIBRARY).response
37 library_CLEAN_FILES += $(response)
38 endif
40 ifndef LIBRARY_NAME
41 LIBRARY_NAME = $(LIBRARY)
42 endif
44 ifdef LIBRARY_COMPAT
45 lib_dir = compat
46 else
47 lib_dir = lib
48 endif
50 the_libdir = $(topdir)/class/$(lib_dir)/$(PROFILE)/
51 ifdef LIBRARY_NEEDS_POSTPROCESSING
52 build_libdir = fixup/$(PROFILE)/
53 else
54 ifdef LIBRARY_USE_INTERMEDIATE_FILE
55 build_libdir = $(the_libdir)tmp/
56 else
57 build_libdir = $(the_libdir)
58 endif
59 endif
61 the_lib = $(the_libdir)$(LIBRARY_NAME)
62 build_lib = $(build_libdir)$(LIBRARY_NAME)
63 library_CLEAN_FILES += $(the_lib) $(the_lib).so $(the_lib).mdb $(the_lib:.dll=.pdb)
64 library_CLEAN_FILES += $(build_lib) $(build_lib).so $(build_lib).mdb $(build_lib:.dll=.pdb)
66 ifdef NO_SIGN_ASSEMBLY
67 SN = :
68 else
69 sn = $(topdir)/class/lib/basic/sn.exe
70 SN = $(Q) MONO_PATH="$(topdir)/class/lib/basic$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(RUNTIME_FLAGS) $(sn)
71 SNFLAGS = -q
72 endif
74 ifeq ($(PLATFORM), win32)
75 GACDIR = `cygpath -w $(mono_libdir)`
76 GACROOT = `cygpath -w $(DESTDIR)$(mono_libdir)`
77 test_flags += -d:WINDOWS
78 else
79 GACDIR = $(mono_libdir)
80 GACROOT = $(DESTDIR)$(mono_libdir)
81 endif
83 ifndef NO_BUILD
84 all-local: $(the_lib) $(extra_targets)
85 endif
87 ifeq ($(LIBRARY_COMPILE),$(BOOT_COMPILE))
88 is_boot=true
89 else
90 is_boot=false
91 endif
93 csproj-local:
94 config_file=`basename $(LIBRARY) .dll`-$(PROFILE).input; \
95 echo $(thisdir):$$config_file >> $(topdir)/../mono/msvc/scripts/order; \
96 (echo $(is_boot); \
97 echo $(MCS); \
98 echo $(USE_MCS_FLAGS) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS); \
99 echo $(LIBRARY_NAME); \
100 echo $(BUILT_SOURCES_cmdline); \
101 echo $(build_lib); \
102 echo $(response)) > $(topdir)/../mono/msvc/scripts/inputs/$$config_file
105 install-local: all-local
106 test-local: all-local
107 uninstall-local:
109 ifdef NO_INSTALL
110 install-local uninstall-local:
113 else
115 aot_lib = $(the_lib)$(PLATFORM_AOT_SUFFIX)
116 aot_libname = $(LIBRARY_NAME)$(PLATFORM_AOT_SUFFIX)
118 ifdef LIBRARY_INSTALL_DIR
119 install-local:
120 $(MKINSTALLDIRS) $(DESTDIR)$(LIBRARY_INSTALL_DIR)
121 $(INSTALL_LIB) $(the_lib) $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME)
122 test ! -f $(the_lib).mdb || $(INSTALL_LIB) $(the_lib).mdb $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME).mdb
123 ifdef PLATFORM_AOT_SUFFIX
124 test ! -f $(aot_lib) || $(INSTALL_LIB) $(aot_lib) $(DESTDIR)$(LIBRARY_INSTALL_DIR)
125 endif
127 uninstall-local:
128 -rm -f $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME) $(DESTDIR)$(LIBRARY_INSTALL_DIR)/$(LIBRARY_NAME).mdb
130 else
132 # If RUNTIME_HAS_CONSISTENT_GACDIR is set, it implies that the internal GACDIR
133 # of the runtime is the same as the GACDIR we want. So, we don't need to pass it
134 # to gacutil. Note that the GACDIR we want may not be the same as the value of
135 # GACDIR set above, since the user could have overridden the value of $(prefix).
137 # This makes a difference only when we're building from the mono/ tree, since we
138 # have to ensure that the internal GACDIR of the in-tree runtime matches where we
139 # install the DLLs.
141 ifndef RUNTIME_HAS_CONSISTENT_GACDIR
142 gacdir_flag = /gacdir $(GACDIR)
143 endif
145 ifndef LIBRARY_PACKAGE
146 ifdef LIBRARY_COMPAT
147 LIBRARY_PACKAGE = compat-$(FRAMEWORK_VERSION)
148 else
149 LIBRARY_PACKAGE = $(FRAMEWORK_VERSION)
150 endif
151 endif
153 ifneq (none, $(LIBRARY_PACKAGE))
154 package_flag = /package $(LIBRARY_PACKAGE)
155 endif
157 install-local: $(gacutil)
158 $(GACUTIL) /i $(the_lib) /f $(gacdir_flag) /root $(GACROOT) $(package_flag)
160 uninstall-local: $(gacutil)
161 -$(GACUTIL) /u $(LIBRARY_NAME:.dll=) $(gacdir_flag) /root $(GACROOT) $(package_flag)
163 endif # LIBRARY_INSTALL_DIR
164 endif # NO_INSTALL
166 clean-local:
167 -rm -f $(tests_CLEAN_FILES) $(library_CLEAN_FILES) $(CLEAN_FILES)
169 test-local run-test-local run-test-ondotnet-local:
172 DISTFILES = $(wildcard *$(LIBRARY)*.sources) $(EXTRA_DISTFILES)
174 ASSEMBLY = $(LIBRARY)
175 ASSEMBLY_EXT = .dll
176 the_assembly = $(the_lib)
177 include $(topdir)/build/tests.make
179 ifdef HAVE_CS_TESTS
180 DISTFILES += $(test_sourcefile)
181 endif
183 # make dist will collect files in .sources files from all profiles
184 dist-local: dist-default
185 subs=' ' ; \
186 for f in `$(topdir)/tools/removecomments.sh $(wildcard *$(LIBRARY).sources)` $(TEST_FILES) ; do \
187 case $$f in \
188 ../*) : ;; \
189 *) dest=`dirname "$$f"` ; \
190 case $$subs in *" $$dest "*) : ;; *) subs=" $$dest$$subs" ; $(MKINSTALLDIRS) $(distdir)/$$dest ;; esac ; \
191 cp -p "$$f" $(distdir)/$$dest || exit 1 ;; \
192 esac ; done ; \
193 for d in . $$subs ; do \
194 case $$d in .) : ;; *) test ! -f $$d/ChangeLog || cp -p $$d/ChangeLog $(distdir)/$$d ;; esac ; done
196 ifdef LIBRARY_NEEDS_POSTPROCESSING
197 dist-local: dist-fixup
198 FIXUP_PROFILES = default net_2_0
199 dist-fixup:
200 $(MKINSTALLDIRS) $(distdir)/fixup $(FIXUP_PROFILES:%=$(distdir)/fixup/%)
201 endif
203 ifndef LIBRARY_COMPILE
204 LIBRARY_COMPILE = $(CSCOMPILE)
205 endif
207 ifndef LIBRARY_SNK
208 LIBRARY_SNK = $(topdir)/class/mono.snk
209 endif
211 ifdef BUILT_SOURCES
212 library_CLEAN_FILES += $(BUILT_SOURCES)
213 ifeq (cat, $(PLATFORM_CHANGE_SEPARATOR_CMD))
214 BUILT_SOURCES_cmdline = $(BUILT_SOURCES)
215 else
216 BUILT_SOURCES_cmdline = `echo $(BUILT_SOURCES) | $(PLATFORM_CHANGE_SEPARATOR_CMD)`
217 endif
218 endif
220 # The library
222 $(the_lib): $(the_libdir)/.stamp
224 $(build_lib): $(response) $(sn) $(BUILT_SOURCES) $(build_libdir:=/.stamp)
225 $(LIBRARY_COMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) -target:library -out:$@ $(BUILT_SOURCES_cmdline) @$(response)
226 $(SN) $(SNFLAGS) -R $@ $(LIBRARY_SNK)
228 ifdef LIBRARY_USE_INTERMEDIATE_FILE
229 $(the_lib): $(build_lib)
230 $(Q) cp $(build_lib) $@
231 $(SN) $(SNFLAGS) -v $@
232 $(Q) test ! -f $(build_lib).mdb || mv $(build_lib).mdb $@.mdb
233 $(Q) test ! -f $(build_lib:.dll=.pdb) || mv $(build_lib:.dll=.pdb) $(the_lib:.dll=.pdb)
234 endif
236 ifdef PLATFORM_AOT_SUFFIX
237 Q_AOT=$(if $(V),,@echo "AOT [$(PROFILE)] $(notdir $(@))";)
238 $(the_lib)$(PLATFORM_AOT_SUFFIX): $(the_lib)
239 $(Q_AOT) MONO_PATH='$(the_libdir)' > $(PROFILE)_aot.log 2>&1 $(RUNTIME) --aot=bind-to-runtime-version --debug $(the_lib)
240 endif
242 ifdef ENABLE_AOT
243 ifneq (,$(filter $(AOT_IN_PROFILES), $(PROFILE)))
245 all-local: $(the_lib)$(PLATFORM_AOT_SUFFIX)
247 endif
248 endif
250 makefrag = $(depsdir)/$(PROFILE)_$(LIBRARY).makefrag
251 library_CLEAN_FILES += $(makefrag)
252 $(makefrag): $(sourcefile)
253 @echo Creating $@ ...
254 @sed 's,^,$(build_lib): ,' $< >$@
255 @if test ! -f $(sourcefile).makefrag; then :; else \
256 cat $(sourcefile).makefrag >> $@ ; \
257 echo '$@: $(sourcefile).makefrag' >> $@; \
258 echo '$(sourcefile).makefrag:' >> $@; fi
260 ifneq ($(response),$(sourcefile))
261 $(response): $(sourcefile) $(PLATFORM_excludes)
262 @echo Creating $@ ...
263 @sort $(sourcefile) $(PLATFORM_excludes) | uniq -u | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
264 endif
266 -include $(makefrag)
268 # for now, don't give any /lib flags or set MONO_PATH, since we
269 # give a full path to the assembly.
271 ## Include corcompare stuff
272 include $(topdir)/build/corcompare.make
274 all-local: $(makefrag) $(test_makefrag) $(btest_makefrag)
275 ifneq ($(response),$(sourcefile))
276 $(response): $(topdir)/build/library.make $(depsdir)/.stamp
277 endif
278 $(makefrag) $(test_response) $(test_makefrag) $(btest_response) $(btest_makefrag): $(topdir)/build/library.make $(depsdir)/.stamp
280 ## Documentation stuff
282 Q_MDOC_UP=$(if $(V),,@echo "MDOC-UP [$(PROFILE)] $(notdir $(@))";)
283 MDOC_UP =$(Q_MDOC_UP) \
284 MONO_PATH="$(topdir)/class/lib/net_4_0$(PLATFORM_PATH_SEPARATOR)$(topdir)/class/lib/net_2_0$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" \
285 $(RUNTIME) $(topdir)/tools/mdoc/mdoc.exe update --delete \
286 -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" > $@