Merge pull request #3773 from mono/bockbuild-integration
[mono.git] / runtime / Makefile.am
1 tmpinst = _tmpinst
2
3 noinst_SCRIPTS = mono-wrapper monodis-wrapper
4
5 etctmp = etc
6 symlinks = etc/mono/1.0/machine.config etc/mono/2.0/machine.config etc/mono/2.0/web.config etc/mono/browscap.ini etc/mono/2.0/Browsers/Compat.browser
7
8 if INSTALL_4_x
9 symlinks += etc/mono/4.0/machine.config etc/mono/4.0/web.config etc/mono/4.5/web.config etc/mono/4.5/machine.config etc/mono/4.0/Browsers/Compat.browser etc/mono/4.5/Browsers/Compat.browser
10 endif
11
12 etc/mono/2.0/machine.config: $(top_srcdir)/data/net_2_0/machine.config
13 etc/mono/2.0/web.config: $(top_srcdir)/data/net_2_0/web.config
14 etc/mono/browscap.ini: $(top_srcdir)/data/browscap.ini
15 etc/mono/2.0/Browsers/Compat.browser: $(top_srcdir)/data/Browsers/Compat.browser
16 etc/mono/4.0/Browsers/Compat.browser: $(top_srcdir)/data/Browsers/Compat.browser
17 etc/mono/4.5/Browsers/Compat.browser: $(top_srcdir)/data/Browsers/Compat.browser
18 etc/mono/4.0/machine.config: $(top_srcdir)/data/net_4_0/machine.config
19 etc/mono/4.0/web.config: $(top_srcdir)/data/net_4_0/web.config
20 etc/mono/4.5/machine.config: $(top_srcdir)/data/net_4_5/machine.config
21 etc/mono/4.5/web.config: $(top_srcdir)/data/net_4_5/web.config
22
23 $(symlinks):
24         cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
25
26 SUPPORT_FILES = $(symlinks) mono-wrapper etc/mono/config
27
28 build_profiles = 
29
30 if INSTALL_4_x
31 build_profiles += binary_reference_assemblies net_4_x xbuild_12 xbuild_14
32 al_profile = net_4_x
33 endif
34
35 if INSTALL_MONODROID
36 build_profiles += monodroid
37 endif
38
39 if INSTALL_MONOTOUCH
40 build_profiles += monotouch monotouch_runtime
41 endif
42
43 if INSTALL_MONOTOUCH_WATCH
44 build_profiles += monotouch_watch monotouch_watch_runtime
45 endif
46
47 if INSTALL_MONOTOUCH_TV
48 build_profiles += monotouch_tv monotouch_tv_runtime
49 endif
50
51 if INSTALL_MOBILE_STATIC
52 build_profiles += mobile_static
53 endif
54
55 if INSTALL_XAMMAC
56 build_profiles += xammac xammac_net_4_5
57 endif
58
59 test_profiles = $(build_profiles)
60
61 if BUILD_MCS
62
63 MAKE_FLAGS=$(if $(V),,--no-print-directory -s)
64
65 # The write check is to foil 'make distcheck'
66 all-local: $(SUPPORT_FILES) $(TEST_SUPPORT_FILES)
67         if test -w $(mcs_topdir); then :; else chmod -R +w $(mcs_topdir); fi
68         cd $(mcs_topdir) && $(MAKE) $(MAKE_FLAGS) NO_DIR_CHECK=1 PROFILES='$(build_profiles)' CC='$(CC)' all-profiles
69
70 # override automake
71 install: install-exec install-data
72
73 # override automake
74 install-exec: $(SUPPORT_FILES) $(TEST_SUPPORT_FILES)
75         cd $(mcs_topdir) && $(MAKE) NO_DIR_CHECK=1 PROFILES='$(build_profiles)' RUNTIME_HAS_CONSISTENT_GACDIR=yes prefix=$(prefix) install-profiles
76
77 # override automake
78 install-data:
79         @:
80
81 # override automake
82 uninstall:
83         cd $(mcs_topdir) && $(MAKE) NO_DIR_CHECK=1 PROFILES='$(build_profiles)' RUNTIME_HAS_CONSISTENT_GACDIR=yes prefix=$(prefix) uninstall-profiles
84
85 clean-local:
86         cd $(mcs_topdir) && $(MAKE) NO_DIR_CHECK=1 PROFILES='$(build_profiles)' clean-profiles
87         -rm -fr $(etctmp) $(tmpinst)
88
89 endif BUILD_MCS
90
91 TEST_SUPPORT_FILES = $(tmpinst)/bin/mono $(tmpinst)/bin/ilasm $(tmpinst)/bin/mcs $(tmpinst)/bin/al
92
93 mcs-do-test-profiles:
94         cd $(mcs_topdir) && $(MAKE) NO_DIR_CHECK=1 PROFILES='$(test_profiles)' test-profiles
95
96 mcs-do-run-test-profiles: test-support-files
97         cd $(mcs_topdir) && $(MAKE) NO_DIR_CHECK=1 PROFILES='$(test_profiles)' run-test-profiles
98
99 if HOST_WIN32
100 if CROSS_COMPILING
101 cur_dir_cmd = pwd
102 PLATFORM_PATH_SEPARATOR = :
103 else
104 cur_dir_cmd = cygpath -w -a .
105 PLATFORM_PATH_SEPARATOR = ;
106 endif
107 else
108 cur_dir_cmd = pwd
109 PLATFORM_PATH_SEPARATOR = :
110 endif
111
112 if INSTALL_MOBILE_STATIC
113 #  ILASM.exe has features which a mobile_static runtime will not support.
114 #  It is invoked with an external mono when used in the runtime.
115 #  We skip it here because otherwise it will fail to verify.
116 MOBILE_STATIC_FILTER=grep -v ilasm
117 else
118 MOBILE_STATIC_FILTER=echo
119 endif
120
121 # Compile all assemblies with the verifier turned on. Code must be valid but not verifiable.
122 # TODO it would be nice to split assemblies without unsafe code to use the verifier with verifiable mode.
123 # Skip binary_reference_assemblies because they contain metadata only
124 mcs-compileall: mono-wrapper etc/mono/config
125         export verifiable_files=`ls "$(mcs_topdir)/class/lib/$$profile/" | grep -E '\.(dll|exe)$$' | $(MOBILE_STATIC_FILTER)` ; \
126         save_MONO_PATH=$$MONO_PATH; mcs_topdir=`cd $(mcs_topdir) && $(cur_dir_cmd)`; ok=:; \
127         for profile in $(test_profiles); do \
128           if [ "binary_reference_assemblies" = "$$profile" ]; then \
129           continue; \
130       fi; \
131           if [ "xbuild_12" = "$$profile" ]; then \
132                   MONO_PATH="$$mcs_topdir/class/lib/$$profile$(PLATFORM_PATH_SEPARATOR)$$mcs_topdir/class/lib/net_4_x$(PLATFORM_PATH_SEPARATOR)$$save_MONO_PATH"; \
133           elif [ "xbuild_14" = "$$profile" ]; then \
134                   MONO_PATH="$$mcs_topdir/class/lib/$$profile$(PLATFORM_PATH_SEPARATOR)$$mcs_topdir/class/lib/net_4_x$(PLATFORM_PATH_SEPARATOR)$$save_MONO_PATH"; \
135           else \
136                   MONO_PATH="$$mcs_topdir/class/lib/$$profile$(PLATFORM_PATH_SEPARATOR)$$save_MONO_PATH"; \
137           fi; \
138           export MONO_PATH; \
139           for stub in $$verifiable_files; do \
140           i=$(mcs_topdir)/class/lib/$$profile/$$stub ; \
141           echo $$i ; \
142                 if [ ! -f $$i ] ; then \
143                         continue ; \
144                 fi ;  \
145             if ./mono-wrapper --compile-all --verify-all --security=verifiable $$i; then \
146               echo $$i verified OK; \
147             else \
148               echo $$i verification failed; ok=false; \
149             fi; done; done; \
150         $$ok
151
152 if NACL_CODEGEN
153 check-local:
154 else
155 check-local: mcs-compileall mcs-do-test-profiles
156         $(MAKE) mcs-do-run-test-profiles
157 endif
158
159 # Compile all mcs tests
160 test: mcs-do-test-profiles
161
162 CLEANFILES = etc/mono/config
163
164 # depend on $(symlinks) to ensure 'etc/mono' directory exists
165 etc/mono/config: ../data/config Makefile $(symlinks)
166         d=`cd ../support && pwd`; \
167         sed 's,target="$$mono_libdir/libMonoPosixHelper$(libsuffix)",target="'$$d'/libMonoPosixHelper.la",' ../data/config > $@t
168         d=`cd ../mono/btls/build-shared && pwd`; \
169         sed 's,target="$$mono_libdir/libmono-btls-shared$(libsuffix)",target="'$$d'/libmono-btls-shared$(libsuffix)",' $@t > $@tt
170         if test -z "$(libgdiplus_loc)"; then :; else \
171           sed 's,target="$(libgdiplus_install_loc)",target="$(libgdiplus_loc)",' $@tt > $@ttt; \
172           mv -f $@ttt $@tt; fi
173         mv -f $@tt $@
174         rm -f $@t
175
176 $(tmpinst)/bin/mono: mono-wrapper etc/mono/config
177         $(mkinstalldirs) $(tmpinst)/bin
178         cp mono-wrapper $@
179
180 $(tmpinst)/bin/mcs: $(tmpinst)/bin/mono Makefile
181         echo '#! /bin/sh' > $@ ; \
182         r=`pwd`; m=`cd $(mcs_topdir) && pwd`; \
183         echo 'exec "'"$$r/$(tmpinst)/bin/mono"'" "'"$$m/class/lib/build/mcs.exe"'" "$$@"' >> $@ ; \
184         chmod +x $@
185
186 $(tmpinst)/bin/ilasm: $(tmpinst)/bin/mono Makefile
187         echo '#! /bin/sh' > $@ ; \
188         r=`pwd`; m=`cd $(mcs_topdir) && pwd`; \
189         echo 'exec "'"$$r/$(tmpinst)/bin/mono"'" "'"$$m/ilasm/ilasm.exe"'" "$$@"' >> $@ ; \
190         chmod +x $@
191
192 $(tmpinst)/bin/al: $(tmpinst)/bin/mono Makefile
193         echo '#! /bin/sh' > $@ ; \
194         r=`pwd`; m=`cd $(mcs_topdir) && pwd`; \
195         echo 'exec "'"$$r/$(tmpinst)/bin/mono"'" "'"$$m/class/lib/$(al_profile)/al.exe"'" "$$@"' >> $@ ; \
196         chmod +x $@
197
198 test-support-files: $(TEST_SUPPORT_FILES)
199         @:
200
201 # the 'cygnus' option also disables the default 'distdir:' target, which we _do_ want
202 MYDISTFILES = $(DIST_COMMON)
203 distdir: $(MYDISTFILES)
204         rm -fr $(distdir)
205         mkdir $(distdir)
206         test -z '$(MYDISTFILES)' || for file in ''$(MYDISTFILES); do \
207           cp -p $$file $(distdir) ; done
208         find $(distdir) -type f -exec chmod a+r {} ';'