]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
pull-in emu-lite branch
authorBVK Chaitanya <bvk.groups@gmail.com>
Wed, 26 May 2010 12:19:05 +0000 (17:49 +0530)
committerBVK Chaitanya <bvk.groups@gmail.com>
Wed, 26 May 2010 12:19:05 +0000 (17:49 +0530)
73 files changed:
1  2 
configure.common
gentpl.py
grub-core/Makefile.kernel
grub-core/Makefile.vars
grub-core/boot/i386/qemu/boot.S
grub-core/boot/sparc64/ieee1275/diskboot.S
grub-core/commands/i386/cmostest.c
grub-core/commands/usbtest.c
grub-core/conf/any-emu.rmk
grub-core/conf/common.rmk
grub-core/conf/i386-coreboot.rmk
grub-core/conf/i386-pc.rmk
grub-core/conf/i386-qemu.rmk
grub-core/conf/mips-qemu-mips.rmk
grub-core/conf/mips-yeeloong.rmk
grub-core/conf/mips.rmk
grub-core/conf/sparc64-ieee1275.rmk
grub-core/conf/x86-efi.rmk
grub-core/gfxmenu/gfxmenu.c
grub-core/gfxmenu/gui_circular_progress.c
grub-core/gfxmenu/gui_label.c
grub-core/gfxmenu/gui_list.c
grub-core/gfxmenu/gui_progress_bar.c
grub-core/gfxmenu/view.c
grub-core/include/grub/cache.h
grub-core/include/grub/dl.h
grub-core/include/grub/efi/pe32.h
grub-core/include/grub/elf.h
grub-core/include/grub/emu/misc.h
grub-core/include/grub/gui.h
grub-core/include/grub/i18n.h
grub-core/include/grub/i386/pc/boot.h
grub-core/include/grub/i386/pc/kernel.h
grub-core/include/grub/i386/pc/memory.h
grub-core/include/grub/i386/qemu/boot.h
grub-core/include/grub/i386/qemu/kernel.h
grub-core/include/grub/kernel.h
grub-core/include/grub/mips/qemu-mips/kernel.h
grub-core/include/grub/mips/yeeloong/kernel.h
grub-core/include/grub/offsets.h
grub-core/include/grub/powerpc/kernel.h
grub-core/include/grub/sparc64/ieee1275/boot.h
grub-core/include/grub/sparc64/ieee1275/kernel.h
grub-core/include/grub/types.h
grub-core/include/grub/x86_64/efi/boot.h
grub-core/kern/efi/init.c
grub-core/kern/emu/hostdisk.c
grub-core/kern/emu/misc.c
grub-core/kern/i386/coreboot/init.c
grub-core/kern/i386/coreboot/startup.S
grub-core/kern/i386/ieee1275/startup.S
grub-core/kern/i386/pc/init.c
grub-core/kern/i386/pc/mmap.c
grub-core/kern/i386/qemu/startup.S
grub-core/kern/ieee1275/cmain.c
grub-core/kern/ieee1275/init.c
grub-core/kern/ieee1275/openfw.c
grub-core/kern/mips/init.c
grub-core/kern/mips/startup.S
grub-core/kern/mips/yeeloong/init.c
grub-core/kern/powerpc/ieee1275/startup.S
grub-core/kern/sparc64/ieee1275/crt0.S
grub-core/modules.def
grub-core/po/POTFILES
grub-core/term/gfxterm.c
modules.def
tests/util/grub-shell.in
util/grub-mkdevicemap.c
util/grub-mkimage.c
util/grub-mkrescue.in
util/i386/pc/grub-setup.c
util/misc.c
util/sparc64/ieee1275/grub-setup.c

index a18bc803f6114006eee6af16f017b2f070baa3b6,0000000000000000000000000000000000000000..5529d28debff81dd97d767b7701167f8131a0702
mode 100644,000000..100644
--- /dev/null
@@@ -1,806 -1,0 +1,807 @@@
 +# -*- autoconf -*-
 +
 +# Process this file with autoconf to produce a configure script.
 +
 +# Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010  Free Software Foundation, Inc.
 +#
 +# This configure.ac is free software; the author
 +# gives unlimited permission to copy and/or distribute it,
 +# with or without modifications, as long as this notice is preserved.
 +#
 +# This program is distributed in the hope that it will be useful,
 +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
 +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 +# PARTICULAR PURPOSE.
 +
 +# This file is shared between grub-core and util configure scripts.
 +
 +# Program name transformations
 +AC_ARG_PROGRAM
 +
 +# Optimization flag.  Allow user to override.
 +if test "x$CFLAGS" = x; then
 +  CFLAGS="$CFLAGS -Os"
 +fi
 +
 +# Default HOST_CPPFLAGS
 +CPPFLAGS=''
 +HOST_CPPFLAGS="$HOST_CPPFLAGS -Wall -W"
 +HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_srcdir)/grub-core/include"
 +HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include"
 +HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_srcdir)/grub-core/gnulib"
 +HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_UTIL=1"
 +HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_LIBDIR=\\\"\$(pkglibdir)\\\""
 +HOST_CPPFLAGS="$HOST_CPPFLAGS -DLOCALEDIR=\\\"\$(localedir)\\\""
 +
 +TARGET_CPPFLAGS="$TARGET_CPPFLAGS -Wall -W"
 +TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include"
 +TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include"
 +
 +case "$target_cpu" in
 +  i[[3456]]86)        target_cpu=i386 ;;
 +  amd64)      target_cpu=x86_64 ;;
 +  sparc)      target_cpu=sparc64 ;;
 +  mipsel|mips64el)
 +                target_cpu=mips;
 +              cpu_CPPFLAGS="-DGRUB_CPU_MIPSEL=1";
 +              ;;
 +  mips|mips64)
 +                target_cpu=mips;
 +              cpu_CPPFLAGS="-DGRUB_CPU_MIPS=1";
 +              ;;
 +esac
 +
 +# Specify the platform (such as firmware).
 +AC_ARG_WITH([platform],
 +            AS_HELP_STRING([--with-platform=PLATFORM],
 +                           [select the host platform [[guessed]]]))
 +
 +# Guess the platform if not specified.
 +if test "x$with_platform" = x; then
 +  case "$target_cpu"-"$target_vendor" in
 +    i386-apple) platform=efi ;;
 +    i386-*) platform=pc ;;
 +    x86_64-apple) platform=efi ;;
 +    x86_64-*) platform=pc ;;
 +    powerpc-*) platform=ieee1275 ;;
 +    powerpc64-*) platform=ieee1275 ;;
 +    sparc64-*) platform=ieee1275 ;;
 +    mips-*) platform=yeeloong ;;
 +    *) AC_MSG_ERROR([unsupported CPU: "$target_cpu"]) ;;
 +  esac
 +else
 +  platform="$with_platform"
 +fi
 +
 +# Adjust CPU unless target was explicitly specified.
 +if test -z "$target_alias"; then
 +  case "$target_cpu"-"$platform" in
 +    x86_64-efi) ;;
 +    x86_64-emu) ;;
 +    x86_64-*) target_cpu=i386 ;;
 +    powerpc64-ieee1275) target_cpu=powerpc ;;
 +  esac
 +fi
 +
 +# Check if the platform is supported, make final adjustments.
 +case "$target_cpu"-"$platform" in
 +  i386-efi) ;;
 +  x86_64-efi) ;;
 +  i386-pc) ;;
 +  i386-multiboot) ;;
 +  i386-coreboot) ;;
 +  i386-linuxbios) platform=coreboot ;;
 +  i386-ieee1275) ;;
 +  i386-qemu) ;;
 +  powerpc-ieee1275) ;;
 +  sparc64-ieee1275) ;;
 +  mips-qemu-mips) ;;
 +  mips-yeeloong) ;;
 +  *-emu) ;;
 +  *) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;;
 +esac
 +
 +case "$target_cpu" in
 +  i386 | powerpc) target_m32=1 ;;
 +  x86_64 | sparc64) target_m64=1 ;;
 +esac
 +
 +case "$host_os" in
 +  mingw32*) host_os=cygwin ;;
 +esac
 +
 +# This normalizes the names, and creates a new variable ("host_kernel")
 +# while at it, since the mapping is not always 1:1 (e.g. different OSes
 +# using the same kernel type).
 +case "$host_os" in
 +  gnu*)                               host_kernel=hurd ;;
 +  linux*)                     host_kernel=linux ;;
 +  freebsd* | kfreebsd*-gnu)   host_kernel=kfreebsd ;;
 +  netbsd*)                    host_kernel=netbsd ;;
 +  cygwin)                     host_kernel=windows ;;
 +esac
 +
 +case "$platform" in
 +  coreboot)   machine_CPPFLAGS="-DGRUB_MACHINE_COREBOOT=1" ;;
 +  multiboot)  machine_CPPFLAGS="-DGRUB_MACHINE_MULTIBOOT=1" ;;
 +  efi)                machine_CPPFLAGS="-DGRUB_MACHINE_EFI=1" ;;
 +  ieee1275)   machine_CPPFLAGS="-DGRUB_MACHINE_IEEE1275=1" ;;
 +  qemu)               machine_CPPFLAGS="-DGRUB_MACHINE_QEMU=1" ;;
 +  pc)         machine_CPPFLAGS="-DGRUB_MACHINE_PCBIOS=1" ;;
 +  emu)                machine_CPPFLAGS="-DGRUB_MACHINE_EMU=1" ;;
 +  yeeloong)   machine_CPPFLAGS="-DGRUB_MACHINE_MIPS_YEELOONG=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
 +  qemu-mips)  machine_CPPFLAGS="-DGRUB_MACHINE_MIPS_QEMU_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
 +esac
 +case "$target_cpu" in
 +  i386)         cpu_CPPFLAGS="$cpu_CPPFLAGS -DGRUB_CPU_I386";;
 +  x86_64)       cpu_CPPFLAGS="$cpu_CPPFLAGS -DGRUB_CPU_X86_64";;
 +  powerpc)      cpu_CPPFLAGS="$cpu_CPPFLAGS -DGRUB_CPU_POWERPC";;
 +  mips)       machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS=1" ;; # cpu_CPPFLAGS handled above
 +  sparc64)      cpu_CPPFLAGS="$cpu_CPPFLAGS -DGRUB_CPU_SPARC64";
 +                machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_SPARC64=1" ;;
 +esac
++machine_CPPFLAGS="$machine_CPPFLAGS -DMACHINE=`echo ${target_cpu}_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
 +
 +HOST_CPPFLAGS="$HOST_CPPFLAGS $cpu_CPPFLAGS $machine_CPPFLAGS"
 +TARGET_CPPFLAGS="$TARGET_CPPFLAGS $cpu_CPPFLAGS $machine_CPPFLAGS"
 +
 +AC_SUBST(host_cpu)
 +AC_SUBST(host_os)
 +AC_SUBST(host_kernel)
 +
 +AC_SUBST(target_cpu)
 +AC_SUBST(platform)
 +
 +#
 +# Checks for build programs.
 +#
 +
 +# Although cmp is listed in the GNU Coding Standards as a command which
 +# can used directly, OpenBSD lacks cmp in the default installation.
 +AC_CHECK_PROGS([CMP], [cmp])
 +if test "x$CMP" = x; then
 +  AC_MSG_ERROR([cmp is not found])
 +fi
 +
 +for file in /usr/src/unifont.bdf /usr/share/fonts/X11/misc/unifont.pcf.gz /usr/share/fonts/unifont/unifont.pcf.gz; do
 +  if test -e $file ; then
 +    FONT_SOURCE=$file
 +    HOST_CPPFLAGS="$HOST_CPPFLAGS -DUSE_ASCII_FAILBACK=1"
 +    TARGET_CPPFLAGS="$TARGET_CPPFLAGS -DUSE_ASCII_FAILBACK=1"
 +    break
 +  fi
 +done
 +
 +AC_PROG_RANLIB
 +AC_PROG_INSTALL
 +AC_PROG_AWK
 +AC_PROG_LEX
 +AC_PROG_YACC
 +AC_PROG_MAKE_SET
 +AC_PROG_MKDIR_P
 +
 +if test "x$LEX" = x; then
 +  AC_MSG_ERROR([flex is not found])
 +else
 +  version=`$LEX --version | $AWK '{ split($NF,x,"."); print x[[1]]*10000+x[[2]]*100+x[[3]]; }'`
 +  if test -n "$version" -a "$version" -ge 20535; then
 +    :
 +  else
 +    AC_MSG_ERROR([flex is too old. GRUB requires 2.5.35 or above])
 +  fi
 +fi
 +
 +# These are not a "must".
 +AC_PATH_PROG(MAKEINFO, makeinfo)
 +
 +#
 +# Checks for host programs.
 +#
 +
 +AC_PROG_CC
 +AM_PROG_CC_C_O
 +AM_PROG_AS
 +
 +# Must be GCC.
 +test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required])
 +
 +AC_GNU_SOURCE
 +AM_GNU_GETTEXT([external])
 +AC_SYS_LARGEFILE
 +
 +# Identify characteristics of the host architecture.
 +AC_C_BIGENDIAN
 +AC_CHECK_SIZEOF(void *)
 +AC_CHECK_SIZEOF(long)
 +
 +grub_apple_cc
 +if test x$grub_cv_apple_cc = xyes ; then
 +  HOST_CPPFLAGS="$HOST_CPPFLAGS -DAPPLE_CC=1"
 +  HOST_CFLAGS="$HOST_CFLAGS -fnested-functions"
 +fi
 +
 +if test "x$cross_compiling" = xyes; then
 +  AC_MSG_WARN([cannot generate manual pages while cross compiling])
 +else
 +  AC_PATH_PROG(HELP2MAN, help2man)
 +fi
 +
 +# Check for functions.
 +AC_CHECK_FUNCS(posix_memalign memalign asprintf vasprintf)
 +
 +# For grub-mkisofs
 +AC_HEADER_MAJOR
 +AC_HEADER_DIRENT
 +AC_CHECK_FUNCS(memmove sbrk strdup lstat getuid getgid)
 +AC_CHECK_HEADERS(sys/mkdev.h sys/sysmacros.h malloc.h termios.h sys/types.h)
 +AC_CHECK_HEADERS(unistd.h string.h strings.h sys/stat.h sys/fcntl.h limits.h)
 +
 +# For opendisk() and getrawpartition() on NetBSD.
 +# Used in util/deviceiter.c and in util/hostdisk.c.
 +AC_CHECK_HEADER([util.h], [
 +  AC_CHECK_LIB([util], [opendisk], [
 +    LIBUTIL="-lutil"
 +    AC_DEFINE(HAVE_OPENDISK, 1, [Define if opendisk() in -lutil can be used])
 +  ])
 +  AC_CHECK_LIB([util], [getrawpartition], [
 +    LIBUTIL="-lutil"
 +    AC_DEFINE(HAVE_GETRAWPARTITION, 1, [Define if getrawpartition() in -lutil can be used])
 +  ])
 +])
 +AC_SUBST([LIBUTIL])
 +
 +#
 +# Check for host and build compilers.
 +#
 +HOST_CC=$CC
 +AC_CHECK_PROGS(BUILD_CC, [gcc egcs cc],
 +                 [AC_MSG_ERROR([none of gcc, egcs and cc is found. set BUILD_CC manually.])])
 +
 +#
 +# Check for target programs.
 +#
 +
 +# Find tools for the target.
 +if test "x$target_alias" != x && test "x$host_alias" != "x$target_alias"; then
 +  tmp_ac_tool_prefix="$ac_tool_prefix"
 +  ac_tool_prefix=$target_alias-
 +
 +  AC_CHECK_TOOLS(TARGET_CC, [gcc egcs cc],
 +                 [AC_MSG_ERROR([none of gcc, egcs and cc is found. set TARGET_CC manually.])])
 +  AC_CHECK_TOOL(OBJCOPY, objcopy)
 +  AC_CHECK_TOOL(STRIP, strip)
 +  AC_CHECK_TOOL(NM, nm)
 +
 +  ac_tool_prefix="$tmp_ac_tool_prefix"
 +else
 +  if test "x$TARGET_CC" = x; then
 +    TARGET_CC=$CC
 +  fi
 +  AC_CHECK_TOOL(OBJCOPY, objcopy)
 +  AC_CHECK_TOOL(STRIP, strip)
 +  AC_CHECK_TOOL(NM, nm)
 +fi
 +AC_SUBST(HOST_CC)
 +AC_SUBST(BUILD_CC)
 +AC_SUBST(TARGET_CC)
 +
 +# Test the C compiler for the target environment.
 +tmp_CC="$CC"
 +tmp_CFLAGS="$CFLAGS"
 +tmp_LDFLAGS="$LDFLAGS"
 +tmp_CPPFLAGS="$CPPFLAGS"
 +tmp_LIBS="$LIBS"
 +CC="$TARGET_CC"
 +CFLAGS="$TARGET_CFLAGS"
 +CPPFLAGS="$TARGET_CPPFLAGS"
 +LDFLAGS="$TARGET_LDFLAGS"
 +LIBS=""
 +
 +# debug flags.
 +TARGET_CFLAGS="$TARGET_CFLAGS -Wall -W -Wshadow -Wpointer-arith -Wmissing-prototypes -Wundef -Wstrict-prototypes -g"
 +TARGET_CCASFLAGS="$TARGET_CCASFLAGS -g"
 +
 +# Force no alignment to save space on i386.
 +if test "x$target_cpu" = xi386; then
 +  AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [
 +    CFLAGS="$CFLAGS -falign-loops=1"
 +    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
 +        [grub_cv_cc_falign_loop=yes],
 +      [grub_cv_cc_falign_loop=no])
 +  ])
 +
 +  if test "x$grub_cv_cc_falign_loop" = xyes; then
 +    TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1"
 +  else
 +    TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1"
 +  fi
 +
 +  # Some toolchains enable these features by default, but they need
 +  # registers that aren't set up properly in GRUB.
 +  TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-3dnow"
 +fi
 +
 +# By default, GCC 4.4 generates .eh_frame sections containing unwind
 +# information in some cases where it previously did not. GRUB doesn't need
 +# these and they just use up vital space. Restore the old compiler
 +# behaviour.
 +AC_CACHE_CHECK([whether -fno-dwarf2-cfi-asm works], [grub_cv_cc_fno_dwarf2_cfi_asm], [
 +  SAVE_CFLAGS="$CFLAGS"
 +  CFLAGS="$CFLAGS -fno-dwarf2-cfi-asm"
 +  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
 +      [grub_cv_cc_fno_dwarf2_cfi_asm=yes],
 +      [grub_cv_cc_fno_dwarf2_cfi_asm=no])
 +  CFLAGS="$SAVE_CFLAGS"
 +])
 +
 +if test "x$grub_cv_cc_fno_dwarf2_cfi_asm" = xyes; then
 +  TARGET_CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
 +fi
 +
 +grub_apple_target_cc
 +if test x$grub_cv_apple_target_cc = xyes ; then
 +  TARGET_CPPFLAGS="$TARGET_CPPFLAGS -DAPPLE_CC=1"
 +  TARGET_CFLAGS="$TARGET_CFLAGS -fnested-functions"
 +
 +  CFLAGS="$CFLAGS -DAPPLE_CC=1 -fnested-functions"
 +  TARGET_APPLE_CC=1
 +  AC_CHECK_PROG([OBJCONV], [objconv], [objconv], [])
 +  if test "x$OBJCONV" = x ; then
 +     AC_CHECK_PROG([OBJCONV], [objconv], [./objconv], [], [.])
 +  fi
 +  if test "x$OBJCONV" = x ; then
 +    AC_MSG_ERROR([objconv not found which is required when building with apple compiler])
 +  fi
 +  TARGET_IMG_LDSCRIPT=
 +  TARGET_IMG_CFLAGS="-static"
 +  TARGET_IMG_LDFLAGS='-nostdlib -static -Wl,-preload -Wl,-segalign,20 -Wl,-image_base,'
 +  TARGET_IMG_LDFLAGS_AC='-nostdlib -static -Wl,-preload -Wl,-segalign,20 -Wl,-image_base,'
 +else
 +  TARGET_APPLE_CC=0
 +# Use linker script if present, otherwise use builtin -N script.
 +if test -f "${srcdir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"; then
 +  TARGET_IMG_LDSCRIPT='$(top_srcdir)'"/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc"
 +  TARGET_IMG_LDFLAGS="-Wl,-T${TARGET_IMG_LDSCRIPT}  -Wl,-Ttext,"
 +  TARGET_IMG_LDFLAGS_AC="-Wl,-T${srcdir}/conf/${target_cpu}-${platform}-${host_os}-img-ld.sc  -Wl,-Ttext,"
 +else
 +  TARGET_IMG_LDSCRIPT=
 +  TARGET_IMG_LDFLAGS='-Wl,-N  -Wl,-Ttext,'
 +  TARGET_IMG_LDFLAGS_AC='-Wl,-N  -Wl,-Ttext,'
 +fi
 +TARGET_IMG_CFLAGS=
 +fi
 +
 +# For platforms where ELF is not the default link format.
 +AC_MSG_CHECKING([for command to convert module to ELF format])
 +case "${host_os}" in
 +  cygwin) TARGET_OBJ2ELF='grub-pe2elf';
 +# FIXME: put proper test here
 +  AC_DEFINE([NEED_REGISTER_FRAME_INFO], 1,
 +          [Define to 1 if GCC generates calls to __register_frame_info()])
 +  ;;
 +  *) ;;
 +esac
 +AC_MSG_RESULT([$TARGET_OBJ2ELF])
 +
 +if test "x$target_m32" = x1; then
 +  # Force 32-bit mode.
 +  TARGET_CFLAGS="$TARGET_CFLAGS -m32"
 +  TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m32"
 +  TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
 +  TARGET_MODULE_FORMAT="elf32"
 +fi
 +
 +if test "x$target_m64" = x1; then
 +  # Force 64-bit mode.
 +  TARGET_CFLAGS="$TARGET_CFLAGS -m64"
 +  TARGET_CCASFLAGS="$TARGET_CCASFLAGS -m64"
 +  TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
 +  TARGET_MODULE_FORMAT="elf64"
 +fi
 +
 +if test "$target_cpu"-"$platform" = x86_64-efi; then
 +  # Use large model to support 4G memory
 +  AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [
 +    SAVED_CFLAGS=$CFLAGS
 +    CFLAGS="$CFLAGS -m64 -mcmodel=large"
 +    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
 +                    [grub_cv_cc_mcmodel=yes],
 +                    [grub_cv_cc_mcmodel=no])
 +  ])
 +  if test "x$grub_cv_cc_mcmodel" = xno; then
 +    AC_MSG_ERROR([-mcmodel=large not supported. Upgrade your gcc.])
 +  else
 +    TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
 +  fi
 +
 +  # EFI writes to stack below %rsp, we must not use the red zone
 +  AC_CACHE_CHECK([whether option -mno-red-zone works], grub_cv_cc_no_red_zone, [
 +    CFLAGS="$CFLAGS -m64 -mno-red-zone"
 +    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
 +                    [grub_cv_cc_no_red_zone=yes],
 +                    [grub_cv_cc_no_red_zone=no])
 +  ])
 +  if test "x$grub_cv_cc_no_red_zone" = xno; then
 +    AC_MSG_ERROR([-mno-red-zone not supported, upgrade your gcc])
 +  fi
 +
 +  TARGET_CFLAGS="$TARGET_CFLAGS -mno-red-zone"
 +fi
 +
 +#
 +# Compiler features.
 +#
 +
 +# Need __enable_execute_stack() for nested function trampolines?
 +grub_CHECK_ENABLE_EXECUTE_STACK
 +
 +# Position independent executable.
 +grub_CHECK_PIE
 +[# Need that, because some distributions ship compilers that include
 +# `-fPIE' in the default specs.
 +if [ x"$pie_possible" = xyes ]; then
 +  TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE"
 +fi]
 +
 +# Smashing stack protector.
 +grub_CHECK_STACK_PROTECTOR
 +# Need that, because some distributions ship compilers that include
 +# `-fstack-protector' in the default specs.
 +if test "x$ssp_possible" = xyes; then
 +  TARGET_CFLAGS="$TARGET_CFLAGS -fno-stack-protector"
 +fi
 +grub_CHECK_STACK_ARG_PROBE
 +# Cygwin's GCC uses alloca() to probe the stackframe on static
 +# stack allocations above some threshold.
 +if test x"$sap_possible" = xyes; then
 +  TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe"
 +fi
 +
 +AC_ARG_ENABLE([werror],
 +            [AS_HELP_STRING([--disable-werror],
 +                             [do not use -Werror when building GRUB])])
 +if test x"$enable_werror" != xno ; then
 +  TARGET_CFLAGS="$TARGET_CFLAGS -Werror"
 +fi
 +
 +AC_SUBST(TARGET_MODULE_FORMAT)
 +AC_SUBST(OBJCONV)
 +AC_SUBST(TARGET_APPLE_CC)
 +
 +AC_SUBST(TARGET_CFLAGS)
 +AC_SUBST(TARGET_LDFLAGS)
 +AC_SUBST(TARGET_CPPFLAGS)
 +AC_SUBST(TARGET_CCASFLAGS)
 +
 +AC_SUBST(HOST_CFLAGS)
 +AC_SUBST(HOST_LDFLAGS)
 +AC_SUBST(HOST_CPPFLAGS)
 +AC_SUBST(HOST_CCASFLAGS)
 +
 +# Set them to their new values for the tests below.
 +CC="$TARGET_CC"
 +if test "x$TARGET_APPLE_CC" = x1 ; then
 +CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error"
 +else
 +CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100 -Wno-error"
 +fi
 +CPPFLAGS="$TARGET_CPPFLAGS"
 +LDFLAGS="$TARGET_LDFLAGS"
 +LIBS=-lgcc
 +
 +grub_ASM_USCORE
 +if test x$grub_cv_asm_uscore = xyes; then
 +CFLAGS="$CFLAGS -Wl,--defsym,_abort=_main"
 +else
 +CFLAGS="$CFLAGS -Wl,--defsym,abort=main"
 +fi
 +
 +# Check for libgcc symbols
 +AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __trampoline_setup __ucmpdi2 _restgpr_14_x)
 +
 +if test "x$TARGET_APPLE_CC" = x1 ; then
 +CFLAGS="$TARGET_CFLAGS -nostdlib"
 +else
 +CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100"
 +fi
 +LIBS=""
 +
 +# Defined in aclocal.m4.
 +grub_PROG_TARGET_CC
 +if test "x$TARGET_APPLE_CC" != x1 ; then
 +grub_PROG_OBJCOPY_ABSOLUTE
 +fi
 +grub_PROG_LD_BUILD_ID_NONE
 +if test "x$target_cpu" = xi386; then
 +  if test "$platform" != emu && test "x$TARGET_APPLE_CC" != x1 ; then
 +    if test ! -z "$TARGET_IMG_LDSCRIPT"; then
 +      # Check symbols provided by linker script.
 +      CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC}8000 -Wl,--defsym,___main=0x8100"
 +    fi
 +    grub_CHECK_BSS_START_SYMBOL
 +    grub_CHECK_END_SYMBOL
 +  fi
 +  CFLAGS="$TARGET_CFLAGS"
 +  grub_I386_ASM_PREFIX_REQUIREMENT
 +  grub_I386_ASM_ADDR32
 +  grub_I386_ASM_ABSOLUTE_WITHOUT_ASTERISK
 +else
 +  AC_DEFINE([NESTED_FUNC_ATTR], [], [Catch gcc bug])
 +fi
 +
 +AH_BOTTOM([#if defined(__i386__) && !defined(GRUB_UTIL)
 +#define NESTED_FUNC_ATTR __attribute__ ((__regparm__ (1)))
 +#else
 +#define NESTED_FUNC_ATTR
 +#endif])
 +
 +AC_ARG_ENABLE([efiemu],
 +            [AS_HELP_STRING([--enable-efiemu],
 +                             [build and install the efiemu runtimes (default=guessed)])])
 +if test x"$enable_efiemu" = xno ; then
 +  efiemu_excuse="explicitly disabled"
 +fi
 +if test x"$efiemu_excuse" = x ; then
 +  AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [
 +    CFLAGS="$CFLAGS -m64 -mcmodel=large -mno-red-zone -nostdlib"
 +    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
 +                    [grub_cv_cc_efiemu=yes],
 +                    [grub_cv_cc_efiemu=no])
 +  ])
 +  if test x$grub_cv_cc_efiemu = xno; then
 +     efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib"
 +  fi
 +fi
 +if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then
 +  AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled])
 +fi
 +if test x"$efiemu_excuse" = x ; then
 +enable_efiemu=yes
 +else
 +enable_efiemu=no
 +fi
 +AC_SUBST([enable_efiemu])
 +
 +if test "$platform" != emu; then
 +AC_CACHE_CHECK([whether -nostdinc -isystem works], [grub_cv_cc_isystem], [
 +  SAVED_CPPFLAGS="$CPPFLAGS"
 +  CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
 +  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdarg.h>
 +int va_arg_func (int fixed, va_list args);]], [[]])],
 +      [grub_cv_cc_isystem=yes],
 +      [grub_cv_cc_isystem=no])
 +  CPPFLAGS="$SAVED_CPPFLAGS"
 +])
 +
 +if test x"$grub_cv_cc_isystem" = xyes ; then
 +  TARGET_CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
 +fi
 +fi
 +
 +# Restore the flags.
 +CC="$tmp_CC"
 +CFLAGS="$tmp_CFLAGS"
 +CPPFLAGS="$tmp_CPPFLAGS"
 +LDFLAGS="$tmp_LDFLAGS"
 +LIBS="$tmp_LIBS"
 +
 +#
 +# Check for options.
 +#
 +
 +# Memory manager debugging.
 +AC_ARG_ENABLE([mm-debug],
 +            AS_HELP_STRING([--enable-mm-debug],
 +                             [include memory manager debugging]),
 +              [AC_DEFINE([MM_DEBUG], [1],
 +                         [Define to 1 if you enable memory manager debugging.])])
 +
 +AC_ARG_ENABLE([grub-emu-usb],
 +            [AS_HELP_STRING([--enable-grub-emu-usb],
 +                             [build and install the `grub-emu' debugging utility with USB support (default=guessed)])])
 +
 +AC_ARG_ENABLE([grub-emu-sdl],
 +            [AS_HELP_STRING([--enable-grub-emu-sdl],
 +                             [build and install the `grub-emu' debugging utility with SDL support (default=guessed)])])
 +
 +AC_ARG_ENABLE([grub-emu-pci],
 +            [AS_HELP_STRING([--enable-grub-emu-pci],
 +                             [build and install the `grub-emu' debugging utility with PCI support (potentially dangerous) (default=no)])])
 +
 +if test "$platform" = emu; then
 +  missing_ncurses=
 +[# Check for curses libraries.]
 +  AC_CHECK_LIB([ncurses], [wgetch], [LIBCURSES="-lncurses"],
 +    [AC_CHECK_LIB([curses], [wgetch], [LIBCURSES="-lcurses"],
 +      [missing_ncurses=[true]])])
 +  AC_SUBST([LIBCURSES])
 +[if [ x"$missing_ncurses" = x ]; then ]
 +  [# Check for headers.]
 +  AC_CHECK_HEADERS([ncurses/curses.h], [],
 +    [AC_CHECK_HEADERS([ncurses.h], [],
 +      [AC_CHECK_HEADERS([curses.h], [],
 +      [missing_ncurses=[true]])])])
 +[fi]
 +if test x"$missing_ncurses" = xtrue ; then
 +  AC_MSG_ERROR([grub-emu can't be compiled without ncurses])
 +fi
 +
 +if test x"$enable_grub_emu_usb" = xno ; then
 +  grub_emu_usb_excuse="explicitly disabled"
 +fi
 +
 +if test x"$enable_grub_emu_pci" = xyes ; then
 +   grub_emu_usb_excuse="conflicts with PCI support"
 +fi
 +
 +[if [ x"$grub_emu_usb_excuse" = x ]; then
 +    # Check for libusb libraries.]
 +AC_CHECK_LIB([usb], [usb_claim_interface], [LIBUSB="-lusb"],
 +    [grub_emu_usb_excuse=["need libusb library"]])
 +    AC_SUBST([LIBUSB])
 +[fi]
 +[if [ x"$grub_emu_usb_excuse" = x ]; then
 +    # Check for headers.]
 +    AC_CHECK_HEADERS([usb.h], [],
 +      [grub_emu_usb_excuse=["need libusb headers"]])
 +[fi]
 +if test x"$enable_grub_emu_usb" = xyes && test x"$grub_emu_usb_excuse" != x ; then
 +  AC_MSG_ERROR([USB support for grub-emu was explicitly requested but can't be compiled])
 +fi
 +if test x"$grub_emu_usb_excuse" = x ; then
 +enable_grub_emu_usb=yes
 +else
 +enable_grub_emu_usb=no
 +fi
 +
 +if test x"$enable_grub_emu_sdl" = xno ; then
 +  grub_emu_sdl_excuse="explicitely disabled"
 +fi
 +[if [ x"$grub_emu_sdl_excuse" = x ]; then
 +    # Check for libSDL libraries.]
 +AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL="-lSDL"],
 +    [grub_emu_sdl_excuse=["libSDL libraries are required to build \`grub-emu' with SDL support"]])
 +    AC_SUBST([LIBSDL])
 +[fi]
 +
 +[if [ x"$grub_emu_sdl_excuse" = x ]; then
 +    # Check for headers.]
 +    AC_CHECK_HEADERS([SDL/SDL.h], [],
 +      [grub_emu_sdl_excuse=["libSDL header file is required to build \`grub-emu' with SDL support"]])
 +[fi]
 +
 +if test x"enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x ; then
 +  AC_MSG_ERROR([SDL support for grub-emu was explicitely requested but can't be compiled])
 +fi
 +if test x"$grub_emu_sdl_excuse" = x ; then
 +enable_grub_emu_sdl=yes
 +else
 +enable_grub_emu_sdl=no
 +fi
 +
 +if test x"$enable_grub_emu_pci" != xyes ; then
 +   grub_emu_pci_excuse="not enabled"
 +fi
 +
 +if test x"$enable_grub_emu_usb" = xyes ; then
 +   grub_emu_pci_excuse="conflicts with USB support"
 +fi
 +
 +[if [ x"$grub_emu_pci_excuse" = x ]; then
 +      # Check for libpci libraries.]
 +   AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"],
 +      [grub_emu_pci_excuse=["need libpciaccess library"]])
 +    AC_SUBST([LIBPCIACCESS])
 +[fi]
 +[if [ x"$grub_emu_pci_excuse" = x ]; then
 +    # Check for headers.]
 +    AC_CHECK_HEADERS([pci/pci.h], [],
 +      [grub_emu_pci_excuse=["need libpciaccess headers"]])
 +[fi]
 +
 +if test x"$grub_emu_pci_excuse" = x ; then
 +enable_grub_emu_pci=yes
 +else
 +
 +enable_grub_emu_pci=no
 +fi
 +
 +AC_SUBST([enable_grub_emu_sdl])
 +AC_SUBST([enable_grub_emu_usb])
 +AC_SUBST([enable_grub_emu_pci])
 +fi
 +
 +AC_ARG_ENABLE([grub-fstest],
 +            [AS_HELP_STRING([--enable-grub-fstest],
 +                             [build and install the `grub-fstest' debugging utility (default=guessed)])])
 +if test x"$enable_grub_fstest" = xno ; then
 +  grub_fstest_excuse="explicitly disabled"
 +fi
 +if test x"$grub_fstest_excuse" = x ; then
 +enable_grub_fstest=yes
 +else
 +enable_grub_fstest=no
 +fi
 +AC_SUBST([enable_grub_fstest])
 +
 +AC_ARG_ENABLE([grub-mkfont],
 +            [AS_HELP_STRING([--enable-grub-mkfont],
 +                             [build and install the `grub-mkfont' utility (default=guessed)])])
 +if test x"$enable_grub_mkfont" = xno ; then
 +  grub_mkfont_excuse="explicitly disabled"
 +fi
 +
 +if test x"$grub_mkfont_excuse" = x ; then
 +  # Check for freetype libraries.
 +  AC_CHECK_PROGS([FREETYPE], [freetype-config])
 +  if test "x$FREETYPE" = x ; then
 +    grub_mkfont_excuse=["need freetype2 library"]
 +  fi
 +  freetype_cflags=`freetype-config --cflags`
 +  freetype_libs=`freetype-config --libs`
 +fi
 +
 +if test x"$grub_mkfont_excuse" = x ; then
 +  # Check for freetype libraries.
 +  SAVED_CPPFLAGS="$CPPFLAGS"
 +  CPPFLAGS="$CPPFLAGS $freetype_cflags"
 +  AC_CHECK_HEADERS([ft2build.h], [],
 +      [grub_mkfont_excuse=["need freetype2 headers"]])
 +  CPPFLAGS="$SAVED_CPPFLAGS"
 +fi
 +
 +if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then
 +  AC_MSG_ERROR([grub-mkfont was explicitly requested but can't be compiled])
 +fi
 +if test x"$grub_mkfont_excuse" = x ; then
 +enable_grub_mkfont=yes
 +else
 +enable_grub_mkfont=no
 +fi
 +AC_SUBST([enable_grub_mkfont])
 +AC_SUBST([freetype_cflags])
 +AC_SUBST([freetype_libs])
 +
 +AC_SUBST([FONT_SOURCE])
 +AS_IF([test x$target_cpu = xi386 -a x$platform = xpc],
 +          [AC_SUBST([GRUB_KERNEL_MACHINE_LINK_ADDR], 0x8200)])
 +AS_IF([test x$target_cpu = xi386 -a x$platform = xcoreboot],
 +          [AC_SUBST([GRUB_KERNEL_MACHINE_LINK_ADDR], 0x8200)])
 +AS_IF([test x$target_cpu = xi386 -a x$platform = xmultiboot],
 +          [AC_SUBST([GRUB_KERNEL_MACHINE_LINK_ADDR], 0x8200)])
 +AS_IF([test x$target_cpu = xmips -a x$platform = xyeeloong],
 +          [AC_SUBST([GRUB_KERNEL_MACHINE_LINK_ADDR], 0x80200000)])
 +AS_IF([test x$target_cpu = xpowerpc -a x$platform = xieee1275],
 +          [AC_SUBST([GRUB_KERNEL_MACHINE_LINK_ADDR], 0x200000)])
 +AS_IF([test x$target_cpu = xi386 -a x$platform = xqemu],
 +          [AC_SUBST([GRUB_BOOT_MACHINE_LINK_ADDR], 0xffe00)])
 +AS_IF([test x$target_cpu = xi386 -a x$platform = xieee1275],
 +          [AC_SUBST([GRUB_KERNEL_MACHINE_LINK_ADDR], 0x10000)])
 +AS_IF([test x$TARGET_APPLE_CC = x1],
 +          [AC_SUBST([USE_APPLE_CC_FIXES], yes)])
 +
 +#
 +# Automake conditionals
 +#
 +
 +AM_CONDITIONAL([COND_emu], [test x$platform = xemu])
 +AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc])
 +AM_CONDITIONAL([COND_i386_efi], [test x$target_cpu = xi386 -a x$platform = xefi])
 +AM_CONDITIONAL([COND_i386_qemu], [test x$target_cpu = xi386 -a x$platform = xqemu])
 +AM_CONDITIONAL([COND_i386_ieee1275], [test x$target_cpu = xi386 -a x$platform = xieee1275])
 +AM_CONDITIONAL([COND_i386_coreboot], [test x$target_cpu = xi386 -a x$platform = xcoreboot])
 +AM_CONDITIONAL([COND_i386_multiboot], [test x$target_cpu = xi386 -a x$platform = xmultiboot])
 +AM_CONDITIONAL([COND_x86_64_efi], [test x$target_cpu = xx86_64 -a x$platform = xefi])
 +AM_CONDITIONAL([COND_mips_yeeloong], [test x$target_cpu = xmips -a x$platform = xyeeloong])
 +AM_CONDITIONAL([COND_mips_qemu_mips], [test x$target_cpu = xmips -a x$platform = xqemu_mips])
 +AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275])
 +AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275])
 +
 +AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x])
 +AM_CONDITIONAL([COND_GRUB_EMU_USB], [test x$enable_grub_emu_usb = xyes])
 +AM_CONDITIONAL([COND_GRUB_EMU_SDL], [test x$enable_grub_emu_sdl = xyes])
 +AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes])
 +AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes])
 +AM_CONDITIONAL([COND_HAVE_FONT_SOURCE], [test x$FONT_SOURCE != x])
 +AM_CONDITIONAL([COND_GRUB_FSTEST], [test x$enable_grub_fstest = xyes])
 +AM_CONDITIONAL([COND_ENABLE_EFIEMU], [test x$enable_efiemu = xyes])
diff --cc gentpl.py
index f906bd6d17dd5fe62dff680088c10eb147168f37,0000000000000000000000000000000000000000..9f1828d492efe7c3363ad15d5fda74a838bd3c00
mode 100644,000000..100644
--- /dev/null
+++ b/gentpl.py
@@@ -1,461 -1,0 +1,458 @@@
- def canonical_kernel(): return canonical_name() + "_exec"
 +#! /usr/bin/python
 +
 +#
 +# This is the python script used to generate Makefile.tpl
 +#
 +
 +GRUB_PLATFORMS = [ "emu", "i386_pc", "i386_efi", "i386_qemu", "i386_coreboot",
 +                   "i386_multiboot", "i386_ieee1275", "x86_64_efi",
 +                   "mips_yeeloong", "sparc64_ieee1275",
 +                   "powerpc_ieee1275" ]
 +
 +GROUPS = {}
 +GROUPS["i386"]    = [ "i386_pc", "i386_efi", "i386_qemu", "i386_coreboot", "i386_multiboot", "i386_ieee1275" ]
 +GROUPS["x86_64"]  = [ "x86_64_efi" ]
 +GROUPS["mips"]    = [ "mips_yeeloong" ]
 +GROUPS["sparc64"] = [ "sparc64_ieee1275" ]
 +GROUPS["powerpc"] = [ "powerpc_ieee1275" ]
 +GROUPS["x86"]     = GROUPS["i386"] + GROUPS["x86_64"]
 +GROUPS["x86_efi"] = [ "i386_efi", "x86_64_efi" ]
 +GROUPS["common"]  = GRUB_PLATFORMS[:]
 +GROUPS["nonemu"]  = GRUB_PLATFORMS[:]
 +GROUPS["nonemu"].remove("emu")
 +
 +#
 +# Create platform => groups reverse map, where groups covering that
 +# platform are ordered by their sizes
 +#
 +RMAP = {}
 +for platform in GRUB_PLATFORMS:
 +    # initialize with platform itself as a group
 +    RMAP[platform] = [ platform ]
 +
 +    for k in GROUPS.keys():
 +        v = GROUPS[k]
 +        # skip groups that don't cover this platform
 +        if platform not in v: continue
 +
 +        bigger = []
 +        smaller = []
 +        # partition currently known groups based on their size
 +        for group in RMAP[platform]:
 +            if group in GRUB_PLATFORMS: smaller.append(group)
 +            elif len(GROUPS[group]) < len(v): smaller.append(group)
 +            else: bigger.append(group)
 +        # insert in the middle
 +        RMAP[platform] = smaller + [ k ] + bigger
 +
 +#
 +# Global variables
 +#
 +GVARS = []
 +
 +def gvar_add(var, value):
 +    if var not in GVARS:
 +        GVARS.append(var)
 +    return var + " += " + value + "\n"
 +
 +def global_variable_initializers():
 +    r = ""
 +    for var in GVARS:
 +        r += var + " ?= \n"
 +    return r
 +
 +#
 +# Per PROGRAM/SCRIPT variables 
 +#
 +
 +def var_set(var, value):
 +    return var + "  = " + value + "\n"
 +
 +def var_add(var, value):
 +    return var + " += " + value + "\n"
 +
 +#
 +# Autogen constructs
 +#
 +
 +def if_tag(tag, closure):
 +    return "[+ IF " + tag + " +]" + closure() + "[+ ENDIF +]"
 +
 +def if_tag_defined(tag, closure):
 +    return "[+ IF " + tag + " defined +]" + closure() + "[+ ENDIF +]"
 +
 +def for_tag(tag, closure):
 +    return "[+ FOR ." + tag + " +]" + closure() + "[+ ENDFOR +]"
 +
 +def collect_values(tag, prefix=""):
 +    return for_tag(tag, lambda: prefix + "[+ ." + tag + " +] ")
 +
 +def each_group(platform, suffix, closure):
 +    r = None
 +    for group in RMAP[platform]:
 +        if r == None:
 +            r = "[+ IF ." + group + suffix + " +]"
 +        else:
 +            r += "[+ ELIF ." + group + suffix + " +]"
 +            
 +        r += closure(group)
 +
 +    if r:
 +        r += "[+ ELSE +]"
 +        r += closure(None)
 +        r += "[+ ENDIF +]"
 +    else:
 +        r = closure(None)
 +
 +    return r
 +
 +def each_platform(closure):
 +    r = ""
 +    for platform in GRUB_PLATFORMS:
 +        for group in RMAP[platform]:
 +            if group == RMAP[platform][0]:
 +                r += "[+ IF ." + group + " defined +]"
 +            else:
 +                r += "[+ ELIF ." + group + " defined +]"
 +
 +            r += "if COND_" + platform + "\n"
 +            r += closure(platform)
 +            r += "endif\n"
 +        r += "[+ ENDIF +]"
 +    return r
 +
 +def canonical_name():   return "[+ % name `echo -n %s | sed -e 's/[^0-9A-Za-z@_]/_/g'` +]"
 +def canonical_module(): return canonical_name() + "_module"
-     r  = gvar_add("noinst_PROGRAMS", "[+ name +].exec")
++def canonical_kernel(): return canonical_name() + "_img"
 +def canonical_image(): return canonical_name() + "_image"
 +
 +def shared_sources(prefix=""):        return collect_values("shared", prefix)
 +def shared_nodist_sources(prefix=""): return collect_values("nodist_shared", prefix)
 +
 +def default_sources(prefix=""):        return collect_values("source", prefix)
 +def default_nodist_sources(prefix=""): return collect_values("nodist", prefix)
 +def default_ldadd():     return collect_values("ldadd")
 +def default_cflags():    return collect_values("cflags")
 +def default_ldflags():   return collect_values("ldflags")
 +def default_cppflags():  return collect_values("cppflags")
 +def default_ccasflags(): return collect_values("ccasflags")
 +
 +def group_sources(group, prefix=""):        return collect_values(group, prefix) if group else default_sources(prefix)
 +def group_nodist_sources(group, prefix=""): return collect_values(group + "_nodist", prefix) if group else default_nodist_sources(prefix)
 +
 +def platform_sources(platform, prefix=""):        return each_group(platform, "", lambda g: collect_values(g, prefix) if g else default_sources(prefix))
 +def platform_nodist_sources(platform, prefix=""): return each_group(platform, "_nodist", lambda g: collect_values(g + "_nodist", prefix) if g else default_nodist_sources(prefix))
 +
 +def platform_ldadd(platform):     return each_group(platform, "_ldadd", lambda g: collect_values(g + "_ldadd") if g else default_ldadd())
 +def platform_cflags(platform):    return each_group(platform, "_cflags", lambda g: collect_values(g + "_cflags") if g else default_cflags())
 +def platform_ldflags(platform):   return each_group(platform, "_ldflags", lambda g: collect_values(g + "_ldflags") if g else default_ldflags())
 +def platform_cppflags(platform):  return each_group(platform, "_cppflags", lambda g: collect_values(g + "_cppflags") if g else default_cppflags())
 +def platform_ccasflags(platform): return each_group(platform, "_ccasflags", lambda g: collect_values(g + "_ccasflags") if g else default_ccasflags())
 +def platform_format(platform):    return each_group(platform, "_format", lambda g: collect_values(g + "_format") if g else "binary")
 +
 +def module(platform):
 +    r  = gvar_add("noinst_PROGRAMS", "[+ name +].module")
 +    r += gvar_add("MODULE_FILES", "[+ name +].module")
 +
 +    r += var_set(canonical_module() + "_SOURCES", platform_sources(platform) + "## platform sources")
 +    r += var_add(canonical_module() + "_SOURCES", shared_sources() + "## shared sources")
 +    r += var_set("nodist_" + canonical_module() + "_SOURCES", platform_nodist_sources(platform) + "## platform nodist sources")
 +    r += var_add("nodist_" + canonical_module() + "_SOURCES", shared_nodist_sources() + "## shared nodist sources")
 +    r += var_set(canonical_module() + "_LDADD", platform_ldadd(platform))
 +    r += var_set(canonical_module() + "_CFLAGS", "$(AM_CFLAGS) $(CFLAGS_MODULE) " + platform_cflags(platform))
 +    r += var_set(canonical_module() + "_LDFLAGS", "$(AM_LDFLAGS) $(LDFLAGS_MODULE) " + platform_ldflags(platform))
 +    r += var_set(canonical_module() + "_CPPFLAGS", "$(AM_CPPFLAGS) $(CPPFLAGS_MODULE) " + platform_cppflags(platform))
 +    r += var_set(canonical_module() + "_CCASFLAGS", "$(AM_CCASFLAGS) $(CCASFLAGS_MODULE) " + platform_ccasflags(platform))
 +
 +    r += gvar_add("BUILT_SOURCES", "$(nodist_" + canonical_module() + "_SOURCES)")
 +    r += gvar_add("CLEANFILES", "$(nodist_" + canonical_module() + "_SOURCES)")
 +
 +    r += gvar_add("DEF_FILES", "def-[+ name +].lst")
 +    r += gvar_add("UND_FILES", "und-[+ name +].lst")
 +    r += gvar_add("MOD_FILES", "[+ name +].mod")
 +    r += gvar_add("platform_DATA", "[+ name +].mod")
 +    r += gvar_add("CLEANFILES", "def-[+ name +].lst und-[+ name +].lst mod-[+ name +].c mod-[+ name +].o [+ name +].mod")
 +
 +    r += gvar_add("COMMAND_FILES", "command-[+ name +].lst")
 +    r += gvar_add("FS_FILES", "fs-[+ name +].lst")
 +    r += gvar_add("VIDEO_FILES", "video-[+ name +].lst")
 +    r += gvar_add("PARTMAP_FILES", "partmap-[+ name +].lst")
 +    r += gvar_add("HANDLER_FILES", "handler-[+ name +].lst")
 +    r += gvar_add("PARTTOOL_FILES", "parttool-[+ name +].lst")
 +    r += gvar_add("TERMINAL_FILES", "terminal-[+ name +].lst")
 +    r += gvar_add("CLEANFILES", "command-[+ name +].lst fs-[+ name +].lst")
 +    r += gvar_add("CLEANFILES", "handler-[+ name +].lst terminal-[+ name +].lst")
 +    r += gvar_add("CLEANFILES", "video-[+ name +].lst partmap-[+ name +].lst parttool-[+ name +].lst")
 +
++    r += gvar_add("CLEANFILES", "[+ name +].pp")
 +    r += """
 +[+ name +].pp: $(""" + canonical_module() + """_SOURCES) $(nodist_""" + canonical_module() + """_SOURCES)
 +      $(TARGET_CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(""" + canonical_module() + """_CPPFLAGS) $(CPPFLAGS) $^ > $@ || (rm -f $@; exit 1)
 +
 +def-[+ name +].lst: [+ name +].module
 +      if test x$(USE_APPLE_CC_FIXES) = xyes; then \
 +        $(NM) -g -P -p $< | grep -E '^[a-zA-Z0-9_]* [TDS]' | sed "s/^\\([^ ]*\\).*/\\1 [+ name +]/" >> $@; \
 +      else \
 +        $(NM) -g --defined-only -P -p $< | sed "s/^\\([^ ]*\\).*/\\1 [+ name +]/" >> $@; \
 +      fi
 +
 +und-[+ name +].lst: [+ name +].module
 +      $(NM) -u -P -p $< | sed "s/^\\([^ ]*\\).*/\\1 [+ name +]/" >> $@
 +
 +mod-[+ name +].c: [+ name +].module $(top_builddir)/moddep.lst $(top_srcdir)/genmodsrc.sh
 +      sh $(top_srcdir)/genmodsrc.sh [+ name +] $(top_builddir)/moddep.lst > $@ || (rm -f $@; exit 1)
 +
 +mod-[+ name +].o: mod-[+ name +].c
 +      $(TARGET_CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(CPPFLAGS_MODULE) $(CPPFLAGS) $(CFLAGS_MODULE) $(CFLAGS) -c -o $@ $<
 +
 +[+ name +].mod: [+ name +].module mod-[+ name +].o
 +      if test x$(USE_APPLE_CC_FIXES) = xyes; then \
 +        $(CCLD) $(LDFLAGS_MODULE) $(LDFLAGS) -o $@.bin $^; \
 +        $(OBJCONV) -f$(TARGET_MODULE_FORMAT) -nr:_grub_mod_init:grub_mod_init -nr:_grub_mod_fini:grub_mod_fini -wd1106 -nu -nd $@.bin $@; \
 +        rm -f $@.bin; \
 +      else \
 +        $(CCLD) -o $@ $(LDFLAGS_MODULE) $(LDFLAGS) $^; \
 +        if test ! -z '$(TARGET_OBJ2ELF)'; then $(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi; \
 +        $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -K _grub_mod_init -K _grub_mod_fini -R .note -R .comment $@; \
 +      fi
 +
 +command-[+ name +].lst: [+ name +].pp $(top_srcdir)/gencmdlist.sh
 +      cat $< | sh $(top_srcdir)/gencmdlist.sh [+ name +] > $@ || (rm -f $@; exit 1)
 +
 +fs-[+ name +].lst: [+ name +].pp $(top_srcdir)/genfslist.sh
 +      cat $< | sh $(top_srcdir)/genfslist.sh [+ name +] > $@ || (rm -f $@; exit 1)
 +
 +video-[+ name +].lst: [+ name +].pp $(top_srcdir)/genvideolist.sh
 +      cat $< | sh $(top_srcdir)/genvideolist.sh [+ name +] > $@ || (rm -f $@; exit 1)
 +
 +partmap-[+ name +].lst: [+ name +].pp $(top_srcdir)/genpartmaplist.sh
 +      cat $< | sh $(top_srcdir)/genpartmaplist.sh [+ name +] > $@ || (rm -f $@; exit 1)
 +
 +parttool-[+ name +].lst: [+ name +].pp $(top_srcdir)/genparttoollist.sh
 +      cat $< | sh $(top_srcdir)/genparttoollist.sh [+ name +] > $@ || (rm -f $@; exit 1)
 +
 +handler-[+ name +].lst: [+ name +].pp $(top_srcdir)/genhandlerlist.sh
 +      cat $< | sh $(top_srcdir)/genhandlerlist.sh [+ name +] > $@ || (rm -f $@; exit 1)
 +
 +terminal-[+ name +].lst: [+ name +].pp $(top_srcdir)/genterminallist.sh
 +      cat $< | sh $(top_srcdir)/genterminallist.sh [+ name +] > $@ || (rm -f $@; exit 1)
 +"""
 +    return r
 +
 +def rule(target, source, cmd):
 +    if cmd[0] == "\n":
 +        return "\n" + target + ": " + source + cmd.replace("\n", "\n\t") + "\n"
 +    else:
 +        return "\n" + target + ": " + source + "\n\t" + cmd.replace("\n", "\n\t") + "\n"
 +
 +def image_nostrip(platform):
 +    return if_tag_defined("image_nostrip." + platform, lambda: rule("[+ name +].img", "[+ name +].exec", "cp $< $@"))
 +
 +def image_strip(platform):
 +    return if_tag_defined("image_strip." + platform, lambda: rule("[+ name +].img", "[+ name +].exec", "$(STRIP) -o $@ -R .rel.dyn -R .reginfo -R .note -R .comment $<"))
 +
 +def image_strip_keep_kernel(platform):
 +    return if_tag_defined("image_strip_keep_kernel." + platform, lambda: rule("[+ name +].img", "[+ name +].exec", "$(STRIP) -o $@ --strip-unneeded -K start -R .note -R .comment $<"))
 +
 +def image_strip_macho2img(platform):
 +    return if_tag_defined("image_strip_macho2img." + platform, lambda: rule("[+ name +].img", "[+ name +].exec", """
 +if test "x$(TARGET_APPLE_CC)" = x1; then \
 +  $(MACHO2IMG) --bss $< $@ || exit 1; \
 +else \
 +  $(STRIP) -o $@ -O binary --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .reginfo -R .rel.dyn $< || exit 1; \
 +fi
 +"""))
 +
 +def kernel(platform):
-     r += image_nostrip(platform)
-     r += image_strip(platform)
-     r += image_strip_keep_kernel(platform)
-     r += image_strip_macho2img(platform)
++    r  = gvar_add("noinst_PROGRAMS", "[+ name +].img")
 +    r += var_set(canonical_kernel() + "_SOURCES", platform_sources(platform))
 +    r += var_add(canonical_kernel() + "_SOURCES", shared_sources())
 +    r += var_set("nodist_" + canonical_kernel() + "_SOURCES", platform_nodist_sources(platform) + "## platform nodist sources")
 +    r += var_add("nodist_" + canonical_kernel() + "_SOURCES", shared_nodist_sources() + "## shared nodist sources")
 +    r += var_set(canonical_kernel() + "_LDADD", platform_ldadd(platform))
 +    r += var_set(canonical_kernel() + "_CFLAGS", "$(AM_CFLAGS) $(CFLAGS_KERNEL) " + platform_cflags(platform))
 +    r += var_set(canonical_kernel() + "_LDFLAGS", "$(AM_LDFLAGS) $(LDFLAGS_KERNEL) " + platform_ldflags(platform))
 +    r += var_set(canonical_kernel() + "_CPPFLAGS", "$(AM_CPPFLAGS) $(CPPFLAGS_KERNEL) " + platform_cppflags(platform))
 +    r += var_set(canonical_kernel() + "_CCASFLAGS", "$(AM_CCASFLAGS) $(CCASFLAGS_KERNEL) " + platform_ccasflags(platform))
 +
 +    r += gvar_add("BUILT_SOURCES", "$(nodist_" + canonical_kernel() + "_SOURCES)")
 +    r += gvar_add("CLEANFILES", "$(nodist_" + canonical_kernel() + "_SOURCES)")
 +
 +    r += gvar_add("platform_DATA", "[+ name +].img")
 +    return r
 +
 +def image(platform):
 +    r  = gvar_add("noinst_PROGRAMS", "[+ name +].image")
 +    r += var_set(canonical_image() + "_SOURCES", platform_sources(platform))
 +    r += var_add(canonical_image() + "_SOURCES", shared_sources())
 +    r += var_set("nodist_" + canonical_image() + "_SOURCES", platform_nodist_sources(platform) + "## platform nodist sources")
 +    r += var_add("nodist_" + canonical_image() + "_SOURCES", shared_nodist_sources() + "## shared nodist sources")
 +    r += var_set(canonical_image() + "_LDADD", platform_ldadd(platform))
 +    r += var_set(canonical_image() + "_CFLAGS", "$(AM_CFLAGS) $(CFLAGS_IMAGE) " + platform_cflags(platform))
 +    r += var_set(canonical_image() + "_LDFLAGS", "$(AM_LDFLAGS) $(LDFLAGS_IMAGE) " + platform_ldflags(platform))
 +    r += var_set(canonical_image() + "_CPPFLAGS", "$(AM_CPPFLAGS) $(CPPFLAGS_IMAGE) " + platform_cppflags(platform))
 +    r += var_set(canonical_image() + "_CCASFLAGS", "$(AM_CCASFLAGS) $(CCASFLAGS_IMAGE) " + platform_ccasflags(platform))
 +
 +    r += gvar_add("BUILT_SOURCES", "$(nodist_" + canonical_image() + "_SOURCES)")
 +    r += gvar_add("CLEANFILES", "$(nodist_" + canonical_image() + "_SOURCES)")
 +
 +    r += gvar_add("platform_DATA", "[+ name +].img")
 +    r += rule("[+ name +].img", "[+ name +].image", """
 +if test x$(USE_APPLE_CC_FIXES) = xyes; then \
 +  $(MACHO2IMG) $< $@; \
 +else \
 +  $(OBJCOPY) -O """ + platform_format(platform) + """ --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .reginfo -R .rel.dyn $< $@; \
 +fi
 +""")
 +    return r
 +
 +def library(platform):
 +    r  = gvar_add("noinst_LIBRARIES", "[+ name +]")
 +    r += var_set(canonical_name() + "_SOURCES", platform_sources(platform))
 +    r += var_add(canonical_name() + "_SOURCES", shared_sources())
 +    r += var_set("nodist_" + canonical_name() + "_SOURCES", platform_nodist_sources(platform))
 +    r += var_add("nodist_" + canonical_name() + "_SOURCES", shared_nodist_sources())
 +    r += var_set(canonical_name() + "_CFLAGS", "$(AM_CFLAGS) $(CFLAGS_LIBRARY) " + platform_cflags(platform))
 +    r += var_set(canonical_name() + "_CPPFLAGS", "$(AM_CPPFLAGS) $(CPPFLAGS_LIBRARY) " + platform_cppflags(platform))
 +    r += var_set(canonical_name() + "_CCASFLAGS", "$(AM_CCASFLAGS) $(CCASFLAGS_LIBRARY) " + platform_ccasflags(platform))
 +
 +    r += gvar_add("BUILT_SOURCES", "$(nodist_" + canonical_name() + "_SOURCES)")
 +    r += gvar_add("CLEANFILES", "$(nodist_" + canonical_name() + "_SOURCES)")
 +
 +    return r
 +
 +def installdir(default="bin"):
 +    return "[+ IF installdir +][+ installdir +][+ ELSE +]" + default + "[+ ENDIF +]"
 +
 +def manpage():
 +    r  = "if COND_MAN_PAGES\n"
 +    r += gvar_add("man_MANS", "[+ name +].[+ mansection +]\n")
 +    r += rule("[+ name +].[+ mansection +]", "", """
 +$(MAKE) $(AM_MAKEFLAGS) [+ name +]
 +chmod a+x [+ name +]
 +$(HELP2MAN) --section=[+ mansection +] -o $@ ./[+ name +]
 +""")
 +    r += gvar_add("CLEANFILES", "[+ name +].[+ mansection +]")
 +    r += "endif\n"
 +    return r
 +
 +def program(platform, test=False):
 +    if test:
 +        r = gvar_add("check_PROGRAMS", "[+ name +]")
 +    else:
 +        r  = gvar_add(installdir() + "_PROGRAMS", "[+ name +]")
 +
 +    r += var_set(canonical_name() + "_SOURCES", platform_sources(platform))
 +    r += var_add(canonical_name() + "_SOURCES", shared_sources())
 +    r += var_set("nodist_" + canonical_name() + "_SOURCES", platform_nodist_sources(platform))
 +    r += var_add("nodist_" + canonical_name() + "_SOURCES", shared_nodist_sources())
 +    r += var_set(canonical_name() + "_LDADD", platform_ldadd(platform))
 +    r += var_set(canonical_name() + "_CFLAGS", "$(AM_CFLAGS) $(CFLAGS_PROGRAM) " + platform_cflags(platform))
 +    r += var_set(canonical_name() + "_LDFLAGS", "$(AM_LDFLAGS) $(LDFLAGS_PROGRAM) " + platform_ldflags(platform))
 +    r += var_set(canonical_name() + "_CPPFLAGS", "$(AM_CPPFLAGS) $(CPPFLAGS_PROGRAM) " + platform_cppflags(platform))
 +    r += var_set(canonical_name() + "_CCASFLAGS", "$(AM_CCASFLAGS) $(CCASFLAGS_PROGRAM) " + platform_ccasflags(platform))
 +
 +    r += gvar_add("BUILT_SOURCES", "$(nodist_" + canonical_name() + "_SOURCES)")
 +    r += gvar_add("CLEANFILES", "$(nodist_" + canonical_name() + "_SOURCES)")
 +
 +    if test:
 +        r += if_tag_defined("enable", lambda: gvar_add("TESTS", "[+ name +]"))
 +    else:
 +        r += if_tag("mansection", lambda: manpage())
 +
 +    return r
 +
 +def test_program(platform):
 +    return program(platform, True)
 +
 +def data(platform):
 +    return gvar_add(installdir() + "_DATA", platform_sources(platform))
 +
 +def script(platform, test=False):
 +    if test:
 +        r = gvar_add("check_SCRIPTS", "[+ name +]")
 +    else:
 +        r  = gvar_add(installdir() + "_SCRIPTS", "[+ name +]")
 +
 +    r += rule("[+ name +]", "$(top_builddir)/config.status " + platform_sources(platform), """
 +$(top_builddir)/config.status --file=-:""" + platform_sources(platform) + """ \
 +  | sed -e 's,@pkglib_DATA@,$(pkglib_DATA),g' > $@
 +chmod a+x [+ name +]
 +""")
 +
 +    r += gvar_add("CLEANFILES", "[+ name +]")
 +    r += gvar_add("EXTRA_DIST", platform_sources(platform))
 +
 +    if test:
 +        r += if_tag_defined("enable", lambda: gvar_add("TESTS", "[+ name +]"))
 +    else:
 +        r += if_tag("mansection", lambda: manpage())
 +
 +    return r
 +
 +def test_script(platform):
 +    return script(platform, True)
 +
 +def with_enable_condition(x):
 +    return "[+ IF enable +]if [+ enable +]\n" + x + "endif\n[+ ELSE +]" + x + "[+ ENDIF +]"
 +
 +def module_rules():
 +    return for_tag("module", lambda: with_enable_condition(each_platform(lambda p: module(p))))
 +
 +def kernel_rules():
 +    return for_tag("kernel", lambda: with_enable_condition(each_platform(lambda p: kernel(p))))
 +
 +def image_rules():
 +    return for_tag("image", lambda: with_enable_condition(each_platform(lambda p: image(p))))
 +
 +def library_rules():
 +    return for_tag("library", lambda: with_enable_condition(each_platform(lambda p: library(p))))
 +
 +def program_rules():
 +    return for_tag("program", lambda: with_enable_condition(each_platform(lambda p: program(p))))
 +
 +def script_rules():
 +    return for_tag("script", lambda: with_enable_condition(each_platform(lambda p: script(p))))
 +
 +def data_rules():
 +    return for_tag("data", lambda: with_enable_condition(each_platform(lambda p: data(p))))
 +
 +def test_program_rules():
 +    return for_tag("test_program", lambda: with_enable_condition(each_platform(lambda p: test_program(p))))
 +
 +def test_script_rules():
 +    return for_tag("test_script", lambda: with_enable_condition(each_platform(lambda p: test_script(p))))
 +
 +print "[+ AutoGen5 template +]\n"
 +a = module_rules()
 +b = kernel_rules()
 +c = image_rules()
 +d = library_rules()
 +e = program_rules()
 +f = script_rules()
 +g = data_rules()
 +h = test_program_rules()
 +i = test_script_rules()
 +z = global_variable_initializers()
 +
 +print z # initializer for all vars
 +print a
 +print b
 +print c
 +print d
 +print e
 +print f
 +print g
 +print h
 +print i
 +
 +print """.PRECIOUS: modules.am
 +$(srcdir)/modules.am: $(srcdir)/modules.def $(top_srcdir)/Makefile.tpl
 +      autogen -T $(top_srcdir)/Makefile.tpl $(srcdir)/modules.def | sed -e '/^$$/{N;/^\\n$$/D;}' > $@.new || (rm -f $@.new; exit 1)
 +      mv $@.new $@
 +
 +.PRECIOUS: $(top_srcdir)/Makefile.tpl
 +$(top_srcdir)/Makefile.tpl: $(top_srcdir)/gentpl.py
 +      python $(top_srcdir)/gentpl.py | sed -e '/^$$/{N;/^\\n$$/D;}' > $@.new || (rm -f $@.new; exit 1)
 +      mv $@.new $@
 +"""
index 38e2e0ab7d44a306c8b8aab3d9aea55ea782e8eb,0000000000000000000000000000000000000000..8b48cf153db363493098b0546216593754d96c15
mode 100644,000000..100644
--- /dev/null
@@@ -1,203 -1,0 +1,201 @@@
- KERNEL_HEADER_FILES += include/grub/machine/kernel.h
 +# -*- makefile -*-
 +
 +KERNEL_HEADER_FILES =
 +KERNEL_HEADER_FILES += include/grub/cache.h
 +KERNEL_HEADER_FILES += include/grub/command.h
 +KERNEL_HEADER_FILES += include/grub/device.h
 +KERNEL_HEADER_FILES += include/grub/disk.h
 +KERNEL_HEADER_FILES += include/grub/dl.h
 +KERNEL_HEADER_FILES += include/grub/elf.h
 +KERNEL_HEADER_FILES += include/grub/elfload.h
 +KERNEL_HEADER_FILES += include/grub/env.h
 +KERNEL_HEADER_FILES += include/grub/env_private.h
 +KERNEL_HEADER_FILES += include/grub/err.h
 +KERNEL_HEADER_FILES += include/grub/file.h
 +KERNEL_HEADER_FILES += include/grub/fs.h
 +KERNEL_HEADER_FILES += include/grub/handler.h
 +KERNEL_HEADER_FILES += include/grub/i18n.h
 +KERNEL_HEADER_FILES += include/grub/kernel.h
 +KERNEL_HEADER_FILES += include/grub/list.h
 +KERNEL_HEADER_FILES += include/grub/misc.h
 +KERNEL_HEADER_FILES += include/grub/mm.h
 +KERNEL_HEADER_FILES += include/grub/net.h
 +KERNEL_HEADER_FILES += include/grub/parser.h
 +KERNEL_HEADER_FILES += include/grub/partition.h
 +KERNEL_HEADER_FILES += include/grub/reader.h
 +KERNEL_HEADER_FILES += include/grub/symbol.h
 +KERNEL_HEADER_FILES += include/grub/term.h
 +KERNEL_HEADER_FILES += include/grub/time.h
 +KERNEL_HEADER_FILES += include/grub/types.h
 +
 +if COND_i386_pc
 +KERNEL_HEADER_FILES += include/grub/boot.h
 +KERNEL_HEADER_FILES += include/grub/loader.h
 +KERNEL_HEADER_FILES += include/grub/msdos_partition.h
 +KERNEL_HEADER_FILES += include/grub/machine/biosdisk.h
 +KERNEL_HEADER_FILES += include/grub/machine/boot.h
 +KERNEL_HEADER_FILES += include/grub/machine/console.h
 +KERNEL_HEADER_FILES += include/grub/machine/memory.h
 +KERNEL_HEADER_FILES += include/grub/machine/loader.h
 +KERNEL_HEADER_FILES += include/grub/machine/vga.h
 +KERNEL_HEADER_FILES += include/grub/machine/vbe.h
 +KERNEL_HEADER_FILES += include/grub/machine/kernel.h
 +KERNEL_HEADER_FILES += include/grub/machine/pxe.h
 +KERNEL_HEADER_FILES += include/grub/i386/pit.h
 +endif
 +
 +if COND_i386_efi
 +KERNEL_HEADER_FILES += include/grub/boot.h
 +KERNEL_HEADER_FILES += include/grub/loader.h
 +KERNEL_HEADER_FILES += include/grub/msdos_partition.h
 +KERNEL_HEADER_FILES += include/grub/efi/efi.h
 +KERNEL_HEADER_FILES += include/grub/efi/time.h
 +KERNEL_HEADER_FILES += include/grub/efi/disk.h
 +KERNEL_HEADER_FILES += include/grub/i386/pit.h
 +endif
 +
 +if COND_i386_coreboot
 +KERNEL_HEADER_FILES += include/grub/boot.h
 +KERNEL_HEADER_FILES += include/grub/loader.h
 +KERNEL_HEADER_FILES += include/grub/msdos_partition.h
 +KERNEL_HEADER_FILES += include/grub/machine/boot.h
 +KERNEL_HEADER_FILES += include/grub/machine/console.h
 +KERNEL_HEADER_FILES += include/grub/machine/init.h
 +KERNEL_HEADER_FILES += include/grub/machine/memory.h
 +KERNEL_HEADER_FILES += include/grub/machine/loader.h
 +endif
 +
 +if COND_i386_multiboot
 +KERNEL_HEADER_FILES += include/grub/boot.h
 +KERNEL_HEADER_FILES += include/grub/loader.h
 +KERNEL_HEADER_FILES += include/grub/msdos_partition.h
 +KERNEL_HEADER_FILES += include/grub/machine/boot.h
 +KERNEL_HEADER_FILES += include/grub/machine/console.h
 +KERNEL_HEADER_FILES += include/grub/machine/init.h
 +KERNEL_HEADER_FILES += include/grub/machine/memory.h
 +KERNEL_HEADER_FILES += include/grub/machine/loader.h
 +endif
 +
 +if COND_i386_qemu
 +KERNEL_HEADER_FILES += include/grub/boot.h
 +KERNEL_HEADER_FILES += include/grub/loader.h
 +KERNEL_HEADER_FILES += include/grub/msdos_partition.h
 +KERNEL_HEADER_FILES += include/grub/machine/boot.h
 +KERNEL_HEADER_FILES += include/grub/machine/console.h
 +KERNEL_HEADER_FILES += include/grub/machine/init.h
 +KERNEL_HEADER_FILES += include/grub/machine/memory.h
 +KERNEL_HEADER_FILES += include/grub/machine/loader.h
 +endif
 +
 +if COND_i386_ieee1275
 +KERNEL_HEADER_FILES += include/grub/loader.h
 +KERNEL_HEADER_FILES += include/grub/msdos_partition.h
 +KERNEL_HEADER_FILES += include/grub/ieee1275/ieee1275.h
- KERNEL_HEADER_FILES += include/grub/machine/kernel.h
 +KERNEL_HEADER_FILES += include/grub/machine/loader.h
 +KERNEL_HEADER_FILES += include/grub/machine/memory.h
 +endif
 +
 +if COND_x86_64_efi
 +KERNEL_HEADER_FILES += include/grub/boot.h
 +KERNEL_HEADER_FILES += include/grub/loader.h
 +KERNEL_HEADER_FILES += include/grub/msdos_partition.h
 +KERNEL_HEADER_FILES += include/grub/efi/efi.h
 +KERNEL_HEADER_FILES += include/grub/efi/time.h
 +KERNEL_HEADER_FILES += include/grub/efi/disk.h
 +KERNEL_HEADER_FILES += include/grub/machine/loader.h
 +KERNEL_HEADER_FILES += include/grub/i386/pit.h
 +endif
 +
 +if COND_mips_yeeloong
 +KERNEL_HEADER_FILES += include/grub/boot.h
 +KERNEL_HEADER_FILES += include/grub/loader.h
 +KERNEL_HEADER_FILES += include/grub/msdos_partition.h
 +KERNEL_HEADER_FILES += include/grub/machine/kernel.h
 +KERNEL_HEADER_FILES += include/grub/machine/memory.h
 +KERNEL_HEADER_FILES += include/grub/cpu/cache.h
 +KERNEL_HEADER_FILES += include/grub/bitmap.h
 +KERNEL_HEADER_FILES += include/grub/video.h
 +KERNEL_HEADER_FILES += include/grub/gfxterm.h
 +KERNEL_HEADER_FILES += include/grub/font.h
 +KERNEL_HEADER_FILES += include/grub/bitmap_scale.h
 +KERNEL_HEADER_FILES += include/grub/bufio.h
 +KERNEL_HEADER_FILES += include/grub/pci.h
 +KERNEL_HEADER_FILES += include/grub/libgcc.h
 +endif
 +
 +if COND_powerpc_ieee1275
 +KERNEL_HEADER_FILES += include/grub/boot.h
 +KERNEL_HEADER_FILES += include/grub/loader.h
 +KERNEL_HEADER_FILES += include/grub/msdos_partition.h
 +KERNEL_HEADER_FILES += include/grub/ieee1275/ieee1275.h
 +KERNEL_HEADER_FILES += include/grub/libgcc.h
 +endif
 +
 +if COND_sparc64_ieee1275
 +KERNEL_HEADER_FILES += include/grub/boot.h
 +KERNEL_HEADER_FILES += include/grub/loader.h
 +KERNEL_HEADER_FILES += include/grub/msdos_partition.h
 +KERNEL_HEADER_FILES += include/grub/libgcc.h
 +KERNEL_HEADER_FILES += include/grub/ieee1275/ieee1275.h
 +KERNEL_HEADER_FILES += include/grub/machine/kernel.h
 +KERNEL_HEADER_FILES += include/grub/sparc64/ieee1275/ieee1275.h
 +endif
 +
 +if COND_emu
 +KERNEL_HEADER_FILES += include/grub/cpu/time.h
 +KERNEL_HEADER_FILES += include/grub/cpu/types.h
 +KERNEL_HEADER_FILES += include/grub/gzio.h
 +KERNEL_HEADER_FILES += include/grub/menu.h
 +KERNEL_HEADER_FILES += include/grub/datetime.h
 +KERNEL_HEADER_FILES += include/grub/emu/misc.h
 +if COND_GRUB_EMU_SDL
 +KERNEL_HEADER_FILES += include/grub/sdl.h
 +endif
 +if COND_GRUB_EMU_USB
 +KERNEL_HEADER_FILES += include/grub/libusb.h
 +endif
 +if COND_GRUB_EMU_PCI
 +KERNEL_HEADER_FILES += include/grub/libpciaccess.h
 +endif
 +endif
 +
 +symlist.h: config.h $(KERNEL_HEADER_FILES)
 +      @list='$^'; \
 +      for p in $$list; do \
 +        echo "#include <$$p>" >> $@ || (rm -f $@; exit 1); \
 +      done
 +CLEANFILES += symlist.h
 +BUILT_SOURCES += symlist.h
 +
 +symlist.c: symlist.h gensymlist.sh
 +      $(TARGET_CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL) $(CPPFLAGS) -DGRUB_SYMBOL_GENERATOR=1 symlist.h > symlist.p || (rm -f symlist.p; exit 1)
 +      cat symlist.p | /bin/sh $(srcdir)/gensymlist.sh config.h $(KERNEL_HEADER_FILES) >$@ || (rm -f $@; exit 1)
 +      rm -f symlist.p
 +CLEANFILES += symlist.c
 +BUILT_SOURCES += symlist.c
 +
 +noinst_DATA += kernel_syms.lst
 +kernel_syms.lst: $(KERNEL_HEADER_FILES) config.h
 +      if grep "^#define HAVE_ASM_USCORE" config.h; then u="_"; else u=""; fi
 +      $(TARGET_CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS_KERNEL) $(CPPFLAGS) $(CFLAGS) -DGRUB_SYMBOL_GENERATOR=1 $^ >kernel_syms.input
 +      cat kernel_syms.input | grep -v '^#' | sed -n \
 +        -e '/EXPORT_FUNC *([a-zA-Z0-9_]*)/{s/.*EXPORT_FUNC *(\([a-zA-Z0-9_]*\)).*/'"$$u"'\1 kernel/;p;}' \
 +        -e '/EXPORT_VAR *([a-zA-Z0-9_]*)/{s/.*EXPORT_VAR *(\([a-zA-Z0-9_]*\)).*/'"$$u"'\1 kernel/;p;}' \
 +        | sort -u >$@
 +      rm -f kernel_syms.input
 +CLEANFILES += kernel_syms.lst
 +
 +if COND_emu
 +kern/emu/grub_emu-main.$(OBJEXT):grub_emu_init.h
 +grub_emu-grub_emu_init.$(OBJEXT):grub_emu_init.h
 +kern/emu/grub_emu_dyn-main.$(OBJEXT):grub_emu_init.h
 +grub_emu_dyn-grub_emu_init.$(OBJEXT):grub_emu_init.h
 +
 +grub_emu_init.h: genemuinitheader.sh $(MOD_FILES)
 +      rm -f $@; echo $(MOD_FILES) | sh $(srcdir)/genemuinitheader.sh $(NM) > $@
 +CLEANFILES += grub_emu_init.h
 +
 +grub_emu_init.c: grub_emu_init.h genemuinit.sh $(MOD_FILES)
 +      rm -f $@; echo $(MOD_FILES) | sh $(srcdir)/genemuinit.sh $(NM) > $@
 +CLEANFILES += grub_emu_init.c
 +endif
index 710a8fd0b69fcd25e0afa3ab7eb8dc80ec2f4cea,0000000000000000000000000000000000000000..dd4ee8d56b4d982e595c46e4085defbc1a302228
mode 100644,000000..100644
--- /dev/null
@@@ -1,80 -1,0 +1,81 @@@
- grubconfdir = $(sysconfdir)/grub.d
- platformdir = $(pkglibdir)/$(target_cpu)-$(platform)
 +# -*- makefile -*-
 +
++pkglibroot = $(libdir)/$(shell echo $(PACKAGE) | sed "$(transform)")
++grubconfdir = $(sysconfdir)/grub.d
++platformdir = $(pkglibroot)/$(target_cpu)-$(platform)
++
 +# Platform specific options
 +if COND_i386_pc
 +  CFLAGS_PLATFORM = -mrtd -mregparm=3
 +endif
 +if COND_i386_efi
 +  LDFLAGS_PLATFORM = -melf_i386
 +endif
 +if COND_x86_64_efi
 +  LDFLAGS_PLATFORM = -melf_x86_64
 +endif
 +if COND_i386_qemu
 +  CFLAGS_PLATFORM = -mrtd -mregparm=3
 +endif
 +if COND_i386_coreboot
 +  CFLAGS_PLATFORM = -mrtd -mregparm=3
 +endif
 +if COND_i386_ieee1275
 +  CFLAGS_PLATFORM = -mrtd -mregparm=3
 +endif
 +if COND_mips_yeeloong
 +  CFLAGS_PLATFORM = -march=mips3 -mexplicit-relocs -mflush-func=grub_cpu_flush_cache
 +  CCASFLAGS_PLATFORM = -march=mips3
 +endif
 +if COND_sparc64_ieee1275
 +  CFLAGS_PLATFORM = -mno-app-regs
 +  LDFLAGS_PLATFORM = -melf64_sparc -mno-relax
 +endif
 +
 +CPPFLAGS_GRUB = -I$(builddir) -I$(srcdir) -I$(top_builddir) -I$(top_srcdir)
 +CPPFLAGS_GRUB += -I$(top_srcdir)/include -I$(top_builddir)/include
 +
 +CFLAGS_GCRY = -Wno-error -Wno-missing-field-initializers
 +CPPFLAGS_GCRY = -I$(top_srcdir)/lib/libgcrypt_wrap
 +
 +CFLAGS_GNULIB = -Wno-undef -Wno-sign-compare -Wno-unused -D_GL_UNUSED="__attribute__ ((unused))"
 +CPPFLAGS_GNULIB = -I$(top_srcdir)/gnulib
 +
 +CFLAGS_MKISOFS = -Wno-all -Werror
 +CPPFLAGS_MKISOFS = -D_FILE_OFFSET_BITS=64 -I$(top_srcdir)/util/mkisofs/include
 +
 +CFLAGS_POSIX = -fno-builtin
 +CPPFLAGS_POSIX = -I$(top_srcdir)/lib/posix_wrap
 +
 +CPPFLAGS_EFIEMU = -I$(top_srcdir)/efiemu/runtime
 +
 +# to calm down automake
 +BUILT_SOURCES =
 +CLEANFILES =
 +COMMAND_FILES =
 +DEF_FILES =
 +FS_FILES =
 +HANDLER_FILES =
 +IMG_FILES =
 +MOD_FILES =
 +MODULE_FILES =
 +PARTMAP_FILES =
 +PARTTOOL_FILES =
 +TERMINAL_FILES =
 +TESTS =
 +UND_FILES =
 +VIDEO_FILES =
 +bin_PROGRAMS =
 +bin_SCRIPTS =
 +check_PROGRAMS =
 +check_SCRIPTS =
 +grubconf_DATA =
 +grubconf_SCRIPTS =
 +man_MANS =
 +noinst_DATA =
 +noinst_LIBRARIES =
 +noinst_PROGRAMS =
 +pkglib_SCRIPTS =
 +platform_DATA =
 +sbin_PROGRAMS =
 +sbin_SCRIPTS =
Simple merge
index 0000000000000000000000000000000000000000,36c35e6c421c415612a72ad880521bcdb44ed886..36c35e6c421c415612a72ad880521bcdb44ed886
mode 000000,100644..100644
--- /dev/null
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
index 0000000000000000000000000000000000000000,ae0b2557e8c6b47c111b03ca49f7648db5527dbe..ae0b2557e8c6b47c111b03ca49f7648db5527dbe
mode 000000,100644..100644
--- /dev/null
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
index fe77c4cbdfc3804524d65573038fc322af444d22,0000000000000000000000000000000000000000..80bb1cbddbe8679eee705ee7683012d6ffe5f63d
mode 100644,000000..100644
--- /dev/null
@@@ -1,1607 -1,0 +1,1602 @@@
-   image_nostrip = { emu; };
-   image_strip_keep_kernel = { i386_efi; x86_64_efi; };
-   image_strip = { powerpc_ieee1275; i386_coreboot; i386_multiboot; i386_ieee1275; };
-   image_strip_macho2img = { mips_yeeloong; i386_pc; i386_qemu; sparc64_ieee1275; };
 +AutoGen definitions Makefile.tpl;
 +
 +kernel = {
 +  name = kernel;
 +
 +  emu_ldflags              = '-Wl,-r';
 +  x86_efi_ldflags          = '-Wl,-r';
 +  i386_pc_ldflags          = '-Wl,-Ttext=$(GRUB_KERNEL_MACHINE_LINK_ADDR)';
 +  i386_coreboot_ldflags    = '-Wl,-Ttext=$(GRUB_KERNEL_MACHINE_LINK_ADDR)';
 +  i386_multiboot_ldflags   = '-Wl,-Ttext=$(GRUB_KERNEL_MACHINE_LINK_ADDR)';
 +  i386_qemu_ldflags        = '-Wl,-Ttext=$(GRUB_KERNEL_MACHINE_LINK_ADDR)';
 +  i386_ieee1275_ldflags    = '-Wl,-Ttext=$(GRUB_KERNEL_MACHINE_LINK_ADDR)';
 +  mips_yeeloong_ldflags    = '-Wl,-Ttext,$(GRUB_KERNEL_MACHINE_LINK_ADDR)';
 +  powerpc_ieee1275_ldflags = '-Wl,-Ttext,$(GRUB_KERNEL_MACHINE_LINK_ADDR)';
 +
 +  mips_yeeloong_cppflags = '-DUSE_ASCII_FAILBACK';
 +  i386_qemu_cppflags     = '-DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)';
 +  i386_qemu_ccasflags    = '-DGRUB_KERNEL_MACHINE_LINK_ADDR=$(GRUB_KERNEL_MACHINE_LINK_ADDR)';
 +  emu_cflags = '$(CFLAGS_GNULIB)';
 +  emu_cppflags = '$(CPPFLAGS_GNULIB)';
 +
 +  mips_ldadd = '-lgcc';
 +  powerpc_ldadd = '-lgcc';
 +  sparc64_ldadd = '-lgcc';
 +
 +  nonemu_nodist = symlist.c;
 +
 +  shared = kern/command.c;
 +  shared = kern/corecmd.c;
 +  shared = kern/device.c;
 +  shared = kern/disk.c;
 +  shared = kern/dl.c;
 +  shared = kern/env.c;
 +  shared = kern/err.c;
 +  shared = kern/file.c;
 +  shared = kern/fs.c;
 +  shared = kern/handler.c;
 +  shared = kern/list.c;
 +  shared = kern/main.c;
 +  shared = kern/misc.c;
 +  shared = kern/parser.c;
 +  shared = kern/partition.c;
 +  shared = kern/rescue_parser.c;
 +  shared = kern/rescue_reader.c;
 +  shared = kern/term.c;
 +
 +  i386_pc = kern/i386/pc/startup.S;
 +  i386_pc = kern/i386/misc.S;
 +  i386_pc = kern/mm.c;
 +  i386_pc = kern/time.c;
 +  i386_pc = kern/i386/dl.c;
 +  i386_pc = kern/i386/pc/init.c;
 +  i386_pc = kern/i386/pc/mmap.c;
 +  i386_pc = kern/i386/tsc.c;
 +  i386_pc = kern/i386/pit.c;
 +  i386_pc = kern/generic/rtc_get_time_ms.c;
 +  i386_pc = kern/generic/millisleep.c;
 +  i386_pc = term/i386/pc/console.c;
 +  i386_pc = term/i386/vga_common.c;
 +
 +  i386_efi = kern/i386/efi/startup.S;
 +  i386_efi = kern/mm.c;
 +  i386_efi = kern/i386/dl.c;
 +  i386_efi = kern/i386/efi/init.c;
 +  i386_efi = kern/efi/efi.c;
 +  i386_efi = kern/efi/init.c;
 +  i386_efi = kern/efi/mm.c;
 +  i386_efi = kern/time.c;
 +  i386_efi = kern/i386/tsc.c;
 +  i386_efi = kern/i386/pit.c;
 +  i386_efi = kern/generic/rtc_get_time_ms.c;
 +  i386_efi = kern/generic/millisleep.c;
 +  i386_efi = term/efi/console.c;
 +  i386_efi = disk/efi/efidisk.c;
 +
 +  i386_coreboot = kern/i386/coreboot/startup.S;
 +  i386_coreboot = kern/i386/misc.S;
 +  i386_coreboot = kern/i386/coreboot/init.c;
 +  i386_coreboot = kern/i386/coreboot/mmap.c;
 +  i386_coreboot = kern/i386/halt.c;
 +  i386_coreboot = kern/mm.c;
 +  i386_coreboot = kern/time.c;
 +  i386_coreboot = kern/i386/dl.c;
 +  i386_coreboot = kern/i386/tsc.c;
 +  i386_coreboot = kern/i386/pit.c;
 +  i386_coreboot = kern/generic/rtc_get_time_ms.c;
 +  i386_coreboot = kern/generic/millisleep.c;
 +  i386_coreboot = term/i386/pc/vga_text.c;
 +  i386_coreboot = term/i386/vga_common.c;
 +
 +  i386_multiboot = kern/i386/coreboot/startup.S;
 +  i386_multiboot = kern/i386/misc.S;
 +  i386_multiboot = kern/i386/coreboot/init.c;
 +  i386_multiboot = kern/i386/multiboot_mmap.c;
 +  i386_multiboot = kern/i386/halt.c;
 +  i386_multiboot = kern/mm.c;
 +  i386_multiboot = kern/time.c;
 +  i386_multiboot = kern/i386/dl.c;
 +  i386_multiboot = kern/i386/tsc.c;
 +  i386_multiboot = kern/i386/pit.c;
 +  i386_multiboot = kern/generic/rtc_get_time_ms.c;
 +  i386_multiboot = kern/generic/millisleep.c;
 +  i386_multiboot = term/i386/pc/vga_text.c;
 +  i386_multiboot = term/i386/vga_common.c;
 +
 +  i386_qemu = kern/i386/qemu/startup.S;
 +  i386_qemu = kern/i386/misc.S;
 +  i386_qemu = kern/i386/coreboot/init.c;
 +  i386_qemu = kern/i386/qemu/mmap.c;
 +  i386_qemu = kern/i386/halt.c;
 +  i386_qemu = kern/mm.c;
 +  i386_qemu = kern/time.c;
 +  i386_qemu = kern/i386/dl.c;
 +  i386_qemu = kern/i386/tsc.c;
 +  i386_qemu = kern/i386/pit.c;
 +  i386_qemu = kern/generic/rtc_get_time_ms.c;
 +  i386_qemu = kern/generic/millisleep.c;
 +  i386_qemu = term/i386/pc/vga_text.c;
 +  i386_qemu = term/i386/vga_common.c;
 +
 +  i386_ieee1275 = kern/i386/ieee1275/startup.S;
 +  i386_ieee1275 = kern/i386/misc.S;
 +  i386_ieee1275 = kern/i386/ieee1275/init.c;
 +  i386_ieee1275 = kern/ieee1275/init.c;
 +  i386_ieee1275 = kern/ieee1275/mmap.c;
 +  i386_ieee1275 = kern/ieee1275/cmain.c;
 +  i386_ieee1275 = kern/ieee1275/openfw.c;
 +  i386_ieee1275 = kern/mm.c;
 +  i386_ieee1275 = kern/i386/dl.c;
 +  i386_ieee1275 = kern/time.c;
 +  i386_ieee1275 = kern/generic/millisleep.c;
 +  i386_ieee1275 = kern/ieee1275/ieee1275.c;
 +  i386_ieee1275 = term/ieee1275/ofconsole.c;
 +  i386_ieee1275 = disk/ieee1275/ofdisk.c;
 +
 +  x86_64_efi = kern/x86_64/efi/startup.S;
 +  x86_64_efi = kern/x86_64/efi/callwrap.S;
 +  x86_64_efi = kern/mm.c;
 +  x86_64_efi = kern/x86_64/dl.c;
 +  x86_64_efi = kern/i386/efi/init.c;
 +  x86_64_efi = kern/efi/efi.c;
 +  x86_64_efi = kern/efi/init.c;
 +  x86_64_efi = kern/efi/mm.c;
 +  x86_64_efi = kern/time.c;
 +  x86_64_efi = kern/i386/tsc.c;
 +  x86_64_efi = kern/i386/pit.c;
 +  x86_64_efi = kern/generic/millisleep.c;
 +  x86_64_efi = kern/generic/rtc_get_time_ms.c;
 +  x86_64_efi = term/efi/console.c;
 +  x86_64_efi = disk/efi/efidisk.c;
 +
 +  mips_yeeloong = kern/mips/startup.S;
 +  mips_yeeloong = kern/mips/init.c;
 +  mips_yeeloong = kern/mips/yeeloong/init.c;
 +  mips_yeeloong = kern/mm.c;
 +  mips_yeeloong = kern/mips/dl.c;
 +  mips_yeeloong = kern/generic/millisleep.c;
 +  mips_yeeloong = kern/generic/rtc_get_time_ms.c;
 +  mips_yeeloong = kern/time.c;
 +  mips_yeeloong = kern/mips/cache.S;
 +  mips_yeeloong = io/bufio.c;
 +  mips_yeeloong = lib/arg.c;
 +  mips_yeeloong = commands/extcmd.c;
 +  mips_yeeloong = bus/pci.c;
 +  mips_yeeloong = bus/bonito.c;
 +  mips_yeeloong = font/font_cmd.c;
 +  mips_yeeloong = font/font.c;
 +  mips_yeeloong = term/at_keyboard.c;
 +  mips_yeeloong = term/gfxterm.c;
 +  mips_yeeloong = video/video.c;
 +  mips_yeeloong = video/fb/video_fb.c;
 +  mips_yeeloong = video/fb/fbblit.c;
 +  mips_yeeloong = video/fb/fbfill.c;
 +  mips_yeeloong = video/fb/fbutil.c;
 +  mips_yeeloong = video/bitmap.c;
 +  mips_yeeloong = video/bitmap_scale.c;
 +  mips_yeeloong = video/sm712.c;
 +
 +  powerpc_ieee1275 = kern/powerpc/ieee1275/startup.S;
 +  powerpc_ieee1275 = kern/ieee1275/cmain.c;
 +  powerpc_ieee1275 = kern/ieee1275/ieee1275.c;
 +  powerpc_ieee1275 = kern/mm.c;
 +  powerpc_ieee1275 = kern/ieee1275/init.c;
 +  powerpc_ieee1275 = kern/ieee1275/mmap.c;
 +  powerpc_ieee1275 = kern/ieee1275/openfw.c;
 +  powerpc_ieee1275 = kern/powerpc/dl.c;
 +  powerpc_ieee1275 = kern/generic/millisleep.c;
 +  powerpc_ieee1275 = kern/time.c;
 +  powerpc_ieee1275 = kern/powerpc/cache.S;
 +  powerpc_ieee1275 = term/ieee1275/ofconsole.c;
 +  powerpc_ieee1275 = disk/ieee1275/ofdisk.c;
 +
 +  sparc64_ieee1275 = kern/sparc64/ieee1275/crt0.S;
 +  sparc64_ieee1275 = kern/ieee1275/cmain.c;
 +  sparc64_ieee1275 = kern/ieee1275/ieee1275.c;
 +  sparc64_ieee1275 = kern/mm.c;
 +  sparc64_ieee1275 = kern/sparc64/ieee1275/ieee1275.c;
 +  sparc64_ieee1275 = kern/sparc64/ieee1275/init.c;
 +  sparc64_ieee1275 = kern/ieee1275/mmap.c;
 +  sparc64_ieee1275 = kern/ieee1275/openfw.c;
 +  sparc64_ieee1275 = kern/sparc64/dl.c;
 +  sparc64_ieee1275 = kern/generic/millisleep.c;
 +  sparc64_ieee1275 = kern/time.c;
 +  sparc64_ieee1275 = kern/sparc64/cache.S;
 +  sparc64_ieee1275 = disk/ieee1275/ofdisk.c;
 +  sparc64_ieee1275 = term/ieee1275/ofconsole.c;
 +
 +  emu = kern/emu/mm.c;
 +  emu = kern/emu/main.c;
 +  emu = kern/emu/misc.c;
 +  emu = kern/emu/getroot.c;
 +  emu = kern/emu/time.c;
 +  emu = kern/emu/hostdisk.c;
 +  emu = kern/emu/hostfs.c;
 +  emu = kern/emu/console.c;
 +  emu = disk/host.c;
 +  emu = gnulib/progname.c;
-   ldadd = kernel.exec;
 +};
 +
 +program = {
 +  name = grub-emu;
 +  mansection = 1;
 +
 +  source = kern/emu/full.c;
 +  nodist = grub_emu_init.c;
 +
-   ldadd = kernel.exec;
++  ldadd = kernel.img;
 +  ldadd = '$(MODULE_FILES)';
 +  ldadd = '$(LIBCURSES) $(LIBSDL) $(LIBUSB) $(LIBPCIACCESS)';
 +
 +  emu;
 +};
 +
 +program = {
 +  name = grub-emu-lite;
 +
 +  source = kern/emu/lite.c;
 +  source = kern/emu/cache.S;
 +  nodist = symlist.c;
 +
++  ldadd = kernel.img;
 +  ldadd = '$(LIBCURSES) $(LIBSDL) $(LIBUSB) $(LIBPCIACCESS)';
 +
 +  emu;
 +};
 +
 +module = {
 +  name = trig;
 +  nodist = trigtables.c;
 +  common;
 +};
 +
 +image = {
 +  name = boot;
 +  i386_pc = boot/i386/pc/boot.S;
 +  i386_pc_ldflags = "-Wl,-Ttext=0x7C00";
 +
 +  i386_qemu = boot/i386/qemu/boot.S;
 +  i386_qemu_ldflags = '-Wl,-Ttext,$(GRUB_BOOT_MACHINE_LINK_ADDR)';
 +  i386_qemu_ccasflags = '-DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)';
 +
 +  sparc64_ieee1275 = boot/sparc64/ieee1275/boot.S;
 +  sparc64_ieee1275_format = a.out-sunos-big;
 +  sparc64_ieee1275_ldflags = ' -Wl,-Ttext=0x4000';
 +};
 +
 +image = {
 +  name = cdboot;
 +  source = boot/i386/pc/cdboot.S;
 +  ldflags = "-Wl,-Ttext=0x7C00";
 +
 +  i386_pc;
 +};
 +
 +image = {
 +  name = pxeboot;
 +  source = boot/i386/pc/pxeboot.S;
 +  ldflags = '-Wl,-Ttext=0x7C00';
 +
 +  i386_pc;
 +};
 +
 +image = {
 +  name = diskboot;
 +  i386_pc = boot/i386/pc/diskboot.S;
 +  i386_pc_ldflags = '-Wl,-Ttext=0x8000';
 +
 +  sparc64_ieee1275 = boot/sparc64/ieee1275/diskboot.S;
 +  sparc64_ieee1275_ldflags = '-Wl,-Ttext=0x4200';
 +};
 +
 +image = {
 +  name = lnxboot;
 +  source = boot/i386/pc/lnxboot.S;
 +  ldflags = '-Wl,-Ttext=0x6000';
 +
 +  i386_pc;
 +};
 +
 +module = {
 +  name = libusb;
 +  source = bus/usb/emu/usb.c;
 +  emu;
 +  enable = COND_GRUB_EMU_USB;
 +};
 +
 +module = {
 +  name = pci;
 +  source = bus/emu/pci.c;
 +  source = commands/lspci.c;
 +  emu;
 +  enable = COND_GRUB_EMU_PCI;
 +};
 +
 +module = {
 +  name = usb;
 +  source = bus/usb/usb.c;
 +  source = bus/usb/usbtrans.c;
 +  source = bus/usb/usbhub.c;
 +  i386;
 +};
 +
 +module = {
 +  name = usb;
 +  source = bus/usb/usb.c;
 +  emu;
 +  enable = COND_GRUB_EMU_USB;
 +};
 +
 +module = {
 +  name = uhci;
 +  source = bus/usb/uhci.c;
 +  x86;
 +};
 +
 +module = {
 +  name = ohci;
 +  source = bus/usb/ohci.c;
 +  x86;
 +};
 +
 +module = {
 +  name = pci;
 +  source = bus/pci.c;
 +  x86;
 +};
 +
 +library = {
 +  name = libgnulib.a;
 +  source = gnulib/regex.c;
 +  cflags = '$(CFLAGS_POSIX) $(CFLAGS_GNULIB)';
 +  cppflags = '$(CPPFLAGS_POSIX) $(CPPFLAGS_GNULIB)';
 +  common;
 +};
 +
 +module = {
 +  name = iorw;
 +  source = commands/iorw.c;
 +  i386;
 +};
 +
 +module = {
 +  name = regexp;
 +  source = commands/regexp.c;
 +  ldadd = libgnulib.a;
 +  cflags = '$(CFLAGS_POSIX) $(CFLAGS_GNULIB)';
 +  cppflags = '$(CPPFLAGS_POSIX) $(CPPFLAGS_GNULIB)';
 +  common;
 +};
 +
 +module = {
 +  name = acpi;
 +
 +  x86_efi = commands/acpi.c;
 +  x86_efi = commands/efi/acpi.c;
 +
 +  i386_pc = commands/acpi.c;
 +  i386_pc = commands/i386/pc/acpi.c;
 +};
 +
 +module = {
 +  common;
 +  name = blocklist;
 +  source = commands/blocklist.c;
 +};
 +
 +module = {
 +  common;
 +  name = boot;
 +  source = commands/boot.c;
 +
 +  i386_pc = commands/boot.c;
 +  i386_pc = lib/i386/pc/biosnum.c;
 +};
 +
 +module = {
 +  common;
 +  name = cat;
 +  source = commands/cat.c;
 +};
 +
 +module = {
 +  common;
 +  name = cmp;
 +  source = commands/cmp.c;
 +};
 +
 +module = {
 +  common;
 +  name = configfile;
 +  source = commands/configfile.c;
 +};
 +
 +module = {
 +  name = cpuid;
 +  source = commands/i386/cpuid.c;
 +
 +  x86;
 +};
 +
 +module = {
 +  common;
 +  name = crc;
 +  source = commands/crc.c;
 +  source = lib/crc.c;
 +};
 +
 +module = {
 +  common;
 +  name = date;
 +  source = commands/date.c;
 +
 +  x86;
 +  mips;
 +};
 +
 +module = {
 +  name = drivemap;
 +
 +  i386_pc = commands/i386/pc/drivemap.c;
 +  i386_pc = commands/i386/pc/drivemap_int13h.S;
 +};
 +
 +module = {
 +  common;
 +  name = echo;
 +  source = commands/echo.c;
 +};
 +
 +module = {
 +  common;
 +  name = extcmd;
 +  source = commands/extcmd.c;
 +  source = lib/arg.c;
 +};
 +
 +module = {
 +  name = fixvideo;
 +  x86_efi = commands/efi/fixvideo.c;
 +};
 +
 +module = {
 +  common;
 +  name = gptsync;
 +  source = commands/gptsync.c;
 +};
 +
 +module = {
 +  name = halt;
 +  source = commands/halt.c;
 +
 +  i386_pc = commands/i386/pc/halt.c;
 +  emu;
 +  x86;
 +  sparc64;
 +  powerpc;
 +};
 +
 +module = {
 +  common;
 +  name = handler;
 +  source = commands/handler.c;
 +};
 +
 +module = {
 +  common;
 +  name = hashsum;
 +  source = commands/hashsum.c;
 +};
 +
 +module = {
 +  name = hdparm;
 +  source = commands/hdparm.c;
 +  source = lib/hexdump.c;
 +
 +  i386_pc;
 +};
 +
 +module = {
 +  common;
 +  name = help;
 +  source = commands/help.c;
 +};
 +
 +module = {
 +  common;
 +  name = hexdump;
 +  source = commands/hexdump.c;
 +  source = lib/hexdump.c;
 +};
 +
 +module = {
 +  common;
 +  name = keystatus;
 +  source = commands/keystatus.c;
 +};
 +
 +module = {
 +  name = loadbios;
 +  x86_efi = commands/efi/loadbios.c;
 +};
 +
 +module = {
 +  common;
 +  name = loadenv;
 +  source = commands/loadenv.c;
 +  source = lib/envblk.c;
 +};
 +
 +module = {
 +  common;
 +  name = ls;
 +  source = commands/ls.c;
 +};
 +
 +module = {
 +  common;
 +  name = lsmmap;
 +  source = commands/lsmmap.c;
 +
 +  i386_pc;
 +  i386_qemu;
 +  i386_coreboot;
 +  i386_multiboot;
 +  i386_ieee1275;
 +  mips_yeeloong;
 +  powerpc_ieee1275;
 +};
 +
 +module = {
 +  name = lspci;
 +  source = commands/lspci.c;
 +
 +  x86;
 +  mips;
 +};
 +
 +module = {
 +  common;
 +  name = memrw;
 +  source = commands/memrw.c;
 +};
 +
 +module = {
 +  common;
 +  name = minicmd;
 +  source = commands/minicmd.c;
 +};
 +
 +module = {
 +  common;
 +  name = parttool;
 +  source = commands/parttool.c;
 +};
 +
 +module = {
 +  common;
 +  name = password;
 +  source = commands/password.c;
 +};
 +
 +module = {
 +  common;
 +  name = password_pbkdf2;
 +  source = commands/password_pbkdf2.c;
 +};
 +
 +module = {
 +  name = play;
 +  source = commands/i386/pc/play.c;
 +  i386;
 +};
 +
 +module = {
 +  common;
 +  name = probe;
 +  source = commands/probe.c;
 +};
 +
 +module = {
 +  name = pxecmd;
 +  i386_pc = commands/i386/pc/pxecmd.c;
 +};
 +
 +module = {
 +  common;
 +  name = read;
 +  source = commands/read.c;
 +};
 +
 +module = {
 +  common;
 +  name = reboot;
 +  source = commands/reboot.c;
 +
 +  x86; powerpc; sparc64;
 +};
 +
 +module = {
 +  common;
 +  name = search;
 +  source = commands/search_wrap.c;
 +};
 +
 +module = {
 +  common;
 +  name = search_fs_file;
 +  source = commands/search_file.c;
 +};
 +
 +module = {
 +  common;
 +  name = search_fs_uuid;
 +  source = commands/search_uuid.c;
 +};
 +
 +module = {
 +  common;
 +  name = search_label;
 +  source = commands/search_label.c;
 +};
 +
 +module = {
 +  name = setpci;
 +  source = commands/setpci.c;
 +
 +  x86;
 +};
 +
 +module = {
 +  common;
 +  name = sleep;
 +  source = commands/sleep.c;
 +};
 +
 +module = {
 +  name = suspend;
 +  source = commands/ieee1275/suspend.c;
 +  i386_ieee1275;
 +  powerpc_ieee1275;
 +};
 +
 +module = {
 +  common;
 +  name = terminal;
 +  source = commands/terminal.c;
 +};
 +
 +module = {
 +  common;
 +  name = test;
 +  source = commands/test.c;
 +};
 +
 +module = {
 +  common;
 +  name = true;
 +  source = commands/true.c;
 +};
 +
 +module = {
 +  name = usbtest;
 +  source = commands/usbtest.c;
 +  i386_pc;
 +};
 +
 +module = {
 +  name = usbtest;
 +  source = commands/usbtest.c;
 +  emu;
 +  enable = COND_GRUB_EMU_USB;
 +};
 +
 +module = {
 +  name = vbeinfo;
 +  i386_pc = commands/i386/pc/vbeinfo.c;
 +};
 +
 +module = {
 +  name = vbetest;
 +  i386_pc = commands/i386/pc/vbetest.c;
 +};
 +
 +module = {
 +  common;
 +  name = videotest;
 +  source = commands/videotest.c;
 +};
 +
 +module = {
 +  common;
 +  name = xnu_uuid;
 +  source = commands/xnu_uuid.c;
 +};
 +
 +module = {
 +  common;
 +  name = dm_nv;
 +  source = disk/dmraid_nvidia.c;
 +};
 +
 +module = {
 +  common;
 +  name = loopback;
 +  source = disk/loopback.c;
 +};
 +
 +module = {
 +  common;
 +  name = lvm;
 +  source = disk/lvm.c;
 +};
 +
 +module = {
 +  common;
 +  name = mdraid;
 +  source = disk/mdraid_linux.c;
 +};
 +
 +module = {
 +  common;
 +  name = raid;
 +  source = disk/raid.c;
 +};
 +
 +module = {
 +  common;
 +  name = raid5rec;
 +  source = disk/raid5_recover.c;
 +};
 +
 +module = {
 +  common;
 +  name = raid6rec;
 +  source = disk/raid6_recover.c;
 +};
 +
 +module = {
 +  common;
 +  name = scsi;
 +  source = disk/scsi.c;
 +};
 +
 +module = {
 +  common;
 +  name = memdisk;
 +  source = disk/memdisk.c;
 +};
 +
 +module = {
 +  name = ata;
 +  source = disk/ata.c;
 +
 +  x86;
 +  mips;
 +};
 +
 +module = {
 +  name = ata_pthru;
 +  source = disk/ata_pthru.c;
 +
 +  x86;
 +  mips_yeeloong;
 +};
 +
 +module = {
 +  name = biosdisk;
 +  i386_pc = disk/i386/pc/biosdisk.c;
 +};
 +
 +module = {
 +  name = usbms;
 +  source = disk/usbms.c;
 +  i386_pc;
 +};
 +
 +module = {
 +  name = usbms;
 +  source = disk/usbms.c;
 +  emu;
 +  enable = COND_GRUB_EMU_USB;
 +};
 +
 +module = {
 +  name = nand;
 +  source = disk/ieee1275/nand.c;
 +
 +  i386_ieee1275;
 +};
 +
 +module = {
 +  name = efiemu;
 +  i386_pc = efiemu/main.c;
 +  i386_pc = efiemu/i386/loadcore32.c;
 +  i386_pc = efiemu/i386/loadcore64.c;
 +  i386_pc = efiemu/i386/pc/cfgtables.c;
 +  i386_pc = efiemu/mm.c;
 +  i386_pc = efiemu/loadcore_common.c;
 +  i386_pc = efiemu/symbols.c;
 +  i386_pc = efiemu/loadcore32.c;
 +  i386_pc = efiemu/loadcore64.c;
 +  i386_pc = efiemu/prepare32.c;
 +  i386_pc = efiemu/prepare64.c;
 +  i386_pc = efiemu/pnvram.c;
 +  i386_pc = efiemu/i386/coredetect.c;
 +};
 +
 +module = {
 +  name = font;
 +  source = font/font.c;
 +  source = font/font_cmd.c;
 +  emu;
 +  x86;
 +  sparc64;
 +  powerpc;
 +};
 +
 +module = {
 +  common;
 +  name = affs;
 +  source = fs/affs.c;
 +};
 +
 +module = {
 +  common;
 +  name = afs;
 +  source = fs/afs.c;
 +};
 +
 +module = {
 +  common;
 +  name = afs_be;
 +  source = fs/afs_be.c;
 +};
 +
 +module = {
 +  common;
 +  name = befs;
 +  source = fs/befs.c;
 +};
 +
 +module = {
 +  common;
 +  name = befs_be;
 +  source = fs/befs_be.c;
 +};
 +
 +module = {
 +  common;
 +  name = cpio;
 +  source = fs/cpio.c;
 +};
 +
 +module = {
 +  common;
 +  name = ext2;
 +  source = fs/ext2.c;
 +};
 +
 +module = {
 +  common;
 +  name = fat;
 +  source = fs/fat.c;
 +};
 +
 +module = {
 +  common;
 +  name = fshelp;
 +  source = fs/fshelp.c;
 +};
 +
 +module = {
 +  common;
 +  name = hfs;
 +  source = fs/hfs.c;
 +};
 +
 +module = {
 +  common;
 +  name = hfsplus;
 +  source = fs/hfsplus.c;
 +};
 +
 +module = {
 +  common;
 +  name = iso9660;
 +  source = fs/iso9660.c;
 +};
 +
 +module = {
 +  common;
 +  name = jfs;
 +  source = fs/jfs.c;
 +};
 +
 +module = {
 +  common;
 +  name = minix;
 +  source = fs/minix.c;
 +};
 +
 +module = {
 +  common;
 +  name = nilfs2;
 +  source = fs/nilfs2.c;
 +};
 +
 +module = {
 +  common;
 +  name = ntfs;
 +  source = fs/ntfs.c;
 +};
 +
 +module = {
 +  common;
 +  name = ntfscomp;
 +  source = fs/ntfscomp.c;
 +};
 +
 +module = {
 +  common;
 +  name = reiserfs;
 +  source = fs/reiserfs.c;
 +};
 +
 +module = {
 +  common;
 +  name = sfs;
 +  source = fs/sfs.c;
 +};
 +
 +module = {
 +  common;
 +  name = tar;
 +  source = fs/tar.c;
 +};
 +
 +module = {
 +  common;
 +  name = udf;
 +  source = fs/udf.c;
 +};
 +
 +module = {
 +  common;
 +  name = ufs1;
 +  source = fs/ufs.c;
 +};
 +
 +module = {
 +  common;
 +  name = ufs2;
 +  source = fs/ufs2.c;
 +};
 +
 +module = {
 +  common;
 +  name = xfs;
 +  source = fs/xfs.c;
 +};
 +
 +module = {
 +  name = pxe;
 +  i386_pc = fs/i386/pc/pxe.c;
 +};
 +
 +module = {
 +  name = gettext;
 +  source = gettext/gettext.c;
 +  common;
 +};
 +
 +module = {
 +  common;
 +  name = gfxmenu;
 +  source = gfxmenu/gfxmenu.c;
 +  source = gfxmenu/model.c;
 +  source = gfxmenu/view.c;
 +  source = gfxmenu/icon_manager.c;
 +  source = gfxmenu/theme_loader.c;
 +  source = gfxmenu/widget-box.c;
 +  source = gfxmenu/gui_canvas.c;
 +  source = gfxmenu/gui_circular_progress.c;
 +  source = gfxmenu/gui_box.c;
 +  source = gfxmenu/gui_label.c;
 +  source = gfxmenu/gui_list.c;
 +  source = gfxmenu/gui_image.c;
 +  source = gfxmenu/gui_progress_bar.c;
 +  source = gfxmenu/gui_util.c;
 +  source = gfxmenu/gui_string_util.c;
 +  source = gfxmenu/named_colors.c;
 +};
 +
 +module = {
 +  common;
 +  name = hello;
 +  source = hello/hello.c;
 +};
 +
 +module = {
 +  common;
 +  name = gzio;
 +  source = io/gzio.c;
 +};
 +
 +module = {
 +  name = bufio;
 +  source = io/bufio.c;
 +  emu;
 +  x86;
 +  sparc64;
 +  powerpc;
 +};
 +
 +module = {
 +  common;
 +  name = elf;
 +  source = kern/elf.c;
 +};
 +
 +module = {
 +  common;
 +  name = charset;
 +  source = lib/charset.c;
 +};
 +
 +module = {
 +  common;
 +  name = crypto;
 +  source = lib/crypto.c;
 +};
 +
 +module = {
 +  common;
 +  name = gcry_arcfour;
 +  cflags = '$(CFLAGS_GCRY)';
 +  cppflags = '$(CPPFLAGS_GCRY)';
 +  source = lib/libgcrypt-grub/cipher/arcfour.c;
 +};
 +
 +module = {
 +  common;
 +  name = gcry_blowfish;
 +  cflags = '$(CFLAGS_GCRY)';
 +  cppflags = '$(CPPFLAGS_GCRY)';
 +  source = lib/libgcrypt-grub/cipher/blowfish.c;
 +};
 +
 +module = {
 +  common;
 +  name = gcry_camellia;
 +  cflags = '$(CFLAGS_GCRY)';
 +  cppflags = '$(CPPFLAGS_GCRY)';
 +  source = lib/libgcrypt-grub/cipher/camellia.c;
 +  source = lib/libgcrypt-grub/cipher/camellia-glue.c;
 +};
 +
 +module = {
 +  common;
 +  name = gcry_cast5;
 +  cflags = '$(CFLAGS_GCRY)';
 +  cppflags = '$(CPPFLAGS_GCRY)';
 +  source = lib/libgcrypt-grub/cipher/cast5.c;
 +};
 +
 +module = {
 +  common;
 +  name = gcry_crc;
 +  cflags = '$(CFLAGS_GCRY)';
 +  cppflags = '$(CPPFLAGS_GCRY)';
 +  source = lib/libgcrypt-grub/cipher/crc.c;
 +};
 +
 +module = {
 +  common;
 +  name = gcry_des;
 +  cflags = '$(CFLAGS_GCRY)';
 +  cppflags = '$(CPPFLAGS_GCRY)';
 +  source = lib/libgcrypt-grub/cipher/des.c;
 +};
 +
 +module = {
 +  common;
 +  name = gcry_md4;
 +  cflags = '$(CFLAGS_GCRY)';
 +  cppflags = '$(CPPFLAGS_GCRY)';
 +  source = lib/libgcrypt-grub/cipher/md4.c;
 +};
 +
 +module = {
 +  common;
 +  name = gcry_md5;
 +  cflags = '$(CFLAGS_GCRY)';
 +  cppflags = '$(CPPFLAGS_GCRY)';
 +  source = lib/libgcrypt-grub/cipher/md5.c;
 +};
 +
 +module = {
 +  common;
 +  name = gcry_rfc2268;
 +  cflags = '$(CFLAGS_GCRY)';
 +  cppflags = '$(CPPFLAGS_GCRY)';
 +  source = lib/libgcrypt-grub/cipher/rfc2268.c;
 +};
 +
 +module = {
 +  common;
 +  name = gcry_rijndael;
 +  cflags = '$(CFLAGS_GCRY)';
 +  cppflags = '$(CPPFLAGS_GCRY)';
 +  source = lib/libgcrypt-grub/cipher/rijndael.c;
 +};
 +
 +module = {
 +  common;
 +  name = gcry_rmd160;
 +  cflags = '$(CFLAGS_GCRY)';
 +  cppflags = '$(CPPFLAGS_GCRY)';
 +  source = lib/libgcrypt-grub/cipher/rmd160.c;
 +};
 +
 +module = {
 +  common;
 +  name = gcry_seed;
 +  cflags = '$(CFLAGS_GCRY)';
 +  cppflags = '$(CPPFLAGS_GCRY)';
 +  source = lib/libgcrypt-grub/cipher/seed.c;
 +};
 +
 +module = {
 +  common;
 +  name = gcry_serpent;
 +  cflags = '$(CFLAGS_GCRY)';
 +  cppflags = '$(CPPFLAGS_GCRY)';
 +  source = lib/libgcrypt-grub/cipher/serpent.c;
 +};
 +
 +module = {
 +  common;
 +  name = gcry_sha1;
 +  cflags = '$(CFLAGS_GCRY)';
 +  cppflags = '$(CPPFLAGS_GCRY)';
 +  source = lib/libgcrypt-grub/cipher/sha1.c;
 +};
 +
 +module = {
 +  common;
 +  name = gcry_sha256;
 +  cflags = '$(CFLAGS_GCRY)';
 +  cppflags = '$(CPPFLAGS_GCRY)';
 +  source = lib/libgcrypt-grub/cipher/sha256.c;
 +};
 +
 +module = {
 +  common;
 +  name = gcry_sha512;
 +  cflags = '$(CFLAGS_GCRY)';
 +  cppflags = '$(CPPFLAGS_GCRY)';
 +  source = lib/libgcrypt-grub/cipher/sha512.c;
 +};
 +
 +module = {
 +  common;
 +  name = gcry_tiger;
 +  cflags = '$(CFLAGS_GCRY)';
 +  cppflags = '$(CPPFLAGS_GCRY)';
 +  source = lib/libgcrypt-grub/cipher/tiger.c;
 +};
 +
 +module = {
 +  common;
 +  name = gcry_twofish;
 +  cflags = '$(CFLAGS_GCRY)';
 +  cppflags = '$(CPPFLAGS_GCRY)';
 +  source = lib/libgcrypt-grub/cipher/twofish.c;
 +};
 +
 +module = {
 +  common;
 +  name = gcry_whirlpool;
 +  cflags = '$(CFLAGS_GCRY)';
 +  cppflags = '$(CPPFLAGS_GCRY)';
 +  source = lib/libgcrypt-grub/cipher/whirlpool.c;
 +};
 +
 +module = {
 +  common;
 +  name = pbkdf2;
 +  source = lib/pbkdf2.c;
 +};
 +
 +module = {
 +  name = relocator;
 +  mips = lib/mips/relocator.c;
 +  mips = lib/mips/relocator_asm.S;
 +  x86 = lib/i386/relocator.c;
 +  x86 = lib/i386/relocator_asm.S;
 +  x86 = lib/i386/relocator_backward.S;
 +};
 +
 +module = {
 +  name = datetime;
 +  source = lib/cmos_datetime.c;
 +  x86_efi = lib/efi/datetime.c;
 +  sparc64_ieee1275 = lib/ieee1275/datetime.c;
 +  powerpc_ieee1275 = lib/ieee1275/datetime.c;
 +  x86;
 +  mips;
 +};
 +
 +module = {
 +  name = setjmp;
 +  i386 = lib/i386/setjmp.S;
 +  x86_64 = lib/x86_64/setjmp.S;
 +  mips = lib/mips/setjmp.S;
 +  sparc64 = lib/sparc64/setjmp.S;
 +  powerpc = lib/powerpc/setjmp.S;
 +};
 +
 +module = {
 +  name = aout;
 +  source = loader/aout.c;
 +  i386_pc;
 +  i386_qemu;
 +  i386_coreboot;
 +  i386_multiboot;
 +  i386_ieee1275;
 +};
 +
 +module = {
 +  name = bsd;
 +  source = loader/i386/bsd.c;
 +  source = loader/i386/bsd32.c;
 +  source = loader/i386/bsd64.c;
 +  source = loader/i386/bsd_helper.S;
 +  source = loader/i386/bsd_trampoline.S;
 +  i386_pc;
 +  i386_qemu;
 +  i386_coreboot;
 +  i386_multiboot;
 +};
 +
 +module = {
 +  name = linux16;
 +  source = loader/i386/pc/linux.c;
 +  i386_pc;
 +};
 +
 +module = {
 +  name = multiboot2;
 +  cppflags = "-DGRUB_USE_MULTIBOOT2";
 +
 +  source = loader/multiboot.c;
 +  source = loader/multiboot_mbi2.c;
 +  x86;
 +  mips;
 +};
 +
 +module = {
 +  name = multiboot;
 +  source = loader/multiboot.c;
 +  source = loader/i386/multiboot_mbi.c;
 +  x86;
 +};
 +
 +module = {
 +  name = linux;
 +  i386 = loader/i386/linux.c;
 +  i386_efi = loader/i386/efi/linux.c;
 +  i386_ieee1275 = loader/i386/ieee1275/linux.c;
 +  x86_64_efi = loader/i386/efi/linux.c;
 +  x86_64_efi = loader/i386/linux_trampoline.S;
 +  mips = loader/mips/linux.c;
 +  powerpc_ieee1275 = loader/powerpc/ieee1275/linux.c;
 +  sparc64_ieee1275 = loader/sparc64/ieee1275/linux.c;
 +};
 +
 +module = {
 +  name = xnu;
 +  x86_efi = loader/xnu_resume.c;
 +  x86_efi = loader/i386/xnu.c;
 +  x86_efi = loader/i386/efi/xnu.c;
 +  x86_efi = loader/macho32.c;
 +  x86_efi = loader/macho64.c;
 +  x86_efi = loader/macho.c;
 +  x86_efi = loader/xnu.c;
 +
 +  i386_pc = loader/xnu_resume.c;
 +  i386_pc = loader/i386/xnu.c;
 +  i386_pc = loader/i386/pc/xnu.c;
 +  i386_pc = loader/macho32.c;
 +  i386_pc = loader/macho64.c;
 +  i386_pc = loader/macho.c;
 +  i386_pc = loader/xnu.c;
 +};
 +
 +module = {
 +  name = appleldr;
 +  x86_efi = loader/efi/appleloader.c;
 +};
 +
 +module = {
 +  name = chain;
 +  x86_efi = loader/efi/chainloader.c;
 +  i386_pc = loader/i386/pc/chainloader.c;
 +};
 +
 +module = {
 +  name = mmap;
 +  i386_pc = mmap/mmap.c;
 +  i386_pc = mmap/i386/uppermem.c;
 +  i386_pc = mmap/i386/mmap.c;
 +  i386_pc = mmap/i386/pc/mmap.c;
 +  i386_pc = mmap/i386/pc/mmap_helper.S;
 +
 +  x86_efi = mmap/mmap.c;
 +  x86_efi = mmap/i386/uppermem.c;
 +  x86_efi = mmap/i386/mmap.c;
 +  x86_efi = mmap/efi/mmap.c;
 +
 +  i386_coreboot = mmap/mmap.c;
 +  i386_coreboot = mmap/i386/uppermem.c;
 +  i386_coreboot = mmap/i386/mmap.c;
 +
 +  i386_multiboot = mmap/mmap.c;
 +  i386_multiboot = mmap/i386/uppermem.c;
 +  i386_multiboot = mmap/i386/mmap.c;
 +
 +  i386_qemu = mmap/mmap.c;
 +  i386_qemu = mmap/i386/uppermem.c;
 +  i386_qemu = mmap/i386/mmap.c;
 +
 +  i386_ieee1275 = mmap/mmap.c;
 +  i386_ieee1275 = mmap/i386/uppermem.c;
 +  i386_ieee1275 = mmap/i386/mmap.c;
 +
 +  mips_yeeloong = mmap/mmap.c;
 +  mips_yeeloong = mmap/mips/yeeloong/uppermem.c;
 +};
 +
 +module = {
 +  common;
 +  name = normal;
 +  source = normal/main.c;
 +  source = normal/cmdline.c;
 +  source = normal/dyncmd.c;
 +  source = normal/auth.c;
 +  source = normal/autofs.c;
 +  source = normal/handler.c;
 +  source = normal/color.c;
 +  source = normal/completion.c;
 +  source = normal/datetime.c;
 +  source = normal/menu.c;
 +  source = normal/menu_entry.c;
 +  source = normal/menu_text.c;
 +  source = normal/misc.c;
 +  source = normal/crypto.c;
 +  source = normal/term.c;
 +  source = normal/context.c;
 +};
 +
 +module = {
 +  common;
 +  name = part_acorn;
 +  source = partmap/acorn.c;
 +};
 +
 +module = {
 +  common;
 +  name = part_amiga;
 +  source = partmap/amiga.c;
 +};
 +
 +module = {
 +  common;
 +  name = part_apple;
 +  source = partmap/apple.c;
 +};
 +
 +module = {
 +  common;
 +  name = part_gpt;
 +  source = partmap/gpt.c;
 +};
 +
 +module = {
 +  common;
 +  name = part_msdos;
 +  source = partmap/msdos.c;
 +};
 +
 +module = {
 +  common;
 +  name = part_sun;
 +  source = partmap/sun.c;
 +};
 +
 +module = {
 +  common;
 +  name = part_bsd;
 +  source = partmap/bsdlabel.c;
 +};
 +
 +module = {
 +  common;
 +  name = part_sunpc;
 +  source = partmap/sunpc.c;
 +};
 +
 +module = {
 +  common;
 +  name = msdospart;
 +  source = parttool/msdospart.c;
 +};
 +
 +module = {
 +  common;
 +  name = sh;
 +  source = script/main.c;
 +  source = script/script.c;
 +  source = script/execute.c;
 +  source = script/function.c;
 +  source = script/lexer.c;
 +  nodist = grub_script.tab.c;
 +  nodist = grub_script.yy.c;
 +  nodist = grub_script.tab.h;
 +  nodist = grub_script.yy.h;
 +  cflags = '$(CFLAGS_POSIX) -Wno-error';
 +  cppflags = '$(CPPFLAGS_POSIX)';
 +};
 +
 +module = {
 +  name = at_keyboard;
 +  source = term/at_keyboard.c;
 +  x86;
 +};
 +
 +module = {
 +  name = gfxterm;
 +  source = term/gfxterm.c;
 +  emu;
 +  x86;
 +  sparc64;
 +  powerpc;
 +};
 +
 +module = {
 +  name = serial;
 +  source = term/serial.c;
 +  mips;
 +  i386;
 +};
 +
 +module = {
 +  common;
 +  name = terminfo;
 +  source = term/terminfo.c;
 +  source = term/tparm.c;
 +};
 +
 +module = {
 +  name = usb_keyboard;
 +  source = term/usb_keyboard.c;
 +  i386_pc;
 +};
 +
 +module = {
 +  name = vga;
 +  i386_pc = video/i386/pc/vga.c;
 +};
 +
 +module = {
 +  name = vga_text;
 +  x86 = term/i386/pc/vga_text.c;
 +  x86 = term/i386/vga_common.c;
 +};
 +
 +module = {
 +  name = functional_test;
 +  source = tests/lib/functional_test.c;
 +  source = tests/lib/test.c;
 +  common;
 +};
 +
 +module = {
 +  name = example_functional_test;
 +  source = tests/example_functional_test.c;
 +  cflags = -Wno-format;
 +  common;
 +};
 +
 +module = {
 +  name = bitmap;
 +  source = video/bitmap.c;
 +  emu;
 +  x86;
 +  sparc64;
 +  powerpc;
 +};
 +
 +module = {
 +  name = bitmap_scale;
 +  source = video/bitmap_scale.c;
 +  emu;
 +  x86;
 +  sparc64;
 +  powerpc;
 +};
 +
 +module = {
 +  name = efi_gop;
 +  x86_efi = video/efi_gop.c;
 +};
 +
 +module = {
 +  name = efi_uga;
 +  x86_efi = video/efi_uga.c;
 +};
 +
 +module = {
 +  common;
 +  name = jpeg;
 +  source = video/readers/jpeg.c;
 +};
 +
 +module = {
 +  common;
 +  name = png;
 +  source = video/readers/png.c;
 +};
 +
 +module = {
 +  common;
 +  name = tga;
 +  source = video/readers/tga.c;
 +};
 +
 +module = {
 +  name = vbe;
 +  i386_pc = video/i386/pc/vbe.c;
 +};
 +
 +module = {
 +  name = video_fb;
 +  source = video/fb/video_fb.c;
 +  source = video/fb/fbblit.c;
 +  source = video/fb/fbfill.c;
 +  source = video/fb/fbutil.c;
 +  emu;
 +  x86;
 +  sparc64;
 +  powerpc;
 +};
 +
 +module = {
 +  name = video;
 +  source = video/video.c;
 +  emu;
 +  x86;
 +  sparc64;
 +  powerpc;
 +};
 +
 +module = {
 +  name = ieee1275_fb;
 +  source = video/ieee1275.c;
 +  powerpc;
 +  sparc64;
 +};
 +
 +module = {
 +  name = sdl;
 +  source = video/emu/sdl.c;
 +  enable = COND_GRUB_EMU_SDL;
 +  emu;
 +};
 +
 +module = {
 +  name = datehook;
 +  source = hook/datehook.c;
 +  common;
 +};
Simple merge
Simple merge
diff --cc modules.def
index 2ff2364e1b04271356ed5e6b70e89cbf733eb3d1,0000000000000000000000000000000000000000..d9758423f145f57c053866ae8a9cca9c42234de0
mode 100644,000000..100644
--- /dev/null
@@@ -1,498 -1,0 +1,461 @@@
-   source = util/grub-mkrawimage.c;
-   source = util/resolve.c;
-   x86_efi = util/i386/efi/grub-mkimage.c;
-   x86_efi = util/resolve.c;
-   ldadd = libutil.a;
-   sparc64_ieee1275_cppflags = '-DGRUB_KERNEL_MACHINE_LINK_ADDR=$(GRUB_KERNEL_MACHINE_LINK_ADDR)';
-   mips_cppflags = '-DGRUB_KERNEL_MACHINE_LINK_ADDR=$(GRUB_KERNEL_MACHINE_LINK_ADDR)';
-   i386_pc_cppflags = '-DGRUB_KERNEL_MACHINE_LINK_ADDR=$(GRUB_KERNEL_MACHINE_LINK_ADDR)';
-   i386_qemu_cppflags = '-DGRUB_KERNEL_MACHINE_LINK_ADDR=$(GRUB_KERNEL_MACHINE_LINK_ADDR)';
-   i386_pc; i386_qemu; mips; sparc64_ieee1275;
- };
- program = {
-   name = grub-mkelfimage;
-   mansection = 1;
-   source = util/elf/grub-mkimage.c;
 +AutoGen definitions Makefile.tpl;
 +
 +library = {
 +  name = libutil.a;
 +  cflags = '$(CFLAGS_GCRY)';
 +  cppflags = '$(CPPFLAGS_GCRY)';
 +
 +  nodist = grub_script.tab.c;
 +  nodist = grub_script.yy.c;
 +  nodist = libutil_a_init.c;
 +
 +  source = grub-core/gnulib/error.c;
 +  source = grub-core/gnulib/fnmatch.c;
 +  source = grub-core/gnulib/getdelim.c;
 +  source = grub-core/gnulib/getline.c;
 +  source = grub-core/gnulib/getopt1.c;
 +  source = grub-core/gnulib/getopt.c;
 +  source = grub-core/gnulib/progname.c;
 +
 +  source = util/misc.c;
 +  source = grub-core/kern/misc.c;
 +  source = grub-core/kern/emu/mm.c;
 +  source = grub-core/kern/emu/misc.c;
 +  source = grub-core/kern/emu/hostfs.c;
 +  source = grub-core/kern/emu/getroot.c;
 +  source = grub-core/kern/emu/hostdisk.c;
 +
 +  source = grub-core/commands/blocklist.c;
 +  source = grub-core/commands/extcmd.c;
 +  source = grub-core/commands/ls.c;
 +  source = grub-core/disk/dmraid_nvidia.c;
 +  source = grub-core/disk/host.c;
 +  source = grub-core/disk/loopback.c;
 +  source = grub-core/disk/lvm.c;
 +  source = grub-core/disk/mdraid_linux.c;
 +  source = grub-core/disk/raid5_recover.c;
 +  source = grub-core/disk/raid6_recover.c;
 +  source = grub-core/disk/raid.c;
 +  source = grub-core/fs/affs.c;
 +  source = grub-core/fs/afs_be.c;
 +  source = grub-core/fs/afs.c;
 +  source = grub-core/fs/befs_be.c;
 +  source = grub-core/fs/befs.c;
 +  source = grub-core/fs/cpio.c;
 +  source = grub-core/fs/ext2.c;
 +  source = grub-core/fs/fat.c;
 +  source = grub-core/fs/fshelp.c;
 +  source = grub-core/fs/hfs.c;
 +  source = grub-core/fs/hfsplus.c;
 +  source = grub-core/fs/iso9660.c;
 +  source = grub-core/fs/jfs.c;
 +  source = grub-core/fs/minix.c;
 +  source = grub-core/fs/nilfs2.c;
 +  source = grub-core/fs/ntfs.c;
 +  source = grub-core/fs/ntfscomp.c;
 +  source = grub-core/fs/reiserfs.c;
 +  source = grub-core/fs/sfs.c;
 +  source = grub-core/fs/tar.c;
 +  source = grub-core/fs/udf.c;
 +  source = grub-core/fs/ufs2.c;
 +  source = grub-core/fs/ufs.c;
 +  source = grub-core/fs/xfs.c;
 +  source = grub-core/kern/command.c;
 +  source = grub-core/kern/device.c;
 +  source = grub-core/kern/disk.c;
 +  source = grub-core/kern/env.c;
 +  source = grub-core/kern/err.c;
 +  source = grub-core/kern/file.c;
 +  source = grub-core/kern/fs.c;
 +  source = grub-core/kern/handler.c;
 +  source = grub-core/kern/list.c;
 +  source = grub-core/kern/parser.c;
 +  source = grub-core/kern/partition.c;
 +  source = grub-core/lib/arg.c;
 +  source = grub-core/lib/crc.c;
 +  source = grub-core/lib/crypto.c;
 +  source = grub-core/lib/envblk.c;
 +  source = grub-core/lib/hexdump.c;
 +  source = grub-core/lib/libgcrypt-grub/cipher/sha512.c;
 +  source = grub-core/lib/LzFind.c;
 +  source = grub-core/lib/LzmaEnc.c;
 +  source = grub-core/lib/pbkdf2.c;
 +  source = grub-core/normal/datetime.c;
 +  source = grub-core/normal/misc.c;
 +  source = grub-core/partmap/acorn.c;
 +  source = grub-core/partmap/amiga.c;
 +  source = grub-core/partmap/apple.c;
 +  source = grub-core/partmap/gpt.c;
 +  source = grub-core/partmap/msdos.c;
 +  source = grub-core/partmap/sun.c;
 +  source = grub-core/script/function.c;
 +  source = grub-core/script/lexer.c;
 +  source = grub-core/script/main.c;
 +  source = grub-core/script/script.c;
 +  common;
 +};
 +
 +program = {
 +  name = grub-bin2h;
 +  source = util/bin2h.c;
 +  ldadd = libutil.a;
 +  mansection = 1;
 +  common;
 +};
 +
 +program = {
 +  name = grub-mkimage;
 +  mansection = 1;
 +
-   common;
- };
++  source = util/grub-mkimage.c;
 +  source = util/resolve.c;
 +
 +  ldadd = libutil.a;
- program = {
-   name = grub-mkisofs;
-   mansection = 1;
-   source = util/mkisofs/eltorito.c;
-   source = util/mkisofs/hash.c;
-   source = util/mkisofs/joliet.c;
-   source = util/mkisofs/match.c;
-   source = util/mkisofs/mkisofs.c;
-   source = util/mkisofs/multi.c;
-   source = util/mkisofs/name.c;
-   source = util/mkisofs/rock.c;
-   source = util/mkisofs/tree.c;
-   source = util/mkisofs/write.c;
-   source = grub-core/gnulib/progname.c;
-   source = grub-core/gnulib/error.c;
-   cflags = '$(CFLAGS_MKISOFS)';
-   cppflags = '$(CPPFLAGS_MKISOFS)';
 +
++  cppflags = '-DGRUB_PKGLIBROOTDIR=\"$(pkglibroot)\"';
 +  common;
 +};
 +
 +program = {
 +  name = grub-mkrelpath;
 +  mansection = 1;
 +
 +  source = util/grub-mkrelpath.c;
 +
 +  ldadd = libutil.a;
 +  common;
 +};
 +
 +program = {
 +  name = grub-script-check;
 +  mansection = 1;
 +
 +  source = util/grub-script-check.c;
 +
 +  ldadd = libutil.a;
 +  common;
 +};
 +
 +program = {
 +  name = grub-editenv;
 +  mansection = 1;
 +
 +  source = util/grub-editenv.c;
 +
 +  ldadd = libutil.a;
 +  common;
 +};
 +
 +program = {
 +  name = grub-mkpasswd-pbkdf2;
 +  mansection = 1;
 +
 +  source = util/grub-mkpasswd-pbkdf2.c;
 +
 +  ldadd = libutil.a;
 +  cflags = '$(CFLAGS_GCRY)';
 +  cppflags = '$(CPPFLAGS_GCRY)';
 +  common;
 +};
 +
 +program = {
 +  name = grub-macho2img;
 +  mansection = 1;
 +  source = util/grub-macho2img.c;
 +};
 +
 +program = {
 +  name = grub-pe2elf;
 +  mansection = 1;
 +  source = util/grub-pe2elf.c;
 +
 +  ldadd = libutil.a;
 +};
 +
 +program = {
 +  name = grub-fstest;
 +  mansection = 1;
 +  source = util/grub-fstest.c;
 +
 +  ldadd = libutil.a;
 +  enable = COND_GRUB_FSTEST;
 +  common;
 +};
 +
 +program = {
 +  name = grub-mkfont;
 +  mansection = 1;
 +  source = util/grub-mkfont.c;
 +
 +  ldadd = libutil.a;
 +  cflags = '$(freetype_cflags)';
 +  ldflags = '$(freetype_libs)';
 +  common;
 +  enable = COND_GRUB_MKFONT;
 +};
 +
 +program = {
 +  name = grub-mkdevicemap;
 +  installdir = sbin;
 +  mansection = 8;
 +  source = util/grub-mkdevicemap.c;
 +  source = util/deviceiter.c;
 +  source = util/devicemap.c;
 +
 +  sparc64_ieee1275 = util/grub-mkdevicemap.c;
 +  sparc64_ieee1275 = util/deviceiter.c;
 +  sparc64_ieee1275 = util/ieee1275/ofpath.c;
 +  sparc64_ieee1275 = util/ieee1275/devicemap.c;
 +
 +  ldadd = libutil.a;
 +  common;
 +};
 +
 +program = {
 +  name = grub-probe;
 +  installdir = sbin;
 +  mansection = 8;
 +  source = util/grub-probe.c;
 +
 +  ldadd = libutil.a;
 +  common;
 +};
 +
 +program = {
 +  name = grub-setup;
 +  installdir = sbin;
 +  mansection = 8;
 +  i386_pc = util/i386/pc/grub-setup.c;
 +  i386_pc = util/raid.c;
 +  i386_pc = util/lvm.c;
 +
 +  sparc64_ieee1275 = util/ieee1275/ofpath.c;
 +  sparc64_ieee1275 = util/sparc64/ieee1275/grub-setup.c;
 +  sparc64_ieee1275 = util/raid.c;
 +  sparc64_ieee1275 = util/lvm.c;
 +
 +  ldadd = libutil.a;
 +};
 +
 +program = {
 +  name = grub-ofpathname;
 +  installdir = sbin;
 +  source = util/ieee1275/grub-ofpathname.c;
 +  source = util/ieee1275/ofpath.c;
 +
 +  ldadd = libutil.a;
 +  sparc64_ieee1275;
 +};
 +
 +data = {
 +  source = util/grub.d/README;
 +  installdir = grubconf;
 +  common;
 +};
 +
 +script = {
 +  name = '00_header';
 +  source = util/grub.d/00_header.in;
 +  installdir = grubconf;
 +  common;
 +};
 +
 +script = {
 +  name = '10_windows';
 +  source = util/grub.d/10_windows.in;
 +  installdir = grubconf;
 +};
 +
 +script = {
 +  name = '10_hurd';
 +  source = util/grub.d/10_hurd.in;
 +  installdir = grubconf;
 +};
 +
 +script = {
 +  name = '10_linux';
 +  source = util/grub.d/10_linux.in;
 +  installdir = grubconf;
 +  common;
 +};
 +
 +script = {
 +  name = '30_os-prober';
 +  source = util/grub.d/30_os-prober.in;
 +  installdir = grubconf;
 +  common;
 +};
 +
 +script = {
 +  name = '40_custom';
 +  source = util/grub.d/40_custom.in;
 +  installdir = grubconf;
 +  common;
 +};
 +
 +script = {
 +  mansection = 1;
 +  name = grub-mkrescue;
 +  source = util/grub-mkrescue.in;
 +  powerpc_ieee1275 = util/powerpc/ieee1275/grub-mkrescue.in;
 +  i386_pc;
 +  i386_qemu;
 +  i386_coreboot;
 +};
 +
 +script = {
 +  mansection = 8;
 +  installdir = sbin;
 +  name = grub-install;
 +  source = util/grub-install.in;
 +  x86_efi = util/i386/efi/grub-install.in;
 +  i386_ieee1275 = util/ieee1275/grub-install.in;
 +  powerpc_ieee1275 = util/ieee1275/grub-install.in;
 +  mips;
 +  i386_pc;
 +  i386_qemu;
 +  i386_coreboot;
 +};
 +
 +script = {
 +  name = grub-mkconfig;
 +  source = util/grub-mkconfig.in;
 +  mansection = 8;
 +  installdir = sbin;
 +  common;
 +};
 +
 +script = {
 +  name = grub-set-default;
 +  source = util/grub-set-default.in;
 +  mansection = 8;
 +  installdir = sbin;
 +  common;
 +};
 +
 +script = {
 +  name = grub-reboot;
 +  source = util/grub-reboot.in;
 +  mansection = 8;
 +  installdir = sbin;
 +  common;
 +};
 +
 +script = {
 +  name = grub-mkconfig_lib;
 +  source = util/grub-mkconfig_lib.in;
 +  installdir = pkglib;
 +  common;
 +};
 +
 +script = {
 +  name = update-grub_lib;
 +  source = util/update-grub_lib.in;
 +  installdir = pkglib;
 +  common;
 +};
 +
 +test_script = {
 +  name = grub-shell;
 +  source = tests/util/grub-shell.in;
 +  common;
 +};
 +
 +test_script = {
 +  name = grub-shell-tester;
 +  source = tests/util/grub-shell-tester.in;
 +  common;
 +};
 +
 +test_script = {
 +  name = example_scripted_test;
 +  source = tests/example_scripted_test.in;
 +  common;
 +};
 +
 +test_script = {
 +  name = example_grub_script_test;
 +  source = tests/example_grub_script_test.in;
 +  common;
 +};
 +
 +test_script = {
 +  name = grub_script_echo1;
 +  source = tests/grub_script_echo1.in;
 +  common;
 +  enable;
 +};
 +
 +test_script = {
 +  name = grub_script_echo_keywords;
 +  source = tests/grub_script_echo_keywords.in;
 +  common;
 +  enable;
 +};
 +
 +test_script = {
 +  name = grub_script_vars1;
 +  source = tests/grub_script_vars1.in;
 +  common;
 +  enable;
 +};
 +
 +test_script = {
 +  name = grub_script_for1;
 +  source = tests/grub_script_for1.in;
 +  common;
 +  enable;
 +};
 +
 +test_script = {
 +  name = grub_script_while1;
 +  source = tests/grub_script_while1.in;
 +  common;
 +  enable;
 +};
 +
 +test_script = {
 +  name = grub_script_if;
 +  source = tests/grub_script_if.in;
 +  common;
 +  enable;
 +};
 +
 +test_script = {
 +  name = grub_script_blanklines;
 +  source = tests/grub_script_blanklines.in;
 +  common;
 +  enable;
 +};
 +
 +test_script = {
 +  name = grub_script_final_semicolon;
 +  source = tests/grub_script_final_semicolon.in;
 +  common;
 +  enable;
 +};
 +
 +test_script = {
 +  name = grub_script_dollar;
 +  source = tests/grub_script_dollar.in;
 +  common;
 +  enable;
 +};
 +
 +test_script = {
 +  name = grub_script_comments;
 +  source = tests/grub_script_comments.in;
 +  common;
 +  enable;
 +};
 +
 +test_program = {
 +  name = example_unit_test;
 +  source = tests/example_unit_test.c;
 +  source = tests/lib/unit_test.c;
 +  source = grub-core/kern/list.c;
 +  source = grub-core/kern/misc.c;
 +  source = grub-core/tests/lib/test.c;
 +  cflags = -Wno-format;
 +  common;
 +};
index 8324beb9766f050d99ef10d803fd42f1383031d8,17da6c8c03747e26a77a48502e4f809e918e5b16..abdcaab8b8cbeb5fa2229b24156f12bf772f7985
@@@ -123,14 -123,11 +123,15 @@@ source /boot/grub/testcase.cf
  halt
  EOF
  
 +rootdir=`mktemp -d`
 +(cd @abs_top_builddir@ && make DESTDIR=$rootdir install) >/dev/null 2>&1
 +
  isofile=`mktemp`
- sh @abs_top_builddir@/grub-mkrescue --output=${isofile} \
 -grub-mkrescue --grub-mkimage=${builddir}/grub-mkimage --output=${isofile} \
 -  --override-directory=${builddir} \
 -  /boot/grub/grub.cfg=${cfgfile} /boot/grub/testcase.cfg=${source} \
 -  >/dev/null 2>&1
++sh @abs_top_builddir@/grub-mkrescue --grub-mkimage=${builddir}/grub-mkimage \
++  --override-directory=${builddir}/grub-core --output=${isofile} \
 +  --root-directory=${rootdir} /boot/grub/grub.cfg=${cfgfile} \
 +  /boot/grub/testcase.cfg=${source} >/dev/null 2>&1
 +rm -rf $rootdir
  
  hdafile=`mktemp`
  cp ${isofile} ${hdafile}
index d534ff9efcf1b2cb9e0332d5d8cd2a049b629d66,db37f99e61de807835062b0afaaeef159483bc78..bdecae4a35586945bf6a9e0f8784a32e6d9cf935
  #include <fcntl.h>
  #include <limits.h>
  
 +#include <grub/emu/misc.h>
  #include <grub/util/misc.h>
  #include <grub/util/deviceiter.h>
+ #include <grub/env.h>
  #include <grub/i18n.h>
  
  #define _GNU_SOURCE   1
index 0000000000000000000000000000000000000000,6366a98036d13ee361a394688b1ffdb4a2e64ce5..9da89c53e3184edd9a58ecbf269ec9a64a277128
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,1364 +1,1365 @@@
+ /* grub-mkimage.c - make a bootable image */
+ /*
+  *  GRUB  --  GRand Unified Bootloader
+  *  Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010  Free Software Foundation, Inc.
+  *
+  *  GRUB is free software: you can redistribute it and/or modify
+  *  it under the terms of the GNU General Public License as published by
+  *  the Free Software Foundation, either version 3 of the License, or
+  *  (at your option) any later version.
+  *
+  *  GRUB is distributed in the hope that it will be useful,
+  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  *  GNU General Public License for more details.
+  *
+  *  You should have received a copy of the GNU General Public License
+  *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
+  */
+ #include <config.h>
+ #include <grub/types.h>
+ #include <grub/elf.h>
+ #include <grub/aout.h>
+ #include <grub/i18n.h>
+ #include <grub/kernel.h>
+ #include <grub/disk.h>
++#include <grub/emu/misc.h>
+ #include <grub/util/misc.h>
+ #include <grub/util/resolve.h>
+ #include <grub/misc.h>
+ #include <grub/offsets.h>
+ #include <time.h>
+ #include <stdio.h>
+ #include <unistd.h>
+ #include <string.h>
+ #include <stdlib.h>
+ #include <assert.h>
+ #include <grub/efi/pe32.h>
+ #define _GNU_SOURCE   1
+ #include <getopt.h>
+ #include "progname.h"
+ #define ALIGN_ADDR(x) (ALIGN_UP((x), image_target->voidp_sizeof))
+ #define TARGET_NO_FIELD 0xffffffff
+ struct image_target_desc
+ {
+   const char *name;
+   grub_size_t voidp_sizeof;
+   int bigendian;
+   enum {
+     IMAGE_I386_PC, IMAGE_EFI, IMAGE_COREBOOT,
+     IMAGE_SPARC64_AOUT, IMAGE_SPARC64_RAW, IMAGE_I386_IEEE1275,
+     IMAGE_YEELOONG_ELF, IMAGE_QEMU, IMAGE_PPC
+   } id;
+   enum
+     {
+       PLATFORM_FLAGS_NONE = 0,
+       PLATFORM_FLAGS_LZMA = 1
+     } flags;
+   unsigned prefix;
+   unsigned data_end;
+   unsigned raw_size;
+   unsigned total_module_size;
+   unsigned kernel_image_size;
+   unsigned compressed_size;
+   unsigned link_align;
+   grub_uint16_t elf_target;
+   unsigned section_align;
+   signed vaddr_offset;
+   unsigned install_dos_part, install_bsd_part;
+   grub_uint64_t link_addr;
+   unsigned mod_gap, mod_align;
+ };
+ struct image_target_desc image_targets[] =
+   {
+     {
+       .name = "i386-coreboot",
+       .voidp_sizeof = 4,
+       .bigendian = 0,
+       .id = IMAGE_COREBOOT,
+       .flags = PLATFORM_FLAGS_NONE,
+       .prefix = GRUB_KERNEL_I386_COREBOOT_PREFIX,
+       .data_end = GRUB_KERNEL_I386_COREBOOT_DATA_END,
+       .raw_size = 0,
+       .total_module_size = TARGET_NO_FIELD,
+       .kernel_image_size = TARGET_NO_FIELD,
+       .compressed_size = TARGET_NO_FIELD,
+       .section_align = 1,
+       .vaddr_offset = 0,
+       .install_dos_part = TARGET_NO_FIELD,
+       .install_bsd_part = TARGET_NO_FIELD,
+       .link_addr = GRUB_KERNEL_I386_COREBOOT_LINK_ADDR,
+       .elf_target = EM_386,
+       .link_align = 4,
+       .mod_gap = GRUB_KERNEL_I386_COREBOOT_MOD_GAP,
+       .mod_align = GRUB_KERNEL_I386_COREBOOT_MOD_ALIGN
+     },
+     {
+       .name = "i386-multiboot",
+       .voidp_sizeof = 4,
+       .bigendian = 0,
+       .id = IMAGE_COREBOOT,
+       .flags = PLATFORM_FLAGS_NONE,
+       .prefix = GRUB_KERNEL_I386_COREBOOT_PREFIX,
+       .data_end = GRUB_KERNEL_I386_COREBOOT_DATA_END,
+       .raw_size = 0,
+       .total_module_size = TARGET_NO_FIELD,
+       .kernel_image_size = TARGET_NO_FIELD,
+       .compressed_size = TARGET_NO_FIELD,
+       .section_align = 1,
+       .vaddr_offset = 0,
+       .install_dos_part = TARGET_NO_FIELD,
+       .install_bsd_part = TARGET_NO_FIELD,
+       .link_addr = GRUB_KERNEL_I386_COREBOOT_LINK_ADDR,
+       .elf_target = EM_386,
+       .link_align = 4,
+       .mod_gap = GRUB_KERNEL_I386_COREBOOT_MOD_GAP,
+       .mod_align = GRUB_KERNEL_I386_COREBOOT_MOD_ALIGN
+     },
+     {
+       .name = "i386-pc",
+       .voidp_sizeof = 4,
+       .bigendian = 0,
+       .id = IMAGE_I386_PC, 
+       .flags = PLATFORM_FLAGS_LZMA,
+       .prefix = GRUB_KERNEL_I386_PC_PREFIX,
+       .data_end = GRUB_KERNEL_I386_PC_DATA_END,
+       .raw_size = GRUB_KERNEL_I386_PC_RAW_SIZE,
+       .total_module_size = GRUB_KERNEL_I386_PC_TOTAL_MODULE_SIZE,
+       .kernel_image_size = GRUB_KERNEL_I386_PC_KERNEL_IMAGE_SIZE,
+       .compressed_size = GRUB_KERNEL_I386_PC_COMPRESSED_SIZE,
+       .section_align = 1,
+       .vaddr_offset = 0,
+       .install_dos_part = GRUB_KERNEL_I386_PC_INSTALL_DOS_PART,
+       .install_bsd_part = GRUB_KERNEL_I386_PC_INSTALL_BSD_PART,
+       .link_addr = GRUB_KERNEL_I386_PC_LINK_ADDR
+     },
+     {
+       .name = "i386-efi",
+       .voidp_sizeof = 4,
+       .bigendian = 0,
+       .id = IMAGE_EFI,
+       .flags = PLATFORM_FLAGS_NONE,
+       .prefix = GRUB_KERNEL_I386_EFI_PREFIX,
+       .data_end = GRUB_KERNEL_I386_EFI_DATA_END,
+       .raw_size = 0,
+       .total_module_size = TARGET_NO_FIELD,
+       .kernel_image_size = TARGET_NO_FIELD,
+       .compressed_size = TARGET_NO_FIELD,
+       .section_align = GRUB_PE32_SECTION_ALIGNMENT,
+       .vaddr_offset = ALIGN_UP (GRUB_PE32_MSDOS_STUB_SIZE
+                               + GRUB_PE32_SIGNATURE_SIZE
+                               + sizeof (struct grub_pe32_coff_header)
+                               + sizeof (struct grub_pe32_optional_header)
+                               + 4 * sizeof (struct grub_pe32_section_table),
+                               GRUB_PE32_SECTION_ALIGNMENT),
+       .install_dos_part = TARGET_NO_FIELD,
+       .install_bsd_part = TARGET_NO_FIELD,
+     },
+     {
+       .name = "i386-ieee1275",
+       .voidp_sizeof = 4,
+       .bigendian = 0,
+       .id = IMAGE_I386_IEEE1275, 
+       .flags = PLATFORM_FLAGS_NONE,
+       .prefix = GRUB_KERNEL_I386_IEEE1275_PREFIX,
+       .data_end = GRUB_KERNEL_I386_IEEE1275_DATA_END,
+       .raw_size = 0,
+       .total_module_size = TARGET_NO_FIELD,
+       .kernel_image_size = TARGET_NO_FIELD,
+       .compressed_size = TARGET_NO_FIELD,
+       .section_align = 1,
+       .vaddr_offset = 0,
+       .install_dos_part = TARGET_NO_FIELD,
+       .install_bsd_part = TARGET_NO_FIELD,
+       .link_addr = GRUB_KERNEL_I386_IEEE1275_LINK_ADDR,
+       .elf_target = EM_386,
+       .mod_gap = GRUB_KERNEL_I386_IEEE1275_MOD_GAP,
+       .mod_align = GRUB_KERNEL_I386_IEEE1275_MOD_ALIGN,
+       .link_align = 4,
+     },
+     {
+       .name = "i386-qemu",
+       .voidp_sizeof = 4,
+       .bigendian = 0,
+       .id = IMAGE_QEMU, 
+       .flags = PLATFORM_FLAGS_NONE,
+       .prefix = GRUB_KERNEL_I386_QEMU_PREFIX,
+       .data_end = GRUB_KERNEL_I386_QEMU_DATA_END,
+       .raw_size = 0,
+       .total_module_size = TARGET_NO_FIELD,
+       .compressed_size = TARGET_NO_FIELD,
+       .kernel_image_size = GRUB_KERNEL_I386_QEMU_KERNEL_IMAGE_SIZE,
+       .section_align = 1,
+       .vaddr_offset = 0,
+       .install_dos_part = TARGET_NO_FIELD,
+       .install_bsd_part = TARGET_NO_FIELD,
+       .link_addr = GRUB_KERNEL_I386_QEMU_LINK_ADDR
+     },
+     {
+       .name = "x86_64-efi",
+       .voidp_sizeof = 8,
+       .bigendian = 0, 
+       .id = IMAGE_EFI, 
+       .flags = PLATFORM_FLAGS_NONE,
+       .prefix = GRUB_KERNEL_X86_64_EFI_PREFIX,
+       .data_end = GRUB_KERNEL_X86_64_EFI_DATA_END,
+       .raw_size = 0,
+       .total_module_size = TARGET_NO_FIELD,
+       .kernel_image_size = TARGET_NO_FIELD,
+       .compressed_size = TARGET_NO_FIELD,
+       .section_align = GRUB_PE32_SECTION_ALIGNMENT,
+       .vaddr_offset = ALIGN_UP (GRUB_PE32_MSDOS_STUB_SIZE
+                               + GRUB_PE32_SIGNATURE_SIZE
+                               + sizeof (struct grub_pe32_coff_header)
+                               + sizeof (struct grub_pe64_optional_header)
+                               + 4 * sizeof (struct grub_pe32_section_table),
+                               GRUB_PE32_SECTION_ALIGNMENT),
+       .install_dos_part = TARGET_NO_FIELD,
+       .install_bsd_part = TARGET_NO_FIELD,
+     },
+     {
+       .name = "mipsel-yeeloong-elf",
+       .voidp_sizeof = 4,
+       .bigendian = 0,
+       .id = IMAGE_YEELOONG_ELF, 
+       .flags = PLATFORM_FLAGS_NONE,
+       .prefix = GRUB_KERNEL_MIPS_YEELOONG_PREFIX,
+       .data_end = GRUB_KERNEL_MIPS_YEELOONG_DATA_END,
+       .raw_size = GRUB_KERNEL_MIPS_YEELOONG_RAW_SIZE,
+       .total_module_size = GRUB_KERNEL_MIPS_YEELOONG_TOTAL_MODULE_SIZE,
+       .compressed_size = GRUB_KERNEL_MIPS_YEELOONG_COMPRESSED_SIZE,
+       .kernel_image_size = GRUB_KERNEL_MIPS_YEELOONG_KERNEL_IMAGE_SIZE,
+       .section_align = 1,
+       .vaddr_offset = 0,
+       .install_dos_part = TARGET_NO_FIELD,
+       .install_bsd_part = TARGET_NO_FIELD,
+       .link_addr = GRUB_KERNEL_MIPS_YEELOONG_LINK_ADDR,
+       .elf_target = EM_MIPS,
+       .link_align = GRUB_KERNEL_MIPS_YEELOONG_LINK_ALIGN
+     },
+     {
+       .name = "powerpc-ieee1275",
+       .voidp_sizeof = 4,
+       .bigendian = 1,
+       .id = IMAGE_PPC, 
+       .flags = PLATFORM_FLAGS_NONE,
+       .prefix = GRUB_KERNEL_POWERPC_IEEE1275_PREFIX,
+       .data_end = GRUB_KERNEL_POWERPC_IEEE1275_DATA_END,
+       .raw_size = 0,
+       .total_module_size = TARGET_NO_FIELD,
+       .kernel_image_size = TARGET_NO_FIELD,
+       .compressed_size = TARGET_NO_FIELD,
+       .section_align = 1,
+       .vaddr_offset = 0,
+       .install_dos_part = TARGET_NO_FIELD,
+       .install_bsd_part = TARGET_NO_FIELD,
+       .link_addr = GRUB_KERNEL_POWERPC_IEEE1275_LINK_ADDR,
+       .elf_target = EM_PPC,
+       .mod_gap = GRUB_KERNEL_POWERPC_IEEE1275_MOD_GAP,
+       .mod_align = GRUB_KERNEL_POWERPC_IEEE1275_MOD_ALIGN,
+       .link_align = 4
+     },
+     {
+       .name = "sparc64-ieee1275-raw",
+       .voidp_sizeof = 8,
+       .bigendian = 1, 
+       .id = IMAGE_SPARC64_RAW,
+       .flags = PLATFORM_FLAGS_NONE,
+       .prefix = GRUB_KERNEL_SPARC64_IEEE1275_PREFIX,
+       .data_end = GRUB_KERNEL_SPARC64_IEEE1275_DATA_END,
+       .raw_size = GRUB_KERNEL_SPARC64_IEEE1275_RAW_SIZE,
+       .total_module_size = GRUB_KERNEL_SPARC64_IEEE1275_TOTAL_MODULE_SIZE,
+       .kernel_image_size = GRUB_KERNEL_SPARC64_IEEE1275_KERNEL_IMAGE_SIZE,
+       .compressed_size = GRUB_KERNEL_SPARC64_IEEE1275_COMPRESSED_SIZE,
+       .section_align = 1,
+       .vaddr_offset = 0,
+       .install_dos_part = TARGET_NO_FIELD,
+       .install_bsd_part = TARGET_NO_FIELD,
+       .link_addr = GRUB_KERNEL_SPARC64_IEEE1275_LINK_ADDR
+     },
+     {
+       .name = "sparc64-ieee1275-aout",
+       .voidp_sizeof = 8,
+       .bigendian = 1,
+       .id = IMAGE_SPARC64_AOUT,
+       .flags = PLATFORM_FLAGS_NONE,
+       .prefix = GRUB_KERNEL_SPARC64_IEEE1275_PREFIX,
+       .data_end = GRUB_KERNEL_SPARC64_IEEE1275_DATA_END,
+       .raw_size = GRUB_KERNEL_SPARC64_IEEE1275_RAW_SIZE,
+       .total_module_size = GRUB_KERNEL_SPARC64_IEEE1275_TOTAL_MODULE_SIZE,
+       .kernel_image_size = GRUB_KERNEL_SPARC64_IEEE1275_KERNEL_IMAGE_SIZE,
+       .compressed_size = GRUB_KERNEL_SPARC64_IEEE1275_COMPRESSED_SIZE,
+       .section_align = 1,
+       .vaddr_offset = 0,
+       .install_dos_part = TARGET_NO_FIELD,
+       .install_bsd_part = TARGET_NO_FIELD,
+       .link_addr = GRUB_KERNEL_SPARC64_IEEE1275_LINK_ADDR
+     },
+   };
+ #define grub_target_to_host32(x) (grub_target_to_host32_real (image_target, (x)))
+ #define grub_host_to_target32(x) (grub_host_to_target32_real (image_target, (x)))
+ #define grub_target_to_host64(x) (grub_target_to_host64_real (image_target, (x)))
+ #define grub_host_to_target64(x) (grub_host_to_target64_real (image_target, (x)))
+ #define grub_host_to_target_addr(x) (grub_host_to_target_addr_real (image_target, (x)))
+ #define grub_target_to_host16(x) (grub_target_to_host16_real (image_target, (x)))
+ #define grub_host_to_target16(x) (grub_host_to_target16_real (image_target, (x)))
+ static inline grub_uint32_t
+ grub_target_to_host32_real (struct image_target_desc *image_target, grub_uint32_t in)
+ {
+   if (image_target->bigendian)
+     return grub_be_to_cpu32 (in);
+   else
+     return grub_le_to_cpu32 (in);
+ }
+ static inline grub_uint64_t
+ grub_target_to_host64_real (struct image_target_desc *image_target, grub_uint64_t in)
+ {
+   if (image_target->bigendian)
+     return grub_be_to_cpu64 (in);
+   else
+     return grub_le_to_cpu64 (in);
+ }
+ static inline grub_uint64_t
+ grub_host_to_target64_real (struct image_target_desc *image_target, grub_uint64_t in)
+ {
+   if (image_target->bigendian)
+     return grub_cpu_to_be64 (in);
+   else
+     return grub_cpu_to_le64 (in);
+ }
+ static inline grub_uint32_t
+ grub_host_to_target32_real (struct image_target_desc *image_target, grub_uint32_t in)
+ {
+   if (image_target->bigendian)
+     return grub_cpu_to_be32 (in);
+   else
+     return grub_cpu_to_le32 (in);
+ }
+ static inline grub_uint16_t
+ grub_target_to_host16_real (struct image_target_desc *image_target, grub_uint16_t in)
+ {
+   if (image_target->bigendian)
+     return grub_be_to_cpu16 (in);
+   else
+     return grub_le_to_cpu16 (in);
+ }
+ static inline grub_uint16_t
+ grub_host_to_target16_real (struct image_target_desc *image_target, grub_uint16_t in)
+ {
+   if (image_target->bigendian)
+     return grub_cpu_to_be16 (in);
+   else
+     return grub_cpu_to_le16 (in);
+ }
+ static inline grub_uint64_t
+ grub_host_to_target_addr_real (struct image_target_desc *image_target, grub_uint64_t in)
+ {
+   if (image_target->voidp_sizeof == 8)
+     return grub_host_to_target64_real (image_target, in);
+   else
+     return grub_host_to_target32_real (image_target, in);
+ }
+ static inline grub_uint64_t
+ grub_target_to_host_real (struct image_target_desc *image_target, grub_uint64_t in)
+ {
+   if (image_target->voidp_sizeof == 8)
+     return grub_target_to_host64_real (image_target, in);
+   else
+     return grub_target_to_host32_real (image_target, in);
+ }
+ #define GRUB_IEEE1275_NOTE_NAME "PowerPC"
+ #define GRUB_IEEE1275_NOTE_TYPE 0x1275
+ /* These structures are defined according to the CHRP binding to IEEE1275,
+    "Client Program Format" section.  */
+ struct grub_ieee1275_note_hdr
+ {
+   grub_uint32_t namesz;
+   grub_uint32_t descsz;
+   grub_uint32_t type;
+   char name[sizeof (GRUB_IEEE1275_NOTE_NAME)];
+ };
+ struct grub_ieee1275_note_desc
+ {
+   grub_uint32_t real_mode;
+   grub_uint32_t real_base;
+   grub_uint32_t real_size;
+   grub_uint32_t virt_base;
+   grub_uint32_t virt_size;
+   grub_uint32_t load_base;
+ };
+ struct grub_ieee1275_note
+ {
+   struct grub_ieee1275_note_hdr header;
+   struct grub_ieee1275_note_desc descriptor;
+ };
+ #define grub_target_to_host(val) grub_target_to_host_real(image_target, (val))
+ #include <grub/lib/LzmaEnc.h>
+ static void *SzAlloc(void *p, size_t size) { p = p; return xmalloc(size); }
+ static void SzFree(void *p, void *address) { p = p; free(address); }
+ static ISzAlloc g_Alloc = { SzAlloc, SzFree };
+ static void
+ compress_kernel_lzma (char *kernel_img, size_t kernel_size,
+                     char **core_img, size_t *core_size, size_t raw_size)
+ {
+   CLzmaEncProps props;
+   unsigned char out_props[5];
+   size_t out_props_size = 5;
+   LzmaEncProps_Init(&props);
+   props.dictSize = 1 << 16;
+   props.lc = 3;
+   props.lp = 0;
+   props.pb = 2;
+   props.numThreads = 1;
+   if (kernel_size < raw_size)
+     grub_util_error (_("the core image is too small"));
+   *core_img = xmalloc (kernel_size);
+   memcpy (*core_img, kernel_img, raw_size);
+   *core_size = kernel_size - raw_size;
+   if (LzmaEncode ((unsigned char *) *core_img + raw_size, core_size,
+                 (unsigned char *) kernel_img + raw_size,
+                 kernel_size - raw_size,
+                 &props, out_props, &out_props_size,
+                 0, NULL, &g_Alloc, &g_Alloc) != SZ_OK)
+     grub_util_error (_("cannot compress the kernel image"));
+   *core_size += raw_size;
+ }
+ static void
+ compress_kernel (struct image_target_desc *image_target, char *kernel_img,
+                size_t kernel_size, char **core_img, size_t *core_size)
+ {
+  if (image_target->flags & PLATFORM_FLAGS_LZMA)
+    {
+      compress_kernel_lzma (kernel_img, kernel_size, core_img,
+                          core_size, image_target->raw_size);
+      return;
+    }
+   *core_img = xmalloc (kernel_size);
+   memcpy (*core_img, kernel_img, kernel_size);
+   *core_size = kernel_size;
+ }
+ struct fixup_block_list
+ {
+   struct fixup_block_list *next;
+   int state;
+   struct grub_pe32_fixup_block b;
+ };
+ #define MKIMAGE_ELF32 1
+ #include "grub-mkimagexx.c"
+ #undef MKIMAGE_ELF32
+ #define MKIMAGE_ELF64 1
+ #include "grub-mkimagexx.c"
+ #undef MKIMAGE_ELF64
+ static void
+ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
+               char *memdisk_path, char *font_path, char *config_path,
+               struct image_target_desc *image_target, int note)
+ {
+   char *kernel_img, *core_img;
+   size_t kernel_size, total_module_size, core_size, exec_size;
+   size_t memdisk_size = 0, font_size = 0, config_size = 0, config_size_pure = 0;
+   char *kernel_path;
+   size_t offset;
+   struct grub_util_path_list *path_list, *p, *next;
+   grub_size_t bss_size;
+   grub_uint64_t start_address;
+   void *rel_section;
+   grub_size_t reloc_size, align;
+   path_list = grub_util_resolve_dependencies (dir, "moddep.lst", mods);
+   kernel_path = grub_util_get_path (dir, "kernel.img");
+   if (image_target->voidp_sizeof == 8)
+     total_module_size = sizeof (struct grub_module_info64);
+   else
+     total_module_size = sizeof (struct grub_module_info32);
+   if (memdisk_path)
+     {
+       memdisk_size = ALIGN_UP(grub_util_get_image_size (memdisk_path), 512);
+       grub_util_info ("the size of memory disk is 0x%x", memdisk_size);
+       total_module_size += memdisk_size + sizeof (struct grub_module_header);
+     }
+   if (font_path)
+     {
+       font_size = ALIGN_ADDR (grub_util_get_image_size (font_path));
+       total_module_size += font_size + sizeof (struct grub_module_header);
+     }
+   if (config_path)
+     {
+       config_size_pure = grub_util_get_image_size (config_path) + 1;
+       config_size = ALIGN_ADDR (config_size_pure);
+       grub_util_info ("the size of config file is 0x%x", config_size);
+       total_module_size += config_size + sizeof (struct grub_module_header);
+     }
+   for (p = path_list; p; p = p->next)
+     total_module_size += (ALIGN_ADDR (grub_util_get_image_size (p->name))
+                         + sizeof (struct grub_module_header));
+   grub_util_info ("the total module size is 0x%x", total_module_size);
+   if (image_target->voidp_sizeof == 4)
+     kernel_img = load_image32 (kernel_path, &exec_size, &kernel_size, &bss_size,
+                              total_module_size, &start_address, &rel_section,
+                              &reloc_size, &align, image_target);
+   else
+     kernel_img = load_image64 (kernel_path, &exec_size, &kernel_size, &bss_size,
+                              total_module_size, &start_address, &rel_section,
+                              &reloc_size, &align, image_target);
+   if (image_target->prefix + strlen (prefix) + 1 > image_target->data_end)
+     grub_util_error (_("prefix is too long"));
+   strcpy (kernel_img + image_target->prefix, prefix);
+   if (image_target->voidp_sizeof == 8)
+     {
+       /* Fill in the grub_module_info structure.  */
+       struct grub_module_info64 *modinfo;
+       modinfo = (struct grub_module_info64 *) (kernel_img + kernel_size);
+       memset (modinfo, 0, sizeof (struct grub_module_info64));
+       modinfo->magic = grub_host_to_target32 (GRUB_MODULE_MAGIC);
+       modinfo->offset = grub_host_to_target_addr (sizeof (struct grub_module_info64));
+       modinfo->size = grub_host_to_target_addr (total_module_size);
+       offset = kernel_size + sizeof (struct grub_module_info64);
+     }
+   else
+     {
+       /* Fill in the grub_module_info structure.  */
+       struct grub_module_info32 *modinfo;
+       modinfo = (struct grub_module_info32 *) (kernel_img + kernel_size);
+       memset (modinfo, 0, sizeof (struct grub_module_info32));
+       modinfo->magic = grub_host_to_target32 (GRUB_MODULE_MAGIC);
+       modinfo->offset = grub_host_to_target_addr (sizeof (struct grub_module_info32));
+       modinfo->size = grub_host_to_target_addr (total_module_size);
+       offset = kernel_size + sizeof (struct grub_module_info32);
+     }
+   for (p = path_list; p; p = p->next)
+     {
+       struct grub_module_header *header;
+       size_t mod_size, orig_size;
+       orig_size = grub_util_get_image_size (p->name);
+       mod_size = ALIGN_ADDR (orig_size);
+       header = (struct grub_module_header *) (kernel_img + offset);
+       memset (header, 0, sizeof (struct grub_module_header));
+       header->type = grub_host_to_target32 (OBJ_TYPE_ELF);
+       header->size = grub_host_to_target32 (mod_size + sizeof (*header));
+       offset += sizeof (*header);
+       memset (kernel_img + offset + orig_size, 0, mod_size - orig_size);
+       grub_util_load_image (p->name, kernel_img + offset);
+       offset += mod_size;
+     }
+   if (memdisk_path)
+     {
+       struct grub_module_header *header;
+       header = (struct grub_module_header *) (kernel_img + offset);
+       memset (header, 0, sizeof (struct grub_module_header));
+       header->type = grub_host_to_target32 (OBJ_TYPE_MEMDISK);
+       header->size = grub_host_to_target32 (memdisk_size + sizeof (*header));
+       offset += sizeof (*header);
+       grub_util_load_image (memdisk_path, kernel_img + offset);
+       offset += memdisk_size;
+     }
+   if (font_path)
+     {
+       struct grub_module_header *header;
+       header = (struct grub_module_header *) (kernel_img + offset);
+       memset (header, 0, sizeof (struct grub_module_header));
+       header->type = grub_host_to_target32 (OBJ_TYPE_FONT);
+       header->size = grub_host_to_target32 (font_size + sizeof (*header));
+       offset += sizeof (*header);
+       grub_util_load_image (font_path, kernel_img + offset);
+       offset += font_size;
+     }
+   if (config_path)
+     {
+       struct grub_module_header *header;
+       header = (struct grub_module_header *) (kernel_img + offset);
+       memset (header, 0, sizeof (struct grub_module_header));
+       header->type = grub_host_to_target32 (OBJ_TYPE_CONFIG);
+       header->size = grub_host_to_target32 (config_size + sizeof (*header));
+       offset += sizeof (*header);
+       grub_util_load_image (config_path, kernel_img + offset);
+       *(kernel_img + offset + config_size_pure - 1) = 0;
+       offset += config_size;
+     }
+   grub_util_info ("kernel_img=%p, kernel_size=0x%x", kernel_img, kernel_size);
+   compress_kernel (image_target, kernel_img, kernel_size + total_module_size,
+                  &core_img, &core_size);
+   grub_util_info ("the core size is 0x%x", core_size);
+   if (image_target->total_module_size != TARGET_NO_FIELD)
+     *((grub_uint32_t *) (core_img + image_target->total_module_size))
+       = grub_host_to_target32 (total_module_size);
+   if (image_target->kernel_image_size != TARGET_NO_FIELD)
+     *((grub_uint32_t *) (core_img + image_target->kernel_image_size))
+       = grub_host_to_target32 (kernel_size);
+   if (image_target->compressed_size != TARGET_NO_FIELD)
+     *((grub_uint32_t *) (core_img + image_target->compressed_size))
+       = grub_host_to_target32 (core_size - image_target->raw_size);
+   /* If we included a drive in our prefix, let GRUB know it doesn't have to
+      prepend the drive told by BIOS.  */
+   if (image_target->install_dos_part != TARGET_NO_FIELD
+       && image_target->install_bsd_part != TARGET_NO_FIELD && prefix[0] == '(')
+     {
+       *((grub_int32_t *) (core_img + image_target->install_dos_part))
+       = grub_host_to_target32 (-2);
+       *((grub_int32_t *) (core_img + image_target->install_bsd_part))
+       = grub_host_to_target32 (-2);
+     }
+   switch (image_target->id)
+     {
+     case IMAGE_I386_PC:
+       {
+       unsigned num;
+       char *boot_path, *boot_img;
+       size_t boot_size;
+       if (GRUB_KERNEL_I386_PC_LINK_ADDR + core_size > GRUB_MEMORY_I386_PC_UPPER)
+         grub_util_error (_("core image is too big (%p > %p)"),
+                          GRUB_KERNEL_I386_PC_LINK_ADDR + core_size,
+                          GRUB_MEMORY_I386_PC_UPPER);
+       num = ((core_size + GRUB_DISK_SECTOR_SIZE - 1) >> GRUB_DISK_SECTOR_BITS);
+       if (num > 0xffff)
+         grub_util_error (_("the core image is too big"));
+       boot_path = grub_util_get_path (dir, "diskboot.img");
+       boot_size = grub_util_get_image_size (boot_path);
+       if (boot_size != GRUB_DISK_SECTOR_SIZE)
+         grub_util_error (_("diskboot.img size must be %u bytes"),
+                          GRUB_DISK_SECTOR_SIZE);
+       boot_img = grub_util_read_image (boot_path);
+       {
+         struct grub_pc_bios_boot_blocklist *block;
+         block = (struct grub_pc_bios_boot_blocklist *) (boot_img
+                                                         + GRUB_DISK_SECTOR_SIZE
+                                                         - sizeof (*block));
+         block->len = grub_host_to_target16 (num);
+         /* This is filled elsewhere.  Verify it just in case.  */
+         assert (block->segment
+                 == grub_host_to_target16 (GRUB_BOOT_I386_PC_KERNEL_SEG
+                                           + (GRUB_DISK_SECTOR_SIZE >> 4)));
+       }
+       grub_util_write_image (boot_img, boot_size, out);
+       free (boot_img);
+       free (boot_path);
+       }
+       break;
+     case IMAGE_EFI:
+       {
+       void *pe_img;
+       grub_uint8_t *header;
+       void *sections;
+       size_t pe_size;
+       struct grub_pe32_coff_header *c;
+       struct grub_pe32_section_table *text_section, *data_section;
+       struct grub_pe32_section_table *mods_section, *reloc_section;
+       static const grub_uint8_t stub[] = GRUB_PE32_MSDOS_STUB;
+       int header_size;
+       int reloc_addr;
+       if (image_target->voidp_sizeof == 4)
+         header_size = ALIGN_UP (GRUB_PE32_MSDOS_STUB_SIZE
+                                 + GRUB_PE32_SIGNATURE_SIZE
+                                 + sizeof (struct grub_pe32_coff_header)
+                                 + sizeof (struct grub_pe32_optional_header)
+                                 + 4 * sizeof (struct grub_pe32_section_table),
+                                 GRUB_PE32_SECTION_ALIGNMENT);
+       else
+         header_size = ALIGN_UP (GRUB_PE32_MSDOS_STUB_SIZE
+                                 + GRUB_PE32_SIGNATURE_SIZE
+                                 + sizeof (struct grub_pe32_coff_header)
+                                 + sizeof (struct grub_pe64_optional_header)
+                                 + 4 * sizeof (struct grub_pe32_section_table),
+                                 GRUB_PE32_SECTION_ALIGNMENT);
+       reloc_addr = ALIGN_UP (header_size + core_size,
+                              image_target->section_align);
+       pe_size = ALIGN_UP (reloc_addr + reloc_size,
+                           image_target->section_align);
+       pe_img = xmalloc (reloc_addr + reloc_size);
+       memset (pe_img, 0, header_size);
+       memcpy (pe_img + header_size, core_img, core_size);
+       memcpy (pe_img + reloc_addr, rel_section, reloc_size);
+       header = pe_img;
+       /* The magic.  */
+       memcpy (header, stub, GRUB_PE32_MSDOS_STUB_SIZE);
+       memcpy (header + GRUB_PE32_MSDOS_STUB_SIZE, "PE\0\0",
+               GRUB_PE32_SIGNATURE_SIZE);
+       /* The COFF file header.  */
+       c = (struct grub_pe32_coff_header *) (header + GRUB_PE32_MSDOS_STUB_SIZE
+                                             + GRUB_PE32_SIGNATURE_SIZE);
+       if (image_target->voidp_sizeof == 4)
+         c->machine = grub_host_to_target16 (GRUB_PE32_MACHINE_I386);
+       else
+         c->machine = grub_host_to_target16 (GRUB_PE32_MACHINE_X86_64);
+       c->num_sections = grub_host_to_target16 (4);
+       c->time = grub_host_to_target32 (time (0));
+       c->characteristics = grub_host_to_target16 (GRUB_PE32_EXECUTABLE_IMAGE
+                                                   | GRUB_PE32_LINE_NUMS_STRIPPED
+                                                   | ((image_target->voidp_sizeof == 4)
+                                                      ? GRUB_PE32_32BIT_MACHINE
+                                                      : 0)
+                                                   | GRUB_PE32_LOCAL_SYMS_STRIPPED
+                                                   | GRUB_PE32_DEBUG_STRIPPED);
+       /* The PE Optional header.  */
+       if (image_target->voidp_sizeof == 4)
+         {
+           struct grub_pe32_optional_header *o;
+           c->optional_header_size = grub_host_to_target16 (sizeof (struct grub_pe32_optional_header));
+           o = (struct grub_pe32_optional_header *)
+             (header + GRUB_PE32_MSDOS_STUB_SIZE + GRUB_PE32_SIGNATURE_SIZE
+              + sizeof (struct grub_pe32_coff_header));
+           o->magic = grub_host_to_target16 (GRUB_PE32_PE32_MAGIC);
+           o->code_size = grub_host_to_target32 (exec_size);
+           o->data_size = grub_cpu_to_le32 (reloc_addr - exec_size
+                                            - header_size);
+           o->bss_size = grub_cpu_to_le32 (bss_size);
+           o->entry_addr = grub_cpu_to_le32 (start_address);
+           o->code_base = grub_cpu_to_le32 (header_size);
+           o->data_base = grub_host_to_target32 (header_size + exec_size);
+           o->image_base = 0;
+           o->section_alignment = grub_host_to_target32 (image_target->section_align);
+           o->file_alignment = grub_host_to_target32 (image_target->section_align);
+           o->image_size = grub_host_to_target32 (pe_size);
+           o->header_size = grub_host_to_target32 (header_size);
+           o->subsystem = grub_host_to_target16 (GRUB_PE32_SUBSYSTEM_EFI_APPLICATION);
+           /* Do these really matter? */
+           o->stack_reserve_size = grub_host_to_target32 (0x10000);
+           o->stack_commit_size = grub_host_to_target32 (0x10000);
+           o->heap_reserve_size = grub_host_to_target32 (0x10000);
+           o->heap_commit_size = grub_host_to_target32 (0x10000);
+     
+           o->num_data_directories = grub_host_to_target32 (GRUB_PE32_NUM_DATA_DIRECTORIES);
+           o->base_relocation_table.rva = grub_host_to_target32 (reloc_addr);
+           o->base_relocation_table.size = grub_host_to_target32 (reloc_size);
+           sections = o + 1;
+         }
+       else
+         {
+           struct grub_pe64_optional_header *o;
+           c->optional_header_size = grub_host_to_target16 (sizeof (struct grub_pe64_optional_header));
+           o = (struct grub_pe64_optional_header *) 
+             (header + GRUB_PE32_MSDOS_STUB_SIZE + GRUB_PE32_SIGNATURE_SIZE
+              + sizeof (struct grub_pe32_coff_header));
+           o->magic = grub_host_to_target16 (GRUB_PE32_PE64_MAGIC);
+           o->code_size = grub_host_to_target32 (exec_size);
+           o->data_size = grub_cpu_to_le32 (reloc_addr - exec_size
+                                            - header_size);
+           o->bss_size = grub_cpu_to_le32 (bss_size);
+           o->entry_addr = grub_cpu_to_le32 (start_address);
+           o->code_base = grub_cpu_to_le32 (header_size);
+           o->image_base = 0;
+           o->section_alignment = grub_host_to_target32 (image_target->section_align);
+           o->file_alignment = grub_host_to_target32 (image_target->section_align);
+           o->image_size = grub_host_to_target32 (pe_size);
+           o->header_size = grub_host_to_target32 (header_size);
+           o->subsystem = grub_host_to_target16 (GRUB_PE32_SUBSYSTEM_EFI_APPLICATION);
+           /* Do these really matter? */
+           o->stack_reserve_size = grub_host_to_target32 (0x10000);
+           o->stack_commit_size = grub_host_to_target32 (0x10000);
+           o->heap_reserve_size = grub_host_to_target32 (0x10000);
+           o->heap_commit_size = grub_host_to_target32 (0x10000);
+     
+           o->num_data_directories
+             = grub_host_to_target32 (GRUB_PE32_NUM_DATA_DIRECTORIES);
+           o->base_relocation_table.rva = grub_host_to_target32 (reloc_addr);
+           o->base_relocation_table.size = grub_host_to_target32 (reloc_size);
+           sections = o + 1;
+         }
+       /* The sections.  */
+       text_section = sections;
+       strcpy (text_section->name, ".text");
+       text_section->virtual_size = grub_cpu_to_le32 (exec_size);
+       text_section->virtual_address = grub_cpu_to_le32 (header_size);
+       text_section->raw_data_size = grub_cpu_to_le32 (exec_size);
+       text_section->raw_data_offset = grub_cpu_to_le32 (header_size);
+       text_section->characteristics = grub_cpu_to_le32 (GRUB_PE32_SCN_CNT_CODE
+                                                         | GRUB_PE32_SCN_MEM_EXECUTE
+                                                         | GRUB_PE32_SCN_MEM_READ);
+       data_section = text_section + 1;
+       strcpy (data_section->name, ".data");
+       data_section->virtual_size = grub_cpu_to_le32 (kernel_size - exec_size);
+       data_section->virtual_address = grub_cpu_to_le32 (header_size + exec_size);
+       data_section->raw_data_size = grub_cpu_to_le32 (kernel_size - exec_size);
+       data_section->raw_data_offset = grub_cpu_to_le32 (header_size + exec_size);
+       data_section->characteristics
+         = grub_cpu_to_le32 (GRUB_PE32_SCN_CNT_INITIALIZED_DATA
+                             | GRUB_PE32_SCN_MEM_READ
+                             | GRUB_PE32_SCN_MEM_WRITE);
+ #if 0
+       bss_section = data_section + 1;
+       strcpy (bss_section->name, ".bss");
+       bss_section->virtual_size = grub_cpu_to_le32 (bss_size);
+       bss_section->virtual_address = grub_cpu_to_le32 (header_size + kernel_size);
+       bss_section->raw_data_size = 0;
+       bss_section->raw_data_offset = 0;
+       bss_section->characteristics
+         = grub_cpu_to_le32 (GRUB_PE32_SCN_MEM_READ
+                             | GRUB_PE32_SCN_MEM_WRITE
+                             | GRUB_PE32_SCN_ALIGN_64BYTES
+                             | GRUB_PE32_SCN_CNT_INITIALIZED_DATA
+                             | 0x80);
+ #endif
+     
+       mods_section = data_section + 1;
+       strcpy (mods_section->name, "mods");
+       mods_section->virtual_size = grub_cpu_to_le32 (reloc_addr - kernel_size - header_size);
+       mods_section->virtual_address = grub_cpu_to_le32 (header_size + kernel_size + bss_size);
+       mods_section->raw_data_size = grub_cpu_to_le32 (reloc_addr - kernel_size - header_size);
+       mods_section->raw_data_offset = grub_cpu_to_le32 (header_size + kernel_size);
+       mods_section->characteristics
+         = grub_cpu_to_le32 (GRUB_PE32_SCN_CNT_INITIALIZED_DATA
+                             | GRUB_PE32_SCN_MEM_READ
+                             | GRUB_PE32_SCN_MEM_WRITE);
+       reloc_section = mods_section + 1;
+       strcpy (reloc_section->name, ".reloc");
+       reloc_section->virtual_size = grub_cpu_to_le32 (reloc_size);
+       reloc_section->virtual_address = grub_cpu_to_le32 (reloc_addr + bss_size);
+       reloc_section->raw_data_size = grub_cpu_to_le32 (reloc_size);
+       reloc_section->raw_data_offset = grub_cpu_to_le32 (reloc_addr);
+       reloc_section->characteristics
+         = grub_cpu_to_le32 (GRUB_PE32_SCN_CNT_INITIALIZED_DATA
+                             | GRUB_PE32_SCN_MEM_DISCARDABLE
+                             | GRUB_PE32_SCN_MEM_READ);
+       free (core_img);
+       core_img = pe_img;
+       core_size = pe_size;
+       }
+       break;
+     case IMAGE_QEMU:
+       {
+       char *rom_img;
+       size_t rom_size;
+       char *boot_path, *boot_img;
+       size_t boot_size;
+       boot_path = grub_util_get_path (dir, "boot.img");
+       boot_size = grub_util_get_image_size (boot_path);
+       boot_img = grub_util_read_image (boot_path);
+       /* Rom sizes must be 64k-aligned.  */
+       rom_size = ALIGN_UP (core_size + boot_size, 64 * 1024);
+       rom_img = xmalloc (rom_size);
+       memset (rom_img, 0, rom_size);
+       *((grub_int32_t *) (core_img + GRUB_KERNEL_I386_QEMU_CORE_ENTRY_ADDR))
+         = grub_host_to_target32 ((grub_uint32_t) -rom_size);
+       memcpy (rom_img, core_img, core_size);
+       *((grub_int32_t *) (boot_img + GRUB_BOOT_I386_QEMU_CORE_ENTRY_ADDR))
+         = grub_host_to_target32 ((grub_uint32_t) -rom_size);
+       memcpy (rom_img + rom_size - boot_size, boot_img, boot_size);
+       free (core_img);
+       core_img = rom_img;
+       core_size = rom_size;
+       free (boot_img);
+       free (boot_path);
+       }
+       break;
+     case IMAGE_SPARC64_AOUT:
+       {
+       void *aout_img;
+       size_t aout_size;
+       struct grub_aout32_header *aout_head;
+       aout_size = core_size + sizeof (*aout_head);
+       aout_img = xmalloc (aout_size);
+       aout_head = aout_img;
+       aout_head->a_midmag = grub_host_to_target32 ((AOUT_MID_SUN << 16)
+                                                    | AOUT32_OMAGIC);
+       aout_head->a_text = grub_host_to_target32 (core_size);
+       aout_head->a_entry
+         = grub_host_to_target32 (GRUB_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS);
+       memcpy (aout_img + sizeof (*aout_head), core_img, core_size);
+       free (core_img);
+       core_img = aout_img;
+       core_size = aout_size;
+       }
+       break;
+     case IMAGE_SPARC64_RAW:
+       {
+       unsigned int num;
+       char *boot_path, *boot_img;
+       size_t boot_size;
+       num = ((core_size + GRUB_DISK_SECTOR_SIZE - 1) >> GRUB_DISK_SECTOR_BITS);
+       num <<= GRUB_DISK_SECTOR_BITS;
+       boot_path = grub_util_get_path (dir, "diskboot.img");
+       boot_size = grub_util_get_image_size (boot_path);
+       if (boot_size != GRUB_DISK_SECTOR_SIZE)
+         grub_util_error ("diskboot.img is not one sector size");
+       boot_img = grub_util_read_image (boot_path);
+       *((grub_uint32_t *) (boot_img + GRUB_DISK_SECTOR_SIZE
+                            - GRUB_BOOT_SPARC64_IEEE1275_LIST_SIZE + 8))
+         = grub_host_to_target32 (num);
+       grub_util_write_image (boot_img, boot_size, out);
+       free (boot_img);
+       free (boot_path);
+       }
+       break;
+     case IMAGE_YEELOONG_ELF:
+     case IMAGE_PPC:
+     case IMAGE_COREBOOT:
+     case IMAGE_I386_IEEE1275:
+       {
+       char *elf_img;
+       size_t program_size;
+       Elf32_Ehdr *ehdr;
+       Elf32_Phdr *phdr;
+       grub_uint32_t target_addr;
+       int header_size, footer_size = 0;
+       int phnum = 1;
+       
+       if (image_target->id != IMAGE_YEELOONG_ELF)
+         phnum += 2;
+       if (note)
+         {
+           phnum++;
+           footer_size += sizeof (struct grub_ieee1275_note);
+         }
+       header_size = ALIGN_ADDR (sizeof (*ehdr) + phnum * sizeof (*phdr));
+       program_size = ALIGN_ADDR (core_size);
+       elf_img = xmalloc (program_size + header_size + footer_size);
+       memset (elf_img, 0, program_size + header_size);
+       memcpy (elf_img  + header_size, core_img, core_size);
+       ehdr = (void *) elf_img;
+       phdr = (void *) (elf_img + sizeof (*ehdr));
+       memcpy (ehdr->e_ident, ELFMAG, SELFMAG);
+       ehdr->e_ident[EI_CLASS] = ELFCLASS32;
+       if (!image_target->bigendian)
+         ehdr->e_ident[EI_DATA] = ELFDATA2LSB;
+       else
+         ehdr->e_ident[EI_DATA] = ELFDATA2MSB;
+       ehdr->e_ident[EI_VERSION] = EV_CURRENT;
+       ehdr->e_ident[EI_OSABI] = ELFOSABI_NONE;
+       ehdr->e_type = grub_host_to_target16 (ET_EXEC);
+       ehdr->e_machine = grub_host_to_target16 (image_target->elf_target);
+       ehdr->e_version = grub_host_to_target32 (EV_CURRENT);
+       ehdr->e_phoff = grub_host_to_target32 ((char *) phdr - (char *) ehdr);
+       ehdr->e_phentsize = grub_host_to_target16 (sizeof (*phdr));
+       ehdr->e_phnum = grub_host_to_target16 (phnum);
+       /* No section headers.  */
+       ehdr->e_shoff = grub_host_to_target32 (0);
+       if (image_target->id == IMAGE_YEELOONG_ELF)
+         ehdr->e_shentsize = grub_host_to_target16 (0);
+       else
+         ehdr->e_shentsize = grub_host_to_target16 (sizeof (Elf32_Shdr));
+       ehdr->e_shnum = grub_host_to_target16 (0);
+       ehdr->e_shstrndx = grub_host_to_target16 (0);
+       ehdr->e_ehsize = grub_host_to_target16 (sizeof (*ehdr));
+       phdr->p_type = grub_host_to_target32 (PT_LOAD);
+       phdr->p_offset = grub_host_to_target32 (header_size);
+       phdr->p_flags = grub_host_to_target32 (PF_R | PF_W | PF_X);
+       if (image_target->id == IMAGE_YEELOONG_ELF)
+         target_addr = ALIGN_UP (image_target->link_addr
+                                 + kernel_size + total_module_size, 32);
+       else
+         target_addr = image_target->link_addr;
+       ehdr->e_entry = grub_host_to_target32 (target_addr);
+       phdr->p_vaddr = grub_host_to_target32 (target_addr);
+       phdr->p_paddr = grub_host_to_target32 (target_addr);
+       phdr->p_align = grub_host_to_target32 (align > image_target->link_align ? align : image_target->link_align);
+       if (image_target->id == IMAGE_YEELOONG_ELF)
+         ehdr->e_flags = grub_host_to_target32 (0x1000 | EF_MIPS_NOREORDER 
+                                                | EF_MIPS_PIC | EF_MIPS_CPIC);
+       else
+         ehdr->e_flags = 0;
+       if (image_target->id == IMAGE_YEELOONG_ELF)
+         {
+           phdr->p_filesz = grub_host_to_target32 (core_size);
+           phdr->p_memsz = grub_host_to_target32 (core_size);
+         }
+       else
+         {
+           grub_uint32_t target_addr_mods;
+           phdr->p_filesz = grub_host_to_target32 (kernel_size);
+           phdr->p_memsz = grub_host_to_target32 (kernel_size + bss_size);
+           phdr++;
+           phdr->p_type = grub_host_to_target32 (PT_GNU_STACK);
+           phdr->p_offset = grub_host_to_target32 (header_size + kernel_size);
+           phdr->p_paddr = phdr->p_vaddr = phdr->p_filesz = phdr->p_memsz = 0;
+           phdr->p_flags = grub_host_to_target32 (PF_R | PF_W | PF_X);
+           phdr->p_align = grub_host_to_target32 (image_target->link_align);
+           phdr++;
+           phdr->p_type = grub_host_to_target32 (PT_LOAD);
+           phdr->p_offset = grub_host_to_target32 (header_size + kernel_size);
+           phdr->p_flags = grub_host_to_target32 (PF_R | PF_W | PF_X);
+           phdr->p_filesz = phdr->p_memsz
+             = grub_host_to_target32 (core_size - kernel_size);
+           target_addr_mods = ALIGN_UP (target_addr + kernel_size + bss_size
+                                        + image_target->mod_gap,
+                                        image_target->mod_align);
+           phdr->p_vaddr = grub_host_to_target32 (target_addr_mods);
+           phdr->p_paddr = grub_host_to_target32 (target_addr_mods);
+           phdr->p_align = grub_host_to_target32 (image_target->link_align);
+         }
+       if (note)
+         {
+           int note_size = sizeof (struct grub_ieee1275_note);
+           struct grub_ieee1275_note *note = (struct grub_ieee1275_note *) 
+             (elf_img + program_size + header_size);
+           grub_util_info ("adding CHRP NOTE segment");
+           note->header.namesz = grub_host_to_target32 (sizeof (GRUB_IEEE1275_NOTE_NAME));
+           note->header.descsz = grub_host_to_target32 (note_size);
+           note->header.type = grub_host_to_target32 (GRUB_IEEE1275_NOTE_TYPE);
+           strcpy (note->header.name, GRUB_IEEE1275_NOTE_NAME);
+           note->descriptor.real_mode = grub_host_to_target32 (0xffffffff);
+           note->descriptor.real_base = grub_host_to_target32 (0x00c00000);
+           note->descriptor.real_size = grub_host_to_target32 (0xffffffff);
+           note->descriptor.virt_base = grub_host_to_target32 (0xffffffff);
+           note->descriptor.virt_size = grub_host_to_target32 (0xffffffff);
+           note->descriptor.load_base = grub_host_to_target32 (0x00004000);
+           phdr++;
+           phdr->p_type = grub_host_to_target32 (PT_NOTE);
+           phdr->p_flags = grub_host_to_target32 (PF_R);
+           phdr->p_align = grub_host_to_target32 (image_target->voidp_sizeof);
+           phdr->p_vaddr = 0;
+           phdr->p_paddr = 0;
+           phdr->p_filesz = grub_host_to_target32 (note_size);
+           phdr->p_memsz = 0;
+           phdr->p_offset = grub_host_to_target32 (header_size + program_size);
+         }
+       free (core_img);
+       core_img = elf_img;
+       core_size = program_size + header_size + footer_size;
+       }
+       break;
+     }
+   grub_util_write_image (core_img, core_size, out);
+   free (kernel_img);
+   free (core_img);
+   free (kernel_path);
+   while (path_list)
+     {
+       next = path_list->next;
+       free ((void *) path_list->name);
+       free (path_list);
+       path_list = next;
+     }
+ }
\f
+ static struct option options[] =
+   {
+     {"directory", required_argument, 0, 'd'},
+     {"prefix", required_argument, 0, 'p'},
+     {"memdisk", required_argument, 0, 'm'},
+     {"font", required_argument, 0, 'f'},
+     {"config", required_argument, 0, 'c'},
+     {"output", required_argument, 0, 'o'},
+     {"note", no_argument, 0, 'n'},
+     {"format", required_argument, 0, 'O'},
+     {"help", no_argument, 0, 'h'},
+     {"version", no_argument, 0, 'V'},
+     {"verbose", no_argument, 0, 'v'},
+     {0, 0, 0, 0}
+   };
+ static void
+ usage (int status)
+ {
+   if (status)
+     fprintf (stderr, _("Try `%s --help' for more information.\n"), program_name);
+   else
+     {
+       int format_len = 0;
+       char *formats;
+       char *ptr;
+       unsigned i;
+       for (i = 0; i < ARRAY_SIZE (image_targets); i++)
+       format_len += strlen (image_targets[i].name) + 2;
+       ptr = formats = xmalloc (format_len);
+       for (i = 0; i < ARRAY_SIZE (image_targets); i++)
+       {
+         strcpy (ptr, image_targets[i].name);
+         ptr += strlen (image_targets[i].name);
+         *ptr++ = ',';
+         *ptr++ = ' ';
+       }
+       ptr[-2] = 0;
+       printf (_("\
+ Usage: %s [OPTION]... [MODULES]\n\
+ \n\
+ Make a bootable image of GRUB.\n\
+ \n\
+   -d, --directory=DIR     use images and modules under DIR [default=%s/@platform@]\n\
+   -p, --prefix=DIR        set grub_prefix directory [default=%s]\n\
+   -m, --memdisk=FILE      embed FILE as a memdisk image\n\
+   -f, --font=FILE         embed FILE as a boot font\n\
+   -c, --config=FILE       embed FILE as boot config\n\
+   -n, --note              add NOTE segment for CHRP Open Firmware\n\
+   -o, --output=FILE       output a generated image to FILE [default=stdout]\n\
+   -O, --format=FORMAT     generate an image in format\n\
+                           available formats: %s\n\
+   -h, --help              display this message and exit\n\
+   -V, --version           print version information and exit\n\
+   -v, --verbose           print verbose messages\n\
+ \n\
+ Report bugs to <%s>.\n\
+ "), 
+             program_name, GRUB_PKGLIBROOTDIR, DEFAULT_DIRECTORY,
+             formats,
+             PACKAGE_BUGREPORT);
+       free (formats);
+     }
+   exit (status);
+ }
+ int
+ main (int argc, char *argv[])
+ {
+   char *output = NULL;
+   char *dir = NULL;
+   char *prefix = NULL;
+   char *memdisk = NULL;
+   char *font = NULL;
+   char *config = NULL;
+   FILE *fp = stdout;
+   int note = 0;
+   struct image_target_desc *image_target = NULL;
+   set_program_name (argv[0]);
+   grub_util_init_nls ();
+   while (1)
+     {
+       int c = getopt_long (argc, argv, "d:p:m:c:o:O:f:hVvn", options, 0);
+       if (c == -1)
+       break;
+       else
+       switch (c)
+         {
+         case 'o':
+           if (output)
+             free (output);
+           output = xstrdup (optarg);
+           break;
+         case 'O':
+           {
+             unsigned i;
+             for (i = 0; i < ARRAY_SIZE (image_targets); i++)
+               if (strcmp (optarg, image_targets[i].name) == 0)
+                 image_target = &image_targets[i];
+             if (!image_target)
+               {
+                 printf ("unknown target %s\n", optarg);
+                 usage (1);
+               }
+             break;
+           }
+         case 'd':
+           if (dir)
+             free (dir);
+           dir = xstrdup (optarg);
+           break;
+         case 'n':
+           note = 1;
+           break;
+         case 'm':
+           if (memdisk)
+             free (memdisk);
+           memdisk = xstrdup (optarg);
+           if (prefix)
+             free (prefix);
+           prefix = xstrdup ("(memdisk)/boot/grub");
+           break;
+         case 'f':
+           if (font)
+             free (font);
+           font = xstrdup (optarg);
+           break;
+         case 'c':
+           if (config)
+             free (config);
+           config = xstrdup (optarg);
+           break;
+         case 'h':
+           usage (0);
+           break;
+         case 'p':
+           if (prefix)
+             free (prefix);
+           prefix = xstrdup (optarg);
+           break;
+         case 'V':
+           printf ("grub-mkimage (%s) %s\n", PACKAGE_NAME, PACKAGE_VERSION);
+           return 0;
+         case 'v':
+           verbosity++;
+           break;
+         default:
+           usage (1);
+           break;
+         }
+     }
+   if (!image_target)
+     {
+       printf ("Target not specified.\n");
+       usage (1);
+     }
+   if (output)
+     {
+       fp = fopen (output, "wb");
+       if (! fp)
+       grub_util_error (_("cannot open %s"), output);
+       free (output);
+     }
+   if (!dir)
+     {
+       const char *last;
+       last = strchr (image_target->name, '-');
+       if (last)
+       last = strchr (last + 1, '-');
+       if (!last)
+       last = image_target->name + strlen (image_target->name);
+       dir = xmalloc (sizeof (GRUB_PKGLIBROOTDIR) + (last - image_target->name)
+                    + 1);
+       memcpy (dir, GRUB_PKGLIBROOTDIR, sizeof (GRUB_PKGLIBROOTDIR) - 1);
+       *(dir + sizeof (GRUB_PKGLIBROOTDIR) - 1) = '/';
+       memcpy (dir + sizeof (GRUB_PKGLIBROOTDIR), image_target->name,
+             last - image_target->name);
+       *(dir + sizeof (GRUB_PKGLIBROOTDIR) + (last - image_target->name)) = 0;
+     }
+   generate_image (dir, prefix ? : DEFAULT_DIRECTORY, fp,
+                 argv + optind, memdisk, font, config,
+                 image_target, note);
+   fclose (fp);
+   if (dir)
+     free (dir);
+   return 0;
+ }
index 2fdb58114843865950462aa290bbc4f37fe756b0,7e7253006e656c42166cb0353e68d59ddd832bb5..efe6d7917062f2077362faee35376b4e106fb26f
@@@ -28,13 -28,16 +28,16 @@@ PACKAGE_TARNAME=@PACKAGE_TARNAME
  PACKAGE_VERSION=@PACKAGE_VERSION@
  target_cpu=@target_cpu@
  native_platform=@platform@
 -pkglib_DATA="@pkglib_DATA@"
 +pkglib_DATA="moddep.lst command.lst fs.lst partmap.lst parttool.lst handler.lst video.lst crypto.lst terminal.lst"
  
- mkimage=${bindir}/grub-mkimage
- mkisofs=${bindir}/grub-mkisofs
- mkelfimage=${bindir}/grub-mkelfimage
- multiboot_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/${target_cpu}-multiboot
- pc_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/${target_cpu}-pc
+ multiboot_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-multiboot
+ coreboot_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-coreboot
+ qemu_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-qemu
+ pc_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-pc
+ efi32_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-efi
+ efi64_dir=${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/x86_64-efi
+ rom_directory=
+ grub_mkimage=${bindir}/`echo grub-mkimage | sed ${transform}`
  
  # Usage: usage
  # Print the usage.
index 66d45620c88c4eb94cd2e743587af8902ab19d61,6e6b2e878feb32ee1dcff12711583e0b2a364e0b..fb01dbc566afffbc476e165db7ce9e40985e73d2
@@@ -56,6 -57,34 +56,13 @@@ static const grub_gpt_part_type_t grub_
  #define DEFAULT_BOOT_FILE     "boot.img"
  #define DEFAULT_CORE_FILE     "core.img"
  
 -void
 -grub_putchar (int c)
 -{
 -  putchar (c);
 -}
 -
 -int
 -grub_getkey (void)
 -{
 -  return -1;
 -}
 -
 -struct grub_handler_class grub_term_input_class;
 -struct grub_handler_class grub_term_output_class;
 -
 -void
 -grub_refresh (void)
 -{
 -  fflush (stdout);
 -}
 -
+ #define grub_target_to_host16(x)      grub_le_to_cpu16(x)
+ #define grub_target_to_host32(x)      grub_le_to_cpu32(x)
+ #define grub_target_to_host64(x)      grub_le_to_cpu64(x)
+ #define grub_host_to_target16(x)      grub_cpu_to_le16(x)
+ #define grub_host_to_target32(x)      grub_cpu_to_le32(x)
+ #define grub_host_to_target64(x)      grub_cpu_to_le64(x)
  static void
  setup (const char *dir,
         const char *boot_file, const char *core_file,
diff --cc util/misc.c
Simple merge
Simple merge