2004-06-08 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
44 run-test-ondotnet-local:
45 endif
46
47 DISTFILES = $(sourcefile) $(EXTRA_DISTFILES)
48
49 dist-local: dist-default
50         for f in `cat $(sourcefile)` ; do \
51             dest=`dirname $(distdir)/$$f` ; \
52             $(MKINSTALLDIRS) $$dest && cp $$f $$dest || exit 1 ; \
53         done
54
55 # Changing makefile probably means changing the
56 # sources, so let's be safe and add a Makefile dep
57
58 ifndef PROGRAM_COMPILE
59 PROGRAM_COMPILE = $(CSCOMPILE)
60 endif
61
62 $(PROGRAM): $(makefrag) $(response) $(stampfile)
63         $(PROGRAM_COMPILE) /target:exe /out:$@ $(BUILT_SOURCES) @$(response)
64
65 # warning: embedded tab in the 'echo touch' line
66 $(makefrag): $(sourcefile)
67         @echo Creating $@ ...
68         @echo "HAVE_MAKEFRAG = yes" >$@.new
69         @echo "$(stampfile): $(BUILT_SOURCES) \\" >>$@.new
70         @cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>$@.new
71         @cat $@.new |sed -e '$$s, \\$$,,' >$@
72         @echo " touch \$$@" >>$@
73         @rm -rf $@.new
74
75 ifdef PLATFORM_CHANGE_SEPARATOR_CMD
76 $(response): $(sourcefile)
77         @echo Creating $@ ...
78         @cat $< |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
79 endif
80
81 -include $(makefrag)
82
83 ifndef HAVE_MAKEFRAG
84 $(stampfile):
85         touch $@
86 endif
87