FIXME: toplevel Makefile: 'make ntest' doesn't run versaplexd for now.
[versaplex.git] / wvdotnet / monorules.mk
blobf42888eb305c6921ff9561d6082dde89bd888d20
1 default: all
3 SHELL=/bin/bash
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
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 else
17 CSC?=gmcs -langversion:linq
18 SYMLINK=ln -s
19 PKGS += /r:Mono.Posix
20 endif
22 CSFLAGS=/warn:4 /debug
23 #CSFLAGS += /warnaserror
25 TESTRUNNER=$(WVDOTNET)/wvtestrunner.pl
27 # Rules for generating autodependencies on header files
28 $(patsubst %.cs.E,%.d,$(filter %.cs.E,$(FILES))): %.d: %.cs
29 @echo Generating dependency file $@ for $<
30 @set -e; set -o pipefail; rm -f $@; (\
31 ($(CSCPP) -M -MM -MQ '$@' $(CPPFLAGS) $< && echo Makefile) \
32 | paste -s -d ' ' - && \
33 $(CSCPP) -M -MM -MQ '$<'.E $(CPPFLAGS) $< \
34 ) > $@ \
35 || (rm -f $@ && echo "Error generating dependency file." && exit 1)
37 include $(patsubst %.cs.E,%.d,$(filter %.cs.E,$(FILES)))
39 # Rule for actually preprocessing source files with headers
40 %.cs.E: %.cs
41 @rm -f $@
42 set -o pipefail; $(CSCPP) $(CPPFLAGS) -C -dI $< \
43 | expand -8 \
44 | sed -e 's,^#include,//#include,' \
45 | grep -v '^# [0-9]' \
46 >$@ || (rm -f $@ && exit 1)
49 define csbuild
50 @for d in $(filter ../%.dll,$^); do \
51 rm -f $$(basename $$d); \
52 $(SYMLINK) -v $$d .; \
53 done
54 $(CSC) $(CSFLAGS) /target:$1 /out:$@ \
55 $(PKGS) \
56 $(filter %.cs.E %.cs,$^) \
57 $(patsubst %.dll,/r:%.dll,$(filter %.dll,$^))
58 endef
61 %.dll: assemblyinfo.cs
62 $(call csbuild,library)
64 # This must come before the %.cs rule, since %.cs.E files are better.
65 %.exe: %.cs.E
66 $(call csbuild,exe)
68 %.exe: %.cs
69 $(call csbuild,exe)
71 %: %.exe
72 rm -f $@
73 $(SYMLINK) $< $@
75 %.pass: %.exe
76 rm -f $@
77 $(TESTRUNNER) mono --debug ./$^
78 touch $@
80 clean::
81 rm -f *~ *.E *.d *.exe *.dll *.mdb *.pdb