2004-05-27 Atsushi Enomoto <atsushi@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 = 1.1
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 1.0 
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 else
82 test-local: $(the_lib)
83
84 run-test-local:
85 endif
86
87 DISTFILES = $(sourcefile) $(test_sourcefile) $(EXTRA_DISTFILES)
88
89 ifdef NO_TEST
90 TEST_FILES = 
91 else
92 TEST_FILES = `cat $(test_sourcefile) |sed -e 's,^\(.\),Test/\1,'`
93 endif
94
95 dist-local: dist-default
96         for f in `cat $(sourcefile)` $(TEST_FILES) ; do \
97             dest=`dirname $(distdir)/$$f` ; \
98             $(MKINSTALLDIRS) $$dest && cp $$f $$dest || exit 1 ; \
99         done
100
101 ifndef LIBRARY_COMPILE
102 LIBRARY_COMPILE = $(CSCOMPILE)
103 endif
104
105 # Fun with dependency tracking
106
107 $(the_lib): $(makefrag) $(stampfile) $(response)
108         $(LIBRARY_COMPILE) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) /target:library /out:$@ @$(response)
109
110 # warning: embedded tab in the 'echo touch' line
111 $(makefrag): $(sourcefile)
112         @echo Creating $@ ...
113         @echo "HAVE_MAKEFRAG = yes" >$@.new
114         @echo "$(stampfile): \\" >>$@.new
115         @cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>$@.new
116         @cat $@.new |sed -e '$$s, \\$$,,' >$@
117         @echo " touch \$$@" >>$@
118         @rm -rf $@.new
119
120 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
121 $(response): $(sourcefile)
122         @echo Creating $@ ...
123         @cat $< |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
124 endif
125
126 -include $(makefrag)
127
128 ifndef HAVE_MAKEFRAG
129 $(stampfile):
130         touch $@
131 endif
132
133 # for now, don't give any /lib flags or set MONO_PATH, since we
134 # give a full path to the assembly.
135
136 ifndef NO_TEST
137 $(test_lib): $(test_makefrag) $(the_lib) $(test_response) $(test_stampfile)
138         $(CSCOMPILE) /target:library /out:$@ $(test_flags) @$(test_response)
139
140 $(test_response): $(test_sourcefile)
141         @echo Creating $@ ...
142 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
143         @cat $< |sed -e 's,^\(.\),Test/\1,' |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
144 else
145         @cat $< |sed -e 's,^\(.\),Test/\1,' >$@
146 endif
147
148 # warning: embedded tab in the 'echo touch' line
149 $(test_makefrag): $(test_response)
150         @echo Creating $@ ...
151         @echo "HAVE_TEST_MAKEFRAG = yes" >$@.new
152         @echo "$(test_stampfile): \\" >>$@.new
153         @cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>$@.new
154         @cat $@.new |sed -e '$$s, \\$$,,' >$@
155         @echo " touch \$$@" >>$@
156         @rm -rf $@.new
157
158 -include $(test_makefrag)
159 endif
160
161 ifndef HAVE_TEST_MAKEFRAG
162 $(test_stampfile):
163         touch $@
164 endif
165