2010-06-14 Atsushi Enomoto <atsushi@ximian.com>
[mcs.git] / build / executable.make
blob6030f5e48ee44b2068df8d92e5d1529cf7efde79
1 # -*- makefile -*-
3 # The rules for building a program.
5 base_prog = $(notdir $(PROGRAM))
6 prog_dir := $(filter-out . ./, $(dir $(PROGRAM)))
7 sourcefile = $(base_prog).sources
8 base_prog_config := $(wildcard $(base_prog).config.$(PROFILE))
9 ifndef base_prog_config
10 base_prog_config := $(wildcard $(base_prog).config)
11 endif
12 ifdef base_prog_config
13 PROGRAM_config := $(PROGRAM).config
14 endif
16 executable_CLEAN_FILES = *.exe $(PROGRAM) $(PROGRAM).mdb $(BUILT_SOURCES)
18 ifeq (cat,$(PLATFORM_CHANGE_SEPARATOR_CMD))
19 response = $(sourcefile)
20 else
21 response = $(depsdir)/$(base_prog).response
22 executable_CLEAN_FILES += $(response)
23 endif
25 ifdef KEEP_OUTPUT_FILE_COPY
26 COPY_CMD = cp
27 else
28 COPY_CMD = mv
29 endif
31 makefrag = $(depsdir)/$(PROFILE)_$(base_prog).makefrag
32 pdb = $(patsubst %.exe,%.pdb,$(PROGRAM))
33 mdb = $(patsubst %.exe,%.mdb,$(PROGRAM))
34 executable_CLEAN_FILES += $(makefrag) $(pdb) $(mdb)
36 all-local: $(PROGRAM) $(PROGRAM_config)
38 install-local: all-local
39 test-local: all-local
40 uninstall-local:
42 ifdef NO_INSTALL
43 install-local uninstall-local:
45 else
47 ifndef PROGRAM_INSTALL_DIR
48 PROGRAM_INSTALL_DIR = $(mono_libdir)/mono/$(FRAMEWORK_VERSION)
49 endif
51 install-local: $(PROGRAM) $(PROGRAM_config)
52 $(MKINSTALLDIRS) $(DESTDIR)$(PROGRAM_INSTALL_DIR)
53 $(INSTALL_BIN) $(PROGRAM) $(DESTDIR)$(PROGRAM_INSTALL_DIR)
54 test ! -f $(PROGRAM).mdb || $(INSTALL_BIN) $(PROGRAM).mdb $(DESTDIR)$(PROGRAM_INSTALL_DIR)
55 ifdef PROGRAM_config
56 $(INSTALL_DATA) $(PROGRAM_config) $(DESTDIR)$(PROGRAM_INSTALL_DIR)
57 endif
58 ifdef PLATFORM_AOT_SUFFIX
59 test ! -f $(PROGRAM)$(PLATFORM_AOT_SUFFIX) || $(INSTALL_LIB) $(PROGRAM)$(PLATFORM_AOT_SUFFIX) $(DESTDIR)$(PROGRAM_INSTALL_DIR)
60 endif
62 uninstall-local:
63 -rm -f $(DESTDIR)$(PROGRAM_INSTALL_DIR)/$(base_prog) $(DESTDIR)$(PROGRAM_INSTALL_DIR)/$(base_prog).mdb $(DESTDIR)$(PROGRAM_INSTALL_DIR)/$(base_prog).config
64 endif
66 clean-local:
67 -rm -f $(executable_CLEAN_FILES) $(CLEAN_FILES) $(tests_CLEAN_FILES)
69 test-local:
71 run-test-local:
73 run-test-ondotnet-local:
76 DISTFILES = $(sourcefile) $(base_prog_config) $(EXTRA_DISTFILES)
78 ifdef HAS_NUNIT_TEST
79 ASSEMBLY = $(PROGRAM)
80 ASSEMBLY_EXT = .exe
81 the_assembly = $(PROGRAM)
82 include $(topdir)/build/tests.make
83 endif
85 ifdef HAVE_CS_TESTS
86 DISTFILES += $(test_sourcefile)
87 endif
89 dist-local: dist-default
90 for f in `cat $(sourcefile)` ; do \
91 case $$f in \
92 ../*) : ;; \
93 *) dest=`dirname "$$f"` ; \
94 case $$subs in *" $$dest "*) : ;; *) subs=" $$dest$$subs" ; $(MKINSTALLDIRS) $(distdir)/$$dest ;; esac ; \
95 cp -p "$$f" $(distdir)/$$dest || exit 1 ;; \
96 esac ; done ; \
97 for d in . $$subs ; do \
98 case $$d in .) : ;; *) test ! -f $$d/ChangeLog || cp -p $$d/ChangeLog $(distdir)/$$d ;; esac ; done
100 ifndef PROGRAM_COMPILE
101 PROGRAM_COMPILE = $(CSCOMPILE)
102 endif
104 $(PROGRAM): $(BUILT_SOURCES) $(EXTRA_SOURCES) $(response) $(prog_dir:=/.stamp)
105 $(PROGRAM_COMPILE) -target:exe -out:$(base_prog) $(BUILT_SOURCES) $(EXTRA_SOURCES) @$(response)
106 ifneq ($(base_prog),$(PROGRAM))
107 $(COPY_CMD) $(base_prog) $(PROGRAM)
108 test ! -f $(base_prog).mdb || $(COPY_CMD) $(base_prog).mdb $(PROGRAM).mdb
109 endif
111 ifdef PROGRAM_config
112 ifneq ($(base_prog_config),$(PROGRAM_config))
113 executable_CLEAN_FILES += $(PROGRAM_config)
114 $(PROGRAM_config): $(base_prog_config) $(dir $(PROGRAM_config))/.stamp
115 cp $(base_prog_config) $(PROGRAM_config)
116 endif
117 endif
119 $(makefrag): $(sourcefile)
120 @echo Creating $@ ...
121 @sed 's,^,$(PROGRAM): ,' $< > $@
123 ifneq ($(response),$(sourcefile))
124 $(response): $(sourcefile)
125 @echo Creating $@ ...
126 @( $(PLATFORM_CHANGE_SEPARATOR_CMD) ) <$< >$@
127 endif
129 -include $(makefrag)
131 all-local: $(makefrag) $(extra_targets)
133 csproj-local:
134 config_file=`basename $(PROGRAM) .exe`-$(PROFILE).input; \
135 echo $(thisdir):$$config_file >> $(topdir)/../mono/msvc/scripts/order; \
136 (echo $(is_boot); \
137 echo $(MCS); \
138 echo $(USE_MCS_FLAGS) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS); \
139 echo $(PROGRAM); \
140 echo $(BUILT_SOURCES_cmdline); \
141 echo $(build_lib); \
142 echo $(response)) > $(topdir)/../mono/msvc/scripts/inputs/$$config_file
145 ifneq ($(response),$(sourcefile))
146 $(response): $(topdir)/build/executable.make $(depsdir)/.stamp
147 endif
148 $(makefrag): $(topdir)/build/executable.make $(depsdir)/.stamp
150 doc-update-local: