da6ea0cd9fe3fe73b0ee8bd6413b371b50e2091e
[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 ifeq (1.0, $(FRAMEWORK_VERSION))
17 COMPILER_NAME = mcs
18 endif
19
20 ifeq (2.0, $(FRAMEWORK_VERSION))
21 LOCAL_MCS_FLAGS += -d:GMCS_SOURCE
22 COMPILER_NAME = gmcs
23 endif
24
25 ifeq (2.1, $(FRAMEWORK_VERSION))
26 LOCAL_MCS_FLAGS += -d:GMCS_SOURCE -d:SMCS_SOURCE
27 COMPILER_NAME = smcs
28 endif
29
30 PROGRAM = $(topdir)/class/lib/$(PROFILE)/$(COMPILER_NAME).exe
31
32 BUILT_SOURCES = cs-parser.cs
33
34 PROGRAM_COMPILE = $(BOOT_COMPILE)
35
36 CLEAN_FILES += y.output
37
38 %-parser.cs: %-parser.jay $(topdir)/jay/skeleton.cs
39         $(topdir)/jay/jay -cv < $(topdir)/jay/skeleton.cs $< > jay-tmp.out && mv jay-tmp.out $@
40
41
42 ifeq (net_2_0_bootstrap, $(PROFILE))
43
44 all-local $(STD_TARGETS:=-local):
45         @:
46
47 all-local: $(PROGRAM) $(PROGRAM).config
48 clean-local: clean-program
49 clean-program:
50         rm -f $(PROGRAM) $(PROGRAM).config
51
52 $(PROGRAM) $(PROGRAM).config: $(dir $(PROGRAM))/.stamp
53
54 $(PROGRAM): $(topdir)/class/lib/net_1_1/mcs.exe
55         cp $< $@
56
57 $(PROGRAM).config: gmcs.exe.config
58         cp $< $@
59
60 else
61
62 ifeq (net_2_0, $(PROFILE))
63
64 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)
65
66 clean-local: clean-net_2_0_bootstrap
67 clean-net_2_0_bootstrap:
68         cd .. && $(MAKE) NO_DIR_CHECK=yes 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) NO_DIR_CHECK=yes 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 #
88 # Below this line we have local targets used for testing and development
89 #
90
91 # Testing targets
92
93 TIME = time
94
95 # This used to be called test, but that conflicts with the global
96 # recursive target.
97
98 btest: mcs2.exe mcs3.exe
99         ls -l mcs2.exe mcs3.exe
100
101 mcs2.exe: $(PROGRAM)
102         $(TIME) $(RUNTIME) $(RUNTIME_FLAGS) $(PROGRAM) $(USE_MCS_FLAGS) -target:exe -out:$@ $(BUILT_SOURCES) @$(response)
103
104 mcs3.exe: mcs2.exe
105         $(TIME) $(RUNTIME) $(RUNTIME_FLAGS) ./mcs2.exe $(USE_MCS_FLAGS) -target:exe -out:$@ $(BUILT_SOURCES) @$(response)
106
107 wc:
108         wc -l $(BUILT_SOURCES) `cat $(sourcefile)`
109
110 ctest: 
111         rm -f mcs2.exe mcs3.exe
112         $(MAKE) USE_MCS_FLAGS="-d:NET_1_1 -d:ONLY_1_1" btest
113
114 # we need this because bash tries to use its own crappy timer
115 FRIENDLY_TIME = $(shell which time) -f'%U seconds'
116
117 do-time : $(PROGRAM)
118         @ echo -n "Run 1:   "
119         @ rm -f mcs2.exe
120         @ $(MAKE) TIME="$(FRIENDLY_TIME)" mcs2.exe > /dev/null || (echo FAILED; exit 1)
121         @ echo -n "Run 2:   "
122         @ rm -f mcs3.exe
123         @ $(MAKE) TIME="$(FRIENDLY_TIME)" mcs3.exe > /dev/null || (echo FAILED; exit 1)
124         @ $(MAKE) do-corlib
125
126 do-corlib:
127         @ echo -n "corlib:  "
128         @ rm -f ../class/lib/mscorlib.dll
129         @ cd ../class/corlib ; $(MAKE) BOOTSTRAP_MCS='$(FRIENDLY_TIME) mono $$(topdir)/class/lib/$(PROFILE)/mcs.exe' > /dev/null || (echo FAILED; exit 1)
130
131 PROFILER=default
132
133 do-gettext:
134         xgettext --keyword='Report.Error:3' --keyword='Report.Error:2' --keyword='Report.Warning:3' --keyword='Report.Warning:2' -o mcs.po --language='C#' `cat gmcs.exe.sources | grep -v /`
135
136 profile : $(PROGRAM)
137         $(RUNTIME) $(RUNTIME_FLAGS) --profile=$(PROFILER) $(PROGRAM) $(USE_MCS_FLAGS) -target:exe -out:mcs2.exe $(BUILT_SOURCES) @$(response)
138
139 #
140 # quick hack target, to quickly develop the gmcs compiler
141 # Update manually.
142 qh:
143         MONO_PATH="../class/lib/net_2_0$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) $(RUNTIME_FLAGS) ../class/lib/net_2_0/gmcs.exe  /codepage:65001 -d:GMCS_SOURCE  -d:NET_1_1 -d:NET_2_0 -debug -target:exe -out:gmcs.exe cs-parser.cs  @gmcs.exe.sources
144         @ cp $(COMPILER_NAME).exe* $(topdir)/class/lib/$(PROFILE)/
145
146 q: cs-parser.cs qh
147         echo 'System.Console.WriteLine ("Hello");' | mono csharp.exe
148         echo -e 'using System;\nConsole.WriteLine ("hello");' | mono csharp.exe
149         echo -e '"foo" == "bar";' | mono csharp.exe
150         echo -e 'var a = 1;\na + 2;' | mono csharp.exe
151         echo -e 'int j;\nj = 1;' | mono csharp.exe
152         echo -e 'var a = new int[]{1,2,3};\nfrom x in a select x;' | mono csharp.exe
153         echo -e 'var a = from f in System.IO.Directory.GetFiles ("/tmp") where f == "passwd" select f;' | mono csharp.exe
154
155
156