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