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