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