Blame SOURCES/0026-add-BUILD_EXEEXT-support-to-fix-make-clean-on-Window.patch

4fe85b
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
4fe85b
From: Andrey Borzenkov <arvidjaar@gmail.com>
4fe85b
Date: Sat, 18 Jan 2014 20:41:24 +0400
4fe85b
Subject: [PATCH] add BUILD_EXEEXT support to fix make clean on Windows
4fe85b
4fe85b
Add $(BUILD_EXEEXT) to ensure files are removed. Also add CLEANFILES where
4fe85b
appropriate.
4fe85b
---
4fe85b
 configure.ac          | 21 ++++++++++++++++-----
4fe85b
 Makefile.util.def     |  2 +-
4fe85b
 Makefile.am           | 16 ++++++++--------
4fe85b
 ChangeLog             |  7 +++++++
4fe85b
 grub-core/Makefile.am | 14 ++++++++------
4fe85b
 5 files changed, 40 insertions(+), 20 deletions(-)
4fe85b
4fe85b
diff --git a/configure.ac b/configure.ac
4fe85b
index 2e4cf3c2e22..cf3de3be1fc 100644
4fe85b
--- a/configure.ac
4fe85b
+++ b/configure.ac
4fe85b
@@ -38,7 +38,8 @@ AC_CONFIG_AUX_DIR([build-aux])
4fe85b
 # We don't want -g -O2 by default in CFLAGS
4fe85b
 : ${CFLAGS=""}
4fe85b
 
4fe85b
-# Checks for host and target systems.
4fe85b
+# Checks for build, host and target systems.
4fe85b
+AC_CANONICAL_BUILD
4fe85b
 AC_CANONICAL_HOST
4fe85b
 save_program_prefix="${program_prefix}"
4fe85b
 AC_CANONICAL_TARGET
4fe85b
@@ -422,6 +423,16 @@ case "$build_os" in
4fe85b
   haiku*)				BUILD_LIBM= ;;
4fe85b
   *) 					BUILD_LIBM=-lm ;;
4fe85b
 esac
4fe85b
+
4fe85b
+dnl FIXME proper test seems to require too deep dive into Autoconf internals.
4fe85b
+dnl For now just list known platforms that we support.
4fe85b
+
4fe85b
+case "$build_os" in
4fe85b
+  cygwin*|mingw32*|mingw64*)		BUILD_EXEEXT=.exe ;;
4fe85b
+  *)					BUILD_EXEEXT= ;;
4fe85b
+esac
4fe85b
+AC_SUBST(BUILD_EXEEXT)
4fe85b
+
4fe85b
 # For gnulib.
4fe85b
 gl_INIT
4fe85b
 
4fe85b
@@ -765,11 +776,11 @@ if test x"$platform" = xemu ; then
4fe85b
     *windows* | *cygwin* | *mingw*)
4fe85b
       if test x${target_cpu} = xi386 ; then
4fe85b
         grub_cv_target_cc_link_format=-mi386pe;
4fe85b
-	TARGET_OBJ2ELF='./build-grub-pe2elf';
4fe85b
+	TARGET_OBJ2ELF='./build-grub-pe2elf$(BUILD_EXEEXT)';
4fe85b
       fi
4fe85b
       if test x${target_cpu} = xx86_64 ; then
4fe85b
         grub_cv_target_cc_link_format=-mi386pep;
4fe85b
-	TARGET_OBJ2ELF='./build-grub-pep2elf';
4fe85b
+	TARGET_OBJ2ELF='./build-grub-pep2elf$(BUILD_EXEEXT)';
4fe85b
       fi
4fe85b
       TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format"
4fe85b
       ;;
4fe85b
@@ -803,10 +814,10 @@ elif test x"$target_cpu" = xi386 || test x"$target_cpu" = xx86_64; then
4fe85b
   fi
4fe85b
   TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format"
4fe85b
   if test x"$grub_cv_target_cc_link_format" = x-mi386pe ; then
4fe85b
-    TARGET_OBJ2ELF='./build-grub-pe2elf';
4fe85b
+    TARGET_OBJ2ELF='./build-grub-pe2elf$(BUILD_EXEEXT)';
4fe85b
   fi
4fe85b
   if test x"$grub_cv_target_cc_link_format" = x-mi386pep ; then
4fe85b
-    TARGET_OBJ2ELF='./build-grub-pep2elf';
4fe85b
+    TARGET_OBJ2ELF='./build-grub-pep2elf$(BUILD_EXEEXT)';
4fe85b
   fi
4fe85b
 fi
4fe85b
 
4fe85b
diff --git a/Makefile.util.def b/Makefile.util.def
4fe85b
index 3c99be2b0ca..83df212f412 100644
4fe85b
--- a/Makefile.util.def
4fe85b
+++ b/Makefile.util.def
4fe85b
@@ -708,7 +708,7 @@ script = {
4fe85b
   name = grub-fs-tester;
4fe85b
   common = tests/util/grub-fs-tester.in;
4fe85b
   installdir = noinst;
4fe85b
-  dependencies = garbage-gen;
4fe85b
+  dependencies = 'garbage-gen$(BUILD_EXEEXT)';
4fe85b
 };
4fe85b
 
4fe85b
 script = {
4fe85b
diff --git a/Makefile.am b/Makefile.am
4fe85b
index 1bbec0e79d3..aa526f573c3 100644
4fe85b
--- a/Makefile.am
4fe85b
+++ b/Makefile.am
4fe85b
@@ -66,22 +66,22 @@ endif
4fe85b
 
4fe85b
 starfield_theme_files = $(srcdir)/themes/starfield/blob_w.png $(srcdir)/themes/starfield/boot_menu_c.png $(srcdir)/themes/starfield/boot_menu_e.png $(srcdir)/themes/starfield/boot_menu_ne.png $(srcdir)/themes/starfield/boot_menu_n.png $(srcdir)/themes/starfield/boot_menu_nw.png $(srcdir)/themes/starfield/boot_menu_se.png $(srcdir)/themes/starfield/boot_menu_s.png $(srcdir)/themes/starfield/boot_menu_sw.png $(srcdir)/themes/starfield/boot_menu_w.png $(srcdir)/themes/starfield/slider_c.png $(srcdir)/themes/starfield/slider_n.png $(srcdir)/themes/starfield/slider_s.png $(srcdir)/themes/starfield/starfield.png $(srcdir)/themes/starfield/terminal_box_c.png $(srcdir)/themes/starfield/terminal_box_e.png $(srcdir)/themes/starfield/terminal_box_ne.png $(srcdir)/themes/starfield/terminal_box_n.png $(srcdir)/themes/starfield/terminal_box_nw.png $(srcdir)/themes/starfield/terminal_box_se.png $(srcdir)/themes/starfield/terminal_box_s.png $(srcdir)/themes/starfield/terminal_box_sw.png $(srcdir)/themes/starfield/terminal_box_w.png $(srcdir)/themes/starfield/theme.txt $(srcdir)/themes/starfield/README $(srcdir)/themes/starfield/COPYING.CC-BY-SA-3.0
4fe85b
 
4fe85b
-build-grub-mkfont: util/grub-mkfont.c grub-core/unidata.c grub-core/kern/emu/misc.c util/misc.c
4fe85b
+build-grub-mkfont$(BUILD_EXEEXT): util/grub-mkfont.c grub-core/unidata.c grub-core/kern/emu/misc.c util/misc.c
4fe85b
 	$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DGRUB_MKFONT=1 -DGRUB_BUILD=1 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-mkfont\" $^ $(build_freetype_cflags) $(build_freetype_libs)
4fe85b
-CLEANFILES += build-grub-mkfont
4fe85b
+CLEANFILES += build-grub-mkfont$(BUILD_EXEEXT)
4fe85b
 
4fe85b
-garbage-gen: util/garbage-gen.c
4fe85b
+garbage-gen$(BUILD_EXEEXT): util/garbage-gen.c
4fe85b
 	$(BUILD_CC) -o $@ $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS)  $^
4fe85b
-CLEANFILES += garbage-gen
4fe85b
+CLEANFILES += garbage-gen$(BUILD_EXEEXT)
4fe85b
 EXTRA_DIST += util/garbage-gen.c
4fe85b
 
4fe85b
-build-grub-gen-asciih: util/grub-gen-asciih.c
4fe85b
+build-grub-gen-asciih$(BUILD_EXEEXT): util/grub-gen-asciih.c
4fe85b
 	$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DGRUB_MKFONT=1 -DGRUB_BUILD=1 -DGRUB_UTIL=1 $^ $(build_freetype_cflags) $(build_freetype_libs) -Wall -Werror
4fe85b
-CLEANFILES += build-grub-gen-asciih
4fe85b
+CLEANFILES += build-grub-gen-asciih$(BUILD_EXEEXT)
4fe85b
 
4fe85b
-build-grub-gen-widthspec: util/grub-gen-widthspec.c
4fe85b
+build-grub-gen-widthspec$(BUILD_EXEEXT): util/grub-gen-widthspec.c
4fe85b
 	$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DGRUB_MKFONT=1 -DGRUB_BUILD=1 -DGRUB_UTIL=1 $^ $(build_freetype_cflags) $(build_freetype_libs) -Wall -Werror
4fe85b
-CLEANFILES += build-grub-gen-widthspec
4fe85b
+CLEANFILES += build-grub-gen-widthspec$(BUILD_EXEEXT)
4fe85b
 
4fe85b
 if COND_STARFIELD
4fe85b
 starfield_DATA = dejavu_10.pf2 dejavu_12.pf2 dejavu_bold_14.pf2 dejavu_14.pf2 dejavu_16.pf2 $(starfield_theme_files)
4fe85b
diff --git a/ChangeLog b/ChangeLog
4fe85b
index 5aac7c1d854..dad2da2faef 100644
4fe85b
--- a/ChangeLog
4fe85b
+++ b/ChangeLog
4fe85b
@@ -1,3 +1,10 @@
4fe85b
+2014-01-18  Andrey Borzenkov <arvidjaar@gmail.com>
4fe85b
+
4fe85b
+	* configure.ac: Add support for BUILD_EXEEXT and use it ...
4fe85b
+	* Makefile.am: ... here.
4fe85b
+	* Makefile.util.def: ... and here.
4fe85b
+	* grub-core/Makefile.am: ... and here.
4fe85b
+
4fe85b
 2014-01-18  Andrey Borzenkov <arvidjaar@gmail.com>
4fe85b
 
4fe85b
 	* include/grub/osdep/hostfile_windows.h: Use _W64 instead of
4fe85b
diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am
4fe85b
index 13b7979106f..826b3dd7c1a 100644
4fe85b
--- a/grub-core/Makefile.am
4fe85b
+++ b/grub-core/Makefile.am
4fe85b
@@ -26,20 +26,22 @@ CFLAGS_LIBRARY += $(CFLAGS_PLATFORM) -fno-builtin
4fe85b
 CPPFLAGS_LIBRARY += $(CPPFLAGS_PLATFORM)
4fe85b
 CCASFLAGS_LIBRARY += $(CCASFLAGS_PLATFORM)
4fe85b
 
4fe85b
-build-grub-pep2elf: $(top_srcdir)/util/grub-pe2elf.c $(top_srcdir)/grub-core/kern/emu/misc.c $(top_srcdir)/util/misc.c
4fe85b
+build-grub-pep2elf$(BUILD_EXEEXT): $(top_srcdir)/util/grub-pe2elf.c $(top_srcdir)/grub-core/kern/emu/misc.c $(top_srcdir)/util/misc.c
4fe85b
 	$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DGRUB_BUILD=1 -DGRUB_TARGET_WORDSIZE=64 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-pep2elf\" $^
4fe85b
+CLEANFILES += build-grub-pep2elf$(BUILD_EXEEXT)
4fe85b
 
4fe85b
-build-grub-pe2elf: $(top_srcdir)/util/grub-pe2elf.c $(top_srcdir)/grub-core/kern/emu/misc.c $(top_srcdir)/util/misc.c
4fe85b
+build-grub-pe2elf$(BUILD_EXEEXT): $(top_srcdir)/util/grub-pe2elf.c $(top_srcdir)/grub-core/kern/emu/misc.c $(top_srcdir)/util/misc.c
4fe85b
 	$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DGRUB_BUILD=1 -DGRUB_TARGET_WORDSIZE=32 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-pe2elf\" $^
4fe85b
+CLEANFILES += build-grub-pe2elf$(BUILD_EXEEXT)
4fe85b
 
4fe85b
 # gentrigtables
4fe85b
-gentrigtables: gentrigtables.c
4fe85b
+gentrigtables$(BUILD_EXEEXT): gentrigtables.c
4fe85b
 	$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) $< $(BUILD_LIBM)
4fe85b
-CLEANFILES += gentrigtables
4fe85b
+CLEANFILES += gentrigtables$(BUILD_EXEEXT)
4fe85b
 
4fe85b
 # trigtables.c
4fe85b
-trigtables.c: gentrigtables gentrigtables.c $(top_srcdir)/configure.ac
4fe85b
-	./gentrigtables > $@
4fe85b
+trigtables.c: gentrigtables$(BUILD_EXEEXT) gentrigtables.c $(top_srcdir)/configure.ac
4fe85b
+	./gentrigtables$(BUILD_EXEEXT) > $@
4fe85b
 CLEANFILES += trigtables.c
4fe85b
 
4fe85b
 # XXX Use Automake's LEX & YACC support