2003-12-20 Atsushi Enomoto <atsushi@ximian.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.29.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         @list='$(SUBDIRS)'; for d in $$list ; do \
95             (cd $$d && $(MAKE) $*) || exit 1 ; \
96         done
97
98 # note: dist-local dep, extra subdirs, $* has become $@
99
100 dist-recursive: dist-local
101         @list='$(SUBDIRS) $(DIST_ONLY_SUBDIRS)'; for d in $$list ; do \
102             (cd $$d && $(MAKE) $@) || exit 1 ; \
103         done
104
105 # We do this manually to not have a make[1]: blah message (That is,
106 # instead of using a '%: %-recursive %-local' construct.)
107 #
108 # Let the makefile override these for special situations (running checks
109 # in the toplevel makefile, or a directory that needs to be built before
110 # its subdirectories).
111
112 ifndef OVERRIDE_BARE_TARGETS
113
114 all: all-recursive all-local
115
116 install: install-recursive install-local
117
118 test: test-recursive test-local
119
120 run-test: run-test-recursive test-local run-test-local
121
122 clean: clean-recursive clean-local
123
124 uninstall: uninstall-recursive uninstall-local
125
126 endif
127
128 # Can only do this from the top dir
129 # ## dist: dist-recursive dist-local
130
131 # We invert the test here to not end in an error
132 # if ChangeLog doesn't exist.
133 #
134 # Note that we error out if we try to dist a nonexistant
135 # file. Seems reasonable to me.
136
137 dist-default:
138         -mkdir $(distdir)
139         test '!' -f ChangeLog || cp ChangeLog $(distdir)
140         for f in Makefile $(DISTFILES) ; do \
141             dest=`dirname $(distdir)/$$f` ; \
142             $(MKINSTALLDIRS) $$dest && cp $$f $$dest || exit 1 ; \
143         done
144
145 # Useful
146
147 withmcs:
148         $(MAKE) MCS='$(INTERNAL_MCS)' BOOTSTRAP_MCS='$(INTERNAL_MCS)' all