2007-12-06 Atsushi Enomoto <atsushi@ximian.com>
[mono.git] / mcs / mcs / Makefile
index f79b13b0b6f2d3d0a7bdc46cda2b3eaa31c1ad6c..63f2f512e584adbeae93a4a560cc4d226e9adebb 100644 (file)
@@ -2,82 +2,137 @@ thisdir := mcs
 SUBDIRS := 
 include ../build/rules.make
 
-COMPILER_SOURCES = \
-       AssemblyInfo.cs                 \
-       anonymous.cs                    \
-       assign.cs                       \
-       attribute.cs                    \
-       driver.cs                       \
-       cs-tokenizer.cs                 \
-       cfold.cs                        \
-       class.cs                        \
-       codegen.cs                      \
-       const.cs                        \
-       constant.cs                     \
-       convert.cs                      \
-       decl.cs                         \
-       delegate.cs                     \
-       enum.cs                         \
-       ecore.cs                        \
-       expression.cs                   \
-       genericparser.cs                \
-       interface.cs                    \
-       iterators.cs                    \
-       literal.cs                      \
-       location.cs                     \
-       modifiers.cs                    \
-       namespace.cs                    \
-       parameter.cs                    \
-       pending.cs                      \
-       report.cs                       \
-       rootcontext.cs                  \
-       statement.cs                    \
-       support.cs                      \
-       typemanager.cs                  \
-       symbolwriter.cs                 \
-       tree.cs
-
-all_sources = $(COMPILER_SOURCES) cs-parser.cs
-
-DISTFILES = \
-       $(COMPILER_SOURCES)     \
-       compiler.csproj         \
-       compiler.csproj.user    \
+EXTRA_DISTFILES = \
+       *mcs.csproj             \
        compiler.doc            \
-       compiler.sln            \
-       cs-parser.jay           \
-       mcs.exe.config          \
+       *mcs.sln                \
+       *cs-parser.jay          \
+       *.sources               \
+       generic.cs              \
        NOTES                   \
-       TODO
+       TODO                    \
+       gmcs.exe.config
 
-all-local: mcs.exe
+GMCS_PROFILE := $(filter net_2_0_bootstrap net_2_0 net_2_1, $(PROFILE))
 
-install-local: mcs.exe
-       $(MKINSTALLDIRS) $(DESTDIR)$(prefix)/bin
-       $(INSTALL_BIN) mcs.exe $(DESTDIR)$(prefix)/bin
+ifdef GMCS_PROFILE
+       LOCAL_MCS_FLAGS += -d:GMCS_SOURCE
 
-test-local run-test-local:
+       ifeq (net_2_1, $(PROFILE))
+               INTERNAL_SMCS = $(INTERNAL_GMCS)
+               LOCAL_MCS_FLAGS += -nowarn:618 -noconfig -r:mscorlib -r:System.dll
+               PROGRAM = $(topdir)/class/lib/$(PROFILE)/smcs.exe
+       else
+               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)
+               PROGRAM = $(topdir)/class/lib/$(PROFILE)/gmcs.exe
+       endif   
+else
+       PROGRAM = $(topdir)/class/lib/$(PROFILE)/mcs.exe
+endif
 
-clean-local:
-       rm -f *.exe cs-parser.cs y.output
+BUILT_SOURCES = cs-parser.cs
 
-dist-local: dist-default
+PROGRAM_COMPILE = $(BOOT_COMPILE)
 
-mcs.exe: $(all_sources)
-       $(BOOT_COMPILE) /target:exe /out:$@ $^
+CLEAN_FILES += y.output
 
-cs-parser.cs: cs-parser.jay $(topdir)/jay/skeleton.cs
-       $(topdir)/jay/jay -ctv < $(topdir)/jay/skeleton.cs $< >$@
+%-parser.cs: %-parser.jay $(topdir)/jay/skeleton.cs
+       $(topdir)/jay/jay -ctv < $(topdir)/jay/skeleton.cs $< > jay-tmp.out && mv jay-tmp.out $@
+
+
+ifeq (net_2_0_bootstrap, $(PROFILE))
+
+all-local $(STD_TARGETS:=-local):
+       @:
+
+all-local: $(PROGRAM) $(PROGRAM).config
+clean-local: clean-program
+clean-program:
+       rm -f $(PROGRAM) $(PROGRAM).config
+
+progdir = $(dir $(PROGRAM))
+
+$(progdir)/.stamp:
+       $(MKINSTALLDIRS) $(@D)
+       touch $@
+
+$(PROGRAM) $(PROGRAM).config: $(progdir)/.stamp
+
+$(PROGRAM): $(topdir)/class/lib/default/mcs.exe
+       cp $< $@
+
+$(PROGRAM).config: gmcs.exe.config
+       cp $< $@
+
+else
+
+ifeq (net_2_0, $(PROFILE))
+
+clean-local: clean-net_2_0_bootstrap
+clean-net_2_0_bootstrap:
+       cd .. && $(MAKE) PROFILE=net_2_0_bootstrap clean
+
+bootstrap_libs = mscorlib.dll System.dll System.Xml.dll Mono.CompilerServices.SymbolWriter.dll
+bootstrap_libfiles = $(bootstrap_libs:%=$(topdir)/class/lib/net_2_0_bootstrap/%)
+
+$(bootstrap_libfiles): bootstrap-libs
+       @:
+.PHONY: bootstrap-libs
+bootstrap-libs:
+       cd .. && $(MAKE) PROFILE=net_2_0_bootstrap all
+
+$(PROGRAM): $(bootstrap_libfiles)
+endif
+
+KEEP_OUTPUT_FILE_COPY = yes
+
+include ../build/executable.make
+endif
 
 # Testing targets
 
 TIME = time
 
-test: mcs2.exe mcs3.exe
+# This used to be called test, but that conflicts with the global
+# recursive target.
+
+btest: mcs2.exe mcs3.exe
        ls -l mcs2.exe mcs3.exe
 
-mcs2.exe: mcs.exe
-       $(TIME) $(RUNTIME) ./mcs.exe $(USE_MCS_FLAGS) /target:exe /out:$@ $(all_sources)
+mcs2.exe: $(PROGRAM)
+       $(TIME) $(RUNTIME) $(RUNTIME_FLAGS) $(PROGRAM) $(USE_MCS_FLAGS) -target:exe -out:$@ $(BUILT_SOURCES) @$(response)
 
 mcs3.exe: mcs2.exe
-       $(TIME) $(RUNTIME) ./mcs2.exe $(USE_MCS_FLAGS) /target:exe /out:$@ $(all_sources)
\ No newline at end of file
+       $(TIME) $(RUNTIME) $(RUNTIME_FLAGS) ./mcs2.exe $(USE_MCS_FLAGS) -target:exe -out:$@ $(BUILT_SOURCES) @$(response)
+
+wc:
+       wc -l $(BUILT_SOURCES) `cat $(sourcefile)`
+
+ctest: 
+       rm -f mcs2.exe mcs3.exe
+       $(MAKE) USE_MCS_FLAGS="-d:NET_1_1 -d:ONLY_1_1" btest
+
+# we need this because bash tries to use its own crappy timer
+FRIENDLY_TIME = $(shell which time) -f'%U seconds'
+
+do-time : $(PROGRAM)
+       @ echo -n "Run 1:   "
+       @ rm -f mcs2.exe
+       @ $(MAKE) TIME="$(FRIENDLY_TIME)" mcs2.exe > /dev/null || (echo FAILED; exit 1)
+       @ echo -n "Run 2:   "
+       @ rm -f mcs3.exe
+       @ $(MAKE) TIME="$(FRIENDLY_TIME)" mcs3.exe > /dev/null || (echo FAILED; exit 1)
+       @ $(MAKE) do-corlib
+
+do-corlib:
+       @ echo -n "corlib:  "
+       @ rm -f ../class/lib/mscorlib.dll
+       @ cd ../class/corlib ; $(MAKE) BOOTSTRAP_MCS='$(FRIENDLY_TIME) mono $$(topdir)/class/lib/$(PROFILE)/mcs.exe' > /dev/null || (echo FAILED; exit 1)
+
+PROFILER=default
+
+profile : $(PROGRAM)
+       $(RUNTIME) $(RUNTIME_FLAGS) --profile=$(PROFILER) $(PROGRAM) $(USE_MCS_FLAGS) -target:exe -out:mcs2.exe $(BUILT_SOURCES) @$(response)
+
+qh:
+       MONO_PATH="../class/lib/net_2_0_bootstrap:$MONO_PATH" /cvs/mono/runtime/mono-wrapper  ../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