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