# NOTE: to build with --cli-version 1.0 you must add the '10' suffix to the names of all binaries in this makefile

fsc=..\bin\fsc.exe
fscb=.\bin\fsc.exe

absilsuppc=absil\readpdb.cpp absil\common.cpp absil\writepdb.cpp absil\sign.cpp absil\reslink.cpp absil\getcor.cpp

absil=   absil\nums.mli absil\nums.ml absil\pmap.mli absil\pmap.ml absil\zmap.mli absil\zmap.ml absil\zset.mli absil\zset.ml absil\bytes.mli absil\bytes.ml absil\ildiag.mli absil\ildiag.ml absil\illib.ml absil\il.mli absil\il.ml absil\ilx.mli absil\ilx.ml absil\ilascii.mli absil\ilascii.ml absil\ilprint.mli absil\ilprint.ml absil\ilmorph.mli absil\ilmorph.ml absil\ilbinary.mli absil\ilbinary.ml absil\ilsupp.mli absil\ilsupp.ml absil\ilpars.ml absil\illex.ml absil\ilread.mli absil\ilread.ml

fsccore=ilx\ilxsettings.ml ilx\ilxconfig.ml ilx\msilxlib.ml ilx\pp_erase.ml ilx\nupp_erase.ml ilx\pubclo.ml ilx\cu_erase.ml ilx\ilxerase.ml fsharp\unilex.ml fsharp\lib.ml fsharp\layout.mli fsharp\layout.ml fsharp\range.mli fsharp\range.ml fsharp\ast.ml fsharp\ccuthunk.ml fsharp\tast.ml fsharp\env.ml fsharp\tastops.mli fsharp\tastops.ml fsharp\augment.mli fsharp\augment.ml fsharp\pickle.mli fsharp\pickle.ml

fscfront=fsharp\pars.ml fsharp\lexhelp.ml fsharp\lex.ml fsharp\lexfilter.ml fsharp\import.ml fsharp\infos.ml fsharp\typrelns.ml fsharp\patcompile.mli fsharp\patcompile.ml fsharp\outcome.mli fsharp\outcome.ml fsharp\csolve.ml fsharp\formats.mli fsharp\formats.ml fsharp\nameres.ml fsharp\unsolved.ml fsharp\sreflect.mli fsharp\sreflect.ml fsharp\creflect.mli fsharp\creflect.ml fsharp\check.ml fsharp\tc.mli fsharp\tc.ml

fscback=fsharp\opt.mli fsharp\opt.ml fsharp\detuple.ml fsharp\tlr.ml fsharp\lowertop.ml fsharp\ilxgen.mli fsharp\ilxgen.ml fsharp\build.mli fsharp\build.ml fsharp\fscopts.ml

fsc_files=absil\ilwrite.mli absil\ilwrite.ml fsharp\fsc.ml fsharp\fscmain.ml

fslib=fsharp\fslib\prim-types.fsi fsharp\fslib\prim-types.fs fsharp\fslib\local.fsi fsharp\fslib\local.fs fsharp\fslib\compatarray.fsi fsharp\fslib\compatarray.fs fsharp\fslib\compatarray2.fsi fsharp\fslib\compatarray2.fs fsharp\fslib\array2.fsi fsharp\fslib\array2.fs fsharp\fslib\enum.fsi fsharp\fslib\enum.fs fsharp\fslib\string.fsi fsharp\fslib\string.fs fsharp\fslib\byte.fsi fsharp\fslib\byte.fs fsharp\fslib\sbyte.fs fsharp\fslib\int32.fsi fsharp\fslib\int32.fs fsharp\fslib\int64.fsi fsharp\fslib\int64.fs fsharp\fslib\uint32.fsi fsharp\fslib\uint32.fs fsharp\fslib\uint64.fsi fsharp\fslib\uint64.fs fsharp\fslib\option.fsi fsharp\fslib\option.fs fsharp\fslib\float.fsi fsharp\fslib\float.fs fsharp\fslib\float32.fsi fsharp\fslib\float32.fs fsharp\fslib\ienumerable.fsi fsharp\fslib\ienumerable.fs fsharp\fslib\permutation.fsi fsharp\fslib\permutation.fs fsharp\fslib\lazy.fsi fsharp\fslib\lazy.fs fsharp\fslib\resizearray.fsi fsharp\fslib\resizearray.fs fsharp\fslib\list.fsi fsharp\fslib\list.fs fsharp\fslib\collections.fsi fsharp\fslib\collections.fs fsharp\fslib\ievent.fsi fsharp\fslib\ievent.fs fsharp\fslib\funcconv.fsi fsharp\fslib\funcconv.fs fsharp\fslib\array.fsi fsharp\fslib\array.fs fsharp\fslib\array3.fsi fsharp\fslib\array3.fs fsharp\fslib\int8.fs fsharp\fslib\int16.fs fsharp\fslib\uint8.fs fsharp\fslib\uint16.fs fsharp\fslib\func.fsi fsharp\fslib\func.fs fsharp\fslib\map.fsi fsharp\fslib\map.fs fsharp\fslib\set.fsi fsharp\fslib\set.fs fsharp\fslib\sformat.fsi fsharp\fslib\sformat.fs fsharp\fslib\reflect.fsi fsharp\fslib\reflect.fs fsharp\fslib\math\fft.fsi fsharp\fslib\math\fft.fs fsharp\fslib\math\n.fsi fsharp\fslib\math\n.fs fsharp\fslib\math\z.fsi fsharp\fslib\math\z.fs fsharp\fslib\math\q.fsi fsharp\fslib\math\q.fs fsharp\fslib\slayout.fsi fsharp\fslib\slayout.fs fsharp\fslib\printf.fsi fsharp\fslib\printf.fs fsharp\fslib\quotations.fsi fsharp\fslib\quotations.fs fsharp\fslib\math\INumeric.fsi fsharp\fslib\math\INumeric.fs fsharp\fslib\math\complex.fsi fsharp\fslib\math\complex.fs fsharp\fslib\math\associations.fsi fsharp\fslib\math\associations.fs fsharp\fslib\math\gmatrix.fsi fsharp\fslib\math\gmatrix.fs fsharp\fslib\math\notation.fsi fsharp\fslib\math\notation.fs fsharp\fslib\math\compatibility.fsi fsharp\fslib\math\compatibility.fs fsharp\fslib\math\lalgebra.fsi fsharp\fslib\math\lalgebra.fs fsharp\fslib\nativeptr.fsi fsharp\fslib\nativeptr.fs fsharp\fslib\prim-lexing.fsi fsharp\fslib\prim-lexing.fs fsharp\fslib\prim-parsing.fsi fsharp\fslib\prim-parsing.fs fsharp\fslib\idioms.fsi fsharp\fslib\idioms.fs fsharp\fslib\control.fsi fsharp\fslib\control.fs fsharp\fslib\fslib-extra-pervasives.fsi fsharp\fslib\fslib-extra-pervasives.fs

mllib=fsharp\mllib\char.fsi fsharp\mllib\char.fs fsharp\mllib\pervasives.fsi fsharp\mllib\pervasives.fs fsharp\mllib\arg.fsi fsharp\mllib\arg.fs fsharp\mllib\big_int.fsi fsharp\mllib\big_int.fs fsharp\mllib\num.fsi fsharp\mllib\num.fs fsharp\mllib\bytearray.fsi fsharp\mllib\bytearray.fs fsharp\mllib\buffer.fsi fsharp\mllib\buffer.fs fsharp\mllib\hashtbl.fsi fsharp\mllib\hashtbl.fs fsharp\mllib\printexc.fsi fsharp\mllib\printexc.fs fsharp\mllib\sys.fsi fsharp\mllib\sys.fs fsharp\mllib\obj.fsi fsharp\mllib\obj.fs fsharp\mllib\roarray.fsi fsharp\mllib\roarray.fs fsharp\mllib\lazylist.fsi fsharp\mllib\lazylist.fs fsharp\mllib\filename.fsi fsharp\mllib\filename.fs fsharp\mllib\lexing.fsi fsharp\mllib\lexing.fs fsharp\mllib\map.fsi fsharp\mllib\map.fs fsharp\mllib\set.fsi fsharp\mllib\set.fs fsharp\mllib\parsing.fsi fsharp\mllib\parsing.fs

fslex=   fsharp\unilex.ml fslex\fslexast.ml fslex\fslexpars.ml fslex\fslexlex.ml fslex\fslex.ml

fsyacc=   fsharp\unilex.ml fsyacc\fsyaccast.ml fsyacc\fsyaccpars.ml fsyacc\fsyacclex.ml fsyacc\fsyacc.ml

resxc=fsharp\resxc.fs

fsc_opts=--version-file version -g -O3 --times --progress --no-warn 50 
fsc_defines=               --all-tailcalls --define TAILCALLS  --closures-as-virtuals --define CLOSURE_ENTRYPOINTS_ARE_VIRTUALS  --cli-version 2.0rc --define CLI_AT_LEAST_2_0 -I C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727  --generics --define GENERICS  --multi-entrypoint-closures --define MULTI_ENTRYPOINT_CLOSURES  -O3 --tlr 1  --no-warn 69 --no-warn 65 --no-warn 61 --no-warn 62  --no-warn 44 --no-warn 70 --define GENERICS --define RUNTIME --define CLOSURE_ENTRYPOINTS_ARE_VIRTUALS --define TAILCALLS --define MULTI_ENTRYPOINT_CLOSURES --define CLI_AT_LEAST_2_0 

fsc_compiler_defines=--define COMPILER                --all-tailcalls --define TAILCALLS  --closures-as-virtuals --define CLOSURE_ENTRYPOINTS_ARE_VIRTUALS  --cli-version 2.0rc --define CLI_AT_LEAST_2_0 -I C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727  --generics --define GENERICS  --multi-entrypoint-closures --define MULTI_ENTRYPOINT_CLOSURES  -O3 --tlr 1  --no-warn 69 --no-warn 65 --no-warn 61 --no-warn 62  --no-warn 44

all: bin\absil.dll bin\fsccore.dll bin\fscfront.dll bin\fscback.dll bin\fsc.exe bin\FSharp.Core.dll bin\FSharp.Compatibility.dll bin\FSharp.prep  bin\resxc.exe bin\fslex.exe bin\fsyacc.exe
       @-cmd /c echo F# compiler successfully built.
       @-cmd /c echo NOTE: You must successfully build absilsuppc.dll
       @-cmd /c echo NOTE: if you want debug symbol generation, native resource
       @-cmd /c echo NOTE: linking and strong name signing to work correctly.
       @-cmd /c echo NOTE: At the moment you do this by running one of the ilsupp-*.bat files
       @-cmd /c echo NOTE: Or you can use the absilsuppc.dll that comes with this F# release.
       @-cmd /c echo NOTE: The generated DLLs have been delay-signed and verification entries
       @-cmd /c echo NOTE: added to your registry to let them run on this machine. Do
       @-cmd /c echo NOTE: not redistribute them.

absil\ilpars.ml: absil\ilpars.mly
       ..\bin\fsyacc --module Microsoft.Research.AbstractIL.Internal.AsciiParser --open Microsoft.Research.AbstractIL -o absil\ilpars.ml --ml-compatibility -v absil\ilpars.mly

absil\illex.ml: absil\illex.mll
       ..\bin\fslex -o absil\illex.ml absil\illex.mll

bin\absil.dll: $(absil) 
       -cmd /c mkdir bin
       $(fsc) --no-warn 50 $(fsc_compiler_defines) --public-keyfile absil\absil.pubkey -a $(fsc_opts) -o bin\absil.dll  $(absil)

fsharp\pars.ml: fsharp\pars.mly
       ..\bin\fsyacc -o fsharp\pars.ml --ml-compatibility -v fsharp\pars.mly

fsharp\lex.ml: fsharp\lex.mll
       ..\bin\fslex -o fsharp\lex.ml fsharp\lex.mll

bin\fsccore.dll: $(fsccore) bin\absil.dll
       -cmd /c mkdir bin
       $(fsc) $(fsc_compiler_defines) --public-keyfile fsharp\fs.pubkey -a $(fsc_opts) -o bin\fsccore.dll  -r bin\absil.dll $(fsccore)

bin\fscfront.dll: $(fscfront) bin\fsccore.dll bin\absil.dll
       -cmd /c mkdir bin
       $(fsc) $(fsc_compiler_defines) --public-keyfile fsharp\fs.pubkey -a $(fsc_opts) -o bin\fscfront.dll  -r bin\absil.dll -r bin\fsccore.dll  $(fscfront)

bin\fscback.dll: $(fscback) bin\fsccore.dll bin\fscfront.dll bin\absil.dll
       -cmd /c mkdir bin
       $(fsc) $(fsc_compiler_defines) --public-keyfile fsharp\fs.pubkey -a $(fsc_opts) -o bin\fscback.dll  -r bin\absil.dll -r bin\fsccore.dll -r bin\fscfront.dll $(fscback)

bin\fsc.exe: $(fsc_files)  bin\fsccore.dll bin\fscfront.dll bin\fscback.dll bin\absil.dll
       -cmd /c mkdir bin
       $(fsc) $(fsc_compiler_defines) --public-keyfile fsharp\fs.pubkey $(fsc_opts) -o bin\fsc.exe   -r bin\absil.dll -r bin\fsccore.dll -r bin\fscfront.dll -r bin\fscback.dll  $(fsc_files) 

bin\fsc.prep: bin\absil.dll bin\fsccore.dll bin\fscfront.dll bin\fscback.dll bin\fsc.exe
       @-cmd /c echo "The binaries you have built have strong names but are not signed."
       @-cmd /c echo "Thus registering skip-strong-name-verification entries with the CLR."
       -sn -Vr *,a19089b1c74d0809
       -sn -Vr *,3b734f0d5c10d32e
       @-cmd /c echo "Adding generated component DLLs to the GAC."
       gacutil /i bin\absil.dll
       gacutil /i bin\fsccore.dll
       gacutil /i bin\fscfront.dll
       gacutil /i bin\fscback.dll
       -cmd /c echo hello > bin\fsc.prep

bin\FSharp.Core.dll: $(fslib) bin\fsc.prep
       -cmd /c mkdir bin
       $(fscb) --light --public-keyfile fsharp\fs.pubkey $(fsc_defines) -I .\bin --no-warn 35 --compiling-fslib -a $(fsc_opts) -o bin\FSharp.Core.dll $(fslib)

bin\FSharp.Compatibility.dll: $(mllib) bin\FSharp.Core.dll bin\fsc.prep
       -cmd /c mkdir bin
       $(fscb) --light --public-keyfile fsharp\fs.pubkey $(fsc_defines) --compiling-mllib -a $(fsc_opts) --no-warn 42 --no-warn 60 -o $@ $(mllib)

fslex\fslexpars.ml: fslex\fslexpars.mly
       ..\bin\fsyacc -o fslex\fslexpars.ml --ml-compatibility -v fslex\fslexpars.mly

fslex\fslexlex.ml: fslex\fslexlex.mll
       ..\bin\fslex -o fslex\fslexlex.ml fslex\fslexlex.mll

fsyacc\fsyaccpars.ml: fsyacc\fsyaccpars.mly
       ..\bin\fsyacc -o fsyacc\fsyaccpars.ml --ml-compatibility -v fsyacc\fsyaccpars.mly

fsyacc\fsyacclex.ml: fsyacc\fsyacclex.mll
       ..\bin\fslex -o fsyacc\fsyacclex.ml fsyacc\fsyacclex.mll

bin\fslex.exe: $(fslex) bin\FSharp.Compatibility.dll bin\fsc.prep
       -cmd /c mkdir bin
       $(fscb) $(fsc_opts) -o $@ $(fsc_defines) $(fslex)

bin\fsyacc.exe: $(fsyacc) bin\FSharp.Compatibility.dll bin\fsc.prep
       -cmd /c mkdir bin
       $(fscb) $(fsc_opts) -o $@ $(fsc_defines) $(fsyacc)

bin\resxc.exe: $(resxc) bin\FSharp.Compatibility.dll bin\fsc.prep
       -cmd /c mkdir bin
       $(fscb) $(fsc_opts) -o $@ $(fsc_defines) $(resxc)

bin\FSharp.prep: bin\FSharp.Core.dll bin\FSharp.Compatibility.dll
       -cmd /c echo "Adding generated component DLLs to the GAC."
       gacutil /i bin\FSharp.Core.dll
       gacutil /i bin\FSharp.Compatibility.dll
       -cmd /c echo hello > bin\FSharp.prep

precompile:
       ngen install bin\FSharp.Core.dll
       ngen install bin\FSharp.Compatibility.dll
       ngen install bin\absil.dll
       ngen install bin\fsccore.dll
       ngen install bin\fscfront.dll
       ngen install bin\fscback.dll
       ngen install bin\fsc.exe
