2003-09-16 Ben Maurer <bmaurer@users.sourceforge.net>
[mono.git] / mcs / build / library.make
1 # -*- makefile -*-
2 #
3 # The rules for building our class libraries.
4 #
5 # The NO_TEST stuff is not too pleasant but whatcha
6 # gonna do.
7
8 # All the dep files now land in the same directory so we
9 # munge in the library name to keep the files from clashing.
10
11 sourcefile = $(LIBRARY).sources
12 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
13 response = $(depsdir)/$(LIBRARY).response
14 else
15 response = $(sourcefile)
16 endif
17 makefrag = $(depsdir)/$(LIBRARY).makefrag
18 stampfile = $(depsdir)/$(LIBRARY).stamp
19 the_lib = $(topdir)/class/lib/$(LIBRARY)
20 the_pdb = $(patsubst %.dll,%.pdb,$(the_lib))
21
22 ifndef NO_TEST
23 test_lib = $(patsubst %.dll,%_test.dll,$(LIBRARY))
24 test_pdb = $(patsubst %.dll,%.pdb,$(test_lib))
25 test_sourcefile = $(test_lib).sources
26 test_response = $(depsdir)/$(test_lib).response
27 test_makefrag = $(depsdir)/$(test_lib).makefrag
28 test_stampfile = $(depsdir)/$(test_lib).stamp
29 test_flags = /r:$(the_lib) /r:$(topdir)/class/lib/NUnit.Framework.dll $(TEST_MCS_FLAGS)
30 endif
31
32 all-local: $(the_lib)
33
34 install-local: $(the_lib)
35         $(MKINSTALLDIRS) $(DESTDIR)$(prefix)/lib
36         $(INSTALL_LIB) $(the_lib) $(DESTDIR)$(prefix)/lib
37
38 clean-local:
39         -rm -f $(the_lib) $(makefrag) $(test_lib) \
40                $(test_makefrag) $(test_response) \
41                $(stampfile) $(test_stampfile) \
42                $(the_pdb) $(test_pdb) \
43                TestResult.xml
44 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
45         -rm -rf $(response)
46 endif
47
48 ifndef NO_TEST
49 test-local: $(the_lib) $(test_lib)
50
51 run-test-local:
52         $(TEST_RUNTIME) $(TEST_HARNESS) $(test_lib)
53
54 else
55 test-local: $(the_lib)
56
57 run-test-local:
58 endif
59
60 DISTFILES = $(sourcefile) $(test_sourcefile) $(EXTRA_DISTFILES)
61
62 ifdef NO_TEST
63 TEST_FILES = 
64 else
65 TEST_FILES = `cat $(test_sourcefile) |sed -e 's,^\(.\),Test/\1,'`
66 endif
67
68 dist-local: dist-default
69         for f in `cat $(sourcefile)` $(TEST_FILES) ; do \
70             dest=`dirname $(distdir)/$$f` ; \
71             $(MKINSTALLDIRS) $$dest && cp $$f $$dest || exit 1 ; \
72         done
73
74 # Fun with dependency tracking
75
76 $(the_lib): $(makefrag) $(stampfile) $(response)
77         $(CSCOMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) /target:library /out:$@ @$(response)
78
79 $(makefrag): $(sourcefile)
80         @echo Creating $@ ...
81         @echo "HAVE_MAKEFRAG = yes" >$@.new
82         @echo "$(stampfile): \\" >>$@.new
83         @cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>$@.new
84         @cat $@.new |sed -e '$$s, \\$$,,' >$@
85         @$(ECHO_ESCAPE) "\ttouch \$$@" >>$@
86         @rm -rf $@.new
87
88 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
89 $(response): $(sourcefile)
90         @echo Creating $@ ...
91         @cat $< |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
92 endif
93
94 -include $(makefrag)
95
96 ifndef HAVE_MAKEFRAG
97 $(stampfile):
98         touch $@
99 endif
100
101 # for now, don't give any /lib flags or set MONO_PATH, since we
102 # give a full path to the assembly.
103
104 ifndef NO_TEST
105 $(test_lib): $(test_makefrag) $(the_lib) $(test_response) $(test_stampfile)
106         $(CSCOMPILE) /target:library /out:$@ $(test_flags) @$(test_response)
107
108 $(test_response): $(test_sourcefile)
109         @echo Creating $@ ...
110 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
111         @cat $< |sed -e 's,^\(.\),Test/\1,' |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
112 else
113         @cat $< |sed -e 's,^\(.\),Test/\1,' >$@
114 endif
115
116 $(test_makefrag): $(test_response)
117         @echo Creating $@ ...
118         @echo "HAVE_TEST_MAKEFRAG = yes" >$@.new
119         @echo "$(test_stampfile): \\" >>$@.new
120         @cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>$@.new
121         @cat $@.new |sed -e '$$s, \\$$,,' >$@
122         @$(ECHO_ESCAPE) "\ttouch \$$@" >>$@
123         @rm -rf $@.new
124
125 -include $(test_makefrag)
126 endif
127
128 ifndef HAVE_TEST_MAKEFRAG
129 $(test_stampfile):
130         touch $@
131 endif
132