f08c4f65a092a849e27284340b2b4e7ee8f8d4ec
[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 clean-local:
27         -rm -f *.exe $(BUILT_SOURCES) $(CLEAN_FILES) $(pdb) $(stampfile) $(makefrag)
28 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
29         -rm -f $(response)
30 endif
31
32 ifndef HAS_TEST
33 test-local: $(PROGRAM)
34
35 run-test-local:
36 endif
37
38 DISTFILES = $(sourcefile) $(EXTRA_DISTFILES)
39
40 dist-local: dist-default
41         for f in `cat $(sourcefile)` ; do \
42             dest=`dirname $(distdir)/$$f` ; \
43             $(MKINSTALLDIRS) $$dest && cp $$f $$dest || exit 1 ; \
44         done
45
46 # Changing makefile probably means changing the
47 # sources, so let's be safe and add a Makefile dep
48
49 $(PROGRAM): $(makefrag) $(response) $(stampfile)
50         $(CSCOMPILE) /target:exe /out:$@ $(BUILT_SOURCES) @$(response)
51
52 $(makefrag): $(sourcefile)
53         @echo Creating $@ ...
54         @echo "HAVE_MAKEFRAG = yes" >$@.new
55         @echo "$(stampfile): $(BUILT_SOURCES) \\" >>$@.new
56         @cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>$@.new
57         @cat $@.new |sed -e '$$s, \\$$,,' >$@
58         @$(ECHO_ESCAPE) "\ttouch \$$@" >>$@
59         @rm -rf $@.new
60
61 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
62 $(response): $(sourcefile)
63         @echo Creating $@ ...
64         @cat $< |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
65 endif
66
67 -include $(makefrag)
68
69 ifndef HAVE_MAKEFRAG
70 $(stampfile):
71         touch $@
72 endif
73