]> rtime.felk.cvut.cz Git - wvtest.git/blob - dotnet/monorules.mk
Import latest wvtest for C#/.NET from versaplex project.
[wvtest.git] / dotnet / monorules.mk
1 default: all
2
3 SHELL=/bin/bash
4
5 # cc -E tries to guess by extension what to do with the file.
6 # And it does other weird things. cpp seems to Just Work(tm), so use that for
7 # our C# (.cs) files
8 CSCPP=cpp
9
10 # Cygwin supports symlinks, but they aren't actually useful outside cygwin,
11 # so let's just copy instead.  We also use Microsoft's .net compiler instead
12 # of mono.
13 ifeq ($(OS),Windows_NT)
14   CSC?=csc
15   SYMLINK=cp
16   MONORUN=
17 else
18   CSC?=gmcs -langversion:linq
19   SYMLINK=ln -sf
20   PKGS += /r:Mono.Posix
21   MONORUN=mono --debug
22 endif
23
24 CSFLAGS=/warn:4 /debug
25 #CSFLAGS += /warnaserror
26
27 TESTRUNNER=$(WVDOTNET)/wvtestrunner.pl
28
29 # Rules for generating autodependencies on header files
30 $(patsubst %.cs.E,%.d,$(filter %.cs.E,$(FILES))): %.d: %.cs
31         @echo Generating dependency file $@ for $<
32         @set -e; set -o pipefail; rm -f $@; (\
33             ($(CSCPP) -M -MM -MQ '$@' $(CPPFLAGS) $< && echo Makefile) \
34                 | paste -s -d ' ' - && \
35             $(CSCPP) -M -MM -MQ '$<'.E $(CPPFLAGS) $< \
36         ) > $@ \
37         || (rm -f $@ && echo "Error generating dependency file." && exit 1)
38
39 include $(patsubst %.cs.E,%.d,$(filter %.cs.E,$(FILES)))
40
41 # Rule for actually preprocessing source files with headers
42 %.cs.E: %.cs
43         @rm -f $@
44         set -o pipefail; $(CSCPP) $(CPPFLAGS) -C -dI $< \
45                 | expand -8 \
46                 | sed -e 's,^#include,//#include,' \
47                 | grep -v '^# [0-9]' \
48                 >$@ || (rm -f $@ && exit 1)
49
50
51 define csbuild
52         @for d in $(filter ../%.dll,$^); do \
53                 rm -f $$(basename $$d); \
54                 $(SYMLINK) -v $$d .; \
55         done
56         $(CSC) $(CSFLAGS) /target:$1 /out:$@ \
57                 $(PKGS) \
58                 $(filter %.cs.E %.cs,$^) \
59                 $(patsubst %.dll,/r:%.dll,$(filter %.dll,$^))
60 endef
61
62
63 %.dll: assemblyinfo.cs
64         $(call csbuild,library)
65
66 # This must come before the %.cs rule, since %.cs.E files are better.
67 %.exe: %.cs.E
68         $(call csbuild,exe)
69
70 %.exe: %.cs
71         $(call csbuild,exe)
72
73 %: %.exe
74         rm -f $@
75         $(SYMLINK) $< $@
76
77 %.pass: %.exe
78         rm -f $@
79         $(TESTRUNNER) $(MONORUN) ./$^
80         touch $@
81
82 clean::
83         rm -f *~ *.E *.d *.exe *.dll *.mdb *.pdb