2004-06-08 Sebastien Pouliot <sebastien@ximian.com>
[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_nunitcore = $(topdir)/class/lib/$(PROFILE)/nunit.core.dll 
36 test_nunitutil = $(topdir)/class/lib/$(PROFILE)/nunit.util.dll 
37 test_nunit_ref = -r:$(test_nunitfw) -r:$(test_nunitcore) -r:$(test_nunitutil)
38 test_flags = /r:$(the_lib) $(test_nunit_ref) $(TEST_MCS_FLAGS)
39 endif
40
41 gacutil = $(topdir)/tools/gacutil/gacutil.exe
42
43 PACKAGE = 1.0
44
45 ifeq ($(PROFILE), net_2_0)
46 PACKAGE = 2.0
47 endif
48
49 all-local: $(the_lib)
50
51 install-local: $(the_lib) $(gacutil)
52         $(RUNTIME)  $(gacutil) /i $(the_lib) /f /root $(DESTDIR)$(prefix)/lib /package $(PACKAGE)
53
54 uninstall-local: $(gacutil)
55         $(RUNTIME)  $(gacutil) /u $$(basename $(the_lib) .dll) ; \
56
57 $(gacutil):
58         cd $(topdir)/tools/gacutil && $(MAKE) || exit 1 ;
59
60 clean-local:
61         -rm -f $(the_lib) $(makefrag) $(test_lib) \
62                $(test_makefrag) $(test_response) \
63                $(stampfile) $(test_stampfile) \
64                $(the_pdb) $(test_pdb) $(CLEAN_FILES) \
65                TestResult.xml
66 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
67         -rm -rf $(response)
68 endif
69
70 ifndef NO_TEST
71 $(test_nunitfw):
72         (cd ${topdir}/nunit20 && make)
73
74 test-local: $(test_nunitfw) $(the_lib) $(test_lib)
75
76 run-test-local: run-test-lib
77
78 run-test-lib: test-local
79         $(TEST_RUNTIME) $(TEST_HARNESS) $(test_lib)
80
81 run-test-ondotnet-local: run-test-ondotnet-lib
82
83 run-test-ondotnet-lib: test-local
84         $(TEST_HARNESS) $(test_lib)
85
86 else
87 test-local: $(the_lib)
88
89 run-test-local:
90 run-test-ondotnet-local:
91 endif
92
93 DISTFILES = $(sourcefile) $(test_sourcefile) $(EXTRA_DISTFILES)
94
95 ifdef NO_TEST
96 TEST_FILES = 
97 else
98 TEST_FILES = `cat $(test_sourcefile) |sed -e 's,^\(.\),Test/\1,'`
99 endif
100
101 dist-local: dist-default
102         for f in `cat $(sourcefile)` $(TEST_FILES) ; do \
103             dest=`dirname $(distdir)/$$f` ; \
104             $(MKINSTALLDIRS) $$dest && cp $$f $$dest || exit 1 ; \
105         done
106
107 ifndef LIBRARY_COMPILE
108 LIBRARY_COMPILE = $(CSCOMPILE)
109 endif
110
111 # Fun with dependency tracking
112
113 $(the_lib): $(makefrag) $(stampfile) $(response)
114         $(LIBRARY_COMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) /target:library /out:$@ @$(response)
115
116 # warning: embedded tab in the 'echo touch' line
117 $(makefrag): $(sourcefile)
118         @echo Creating $@ ...
119         @echo "HAVE_MAKEFRAG = yes" >$@.new
120         @echo "$(stampfile): \\" >>$@.new
121         @cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>$@.new
122         @cat $@.new |sed -e '$$s, \\$$,,' >$@
123         @echo " touch \$$@" >>$@
124         @rm -rf $@.new
125
126 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
127 $(response): $(sourcefile)
128         @echo Creating $@ ...
129         @cat $< |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
130 endif
131
132 -include $(makefrag)
133
134 ifndef HAVE_MAKEFRAG
135 $(stampfile):
136         touch $@
137 endif
138
139 # for now, don't give any /lib flags or set MONO_PATH, since we
140 # give a full path to the assembly.
141
142 ifndef NO_TEST
143 $(test_lib): $(test_makefrag) $(the_lib) $(test_response) $(test_stampfile)
144         $(CSCOMPILE) /target:library /out:$@ $(test_flags) @$(test_response)
145
146 $(test_response): $(test_sourcefile)
147         @echo Creating $@ ...
148 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
149         @cat $< |sed -e 's,^\(.\),Test/\1,' |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
150 else
151         @cat $< |sed -e 's,^\(.\),Test/\1,' >$@
152 endif
153
154 # warning: embedded tab in the 'echo touch' line
155 $(test_makefrag): $(test_response)
156         @echo Creating $@ ...
157         @echo "HAVE_TEST_MAKEFRAG = yes" >$@.new
158         @echo "$(test_stampfile): \\" >>$@.new
159         @cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>$@.new
160         @cat $@.new |sed -e '$$s, \\$$,,' >$@
161         @echo " touch \$$@" >>$@
162         @rm -rf $@.new
163
164 -include $(test_makefrag)
165 endif
166
167 ifndef HAVE_TEST_MAKEFRAG
168 $(test_stampfile):
169         touch $@
170 endif
171