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

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