b38031c0d3b82653e3f4f814b0d3c9f5545fd234
[mono.git] / mcs / build / rules.make
1 # -*- makefile -*-
2 #
3 # This is the makefile fragment with default rules
4 # for building things in MCS
5 #
6 # To customize the build, you should edit config.make.
7 # If you need to edit this file, that's a bug; email
8 # peter@newton.cx about it.
9
10 # Some more variables. The leading period in the sed expression prevents
11 # thisdir = . from being changed into '..' for the toplevel directory.
12
13 dots := $(shell echo $(thisdir) |sed -e 's,[^./][^/]*,..,g')
14 topdir := $(dots)
15
16 VERSION = 0.93
17
18 USE_MCS_FLAGS = /codepage:$(CODEPAGE) $(LOCAL_MCS_FLAGS) $(PLATFORM_MCS_FLAGS) $(PROFILE_MCS_FLAGS) $(MCS_FLAGS)
19 USE_MBAS_FLAGS = /codepage:$(CODEPAGE) $(LOCAL_MBAS_FLAGS) $(PLATFORM_MBAS_FLAGS) $(PROFILE_MBAS_FLAGS) $(MBAS_FLAGS)
20 USE_CFLAGS = $(LOCAL_CFLAGS) $(CFLAGS)
21 CSCOMPILE = $(MCS) $(USE_MCS_FLAGS)
22 BASCOMPILE = $(MBAS) $(USE_MBAS_FLAGS)
23 CCOMPILE = $(CC) $(USE_CFLAGS)
24 BOOT_COMPILE = $(BOOTSTRAP_MCS) $(USE_MCS_FLAGS)
25 INSTALL = $(SHELL) $(topdir)/../mono/install-sh
26 INSTALL_DATA = $(INSTALL) -c -m 644
27 INSTALL_BIN = $(INSTALL) -c -m 755
28 INSTALL_LIB = $(INSTALL_BIN)
29 MKINSTALLDIRS = $(SHELL) $(topdir)/mkinstalldirs
30 INTERNAL_MCS = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(PROFILE)/mcs.exe
31 INTERNAL_MBAS = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/mbas/mbas.exe
32 INTERNAL_GMCS = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/mcs/gmcs.exe
33 INTERNAL_ILASM = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(PROFILE)/ilasm.exe
34 INTERNAL_RESGEN = $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/$(BOOTSTRAP_PROFILE)/resgen.exe
35 corlib = mscorlib.dll
36
37 depsdir = $(topdir)/build/deps
38
39 # Make sure these propagate if set manually
40
41 export PLATFORM
42 export PROFILE
43 export MCS
44 export MCS_FLAGS
45 export CC
46 export CFLAGS
47 export INSTALL
48 export MKINSTALLDIRS
49 export TEST_HARNESS
50 export BOOTSTRAP_MCS
51 export DESTDIR
52 export RESGEN
53
54 # Get this so the platform.make platform-check rule doesn't become the
55 # default target
56
57 .DEFAULT: all
58 default: all
59
60 # Get initial configuration. pre-config is so that the builder can
61 # override PLATFORM or PROFILE
62
63 include $(topdir)/build/config-default.make
64 -include $(topdir)/build/pre-config.make
65
66 # Default PLATFORM and PROFILE if they're not already defined.
67
68 ifndef PLATFORM
69 ifeq ($(OS),Windows_NT)
70 PLATFORM = win32
71 else
72 PLATFORM = linux
73 endif
74 endif
75
76 # Platform config
77
78 include $(topdir)/build/platforms/$(PLATFORM).make
79
80 ifdef PLATFORM_CORLIB
81 corlib = $(PLATFORM_CORLIB)
82 endif
83 # Useful
84
85 ifeq ($(PLATFORM_RUNTIME),$(RUNTIME))
86 PLATFORM_MONO_NATIVE = yes
87 endif
88
89 # Rest of the configuration
90
91 ifndef PROFILE
92 PROFILE = default
93 endif
94
95 include $(topdir)/build/profiles/$(PROFILE).make
96 -include $(topdir)/build/config.make
97
98 ifdef OVERRIDE_TARGET_ALL
99 all: all.override
100 else
101 all: do-all
102 endif
103
104 STD_TARGETS = test run-test run-test-ondotnet clean install uninstall
105
106 $(STD_TARGETS): %: do-%
107
108 do-run-test:
109         ok=:; $(MAKE) run-test-recursive || ok=false; $(MAKE) run-test-local || ok=false; $$ok
110
111 do-%: %-recursive
112         $(MAKE) $*-local
113
114 # The way this is set up, any profile-specific subdirs list should
115 # be listed _before_ including rules.make.  However, the default
116 # SUBDIRS list can come after, so don't use the eager := syntax when
117 # using the defaults.
118 PROFILE_SUBDIRS := $($(PROFILE)_SUBDIRS)
119 ifndef PROFILE_SUBDIRS
120 PROFILE_SUBDIRS = $(SUBDIRS)
121 endif
122
123 ifndef FRAMEWORK_VERSION_MAJOR
124 FRAMEWORK_VERSION_MAJOR = $(basename $(FRAMEWORK_VERSION))
125 endif
126
127 %-recursive:
128         @set . $$MAKEFLAGS; final_exit=:; \
129         case $$2 in --unix) shift ;; esac; \
130         case $$2 in *=*) dk="exit 1" ;; *k*) dk=: ;; *) dk="exit 1" ;; esac; \
131         list='$(PROFILE_SUBDIRS)'; for d in $$list ; do \
132             (cd $$d && $(MAKE) $*) || { final_exit="exit 1"; $$dk; } ; \
133         done; \
134         $$final_exit
135
136 ifndef DIST_SUBDIRS
137 DIST_SUBDIRS = $(SUBDIRS) $(DIST_ONLY_SUBDIRS)
138 endif
139 dist-recursive: dist-local
140         @case '$(distdir)' in [\\/$$]* | ?:[\\/]* ) reldir='$(distdir)' ;; *) reldir='../$(distdir)' ;; esac ; \
141         list='$(DIST_SUBDIRS)'; for d in $$list ; do \
142             (cd $$d && $(MAKE) distdir=$$reldir/$$d $@) || exit 1 ; \
143         done
144
145 # The following target can be used like
146 #
147 #   dist-local: dist-default
148 #       ... additional commands ...
149 #
150 # Notes:
151 #  1. we invert the test here to not end in an error if ChangeLog doesn't exist.
152 #  2. we error out if we try to dist a nonexistant file.
153 #  3. we pick up Makefile, makefile, or GNUmakefile.
154 dist-default:
155         -mkdir -p $(distdir)
156         test '!' -f ChangeLog || cp ChangeLog $(distdir)
157         if test -f Makefile; then m=M; fi; \
158         if test -f makefile; then m=m; fi; \
159         if test -f GNUmakefile; then m=GNUm; fi; \
160         for f in $${m}akefile $(DISTFILES) ; do \
161             dest=`dirname $(distdir)/$$f` ; \
162             $(MKINSTALLDIRS) $$dest && cp -p $$f $$dest || exit 1 ; \
163         done
164
165 $(depsdir)/.stamp:
166         $(MKINSTALLDIRS) $(@D)
167         touch $@
168
169 # Useful
170
171 withmcs:
172         $(MAKE) MCS='$(INTERNAL_MCS)' BOOTSTRAP_MCS='$(INTERNAL_MCS)' all