2006-03-16 Peter Dennis Bartok <pbartok@novell.com>
[mono.git] / mcs / build / executable.make
index 156134b28ead93b8392d4f529cb509a69b0ebf59..726ac000f863871c3c92c8304a55a40fad2c4002 100644 (file)
 #
 # The rules for building a program.
 
-# I'd rather not create a response file here,
-# but since on Win32 we need to munge the paths
-# anyway, we might as well.
-
 base_prog = $(shell basename $(PROGRAM))
 sourcefile = $(base_prog).sources
-ifdef PLATFORM_CHANGE_SEPARATOR_CMD
-response = $(depsdir)/$(base_prog).response
-else
+base_prog_config := $(wildcard $(base_prog).config.$(PROFILE))
+ifndef base_prog_config
+base_prog_config := $(wildcard $(base_prog).config)
+endif
+ifdef base_prog_config
+PROGRAM_config := $(PROGRAM).config
+endif
+
+executable_CLEAN_FILES = *.exe $(PROGRAM) $(PROGRAM).mdb $(BUILT_SOURCES)
+
+ifeq (cat,$(PLATFORM_CHANGE_SEPARATOR_CMD))
 response = $(sourcefile)
+else
+response = $(depsdir)/$(base_prog).response
+executable_CLEAN_FILES += $(response)
 endif
-stampfile = $(depsdir)/$(base_prog).stamp
-makefrag = $(depsdir)/$(base_prog).makefrag
-pdb = $(patsubst %.exe,%.pdb,$(PROGRAM))
 
-all-local: $(PROGRAM)
+makefrag = $(depsdir)/$(PROFILE)_$(base_prog).makefrag
+pdb = $(patsubst %.exe,%.pdb,$(PROGRAM))
+mdb = $(patsubst %.exe,%.mdb,$(PROGRAM))
+executable_CLEAN_FILES += $(makefrag) $(pdb) $(mdb)
 
-install-local: $(PROGRAM)
-       $(MKINSTALLDIRS) $(DESTDIR)$(prefix)/bin
-       $(INSTALL_BIN) $(PROGRAM) $(DESTDIR)$(prefix)/bin
+all-local: $(PROGRAM) $(PROGRAM_config)
 
+install-local: all-local
+test-local: all-local
 uninstall-local:
-       -rm -f $(DESTDIR)$(prefix)/bin/$(base_prog)
 
-clean-local:
-       -rm -f *.exe $(BUILT_SOURCES) $(CLEAN_FILES) $(pdb) $(stampfile) $(makefrag)
-ifdef PLATFORM_CHANGE_SEPARATOR_CMD
-       -rm -f $(response)
+ifdef NO_INSTALL
+install-local uninstall-local:
+       @:
+else
+
+ifndef PROGRAM_INSTALL_DIR
+PROGRAM_INSTALL_DIR = $(mono_libdir)/mono/$(FRAMEWORK_VERSION)
 endif
 
-ifndef HAS_TEST
-test-local: $(PROGRAM)
+install-local: $(PROGRAM) $(PROGRAM_config)
+       $(MKINSTALLDIRS) $(DESTDIR)$(PROGRAM_INSTALL_DIR)
+       $(INSTALL_BIN) $(PROGRAM) $(DESTDIR)$(PROGRAM_INSTALL_DIR)
+       test ! -f $(PROGRAM).mdb || $(INSTALL_BIN) $(PROGRAM).mdb $(DESTDIR)$(PROGRAM_INSTALL_DIR)
+ifdef PROGRAM_config
+       $(INSTALL_DATA) $(PROGRAM_config) $(DESTDIR)$(PROGRAM_INSTALL_DIR)
+endif
 
-run-test-local:
+uninstall-local:
+       -rm -f $(DESTDIR)$(PROGRAM_INSTALL_DIR)/$(base_prog) $(DESTDIR)$(PROGRAM_INSTALL_DIR)/$(base_prog).mdb $(DESTDIR)$(PROGRAM_INSTALL_DIR)/$(base_prog).config
 endif
 
-DISTFILES = $(sourcefile) $(EXTRA_DISTFILES)
+clean-local:
+       -rm -f $(executable_CLEAN_FILES) $(CLEAN_FILES)
+
+test-local:
+       @:
+run-test-local:
+       @:
+run-test-ondotnet-local:
+       @:
+
+DISTFILES = $(sourcefile) $(base_prog_config) $(EXTRA_DISTFILES)
 
 dist-local: dist-default
        for f in `cat $(sourcefile)` ; do \
-           dest=`dirname $(distdir)/$$f` ; \
-           $(MKINSTALLDIRS) $$dest && cp $$f $$dest || exit 1 ; \
-       done
+         case $$f in \
+         ../*) : ;; \
+         *) dest=`dirname $$f` ; \
+            case $$subs in *" $$dest "*) : ;; *) subs=" $$dest$$subs" ; $(MKINSTALLDIRS) $(distdir)/$$dest ;; esac ; \
+            cp -p $$f $(distdir)/$$dest || exit 1 ;; \
+         esac ; done ; \
+       for d in . $$subs ; do \
+         case $$d in .) : ;; *) test ! -f $$d/ChangeLog || cp -p $$d/ChangeLog $(distdir)/$$d ;; esac ; done
+
+ifndef PROGRAM_COMPILE
+PROGRAM_COMPILE = $(CSCOMPILE)
+endif
 
-# Changing makefile probably means changing the
-# sources, so let's be safe and add a Makefile dep
+$(PROGRAM): $(BUILT_SOURCES) $(EXTRA_SOURCES) $(response)
+       $(PROGRAM_COMPILE) -target:exe -out:$(base_prog) $(BUILT_SOURCES) $(EXTRA_SOURCES) @$(response)
+ifneq ($(base_prog),$(PROGRAM))
+       mv $(base_prog) $(PROGRAM)
+       test ! -f $(base_prog).mdb || mv $(base_prog).mdb $(PROGRAM).mdb
+endif
 
-$(PROGRAM): $(makefrag) $(response) $(stampfile)
-       $(CSCOMPILE) /target:exe /out:$@ $(BUILT_SOURCES) @$(response)
+ifdef PROGRAM_config
+ifneq ($(base_prog_config),$(PROGRAM_config))
+executable_CLEAN_FILES += $(PROGRAM_config)
+$(PROGRAM_config): $(base_prog_config)
+       cp $(base_prog_config) $(PROGRAM_config)
+endif
+endif
 
 $(makefrag): $(sourcefile)
        @echo Creating $@ ...
-       @echo "HAVE_MAKEFRAG = yes" >$@.new
-       @echo "$(stampfile): $(BUILT_SOURCES) \\" >>$@.new
-       @cat $< |sed -e 's,\.cs[ \t]*$$,\.cs \\,' >>$@.new
-       @cat $@.new |sed -e '$$s, \\$$,,' >$@
-       @$(ECHO_ESCAPE) "\ttouch \$$@" >>$@
-       @rm -rf $@.new
-
-ifdef PLATFORM_CHANGE_SEPARATOR_CMD
+       @sed 's,^,$(PROGRAM): ,' $< > $@
+
+ifneq ($(response),$(sourcefile))
 $(response): $(sourcefile)
        @echo Creating $@ ...
-       @cat $< |$(PLATFORM_CHANGE_SEPARATOR_CMD) >$@
+       @( $(PLATFORM_CHANGE_SEPARATOR_CMD) ) <$< >$@
 endif
 
 -include $(makefrag)
 
-ifndef HAVE_MAKEFRAG
-$(stampfile):
-       touch $@
-endif
-
+all-local: $(makefrag)
+$(makefrag): $(topdir)/build/executable.make