(%-recursive): Honor 'make -k'.
[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.30.99
17
18 USE_MCS_FLAGS = $(LOCAL_MCS_FLAGS) $(PLATFORM_MCS_FLAGS) $(PROFILE_MCS_FLAGS) $(MCS_FLAGS)
19 USE_CFLAGS = $(LOCAL_CFLAGS) $(CFLAGS)
20 CSCOMPILE = $(MCS) $(USE_MCS_FLAGS)
21 CCOMPILE = $(CC) $(USE_CFLAGS)
22 BOOT_COMPILE = $(BOOTSTRAP_MCS) $(USE_MCS_FLAGS)
23 INSTALL_DATA = $(INSTALL) -m 644
24 INSTALL_BIN = $(INSTALL) -m 755
25 INSTALL_LIB = $(INSTALL_BIN)
26 MKINSTALLDIRS = $(SHELL) $(topdir)/mkinstalldirs
27 INTERNAL_MCS = $(RUNTIME) $(topdir)/mcs/mcs.exe
28 corlib = mscorlib.dll
29
30 depsdir = $(topdir)/build/deps
31 distdir = $(dots)/$(package)/$(thisdir)
32
33 # Make sure these propagate if set manually
34
35 export PLATFORM
36 export PROFILE
37 export MCS
38 export MCS_FLAGS
39 export CC
40 export CFLAGS
41 export INSTALL
42 export MKINSTALLDIRS
43 export TEST_HARNESS
44 export BOOTSTRAP_MCS
45 export DESTDIR
46 export RESGEN
47
48 # Get this so the platform.make platform-check rule doesn't become the
49 # default target
50
51 default: all
52
53 # Get initial configuration. pre-config is so that the builder can
54 # override PLATFORM or PROFILE
55
56 include $(topdir)/build/config-default.make
57 -include $(topdir)/build/pre-config.make
58
59 # Default PLATFORM and PROFILE if they're not already defined.
60
61 ifndef PLATFORM
62 ifeq ($(OS),Windows_NT)
63 PLATFORM = win32
64 else
65 PLATFORM = linux
66 endif
67 endif
68
69 # Platform config
70
71 include $(topdir)/build/platforms/$(PLATFORM).make
72
73 ifdef PLATFORM_CORLIB
74 corlib = $(PLATFORM_CORLIB)
75 endif
76 # Useful
77
78 ifeq ($(PLATFORM_RUNTIME),$(RUNTIME))
79 PLATFORM_MONO_NATIVE = yes
80 endif
81
82 # Rest of the configuration
83
84 ifndef PROFILE
85 PROFILE = default
86 endif
87
88 include $(topdir)/build/profiles/$(PROFILE).make
89 -include $(topdir)/build/config.make
90
91 # Simple rules
92
93 %-recursive:
94         @set . $$MAKEFLAGS; \
95         case $$2 in *=*) dk="exit 1" ;; *k*) dk=: ;; *) dk="exit 1" ;; esac; \
96         list='$(SUBDIRS)'; for d in $$list ; do \
97             (cd $$d && $(MAKE) $*) || $$dk ; \
98         done
99
100 # note: dist-local dep, extra subdirs, $* has become $@
101
102 dist-recursive: dist-local
103         @list='$(SUBDIRS) $(DIST_ONLY_SUBDIRS)'; for d in $$list ; do \
104             (cd $$d && $(MAKE) $@) || exit 1 ; \
105         done
106
107 # We do this manually to not have a make[1]: blah message (That is,
108 # instead of using a '%: %-recursive %-local' construct.)
109 #
110 # Let the makefile override these for special situations (running checks
111 # in the toplevel makefile, or a directory that needs to be built before
112 # its subdirectories).
113
114 ifndef OVERRIDE_BARE_TARGETS
115
116 all: all-recursive all-local
117
118 install: install-recursive install-local
119
120 test: test-recursive test-local
121
122 run-test: run-test-recursive test-local run-test-local
123
124 clean: clean-recursive clean-local
125
126 uninstall: uninstall-recursive uninstall-local
127
128 endif
129
130 # Can only do this from the top dir
131 # ## dist: dist-recursive dist-local
132
133 # We invert the test here to not end in an error
134 # if ChangeLog doesn't exist.
135 #
136 # Note that we error out if we try to dist a nonexistant
137 # file. Seems reasonable to me.
138
139 dist-default:
140         -mkdir $(distdir)
141         test '!' -f ChangeLog || cp ChangeLog $(distdir)
142         for f in Makefile $(DISTFILES) ; do \
143             dest=`dirname $(distdir)/$$f` ; \
144             $(MKINSTALLDIRS) $$dest && cp $$f $$dest || exit 1 ; \
145         done
146
147 # Useful
148
149 withmcs:
150         $(MAKE) MCS='$(INTERNAL_MCS)' BOOTSTRAP_MCS='$(INTERNAL_MCS)' all