Added uninstall target
[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 uninstall-local:
39         -rm -f $(DESTDIR)$(prefix)/lib/$(LIBRARY)
40
41 clean-local:
42         -rm -f $(the_lib) $(makefrag) $(test_lib) \
43                $(test_makefrag) $(test_response) \
44                $(stampfile) $(test_stampfile) \
45                $(the_pdb) $(test_pdb) \
46                TestResult.xml
47 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
48         -rm -rf $(response)
49 endif
50
51 ifndef NO_TEST
52 test-local: $(the_lib) $(test_lib)
53
54 run-test-local:
55         $(TEST_RUNTIME) $(TEST_HARNESS) $(test_lib)
56
57 else
58 test-local: $(the_lib)
59
60 run-test-local:
61 endif
62
63 DISTFILES = $(sourcefile) $(test_sourcefile) $(EXTRA_DISTFILES)
64
65 ifdef NO_TEST
66 TEST_FILES = 
67 else
68 TEST_FILES = `cat $(test_sourcefile) |sed -e 's,^\(.\),Test/\1,'`
69 endif
70
71 dist-local: dist-default
72         for f in `cat $(sourcefile)` $(TEST_FILES) ; do \
73             dest=`dirname $(distdir)/$$f` ; \
74             $(MKINSTALLDIRS) $$dest && cp $$f $$dest || exit 1 ; \
75         done
76
77 # Fun with dependency tracking
78
79 $(the_lib): $(makefrag) $(stampfile) $(response)
80         $(CSCOMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) /target:library /out:$@ @$(response)
81
82 $(makefrag): $(sourcefile)
83         @echo Creating $@ ...
84         @echo "HAVE_MAKEFRAG = yes" >$@.new
85         @echo "$(stampfile): \\" >>$@.new
86         @cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>$@.new
87         @cat $@.new |sed -e '$$s, \\$$,,' >$@
88         @$(ECHO_ESCAPE) "\ttouch \$$@" >>$@
89         @rm -rf $@.new
90
91 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
92 $(response): $(sourcefile)
93         @echo Creating $@ ...
94         @cat $< |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
95 endif
96
97 -include $(makefrag)
98
99 ifndef HAVE_MAKEFRAG
100 $(stampfile):
101         touch $@
102 endif
103
104 # for now, don't give any /lib flags or set MONO_PATH, since we
105 # give a full path to the assembly.
106
107 ifndef NO_TEST
108 $(test_lib): $(test_makefrag) $(the_lib) $(test_response) $(test_stampfile)
109         $(CSCOMPILE) /target:library /out:$@ $(test_flags) @$(test_response)
110
111 $(test_response): $(test_sourcefile)
112         @echo Creating $@ ...
113 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
114         @cat $< |sed -e 's,^\(.\),Test/\1,' |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
115 else
116         @cat $< |sed -e 's,^\(.\),Test/\1,' >$@
117 endif
118
119 $(test_makefrag): $(test_response)
120         @echo Creating $@ ...
121         @echo "HAVE_TEST_MAKEFRAG = yes" >$@.new
122         @echo "$(test_stampfile): \\" >>$@.new
123         @cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>$@.new
124         @cat $@.new |sed -e '$$s, \\$$,,' >$@
125         @$(ECHO_ESCAPE) "\ttouch \$$@" >>$@
126         @rm -rf $@.new
127
128 -include $(test_makefrag)
129 endif
130
131 ifndef HAVE_TEST_MAKEFRAG
132 $(test_stampfile):
133         touch $@
134 endif
135