grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] patch to compile grub2 in msys/mingw environment


From: Bean
Subject: Re: [PATCH] patch to compile grub2 in msys/mingw environment
Date: Tue, 17 Mar 2009 13:54:22 +0800

On Sun, Mar 15, 2009 at 11:40 PM, Robert Millan <address@hidden> wrote:
> On Sun, Mar 15, 2009 at 03:27:05AM +0800, Bean wrote:
>> 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  <address@hidden>
>>
>>       * 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.
>
> It seems you defined the mingw32 version of grub_millisleep unconditionally.

Hi,

Are you suggesting adding some test in configure.ac ? Although
grub_millisleep for mingw32 uses Windows API Sleep, I guess it's safe
to assume it's present.

>
> Btw, would be nice if you could send patches as inline attachments, without
> the base64 encoding.  Then I'd have been able to reply using the patch as
> context.

Ok, here it is.

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)
 {

-- 
Bean




reply via email to

[Prev in Thread] Current Thread [Next in Thread]