New build system from Peter Williams (peter@newton.cx)
[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 sourcefile = $(PROGRAM).sources
10 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
11 response = $(depsdir)/$(PROGRAM).response
12 else
13 response = $(sourcefile)
14 endif
15 stampfile = $(depsdir)/$(PROGRAM).stamp
16 makefrag = $(depsdir)/$(PROGRAM).makefrag
17
18 all-local: $(PROGRAM)
19
20 install-local:
21         $(MKINSTALLDIRS) $(DESTDIR)$(prefix)/bin
22         $(INSTALL_BIN) $(PROGRAM) $(DESTDIR)$(prefix)/bin
23
24 clean-local:
25         -rm -f *.exe $(BUILT_SOURCES) $(CLEAN_FILES) $(stampfile) $(makefrag)
26 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
27         -rm -f $(response)
28 endif
29
30 ifndef HAS_TEST
31 test-local: $(PROGRAM)
32
33 run-test-local:
34 endif
35
36 DISTFILES = $(sourcefile) $(EXTRA_DISTFILES)
37
38 dist-local: dist-default
39         cat $(sourcefile) |xargs -n 20 \
40             $(SHELL) -c 'for f in $$* ; do \
41                 dest=`dirname $(distdir)/$$f` ; \
42                 $(MKINSTALLDIRS) $$dest && cp $$f $$dest || exit 1 ; \
43             done' dollar0
44
45 # Changing makefile probably means changing the
46 # sources, so let's be safe and add a Makefile dep
47
48 $(PROGRAM): $(makefrag) $(response) $(stampfile)
49         $(CSCOMPILE) /target:exe /out:$@ $(BUILT_SOURCES) @$(response)
50
51 $(makefrag): $(sourcefile)
52         @echo Creating $@ ...
53         @echo "HAVE_MAKEFRAG = yes" >$@.new
54         @echo "$(stampfile): $(BUILT_SOURCES) \\" >>$@.new
55         @cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>$@.new
56         @cat $@.new |sed -e '$$s, \\$$,,' >$@
57         @echo -e "\ttouch \$$@" >>$@
58         @rm -rf $@.new
59
60 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
61 $(response): $(sourcefile)
62         cat $< |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
63 endif
64
65 -include $(makefrag)
66
67 ifndef HAVE_MAKEFRAG
68 $(stampfile):
69         touch $@
70 endif
71