2003-12-16 Gonzalo Paniagua Javier <gonzalo@ximian.com>
[mono.git] / mcs / build / executable.make
1 # -*- makefile -*-
2 #
3 # The rules for building a program.
4
5 # I'd rather not create a response file here,
6 # but since on Win32 we need to munge the paths
7 # anyway, we might as well.
8
9 base_prog = $(shell basename $(PROGRAM))
10 sourcefile = $(base_prog).sources
11 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
12 response = $(depsdir)/$(base_prog).response
13 else
14 response = $(sourcefile)
15 endif
16 stampfile = $(depsdir)/$(base_prog).stamp
17 makefrag = $(depsdir)/$(base_prog).makefrag
18 pdb = $(patsubst %.exe,%.pdb,$(PROGRAM))
19
20 all-local: $(PROGRAM)
21
22 install-local: $(PROGRAM)
23         $(MKINSTALLDIRS) $(DESTDIR)$(prefix)/bin
24         $(INSTALL_BIN) $(PROGRAM) $(DESTDIR)$(prefix)/bin
25
26 uninstall-local:
27         -rm -f $(DESTDIR)$(prefix)/bin/$(base_prog)
28
29 clean-local:
30         -rm -f *.exe $(BUILT_SOURCES) $(CLEAN_FILES) $(pdb) $(stampfile) $(makefrag)
31 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
32         -rm -f $(response)
33 endif
34
35 ifndef HAS_TEST
36 test-local: $(PROGRAM)
37
38 run-test-local:
39 endif
40
41 DISTFILES = $(sourcefile) $(EXTRA_DISTFILES)
42
43 dist-local: dist-default
44         for f in `cat $(sourcefile)` ; do \
45             dest=`dirname $(distdir)/$$f` ; \
46             $(MKINSTALLDIRS) $$dest && cp $$f $$dest || exit 1 ; \
47         done
48
49 # Changing makefile probably means changing the
50 # sources, so let's be safe and add a Makefile dep
51
52 $(PROGRAM): $(makefrag) $(response) $(stampfile)
53         $(CSCOMPILE) /target:exe /out:$@ $(BUILT_SOURCES) @$(response)
54
55 # warning: embedded tab in the 'echo touch' line
56 $(makefrag): $(sourcefile)
57         @echo Creating $@ ...
58         @echo "HAVE_MAKEFRAG = yes" >$@.new
59         @echo "$(stampfile): $(BUILT_SOURCES) \\" >>$@.new
60         @cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>$@.new
61         @cat $@.new |sed -e '$$s, \\$$,,' >$@
62         @echo " touch \$$@" >>$@
63         @rm -rf $@.new
64
65 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
66 $(response): $(sourcefile)
67         @echo Creating $@ ...
68         @cat $< |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
69 endif
70
71 -include $(makefrag)
72
73 ifndef HAVE_MAKEFRAG
74 $(stampfile):
75         touch $@
76 endif
77