All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] patch to compile grub2 in msys/mingw environment
@ 2009-03-14 19:27 Bean
  2009-03-15 15:40 ` Robert Millan
  0 siblings, 1 reply; 7+ messages in thread
From: Bean @ 2009-03-14 19:27 UTC (permalink / raw)
  To: The development of GRUB 2

[-- Attachment #1: Type: text/plain, Size: 867 bytes --]

Hi,

There are three issue related to msys/mingw environment.

1, no nanosleep in mingw, although, the windows API Sleep support millisecond.

2, Use stat on device like //./PHYSICALDRIVE0 would fail. It should
use utility function grub_util_get_disk_size in read_device_map.

3, The ln command in msys can't handle symbol link properly, which
causes AC_CONFIG_LINKS to fail. This patch add new test
grub_CHECK_LINK_DIR, which is used to decide whether to call
AC_CONFIG_LINKS or copy directory itself.

2009-03-14  Bean  <bean123ch@gmail.com>

	* util/hostdisk.c (read_device_map): Use grub_util_get_disk_size to
	instead of stat in mingw environment.

	* util/misc.c (grub_millisleep): New function in environment.

	* aclocal.m4 (grub_CHECK_LINK_DIR): New function.

	* configure.ac: Use grub_CHECK_LINK_DIR to determine whether to use
	AC_CONFIG_LINKS.

-- 
Bean

[-- Attachment #2: mingw.diff --]
[-- Type: application/octet-stream, Size: 2528 bytes --]

diff --git a/aclocal.m4 b/aclocal.m4
index 1dd5ffb..3c72ca9 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -448,3 +448,21 @@ else
   AC_MSG_RESULT([no])
 [fi]
 ])
+
+dnl Check if ln can handle directories properly (mingw).
+AC_DEFUN(grub_CHECK_LINK_DIR,[
+AC_MSG_CHECKING([whether ln can handle directories properly])
+[mkdir testdir 2>/dev/null
+case $srcdir in
+[\\/$]* | ?:[\\/]* ) reldir=$srcdir/include/grub/util ;;
+    *) reldir=../$srcdir/include/grub/util ;;
+esac
+if ln -s $reldir testdir/util 2>/dev/null ; then]
+  AC_MSG_RESULT([yes])
+  [link_dir=yes
+else
+  link_dir=no]
+  AC_MSG_RESULT([no])
+[fi
+rm -rf testdir]
+])
diff --git a/configure.ac b/configure.ac
index 134e0a3..d9f182d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -474,8 +474,17 @@ AC_SUBST([freetype_cflags])
 AC_SUBST([freetype_libs])
 
 # Output files.
-AC_CONFIG_LINKS([include/grub/cpu:include/grub/$target_cpu
+grub_CHECK_LINK_DIR
+if test x"$link_dir" = xyes ; then
+  AC_CONFIG_LINKS([include/grub/cpu:include/grub/$target_cpu
 	include/grub/machine:include/grub/$target_cpu/$platform])
+else
+  mkdir -p include/grub 2>/dev/null
+  rm -rf include/grub/cpu
+  cp -rp $srcdir/include/grub/$target_cpu include/grub/cpu 2>/dev/null
+  rm -rf include/grub/machine
+  cp -rp $srcdir/include/grub/$target_cpu/$platform include/grub/machine 2>/dev/null
+fi
 AC_CONFIG_FILES([Makefile gensymlist.sh genkernsyms.sh])
 AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
 AC_OUTPUT
diff --git a/util/hostdisk.c b/util/hostdisk.c
index 67a1233..3e73359 100644
--- a/util/hostdisk.c
+++ b/util/hostdisk.c
@@ -555,7 +555,12 @@ read_device_map (const char *dev_map)
 	e++;
       *e = '\0';
 
+#ifdef __MINGW32__
+      (void) st;
+      if (grub_util_get_disk_size (p) == -1LL)
+#else
       if (stat (p, &st) == -1)
+#endif	
 	{
 	  free (map[drive].drive);
 	  map[drive].drive = NULL;
diff --git a/util/misc.c b/util/misc.c
index 8d7d080..43050ce 100644
--- a/util/misc.c
+++ b/util/misc.c
@@ -311,6 +311,7 @@ grub_get_time_ms (void)
   return (tv.tv_sec * 1000 + tv.tv_usec / 1000);
 }
 
+#ifndef __MINGW32__
 void
 grub_millisleep (grub_uint32_t ms)
 {
@@ -320,6 +321,7 @@ grub_millisleep (grub_uint32_t ms)
   ts.tv_nsec = (ms % 1000) * 1000000;
   nanosleep (&ts, NULL);
 }
+#endif
 
 void 
 grub_arch_sync_caches (void *address __attribute__ ((unused)),
@@ -361,6 +363,12 @@ void sleep (int s)
   Sleep (s * 1000);
 }
 
+void
+grub_millisleep (grub_uint32_t ms)
+{
+  Sleep (ms);
+}
+
 grub_int64_t
 grub_util_get_disk_size (char *name)
 {

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-03-21 17:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-14 19:27 [PATCH] patch to compile grub2 in msys/mingw environment Bean
2009-03-15 15:40 ` Robert Millan
2009-03-17  5:54   ` Bean
2009-03-18 10:15     ` Robert Millan
2009-03-18 13:43       ` Bean
2009-03-21  7:48         ` Bean
2009-03-21 17:51         ` Robert Millan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.