4ffc73294034d6191f38115e9dbb1c79db324f2a
[mono.git] / mcs / mcs / Makefile
1 thisdir := mcs
2 SUBDIRS := 
3 include ../build/rules.make
4
5 EXTRA_DISTFILES = \
6         *mcs.csproj             \
7         compiler.doc            \
8         *mcs.sln                \
9         *cs-parser.jay          \
10         NOTES                   \
11         TODO
12
13 GMCS_PROFILE := $(filter net_2_0_bootstrap net_2_0 net_2_1, $(PROFILE))
14
15 ifdef GMCS_PROFILE
16         BUILT_SOURCES = gcs-parser.cs
17         LOCAL_MCS_FLAGS += -d:GMCS_SOURCE
18         
19         ifeq (net_2_1, $(PROFILE))
20                 INTERNAL_SMCS = $(INTERNAL_GMCS)
21                 LOCAL_MCS_FLAGS += -nowarn:618 -noconfig -r:mscorlib -r:System.dll
22                 PROGRAM = $(topdir)/class/lib/$(PROFILE)/smcs.exe
23         else
24                 BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/net_2_0_bootstrap$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(RUNTIME_FLAGS) $(topdir)/class/lib/net_2_0_bootstrap/mcs.exe $(DEBUG_FLAGS)
25                 PROGRAM = $(topdir)/class/lib/$(PROFILE)/gmcs.exe
26         endif   
27 else
28         BUILT_SOURCES = cs-parser.cs
29         PROGRAM = $(topdir)/class/lib/$(PROFILE)/mcs.exe
30 endif
31
32 PROGRAM_COMPILE = $(BOOT_COMPILE)
33
34 CLEAN_FILES += y.output
35
36 %-parser.cs: %-parser.jay $(topdir)/jay/skeleton.cs
37         $(topdir)/jay/jay -ctv < $(topdir)/jay/skeleton.cs $< > jay-tmp.out && mv jay-tmp.out $@
38
39
40 ifeq (net_2_0_bootstrap, $(PROFILE))
41
42 all-local $(STD_TARGETS:=-local):
43         @:
44
45 all-local: $(PROGRAM) $(PROGRAM).config
46 clean-local: clean-program
47 clean-program:
48         rm -f $(PROGRAM) $(PROGRAM).config
49
50 progdir = $(dir $(PROGRAM))
51
52 $(progdir)/.stamp:
53         $(MKINSTALLDIRS) $(@D)
54         touch $@
55
56 $(PROGRAM): $(topdir)/class/lib/default/mcs.exe $(progdir)/.stamp
57         cp $< $@
58
59 $(PROGRAM).config: $(topdir)/gmcs/gmcs.exe.config $(progdir)/.stamp
60         cp $< $@
61
62 else
63
64 ifeq (net_2_0, $(PROFILE))
65
66 clean-local: clean-net_2_0_bootstrap
67 clean-net_2_0_bootstrap:
68         cd .. && $(MAKE) PROFILE=net_2_0_bootstrap clean
69
70 bootstrap_libs = mscorlib.dll System.dll System.Xml.dll Mono.CompilerServices.SymbolWriter.dll
71 bootstrap_libfiles = $(bootstrap_libs:%=$(topdir)/class/lib/net_2_0_bootstrap/%)
72
73 $(bootstrap_libfiles): bootstrap-libs
74         @:
75 .PHONY: bootstrap-libs
76 bootstrap-libs:
77         cd .. && $(MAKE) PROFILE=net_2_0_bootstrap all
78
79 $(PROGRAM): $(bootstrap_libfiles)
80 endif
81
82 KEEP_OUTPUT_FILE_COPY = yes
83
84 include ../build/executable.make
85 endif
86
87 # Testing targets
88
89 TIME = time
90
91 # This used to be called test, but that conflicts with the global
92 # recursive target.
93
94 btest: mcs2.exe mcs3.exe
95         ls -l mcs2.exe mcs3.exe
96
97 mcs2.exe: $(PROGRAM)
98         $(TIME) $(RUNTIME) $(RUNTIME_FLAGS) $(PROGRAM) $(USE_MCS_FLAGS) -target:exe -out:$@ $(BUILT_SOURCES) @$(response)
99
100 mcs3.exe: mcs2.exe
101         $(TIME) $(RUNTIME) $(RUNTIME_FLAGS) ./mcs2.exe $(USE_MCS_FLAGS) -target:exe -out:$@ $(BUILT_SOURCES) @$(response)
102
103 wc:
104         wc -l $(BUILT_SOURCES) `cat $(sourcefile)`
105
106 ctest: 
107         rm -f mcs2.exe mcs3.exe
108         $(MAKE) USE_MCS_FLAGS="-d:NET_1_1 -d:ONLY_1_1" btest
109
110 # we need this because bash tries to use its own crappy timer
111 FRIENDLY_TIME = $(shell which time) -f'%U seconds'
112
113 do-time : $(PROGRAM)
114         @ echo -n "Run 1:   "
115         @ rm -f mcs2.exe
116         @ $(MAKE) TIME="$(FRIENDLY_TIME)" mcs2.exe > /dev/null || (echo FAILED; exit 1)
117         @ echo -n "Run 2:   "
118         @ rm -f mcs3.exe
119         @ $(MAKE) TIME="$(FRIENDLY_TIME)" mcs3.exe > /dev/null || (echo FAILED; exit 1)
120         @ $(MAKE) do-corlib
121
122 do-corlib:
123         @ echo -n "corlib:  "
124         @ rm -f ../class/lib/mscorlib.dll
125         @ cd ../class/corlib ; $(MAKE) BOOTSTRAP_MCS='$(FRIENDLY_TIME) mono $$(topdir)/class/lib/$(PROFILE)/mcs.exe' > /dev/null || (echo FAILED; exit 1)
126
127 PROFILER=default
128
129 profile : $(PROGRAM)
130         $(RUNTIME) $(RUNTIME_FLAGS) --profile=$(PROFILER) $(PROGRAM) $(USE_MCS_FLAGS) -target:exe -out:mcs2.exe $(BUILT_SOURCES) @$(response)