* library.make: Fix uninstall
[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)/$(PROFILE)_$(LIBRARY).response
14 else
15 response = $(sourcefile)
16 endif
17 makefrag = $(depsdir)/$(PROFILE)_$(LIBRARY).makefrag
18 stampfile = $(depsdir)/$(PROFILE)_$(LIBRARY).stamp
19 the_lib = $(topdir)/class/lib/$(PROFILE)/$(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)/$(PROFILE)_$(test_lib).response
27 test_makefrag = $(depsdir)/$(PROFILE)_$(test_lib).makefrag
28 test_stampfile = $(depsdir)/$(PROFILE)_$(test_lib).stamp
29 test_flags = /r:$(the_lib) /r:$(topdir)/class/lib/$(PROFILE)/NUnit.Framework.dll $(TEST_MCS_FLAGS)
30 endif
31
32 gacutil = $(topdir)/tools/gacutil/gacutil.exe
33
34 all-local: $(the_lib)
35
36 install-local: $(the_lib) $(gacutil)
37         @if test -f Assembly/AssemblyInfo.cs ; then \
38                 $(RUNTIME)  $(gacutil) /i $(the_lib) /f || exit 1 ; \
39         else \
40                 $(MKINSTALLDIRS) $(DESTDIR)$(prefix)/lib ; \
41                 $(INSTALL_LIB) $(the_lib) $(DESTDIR)$(prefix)/lib ; \
42         fi
43
44 uninstall-local: $(gacutil)
45         @if test -f Assembly/AssemblyInfo.cs ; then \
46                 $(RUNTIME)  $(gacutil) /u $$(basename $(the_lib) .dll) ; \
47         else \
48                 -rm -f $(DESTDIR)$(prefix)/lib/$(LIBRARY) ; \
49         fi
50
51 $(gacutil):
52         cd $(topdir)/tools/gacutil && $(MAKE) || exit 1 ;
53
54 clean-local:
55         -rm -f $(the_lib) $(makefrag) $(test_lib) \
56                $(test_makefrag) $(test_response) \
57                $(stampfile) $(test_stampfile) \
58                $(the_pdb) $(test_pdb) \
59                TestResult.xml
60 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
61         -rm -rf $(response)
62 endif
63
64 ifndef NO_TEST
65 test-local: $(the_lib) $(test_lib)
66
67 run-test-local:
68         $(TEST_RUNTIME) $(TEST_HARNESS) $(test_lib)
69
70 else
71 test-local: $(the_lib)
72
73 run-test-local:
74 endif
75
76 DISTFILES = $(sourcefile) $(test_sourcefile) $(EXTRA_DISTFILES)
77
78 ifdef NO_TEST
79 TEST_FILES = 
80 else
81 TEST_FILES = `cat $(test_sourcefile) |sed -e 's,^\(.\),Test/\1,'`
82 endif
83
84 dist-local: dist-default
85         for f in `cat $(sourcefile)` $(TEST_FILES) ; do \
86             dest=`dirname $(distdir)/$$f` ; \
87             $(MKINSTALLDIRS) $$dest && cp $$f $$dest || exit 1 ; \
88         done
89
90 # Fun with dependency tracking
91
92 $(the_lib): $(makefrag) $(stampfile) $(response)
93         $(CSCOMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) /target:library /out:$@ @$(response)
94
95 # warning: embedded tab in the 'echo touch' line
96 $(makefrag): $(sourcefile)
97         @echo Creating $@ ...
98         @echo "HAVE_MAKEFRAG = yes" >$@.new
99         @echo "$(stampfile): \\" >>$@.new
100         @cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>$@.new
101         @cat $@.new |sed -e '$$s, \\$$,,' >$@
102         @echo " touch \$$@" >>$@
103         @rm -rf $@.new
104
105 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
106 $(response): $(sourcefile)
107         @echo Creating $@ ...
108         @cat $< |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
109 endif
110
111 -include $(makefrag)
112
113 ifndef HAVE_MAKEFRAG
114 $(stampfile):
115         touch $@
116 endif
117
118 # for now, don't give any /lib flags or set MONO_PATH, since we
119 # give a full path to the assembly.
120
121 ifndef NO_TEST
122 $(test_lib): $(test_makefrag) $(the_lib) $(test_response) $(test_stampfile)
123         $(CSCOMPILE) /target:library /out:$@ $(test_flags) @$(test_response)
124
125 $(test_response): $(test_sourcefile)
126         @echo Creating $@ ...
127 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
128         @cat $< |sed -e 's,^\(.\),Test/\1,' |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
129 else
130         @cat $< |sed -e 's,^\(.\),Test/\1,' >$@
131 endif
132
133 # warning: embedded tab in the 'echo touch' line
134 $(test_makefrag): $(test_response)
135         @echo Creating $@ ...
136         @echo "HAVE_TEST_MAKEFRAG = yes" >$@.new
137         @echo "$(test_stampfile): \\" >>$@.new
138         @cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>$@.new
139         @cat $@.new |sed -e '$$s, \\$$,,' >$@
140         @echo " touch \$$@" >>$@
141         @rm -rf $@.new
142
143 -include $(test_makefrag)
144 endif
145
146 ifndef HAVE_TEST_MAKEFRAG
147 $(test_stampfile):
148         touch $@
149 endif
150