2007-07-12 Jonathan Pobst <monkey@jpobst.com>
[mono.git] / mcs / gmcs / Makefile
1 thisdir := gmcs
2 SUBDIRS := 
3 include ../build/rules.make
4
5 #uncomment to enable some debug stuff
6 #DEBUG_FLAGS=/define:MCS_DEBUG
7
8 LOCAL_MCS_FLAGS += -d:GMCS_SOURCE
9
10 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)
11
12 BUILT_SOURCES = cs-parser.cs
13
14 EXTRA_DISTFILES = cs-parser.jay
15
16 PROGRAM = $(topdir)/class/lib/$(PROFILE)/gmcs.exe
17 PROGRAM_COMPILE = $(BOOT_COMPILE)
18
19 CLEAN_FILES = y.output *.exe *.mdb
20
21 cs-parser.cs: cs-parser.jay $(topdir)/jay/skeleton.cs
22         $(topdir)/jay/jay -ctv < $(topdir)/jay/skeleton.cs $< > jay-tmp.out && mv jay-tmp.out $@
23
24 include ../build/executable.make
25
26 VALID_PROFILE := $(filter net_2_0_bootstrap net_2_0 net_2_1, $(PROFILE))
27 ifdef VALID_PROFILE
28 # Utility rule to make debugging somewhat easier.
29 all-local: gmcs.exe
30 gmcs.exe: $(PROGRAM)
31         cp -p $< $@
32         test ! -f $<.mdb || cp -p $<.mdb $@.mdb
33 endif
34
35 ifeq (net_2_1, $(PROFILE))
36 install-local:
37         rm -f $(mono_libdir)/mono/2.1/gmcs.exe
38         ln -s $(mono_libdir)/mono/2.0/gmcs.exe $(mono_libdir)/mono/2.1
39 endif
40
41 clean-local: clean-net_2_0_bootstrap
42 clean-net_2_0_bootstrap:
43         cd .. && $(MAKE) PROFILE=net_2_0_bootstrap clean
44
45 bootstrap_libs = mscorlib.dll System.dll System.Xml.dll Mono.CompilerServices.SymbolWriter.dll
46 bootstrap_libfiles = $(bootstrap_libs:%=$(topdir)/class/lib/net_2_0_bootstrap/%)
47
48 $(bootstrap_libfiles): bootstrap-libs
49         @:
50 .PHONY: bootstrap-libs
51 bootstrap-libs:
52         cd .. && $(MAKE) PROFILE=net_2_0_bootstrap all
53
54 $(PROGRAM): $(bootstrap_libfiles)
55
56 gmcs2.exe: $(PROGRAM)
57         MONO_PATH="../class/lib/net_2_0$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" time $(RUNTIME) $(RUNTIME_FLAGS) $(PROGRAM) /target:exe /debug /out:$@ -d:GMCS_SOURCE  -d:NET_1_1 -d:NET_2_0 cs-parser.cs  @gmcs.exe.sources
58
59 gmcs3.exe: gmcs2.exe
60         MONO_PATH="../class/lib/net_2_0$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" time $(RUNTIME) $(RUNTIME_FLAGS) ./gmcs2.exe /target:exe /debug /out:$@ -d:GMCS_SOURCE  -d:NET_1_1 -d:NET_2_0 cs-parser.cs  @gmcs.exe.sources
61
62 gmcs4.exe: gmcs3.exe
63         MONO_PATH="../class/lib/net_2_0$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" time $(RUNTIME) $(RUNTIME_FLAGS) ./gmcs3.exe /target:exe /debug /out:$@ -d:GMCS_SOURCE  -d:NET_1_1 -d:NET_2_0 cs-parser.cs  @gmcs.exe.sources
64
65
66 # Testing targets
67
68 TIME = 
69
70 # This used to be called test, but that conflicts with the global
71 # recursive target.
72
73 btest: gmcs2.exe gmcs3.exe gmcs4.exe
74         ls -l gmcs3.exe gmcs4.exe
75
76 wc:
77         wc -l $(all_sources)
78
79 ctest: 
80         rm -f gmcs3.exe mcs4.exe
81         make btest USE_MCS_FLAGS= 
82
83 # we need this because bash tries to use its own crappy timer
84 FRIENDLY_TIME = $(shell which time) -f'%U seconds'
85
86 do-time : mcs.exe
87         @ echo -n "Run 1:   "
88          $(FRIENDLY_TIME) $(RUNTIME) $(RUNTIME_FLAGS) ./mcs.exe $(USE_MCS_FLAGS) /target:exe /out:mcs2.exe $(all_sources) > /dev/null || (echo FAILED; exit 1)
89         @ echo -n "Run 2:   "
90         @ $(FRIENDLY_TIME) $(RUNTIME) $(RUNTIME_FLAGS) ./mcs2.exe $(USE_MCS_FLAGS) /target:exe /out:mcs3.exe $(all_sources) > /dev/null || (echo FAILED; exit 1)
91         @ echo -n "corlib:  "
92         @ rm -f ../class/lib/mscorlib.dll
93         @ (cd ../class/corlib ; make BOOTSTRAP_MCS="$(FRIENDLY_TIME) mono ../../mcs/mcs.exe" > /dev/null ) || (echo FAILED; exit 1)
94
95 do-corlib:
96         @ echo -n "corlib:  "
97         @ rm -f ../class/lib/mscorlib.dll
98         @ (cd ../class/corlib ; make BOOTSTRAP_MCS="$(FRIENDLY_TIME) mono ../../mcs/mcs.exe" > /dev/null ) || (echo FAILED; exit 1)
99
100 PROFILER=default
101
102 profile : gmcs2.exe
103         -rm -f gmcs3.exe
104         make gmcs3.exe RUNTIME_FLAGS='--profile=$(PROFILER)'
105
106 #
107 # This is used to test the various possible expressions that can be
108 # part of a lambda expression (used to exercise the micro-parser built
109 # inside the tokenizer to return OPEN_PARENS or OPEN_PARENS_LAMBDA
110 # that trigger different parsing paths on the compiler
111 #
112 typetest:
113         mono gmcs.exe --typetest ../mcs/lambda.test
114
115 l:
116         mono --debug gmcs.exe -langversion:linq l1.cs
117
118 #
119 # qh="quick hack", a target to quickly rebuild the generics compiler once you
120 # have built it once.
121 #
122 qh:
123         make cs-parser.cs
124         MONO_PATH="../class/lib/net_2_0_bootstrap$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(RUNTIME) ../class/lib/net_2_0_bootstrap/mcs.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