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