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