Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1LjSG8-0005Rd-48 for mharc-grub-devel@gnu.org; Tue, 17 Mar 2009 01:54:40 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LjSG5-0005Pp-4d for grub-devel@gnu.org; Tue, 17 Mar 2009 01:54:37 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LjSFy-0005Lv-6l for grub-devel@gnu.org; Tue, 17 Mar 2009 01:54:34 -0400 Received: from [199.232.76.173] (port=42720 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LjSFy-0005LT-2O for grub-devel@gnu.org; Tue, 17 Mar 2009 01:54:30 -0400 Received: from ti-out-0910.google.com ([209.85.142.190]:18511) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LjSFv-0002aU-Rk for grub-devel@gnu.org; Tue, 17 Mar 2009 01:54:28 -0400 Received: by ti-out-0910.google.com with SMTP id j3so1089617tid.10 for ; Mon, 16 Mar 2009 22:54:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=RRdm+LlHAjuLkG2SrReLh9jtHHhKy4UEgCNVtrKeIvI=; b=AbkWGl85B6K+iCjbdZo6n99x4mNDMRSAYfMV7XjRwUBKrTQVgjDQmYvwLP8+SaGY/0 9QbGipqOxDOjNBEXc5rcGxg8Cq89z/z2RxxyjdPTGgdGHican9SSpsVqUmd2BxBxwCHS pgwob7Q23aHrPXTbXKGKYXfjGA1tyaf9BhXSE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=Jgbezrvt10mNxWoz9RN7L6Ghrz1xSTCtV9EV/a3jwGiG2mLW4NxIZZW/xh1NKSkI38 t+VRoQ0WOZG4cdwdH5nijV/WWcwYXjYFjYUYvbl1b3S8ri9+fnjiA3pvJ6Cv1dDVUr5Z J6Ca7r4jLk3zc9H+0G2BH3Uyn5SLDt99M3S8Q= MIME-Version: 1.0 Received: by 10.110.57.6 with SMTP id f6mr8736065tia.11.1237269262081; Mon, 16 Mar 2009 22:54:22 -0700 (PDT) In-Reply-To: <20090315154002.GC24554@thorin> References: <20090315154002.GC24554@thorin> Date: Tue, 17 Mar 2009 13:54:22 +0800 Message-ID: From: Bean To: The development of GRUB 2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: Re: [PATCH] patch to compile grub2 in msys/mingw environment X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Mar 2009 05:54:38 -0000 On Sun, Mar 15, 2009 at 11:40 PM, Robert Millan 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 millis= econd. >> >> 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 =A0Bean =A0 >> >> =A0 =A0 =A0 * util/hostdisk.c (read_device_map): Use grub_util_get_disk_= size to >> =A0 =A0 =A0 instead of stat in mingw environment. >> >> =A0 =A0 =A0 * util/misc.c (grub_millisleep): New function in environment= . >> >> =A0 =A0 =A0 * aclocal.m4 (grub_CHECK_LINK_DIR): New function. >> >> =A0 =A0 =A0 * configure.ac: Use grub_CHECK_LINK_DIR to determine whether= to use >> =A0 =A0 =A0 AC_CONFIG_LINKS. > > It seems you defined the mingw32 version of grub_millisleep unconditional= ly. 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, witho= ut > the base64 encoding. =A0Then 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=3D$srcdir/include/grub/util ;; + *) reldir=3D../$srcdir/include/grub/util ;; +esac +if ln -s $reldir testdir/util 2>/dev/null ; then] + AC_MSG_RESULT([yes]) + [link_dir=3Dyes +else + link_dir=3Dno] + 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" =3D 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 =3D '\0'; +#ifdef __MINGW32__ + (void) st; + if (grub_util_get_disk_size (p) =3D=3D -1LL) +#else if (stat (p, &st) =3D=3D -1) +#endif=09 { free (map[drive].drive); map[drive].drive =3D 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 =3D (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) { --=20 Bean