Merge pull request #2034 from alexrp/ctx-cleanup
[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_XAMMAC
52 build_profiles += xammac xammac_net_4_5
53 endif
54
55 test_profiles = $(build_profiles)
56
57 if BUILD_MCS
58
59 MAKE_FLAGS=$(if $(V),,--no-print-directory -s)
60
61 # The write check is to foil 'make distcheck'
62 all-local: $(SUPPORT_FILES) $(TEST_SUPPORT_FILES)
63         if test -w $(mcs_topdir); then :; else chmod -R +w $(mcs_topdir); fi
64         cd $(mcs_topdir) && $(MAKE) $(MAKE_FLAGS) NO_DIR_CHECK=1 PROFILES='$(build_profiles)' CC='$(CC)' all-profiles
65
66 # override automake
67 install: install-exec install-data
68
69 # override automake
70 install-exec: $(SUPPORT_FILES) $(TEST_SUPPORT_FILES)
71         cd $(mcs_topdir) && $(MAKE) NO_DIR_CHECK=1 PROFILES='$(build_profiles)' RUNTIME_HAS_CONSISTENT_GACDIR=yes prefix=$(prefix) install-profiles
72
73 # override automake
74 install-data:
75         @:
76
77 # override automake
78 uninstall:
79         cd $(mcs_topdir) && $(MAKE) NO_DIR_CHECK=1 PROFILES='$(build_profiles)' RUNTIME_HAS_CONSISTENT_GACDIR=yes prefix=$(prefix) uninstall-profiles
80
81 clean-local:
82         cd $(mcs_topdir) && $(MAKE) NO_DIR_CHECK=1 PROFILES='$(build_profiles)' clean-profiles
83         -rm -fr $(etctmp) $(tmpinst)
84
85 endif BUILD_MCS
86
87 TEST_SUPPORT_FILES = $(tmpinst)/bin/mono $(tmpinst)/bin/ilasm $(tmpinst)/bin/mcs $(tmpinst)/bin/dmcs $(tmpinst)/bin/al2 $(tmpinst)/bin/al
88
89 mcs-do-test-profiles:
90         cd $(mcs_topdir) && $(MAKE) NO_DIR_CHECK=1 PROFILES='$(test_profiles)' test-profiles
91
92 mcs-do-run-test-profiles: test-support-files
93         cd $(mcs_topdir) && $(MAKE) NO_DIR_CHECK=1 PROFILES='$(test_profiles)' run-test-profiles
94
95 if HOST_WIN32
96 if CROSS_COMPILING
97 cur_dir_cmd = pwd
98 PLATFORM_PATH_SEPARATOR = :
99 else
100 cur_dir_cmd = cygpath -w -a .
101 PLATFORM_PATH_SEPARATOR = ;
102 endif
103 else
104 cur_dir_cmd = pwd
105 PLATFORM_PATH_SEPARATOR = :
106 endif
107
108 # Compile all assemblies with the verifier turned on. Code must be valid but not verifiable.
109 # TODO it would be nice to split assemblies without unsafe code to use the verifier with verifiable mode.
110 # Skip binary_reference_assemblies because they contain metadata only
111 mcs-compileall: mono-wrapper etc/mono/config
112         save_MONO_PATH=$$MONO_PATH; mcs_topdir=`cd $(mcs_topdir) && $(cur_dir_cmd)`; ok=:; \
113         for profile in $(test_profiles); do \
114           if [ "binary_reference_assemblies" = "$$profile" ]; then \
115           continue; \
116       fi; \
117           if [ "xbuild_12" = "$$profile" ]; then \
118                   MONO_PATH="$$mcs_topdir/class/lib/$$profile$(PLATFORM_PATH_SEPARATOR)$$mcs_topdir/class/lib/net_4_x$(PLATFORM_PATH_SEPARATOR)$$save_MONO_PATH"; \
119           elif [ "xbuild_14" = "$$profile" ]; then \
120                   MONO_PATH="$$mcs_topdir/class/lib/$$profile$(PLATFORM_PATH_SEPARATOR)$$mcs_topdir/class/lib/net_4_x$(PLATFORM_PATH_SEPARATOR)$$save_MONO_PATH"; \
121           else \
122                   MONO_PATH="$$mcs_topdir/class/lib/$$profile$(PLATFORM_PATH_SEPARATOR)$$save_MONO_PATH"; \
123           fi; \
124           export MONO_PATH; \
125           for i in $(mcs_topdir)/class/lib/$$profile/*.{dll,exe}; do \
126                 if [ ! -f $$i ] ; then \
127                         continue ; \
128                 fi ;  \
129             if ./mono-wrapper --compile-all --verify-all --security=verifiable $$i; then \
130               echo $$i verified OK; \
131             else \
132               echo $$i verification failed; ok=false; \
133             fi; done; done; \
134         $$ok
135
136 if NACL_CODEGEN
137 check-local:
138 else
139 check-local: mcs-compileall mcs-do-test-profiles
140         $(MAKE) mcs-do-run-test-profiles
141 endif
142
143 # Compile all mcs tests
144 test: mcs-do-test-profiles
145
146 CLEANFILES = etc/mono/config
147
148 # depend on $(symlinks) to ensure 'etc/mono' directory exists
149 etc/mono/config: ../data/config Makefile $(symlinks)
150         d=`cd ../support && pwd`; \
151         sed 's,target="$$mono_libdir/libMonoPosixHelper$(libsuffix)",target="'$$d'/libMonoPosixHelper.la",' ../data/config > $@t
152         if test -z "$(libgdiplus_loc)"; then :; else \
153           sed 's,target="$(libgdiplus_install_loc)",target="$(libgdiplus_loc)",' $@t > $@tt; \
154           mv -f $@tt $@t; fi
155         mv -f $@t $@
156
157 $(tmpinst)/bin/mono: mono-wrapper etc/mono/config
158         $(mkinstalldirs) $(tmpinst)/bin
159         cp mono-wrapper $@
160
161 $(tmpinst)/bin/mcs: $(tmpinst)/bin/mono Makefile
162         echo '#! /bin/sh' > $@ ; \
163         r=`pwd`; m=`cd $(mcs_topdir) && pwd`; \
164         echo 'exec "'"$$r/$(tmpinst)/bin/mono"'" "'"$$m/class/lib/build/mcs.exe"'" "$$@"' >> $@ ; \
165         chmod +x $@
166
167 $(tmpinst)/bin/dmcs: $(tmpinst)/bin/mono Makefile
168         echo '#! /bin/sh' > $@ ; \
169         r=`pwd`; m=`cd $(mcs_topdir) && pwd`; \
170         echo 'exec "'"$$r/$(tmpinst)/bin/mono"'" "'"$$m/class/lib/build/mcs.exe -sdk:4"'" "$$@"' >> $@ ; \
171         chmod +x $@
172
173 $(tmpinst)/bin/ilasm: $(tmpinst)/bin/mono Makefile
174         echo '#! /bin/sh' > $@ ; \
175         r=`pwd`; m=`cd $(mcs_topdir) && pwd`; \
176         echo 'exec "'"$$r/$(tmpinst)/bin/mono"'" "'"$$m/ilasm/ilasm.exe"'" "$$@"' >> $@ ; \
177         chmod +x $@
178
179 $(tmpinst)/bin/al2: $(tmpinst)/bin/mono Makefile
180         echo '#! /bin/sh' > $@ ; \
181         r=`pwd`; m=`cd $(mcs_topdir) && pwd`; \
182         echo 'exec "'"$$r/$(tmpinst)/bin/mono"'" "'"$$m/class/lib/net_2_0/al.exe"'" "$$@"' >> $@ ; \
183         chmod +x $@
184
185 $(tmpinst)/bin/al: $(tmpinst)/bin/mono Makefile
186         echo '#! /bin/sh' > $@ ; \
187         r=`pwd`; m=`cd $(mcs_topdir) && pwd`; \
188         echo 'exec "'"$$r/$(tmpinst)/bin/mono"'" "'"$$m/class/lib/$(al_profile)/al.exe"'" "$$@"' >> $@ ; \
189         chmod +x $@
190
191 test-support-files: $(TEST_SUPPORT_FILES)
192         @:
193
194 # the 'cygnus' option also disables the default 'distdir:' target, which we _do_ want
195 MYDISTFILES = $(DIST_COMMON)
196 distdir: $(MYDISTFILES)
197         rm -fr $(distdir)
198         mkdir $(distdir)
199         test -z '$(MYDISTFILES)' || for file in ''$(MYDISTFILES); do \
200           cp -p $$file $(distdir) ; done
201         find $(distdir) -type f -exec chmod a+r {} ';'