* [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* Re: [PATCH] patch to compile grub2 in msys/mingw environment
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
0 siblings, 1 reply; 7+ messages in thread
From: Robert Millan @ 2009-03-15 15:40 UTC (permalink / raw)
To: The development of GRUB 2
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 <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.
It seems you defined the mingw32 version of grub_millisleep unconditionally.
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.
--
Robert Millan
The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
how) you may access your data; but nobody's threatening your freedom: we
still allow you to remove your data and not access it at all."
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] patch to compile grub2 in msys/mingw environment
2009-03-15 15:40 ` Robert Millan
@ 2009-03-17 5:54 ` Bean
2009-03-18 10:15 ` Robert Millan
0 siblings, 1 reply; 7+ messages in thread
From: Bean @ 2009-03-17 5:54 UTC (permalink / raw)
To: The development of GRUB 2
On Sun, Mar 15, 2009 at 11:40 PM, Robert Millan <rmh@aybabtu.com> 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 <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.
>
> 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
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH] patch to compile grub2 in msys/mingw environment
2009-03-17 5:54 ` Bean
@ 2009-03-18 10:15 ` Robert Millan
2009-03-18 13:43 ` Bean
0 siblings, 1 reply; 7+ messages in thread
From: Robert Millan @ 2009-03-18 10:15 UTC (permalink / raw)
To: The development of GRUB 2
On Tue, Mar 17, 2009 at 01:54:22PM +0800, Bean wrote:
> >
> > 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.
I just meant that when __MINGW32__ is not defined, the function is implemented
twice:
> +#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);
> +}
> +
why not put them together anyway? Like #ifdef __MINGW32__ ... #else ... #endif
--
Robert Millan
The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
how) you may access your data; but nobody's threatening your freedom: we
still allow you to remove your data and not access it at all."
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] patch to compile grub2 in msys/mingw environment
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
0 siblings, 2 replies; 7+ messages in thread
From: Bean @ 2009-03-18 13:43 UTC (permalink / raw)
To: The development of GRUB 2
On Wed, Mar 18, 2009 at 6:15 PM, Robert Millan <rmh@aybabtu.com> wrote:
> On Tue, Mar 17, 2009 at 01:54:22PM +0800, Bean wrote:
>> >
>> > 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.
>
> I just meant that when __MINGW32__ is not defined, the function is implemented
> twice:
>
>> +#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);
>> +}
>> +
>
> why not put them together anyway? Like #ifdef __MINGW32__ ... #else ... #endif
Hi,
The header file <windows.h> is included after grub_millisleep, so
Sleep is not defined yet, perhaps it'd be better to move #include
<windows.h> to the beginning of file.
--
Bean
^ permalink raw reply [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.