Merge pull request #2046 from rolfbjarne/profile-simplification
[mono.git] / mcs / build / executable.make
1 # -*- makefile -*-
2 #
3 # The rules for building a program.
4
5 base_prog = $(notdir $(PROGRAM))
6 ifndef sourcefile
7 sourcefile := $(base_prog).sources
8 endif
9 base_prog_config := $(wildcard $(base_prog).config.$(PROFILE))
10 ifndef base_prog_config
11 base_prog_config := $(wildcard $(base_prog).config)
12 endif
13
14 ifeq (cat,$(PLATFORM_CHANGE_SEPARATOR_CMD))
15 response = $(sourcefile)
16 else
17 response = $(depsdir)/$(sourcefile).response
18 executable_CLEAN_FILES += $(response)
19 endif
20
21 ifndef the_libdir
22 the_libdir = $(topdir)/class/lib/$(PROFILE)/
23 ifdef PROGRAM_USE_INTERMEDIATE_FILE
24 build_libdir = $(the_libdir)tmp/
25 else
26 build_libdir = $(the_libdir)
27 endif
28 endif
29
30 ifdef base_prog_config
31 PROGRAM_config := $(build_libdir)$(PROGRAM).config
32 endif
33
34 the_lib = $(the_libdir)$(base_prog)
35 build_lib = $(build_libdir)$(base_prog)
36
37 executable_CLEAN_FILES += $(the_lib)   $(the_lib).so   $(the_lib).mdb   $(the_lib:.exe=.pdb)
38 executable_CLEAN_FILES += $(build_lib) $(build_lib).so $(build_lib).mdb $(build_lib:.exe=.pdb)
39
40 makefrag = $(depsdir)/$(PROFILE)_$(base_prog).makefrag
41
42 all-local: $(the_lib) $(PROGRAM_config)
43
44 install-local: all-local
45 test-local: all-local
46 uninstall-local:
47
48 ifdef NO_INSTALL
49 install-local uninstall-local:
50         @:
51 else
52
53 ifndef PROGRAM_INSTALL_DIR
54 PROGRAM_INSTALL_DIR = $(mono_libdir)/mono/$(FRAMEWORK_VERSION)
55 endif
56
57 install-local:
58         $(MKINSTALLDIRS) $(DESTDIR)$(PROGRAM_INSTALL_DIR)
59         $(INSTALL_BIN) $(the_lib) $(DESTDIR)$(PROGRAM_INSTALL_DIR)
60         test ! -f $(the_lib).mdb || $(INSTALL_BIN) $(the_lib).mdb $(DESTDIR)$(PROGRAM_INSTALL_DIR)
61 ifdef PROGRAM_config
62         $(INSTALL_DATA) $(PROGRAM_config) $(DESTDIR)$(PROGRAM_INSTALL_DIR)
63 endif
64 ifdef PLATFORM_AOT_SUFFIX
65         test ! -f $(PROGRAM)$(PLATFORM_AOT_SUFFIX) || $(INSTALL_LIB) $(PROGRAM)$(PLATFORM_AOT_SUFFIX) $(DESTDIR)$(PROGRAM_INSTALL_DIR)
66 endif
67
68 uninstall-local:
69         -rm -f $(DESTDIR)$(PROGRAM_INSTALL_DIR)/$(base_prog) $(DESTDIR)$(PROGRAM_INSTALL_DIR)/$(base_prog).mdb $(DESTDIR)$(PROGRAM_INSTALL_DIR)/$(base_prog).config
70 endif
71
72 clean-local:
73         -rm -f $(executable_CLEAN_FILES) $(CLEAN_FILES) $(tests_CLEAN_FILES)
74
75 test-local:
76         @:
77 run-test-local:
78         @:
79 run-test-ondotnet-local:
80         @:
81
82 DISTFILES = $(sourcefile) $(base_prog_config) $(EXTRA_DISTFILES)
83
84 ifdef HAS_NUNIT_TEST
85 ASSEMBLY      = $(PROGRAM)
86 ASSEMBLY_EXT  = .exe
87 the_assembly  = $(PROGRAM)
88 include $(topdir)/build/tests.make
89 endif
90
91 ifdef HAVE_CS_TESTS
92 DISTFILES += $(test_sourcefile)
93 endif
94
95 dist-local: dist-default
96         for f in `cat $(sourcefile)` ; do \
97           case $$f in \
98           ../*) : ;; \
99           *) dest=`dirname "$$f"` ; \
100              case $$subs in *" $$dest "*) : ;; *) subs=" $$dest$$subs" ; $(MKINSTALLDIRS) $(distdir)/$$dest ;; esac ; \
101              cp -p "$$f" $(distdir)/$$dest || exit 1 ;; \
102           esac ; done ; \
103         for d in . $$subs ; do \
104           case $$d in .) : ;; *) test ! -f $$d/ChangeLog || cp -p $$d/ChangeLog $(distdir)/$$d ;; esac ; done
105
106 ifndef PROGRAM_COMPILE
107 PROGRAM_COMPILE = $(CSCOMPILE)
108 endif
109
110 $(the_lib): $(the_libdir)/.stamp
111
112 $(build_lib): $(BUILT_SOURCES) $(EXTRA_SOURCES) $(response) $(build_libdir:=/.stamp)
113         $(PROGRAM_COMPILE) -target:exe -out:$@ $(BUILT_SOURCES) $(EXTRA_SOURCES) @$(response)
114
115 ifdef PROGRAM_USE_INTERMEDIATE_FILE
116 $(the_lib): $(build_lib)
117         $(Q) cp $(build_lib) $@
118         $(Q) test ! -f $(build_lib).mdb || mv $(build_lib).mdb $@.mdb
119         $(Q) test ! -f $(build_lib:.exe=.pdb) || mv $(build_lib:.exe=.pdb) $(the_lib:.exe=.pdb)
120 endif
121
122 ifdef PROGRAM_config
123 ifneq ($(base_prog_config),$(PROGRAM_config))
124 executable_CLEAN_FILES += $(PROGRAM_config)
125 $(PROGRAM_config): $(base_prog_config) $(dir $(PROGRAM_config))/.stamp
126         cp $(base_prog_config) $(PROGRAM_config)
127 endif
128 endif
129
130 $(makefrag): $(sourcefile)
131 #       @echo Creating $@ ...
132         @sed 's,^,$(build_lib): ,' $< >$@
133         @if test ! -f $(sourcefile).makefrag; then :; else \
134            cat $(sourcefile).makefrag >> $@ ; \
135            echo '$@: $(sourcefile).makefrag' >> $@; \
136            echo '$(sourcefile).makefrag:' >> $@; fi
137
138 ifneq ($(response),$(sourcefile))
139 $(response): $(sourcefile)
140         @echo Converting $(sourcefile) to $@ ...
141         @cat $(sourcefile) | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
142 endif
143
144 -include $(makefrag)
145
146 all-local: $(makefrag) $(extra_targets)
147
148 csproj-local:
149         config_file=`basename $(PROGRAM) .exe`-$(PROFILE).input; \
150         echo $(thisdir):$$config_file >> $(topdir)/../msvc/scripts/order; \
151         (echo $(is_boot); \
152         echo $(USE_MCS_FLAGS) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS) $(patsubst %,-r:%,$(LIB_REFS)); \
153         echo $(PROGRAM); \
154         echo $(BUILT_SOURCES_cmdline); \
155         echo $(build_lib); \
156         echo $(FRAMEWORK_VERSION); \
157         echo $(PROFILE); \
158         echo $(response)) > $(topdir)/../msvc/scripts/inputs/$$config_file
159
160
161 ifneq ($(response),$(sourcefile))
162 $(response): $(topdir)/build/executable.make $(depsdir)/.stamp
163 endif
164 $(makefrag): $(topdir)/build/executable.make $(depsdir)/.stamp
165
166 doc-update-local:
167         @:
168
169 # Need to be here so it comes after the definition of DEP_DIRS/DEP_LIBS
170 gen-deps:
171         @echo "$(DEPS_TARGET_DIR): $(DEP_DIRS) $(DEP_LIBS)" >> $(DEPS_FILE)