2004-05-27 Atsushi Enomoto <atsushi@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 ifndef PROGRAM_INSTALL_DIR
21 PROGRAM_INSTALL_DIR = $(prefix)/bin
22 endif
23
24 all-local: $(PROGRAM)
25
26 install-local: $(PROGRAM)
27         $(MKINSTALLDIRS) $(DESTDIR)$(PROGRAM_INSTALL_DIR)
28         $(INSTALL_BIN) $(PROGRAM) $(DESTDIR)$(PROGRAM_INSTALL_DIR)
29
30 uninstall-local:
31         -rm -f $(DESTDIR)$(PROGRAM_INSTALL_DIR)/$(base_prog)
32
33 clean-local:
34         -rm -f *.exe $(BUILT_SOURCES) $(CLEAN_FILES) $(pdb) $(stampfile) $(makefrag)
35 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
36         -rm -f $(response)
37 endif
38
39 ifndef HAS_TEST
40 test-local: $(PROGRAM)
41
42 run-test-local:
43 endif
44
45 DISTFILES = $(sourcefile) $(EXTRA_DISTFILES)
46
47 dist-local: dist-default
48         for f in `cat $(sourcefile)` ; do \
49             dest=`dirname $(distdir)/$$f` ; \
50             $(MKINSTALLDIRS) $$dest && cp $$f $$dest || exit 1 ; \
51         done
52
53 # Changing makefile probably means changing the
54 # sources, so let's be safe and add a Makefile dep
55
56 ifndef PROGRAM_COMPILE
57 PROGRAM_COMPILE = $(CSCOMPILE)
58 endif
59
60 $(PROGRAM): $(makefrag) $(response) $(stampfile)
61         $(PROGRAM_COMPILE) /target:exe /out:$@ $(BUILT_SOURCES) @$(response)
62
63 # warning: embedded tab in the 'echo touch' line
64 $(makefrag): $(sourcefile)
65         @echo Creating $@ ...
66         @echo "HAVE_MAKEFRAG = yes" >$@.new
67         @echo "$(stampfile): $(BUILT_SOURCES) \\" >>$@.new
68         @cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>$@.new
69         @cat $@.new |sed -e '$$s, \\$$,,' >$@
70         @echo " touch \$$@" >>$@
71         @rm -rf $@.new
72
73 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
74 $(response): $(sourcefile)
75         @echo Creating $@ ...
76         @cat $< |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
77 endif
78
79 -include $(makefrag)
80
81 ifndef HAVE_MAKEFRAG
82 $(stampfile):
83         touch $@
84 endif
85