2009-06-12 Bill Holmes <billholmes54@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         *mcs.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 ifeq (4.0, $(FRAMEWORK_VERSION))
31 LOCAL_MCS_FLAGS += -d:GMCS_SOURCE
32 COMPILER_NAME = dmcs
33 endif
34
35 PROGRAM = $(topdir)/class/lib/$(PROFILE)/$(COMPILER_NAME).exe
36
37 BUILT_SOURCES = cs-parser.cs
38
39 PROGRAM_COMPILE = $(BOOT_COMPILE)
40
41 CLEAN_FILES += y.output
42
43 %-parser.cs: %-parser.jay $(topdir)/jay/skeleton.cs
44         $(topdir)/jay/jay -cvt < $(topdir)/jay/skeleton.cs $< > jay-tmp.out && mv jay-tmp.out $@
45
46
47 ifeq (net_2_0_bootstrap, $(PROFILE))
48
49 all-local $(STD_TARGETS:=-local):
50         @:
51
52 all-local: $(PROGRAM) $(PROGRAM).config
53 clean-local: clean-program
54 clean-program:
55         rm -f $(PROGRAM) $(PROGRAM).config
56
57 $(PROGRAM) $(PROGRAM).config: $(dir $(PROGRAM))/.stamp
58
59 $(PROGRAM): $(topdir)/class/lib/net_1_1/mcs.exe
60         cp $< $@
61
62 $(PROGRAM).config: gmcs.exe.config
63         cp $< $@
64
65 else
66
67 ifeq (net_2_0, $(PROFILE))
68
69 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)
70
71 clean-local: clean-net_2_0_bootstrap
72 clean-net_2_0_bootstrap:
73         cd .. && $(MAKE) NO_DIR_CHECK=yes 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) NO_DIR_CHECK=yes 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 csproj-local:
93         config_file=`basename $(PROGRAM) .exe`-$(PROFILE).input; \
94         echo $(thisdir):$$config_file >> $(topdir)/../mono/msvc/scripts/order; \
95         (echo $(is_boot); \
96         echo $(BOOTSTRAP_MCS);  \
97         echo $(USE_MCS_FLAGS) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS); \
98         echo $(PROGRAM); \
99         echo $(BUILT_SOURCES); \
100         echo $(PROGRAM); \
101         echo $(response)) > $(topdir)/../mono/msvc/scripts/inputs/$$config_file
102
103 #
104 # Below this line we have local targets used for testing and development
105 #
106
107 # Testing targets
108
109 TIME = time
110
111 # This used to be called test, but that conflicts with the global
112 # recursive target.
113
114 btest: mcs2.exe mcs3.exe
115         ls -l mcs2.exe mcs3.exe
116
117 mcs2.exe: $(PROGRAM)
118         $(TIME) $(RUNTIME) $(RUNTIME_FLAGS) $(PROGRAM) $(USE_MCS_FLAGS) -target:exe -out:$@ $(BUILT_SOURCES) @$(response)
119
120 mcs3.exe: mcs2.exe
121         $(TIME) $(RUNTIME) $(RUNTIME_FLAGS) ./mcs2.exe $(USE_MCS_FLAGS) -target:exe -out:$@ $(BUILT_SOURCES) @$(response)
122
123 wc:
124         wc -l $(BUILT_SOURCES) `cat $(sourcefile)`
125
126 ctest: 
127         rm -f mcs2.exe mcs3.exe
128         $(MAKE) USE_MCS_FLAGS="-d:NET_1_1 -d:ONLY_1_1" btest
129
130 # we need this because bash tries to use its own crappy timer
131 FRIENDLY_TIME = $(shell which time) -f'%U seconds'
132
133 do-time : $(PROGRAM)
134         @ echo -n "Run 1:   "
135         @ rm -f mcs2.exe
136         @ $(MAKE) TIME="$(FRIENDLY_TIME)" mcs2.exe > /dev/null || (echo FAILED; exit 1)
137         @ echo -n "Run 2:   "
138         @ rm -f mcs3.exe
139         @ $(MAKE) TIME="$(FRIENDLY_TIME)" mcs3.exe > /dev/null || (echo FAILED; exit 1)
140         @ $(MAKE) do-corlib
141
142 do-corlib:
143         @ echo -n "corlib:  "
144         @ rm -f ../class/lib/mscorlib.dll
145         @ cd ../class/corlib ; $(MAKE) BOOTSTRAP_MCS='$(FRIENDLY_TIME) mono $$(topdir)/class/lib/$(PROFILE)/mcs.exe' > /dev/null || (echo FAILED; exit 1)
146
147 PROFILER=default
148
149 do-gettext:
150         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 /`
151
152 profile : $(PROGRAM)
153         $(RUNTIME) $(RUNTIME_FLAGS) --profile=$(PROFILER) $(PROGRAM) $(USE_MCS_FLAGS) -target:exe -out:mcs2.exe $(BUILT_SOURCES) @$(response)
154
155 #
156 # quick hack target, to quickly develop the gmcs compiler
157 # Update manually.
158 qh:
159         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
160         @ cp $(COMPILER_NAME).exe* $(topdir)/class/lib/$(PROFILE)/
161
162 pa: cs-parser.cs
163         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:foo.exe cs-parser.cs foo.cs -main:X  @gmcs.exe.sources
164
165 q: cs-parser.cs qh
166         echo 'System.Console.WriteLine ("Hello");' | mono csharp.exe
167         echo -e 'using System;\nConsole.WriteLine ("hello");' | mono csharp.exe
168         echo -e '"foo" == "bar";' | mono csharp.exe
169         echo -e 'var a = 1;\na + 2;' | mono csharp.exe
170         echo -e 'int j;\nj = 1;' | mono csharp.exe
171         echo -e 'var a = new int[]{1,2,3};\nfrom x in a select x;' | mono csharp.exe
172         echo -e 'var a = from f in System.IO.Directory.GetFiles ("/tmp") where f == "passwd" select f;' | mono csharp.exe
173
174