2006-05-29 Yoshinori K. Okuji <okuji@enbug.org>

* util/powerpc/ieee1275/grub-install.in (host_cpu): Removed.
        (target_cpu): New variable.
        (pkglibdir): Use target_cpu instead of host_cpu.

        * util/i386/pc/grub-install.in (host_cpu): Removed.
        (target_cpu): New variable.
        (pkglibdir): Use target_cpu instead of host_cpu.

        * util/genmoddep.c: Removed.

        * kern/efi/mm.c (filter_memory_map): Use GRUB_CPU_SIZEOF_VOID_P
        instead of GRUB_HOST_SIZEOF_VOID_P.
        * kern/dl.c: Likewise.

        * include/grub/i386/types.h (GRUB_HOST_SIZEOF_VOID_P): Renamed to
        ...
        (GRUB_TARGET_SIZEOF_VOID_P): ... this.
        (GRUB_HOST_SIZEOF_LONG): Renamed to ...
        (GRUB_TARGET_SIZEOF_LONG): ... this.
        (GRUB_HOST_WORDS_BIGENDIAN): Renamed to ...
        (GRUB_TARGET_WORDS_BIGENDIAN): ... this.
        * include/grub/powerpc/types.h (GRUB_HOST_SIZEOF_VOID_P): Renamed
        to ...
        (GRUB_TARGET_SIZEOF_VOID_P): ... this.
        (GRUB_HOST_SIZEOF_LONG): Renamed to ...
        (GRUB_TARGET_SIZEOF_LONG): ... this.
        (GRUB_HOST_WORDS_BIGENDIAN): Renamed to ...
        (GRUB_TARGET_WORDS_BIGENDIAN): ... this.
        * include/grub/sparc64/types.h (GRUB_HOST_SIZEOF_VOID_P): Renamed
        to ...
        (GRUB_TARGET_SIZEOF_VOID_P): ... this.
        (GRUB_HOST_SIZEOF_LONG): Renamed to ...
        (GRUB_TARGET_SIZEOF_LONG): ... this.
        (GRUB_HOST_WORDS_BIGENDIAN): Renamed to ...
        (GRUB_TARGET_WORDS_BIGENDIAN): ... this.

        * include/grub/types.h [!GRUB_UTIL] (GRUB_CPU_SIZEOF_VOID_P): Use
        GRUB_TARGET_SIZEOF_VOID_P instead of GRUB_HOST_SIZEOF_VOID_P.
        [!GRUB_UTIL] (GRUB_CPU_SIZEOF_LONG): Use GRUB_TARGET_SIZEOF_LONG
        instead of GRUB_HOST_SIZEOF_LONG.
        [!GRUB_UTIL]: Refer to GRUB_TARGET_WORDS_BIGENDIAN instead of
        GRUB_HOST_WORDS_BIGENDIAN to define or undefine
        GRUB_CPU_WORDS_BIGENDIAN.
        Refer to SIZEOF_VOID_P instead of GRUB_HOST_SIZEOF_VOID_P to
        define grub_host_addr_t, grub_host_off_t, grub_host_size_t and
        grub_host_ssize_t.

        * conf/i386-efi.rmk (noinst_UTILITIES): Removed.
        (genmoddep_SOURCES): Likewise.
        * conf/i386-pc.rmk (noinst_UTILITIES): Likewise.
        (genmoddep_SOURCES): Likewise.
        * conf/conf/powerpc-ieee1275.rmk (noinst_UTILITIES): Likewise.
        (genmoddep_SOURCES): Likewise.
        * conf/conf/conf/sparc64-ieee1275.rmk (noinst_UTILITIES):
        Likewise.
        (genmoddep_SOURCES): Likewise.

        * genmoddep.awk: New file.

        * genmk.rb (Image::rule): Use TARGET_CC, TARGET_CPPFLAGS,
        TARGET_CFLAGS, TARGET_ASFLAGS and TARGET_LDFLAGS instead of CC,
        CPPFLAGS, CFLAGS, ASFLAGS and LDFLAGS, respectively.
        (PModule::rule): Likewise.
        (Program::rule): Likewise.
        (Utility::rule): Use CC, CPPFLAGS, CFLAGS and LDFLAGS instead of
        BUILD_CC, BUILD_CPPFLAGS, BUILD_CFLAGS and BUILD_LDFLAGS,
        respectively.

        * configure.ac: Rewritten intensively to use host and target
        instead of build and host, respectively.

        * Makefile.in (pkglibdir): Use target_cpu instead of host_cpu.
        (host_cpu): Removed.
        (target_cpu): New variable.
        (CPPFLAGS): Added @CPPFLAGS@ and -DGRUB_LIBDIR=\"$(pkglibdir)\".
        (BUILD_CC): Removed.
        (BUILD_CFLAGS): Likewise.
        (BUILD_CPPFLAGS): Likewise.
        (TARGET_CC): New variable.
        (TARGET_CFLAGS): Likewise.
        (TARGET_CPPFLAGS): Likewise.
        (TARGET_LDFLAGS): Likewise.
        (AWK): Likewise.
        (include): Use target_cpu instead of host_cpu.
        (moddep.lst:): Use genmoddep.awk instead of genmoddep.

        * DISTLIST: Added genmoddep.awk. Removed util/genmoddep.c.
This commit is contained in:
okuji 2006-05-28 23:01:43 +00:00
parent f09771a102
commit b977bf01b3
25 changed files with 3718 additions and 3578 deletions

View file

@ -1,3 +1,93 @@
2006-05-29 Yoshinori K. Okuji <okuji@enbug.org>
* util/powerpc/ieee1275/grub-install.in (host_cpu): Removed.
(target_cpu): New variable.
(pkglibdir): Use target_cpu instead of host_cpu.
* util/i386/pc/grub-install.in (host_cpu): Removed.
(target_cpu): New variable.
(pkglibdir): Use target_cpu instead of host_cpu.
* util/genmoddep.c: Removed.
* kern/efi/mm.c (filter_memory_map): Use GRUB_CPU_SIZEOF_VOID_P
instead of GRUB_HOST_SIZEOF_VOID_P.
* kern/dl.c: Likewise.
* include/grub/i386/types.h (GRUB_HOST_SIZEOF_VOID_P): Renamed to
...
(GRUB_TARGET_SIZEOF_VOID_P): ... this.
(GRUB_HOST_SIZEOF_LONG): Renamed to ...
(GRUB_TARGET_SIZEOF_LONG): ... this.
(GRUB_HOST_WORDS_BIGENDIAN): Renamed to ...
(GRUB_TARGET_WORDS_BIGENDIAN): ... this.
* include/grub/powerpc/types.h (GRUB_HOST_SIZEOF_VOID_P): Renamed
to ...
(GRUB_TARGET_SIZEOF_VOID_P): ... this.
(GRUB_HOST_SIZEOF_LONG): Renamed to ...
(GRUB_TARGET_SIZEOF_LONG): ... this.
(GRUB_HOST_WORDS_BIGENDIAN): Renamed to ...
(GRUB_TARGET_WORDS_BIGENDIAN): ... this.
* include/grub/sparc64/types.h (GRUB_HOST_SIZEOF_VOID_P): Renamed
to ...
(GRUB_TARGET_SIZEOF_VOID_P): ... this.
(GRUB_HOST_SIZEOF_LONG): Renamed to ...
(GRUB_TARGET_SIZEOF_LONG): ... this.
(GRUB_HOST_WORDS_BIGENDIAN): Renamed to ...
(GRUB_TARGET_WORDS_BIGENDIAN): ... this.
* include/grub/types.h [!GRUB_UTIL] (GRUB_CPU_SIZEOF_VOID_P): Use
GRUB_TARGET_SIZEOF_VOID_P instead of GRUB_HOST_SIZEOF_VOID_P.
[!GRUB_UTIL] (GRUB_CPU_SIZEOF_LONG): Use GRUB_TARGET_SIZEOF_LONG
instead of GRUB_HOST_SIZEOF_LONG.
[!GRUB_UTIL]: Refer to GRUB_TARGET_WORDS_BIGENDIAN instead of
GRUB_HOST_WORDS_BIGENDIAN to define or undefine
GRUB_CPU_WORDS_BIGENDIAN.
Refer to SIZEOF_VOID_P instead of GRUB_HOST_SIZEOF_VOID_P to
define grub_host_addr_t, grub_host_off_t, grub_host_size_t and
grub_host_ssize_t.
* conf/i386-efi.rmk (noinst_UTILITIES): Removed.
(genmoddep_SOURCES): Likewise.
* conf/i386-pc.rmk (noinst_UTILITIES): Likewise.
(genmoddep_SOURCES): Likewise.
* conf/conf/powerpc-ieee1275.rmk (noinst_UTILITIES): Likewise.
(genmoddep_SOURCES): Likewise.
* conf/conf/conf/sparc64-ieee1275.rmk (noinst_UTILITIES):
Likewise.
(genmoddep_SOURCES): Likewise.
* genmoddep.awk: New file.
* genmk.rb (Image::rule): Use TARGET_CC, TARGET_CPPFLAGS,
TARGET_CFLAGS, TARGET_ASFLAGS and TARGET_LDFLAGS instead of CC,
CPPFLAGS, CFLAGS, ASFLAGS and LDFLAGS, respectively.
(PModule::rule): Likewise.
(Program::rule): Likewise.
(Utility::rule): Use CC, CPPFLAGS, CFLAGS and LDFLAGS instead of
BUILD_CC, BUILD_CPPFLAGS, BUILD_CFLAGS and BUILD_LDFLAGS,
respectively.
* configure.ac: Rewritten intensively to use host and target
instead of build and host, respectively.
* Makefile.in (pkglibdir): Use target_cpu instead of host_cpu.
(host_cpu): Removed.
(target_cpu): New variable.
(CPPFLAGS): Added @CPPFLAGS@ and -DGRUB_LIBDIR=\"$(pkglibdir)\".
(BUILD_CC): Removed.
(BUILD_CFLAGS): Likewise.
(BUILD_CPPFLAGS): Likewise.
(TARGET_CC): New variable.
(TARGET_CFLAGS): Likewise.
(TARGET_CPPFLAGS): Likewise.
(TARGET_LDFLAGS): Likewise.
(AWK): Likewise.
(include): Use target_cpu instead of host_cpu.
(moddep.lst:): Use genmoddep.awk instead of genmoddep.
* DISTLIST: Added genmoddep.awk. Removed util/genmoddep.c.
2006-05-29 Vesa Jaaskelainen <chaac@nic.fi>
* include/grub/script.h (grub_script_cmdif): Renamed field 'bool' to

View file

@ -22,6 +22,7 @@ geninitheader.sh
geninit.sh
genkernsyms.sh.in
genmk.rb
genmoddep.awk
genmodsrc.sh
gensymlist.sh.in
install-sh
@ -242,7 +243,6 @@ term/i386/pc/vesafb.c
term/i386/pc/vga.c
term/ieee1275/ofconsole.c
util/console.c
util/genmoddep.c
util/grub-emu.c
util/misc.c
util/resolve.c

View file

@ -1,6 +1,6 @@
# -*- makefile -*-
#
# Copyright (C) 1994,1995,1996,1997,1998,1999,2000,2001,2002,2004,2005 Free Software Foundation, Inc.
# Copyright (C) 1994,1995,1996,1997,1998,1999,2000,2001,2002,2004,2005,2006 Free Software Foundation, Inc.
#
# This Makefile.in is free software; the author
# gives unlimited permission to copy and/or distribute it,
@ -35,7 +35,7 @@ infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
pkgdatadir = $(datadir)/@PACKAGE_TARNAME@
pkglibdir = $(libdir)/@PACKAGE_TARNAME@/$(host_cpu)-$(platform)
pkglibdir = $(libdir)/@PACKAGE_TARNAME@/$(target_cpu)-$(platform)
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
@ -43,7 +43,7 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
host_cpu = @host_cpu@
target_cpu = @target_cpu@
platform = @platform@
INSTALL = @INSTALL@
@ -57,15 +57,18 @@ mkinstalldirs = $(srcdir)/mkinstalldirs
CC = @CC@
CFLAGS = @CFLAGS@
LDFLAGS = @LDFLAGS@
CPPFLAGS = -I. -Iinclude -I$(srcdir)/include -Wall -W
BUILD_CC = @BUILD_CC@
BUILD_CFLAGS = -g -O2
BUILD_CPPFLAGS = -I. -Iinclude -I$(srcdir)/include -Wall -W \
CPPFLAGS = @CPPFLAGS@ -I. -Iinclude -I$(srcdir)/include -Wall -W \
-DGRUB_LIBDIR=\"$(pkglibdir)\"
TARGET_CC = @TARGET_CC@
TARGET_CFLAGS = @TARGET_CFLAGS@
TARGET_CPPFLAGS = @TARGET_CPPFLAGS@ -I. -Iinclude -I$(srcdir)/include \
-Wall -W
TARGET_LDFLAGS = @TARGET_LDFLAGS@
OBJCOPY = @OBJCOPY@
STRIP = @STRIP@
NM = @NM@
RUBY = @RUBY@
AWK = @AWK@
LIBCURSES = @LIBCURSES@
LIBLZO = @LIBLZO@
YACC = @YACC@
@ -99,14 +102,15 @@ $(addprefix $(srcdir)/,$(MKFILES)): %.mk: %.rmk genmk.rb
$(RUBY) $(srcdir)/genmk.rb < $< > $@; \
fi
include $(srcdir)/conf/$(host_cpu)-$(platform).mk
include $(srcdir)/conf/$(target_cpu)-$(platform).mk
### General targets.
CLEANFILES += moddep.lst command.lst fs.lst
pkgdata_DATA += moddep.lst command.lst fs.lst
moddep.lst: $(DEFSYMFILES) $(UNDSYMFILES) genmoddep
cat $(DEFSYMFILES) /dev/null | ./genmoddep $(UNDSYMFILES) > $@ \
moddep.lst: $(DEFSYMFILES) $(UNDSYMFILES) genmoddep.awk
cat $(DEFSYMFILES) /dev/null \
| $(AWK) -f $(srcdir)/genmoddep.awk $(UNDSYMFILES) > $@ \
|| (rm -f $@; exit 1)
command.lst: $(COMMANDFILES)

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -7,7 +7,6 @@ COMMON_LDFLAGS = -melf_i386 -nostdlib
# Utilities.
bin_UTILITIES = grub-mkimage
#sbin_UTILITIES = grub-setup grub-emu grub-mkdevicemap grub-probefs
noinst_UTILITIES = genmoddep
# For grub-mkimage.
grub_mkimage_SOURCES = util/i386/efi/grub-mkimage.c util/misc.c \
@ -57,9 +56,6 @@ grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c \
grub_emu_LDFLAGS = $(LIBCURSES)
# For genmoddep.
genmoddep_SOURCES = util/genmoddep.c
# Scripts.
#sbin_SCRIPTS = grub-install

File diff suppressed because it is too large Load diff

View file

@ -52,7 +52,6 @@ kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h genke
# Utilities.
bin_UTILITIES = grub-mkimage
sbin_UTILITIES = grub-setup grub-emu grub-mkdevicemap grub-probefs
noinst_UTILITIES = genmoddep
# For grub-mkimage.
grub_mkimage_SOURCES = util/i386/pc/grub-mkimage.c util/misc.c \
@ -103,9 +102,6 @@ grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c \
grub_emu_LDFLAGS = $(LIBCURSES)
# For genmoddep.
genmoddep_SOURCES = util/genmoddep.c
# Scripts.
sbin_SCRIPTS = grub-install

File diff suppressed because it is too large Load diff

View file

@ -28,7 +28,6 @@ pkgdata_PROGRAMS = kernel.elf
# Utilities.
bin_UTILITIES = grub-emu
sbin_UTILITIES = grub-mkimage
noinst_UTILITIES = genmoddep
# For grub-mkimage.
grub_mkimage_SOURCES = util/powerpc/ieee1275/grub-mkimage.c util/misc.c \
@ -73,9 +72,6 @@ kernel_elf_ASFLAGS = $(COMMON_ASFLAGS)
kernel_elf_LDFLAGS = $(COMMON_LDFLAGS) -static-libgcc -lgcc \
-Wl,-N,-S,-Ttext,0x200000,-Bstatic
# For genmoddep.
genmoddep_SOURCES = util/genmoddep.c
# Scripts.
sbin_SCRIPTS = grub-install

File diff suppressed because it is too large Load diff

View file

@ -31,7 +31,6 @@ pkgdata_PROGRAMS = kernel.elf
# Utilities.
#bin_UTILITIES = grub-emu grub-mkimage
noinst_UTILITIES = genmoddep
# For grub-mkimage.
grub_mkimage_SOURCES = util/sparc64/ieee1275/grub-mkimage.c util/misc.c \
@ -75,9 +74,6 @@ kernel_elf_CFLAGS = $(COMMON_CFLAGS)
kernel_elf_ASFLAGS = $(COMMON_ASFLAGS)
kernel_elf_LDFLAGS = -mno-app-regs -nostdlib -Wl,-N,-Ttext,0x200000,-Bstatic,-melf64_sparc
# For genmoddep.
genmoddep_SOURCES = util/genmoddep.c
# Modules.
#_linux.mod linux.mod
pkgdata_MODULES = fat.mod ufs.mod ext2.mod minix.mod \

3412
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -11,20 +11,45 @@
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
dnl This configure script is complicated, because GRUB needs to deal
dnl with three potentially different types:
dnl
dnl build -- the environment for building GRUB
dnl host -- the environment for running utilities
dnl target -- the environment for running GRUB
dnl
dnl In addition, GRUB needs to deal with a platform specification
dnl which specifies the system running GRUB, such as firmware.
dnl This is necessary because the target type in autoconf does not
dnl describe such a system very well.
dnl
dnl The current strategy is to use variables with no prefix (such as
dnl CC, CFLAGS, etc.) for the host type as well as the build type,
dnl because GRUB does not need to use those variables for the build
dnl type, so there is no conflict. Variables with the prefix "TARGET_"
dnl (such as TARGET_CC, TARGET_CFLAGS, etc.) are used for the target
dnl type.
AC_INIT(GRUB, 1.93, [bug-grub@gnu.org])
AC_PREREQ(2.53)
AC_CONFIG_SRCDIR([include/grub/dl.h])
AC_CONFIG_HEADER([config.h])
# Checks for build and host systems.
AC_CANONICAL_BUILD
# Checks for host and target systems.
AC_CANONICAL_HOST
AC_CANONICAL_TARGET
case "$host_cpu" in
i[[3456]]86) host_cpu=i386 ;;
x86_64) host_cpu=i386 biarch32=1 ;;
x86_64) host_m32=1 ;;
powerpc64) host_m32=1 ;;
esac
case "$target_cpu" in
i[[3456]]86) target_cpu=i386 ;;
x86_64) target_cpu=i386 target_m32=1 ;;
powerpc) ;;
powerpc64) host_cpu=powerpc biarch32=1;;
powerpc64) target_cpu=powerpc target_m32=1;;
sparc64) ;;
*) AC_MSG_ERROR([unsupported CPU type]) ;;
esac
@ -36,7 +61,7 @@ AC_ARG_WITH([platform],
# Guess the platform if not specified.
if test "x$with_platform" = x; then
case "$host_cpu"-"$host_vendor" in
case "$target_cpu"-"$target_vendor" in
i386-apple) platform=efi ;;
i386-*) platform=pc ;;
powerpc-*) platform=ieee1275 ;;
@ -48,7 +73,7 @@ else
fi
# Sanity check.
case "$host_cpu"-"$platform" in
case "$target_cpu"-"$platform" in
i386-efi) ;;
i386-pc) ;;
powerpc-ieee1275) ;;
@ -56,120 +81,48 @@ case "$host_cpu"-"$platform" in
*) AC_MSG_ERROR([unsupported machine type]) ;;
esac
AC_SUBST(host_cpu)
AC_SUBST(target_cpu)
AC_SUBST(platform)
# Checks for programs.
if test "x$CFLAGS" = x; then
default_CFLAGS=yes
fi
AC_PROG_CC
#
# Checks for build programs.
#
AC_CHECK_PROGS([YACC], [bison])
if test "x$YACC" = x; then
AC_MSG_ERROR([Could not find bison.])
fi
AC_SYS_LARGEFILE
# Must be GCC.
test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required])
if test "x$default_CFLAGS" = xyes; then
# debug flags.
tmp_CFLAGS="-Wall -W -Wshadow -Wpointer-arith -Wmissing-prototypes \
-Wundef -Wstrict-prototypes -g"
# optimization flags.
AC_CACHE_CHECK([whether optimization for size works], size_flag, [
CFLAGS=-Os
AC_TRY_COMPILE(, , size_flag=yes, size_flag=no)
])
if test "x$size_flag" = xyes; then
tmp_CFLAGS="$tmp_CFLAGS -Os"
else
tmp_CFLAGS="$tmp_CFLAGS -O2 -fno-strength-reduce -fno-unroll-loops"
fi
# Force no alignment to save space on i386.
if test "x$host_cpu" = xi386; then
AC_CACHE_CHECK([whether -falign-loops works], [falign_loop_flag], [
CFLAGS="-falign-loops=1"
AC_TRY_COMPILE(, , [falign_loop_flag=yes], [falign_loop_flag=no])
])
if test "x$falign_loop_flag" = xyes; then
tmp_CFLAGS="$tmp_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1"
else
tmp_CFLAGS="$tmp_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1"
fi
fi
if test "x$biarch32" = x1; then
tmp_CFLAGS="$tmp_CFLAGS -m32"
LDFLAGS="$LDFLAGS -m32"
AC_SUBST(LDFLAGS)
fi
CFLAGS="$tmp_CFLAGS"
fi
AC_SUBST(CFLAGS)
# Defined in aclocal.m4.
grub_ASM_USCORE
if test "x$host_cpu" = xi386; then
grub_CHECK_START_SYMBOL
grub_CHECK_BSS_START_SYMBOL
grub_CHECK_END_SYMBOL
fi
if test "x$host_cpu" = xi386; then
grub_I386_ASM_PREFIX_REQUIREMENT
grub_I386_ASM_ADDR32
grub_I386_ASM_ABSOLUTE_WITHOUT_ASTERISK
grub_I386_CHECK_REGPARM_BUG
else
AC_DEFINE([NESTED_FUNC_ATTR], [], [Catch gcc bug])
fi
AC_PROG_INSTALL
AC_PROG_AWK
AC_PROG_MAKE_SET
AC_CHECK_TOOL(OBJCOPY, objcopy)
grub_PROG_OBJCOPY_ABSOLUTE
AC_CHECK_TOOL(STRIP, strip)
AC_CHECK_TOOL(NM, nm)
AC_CHECK_TOOL(LD, ld)
# This is not a "must".
AC_PATH_PROG(RUBY, ruby)
# For cross-compiling.
if test "x$build" != "x$host"; then
AC_CHECK_PROGS(BUILD_CC, [gcc egcs cc],
[AC_MSG_ERROR([none of gcc, egcs and cc is found. set BUILD_CC manually.])])
else
BUILD_CC="$CC"
AC_SUBST(BUILD_CC)
fi
#
# Checks for host programs.
#
# Test the C compiler for the build environment.
tmp_CC="$CC"
tmp_CFLAGS="$CFLAGS"
tmp_LDFLAGS="$LDFLAGS"
tmp_CPPFLAGS="$CPPFLAGS"
CC="$BUILD_CC"
CFLAGS="$BUILD_CFLAGS"
CPPFLAGS="$BUILD_CPPFLAGS"
LDFLAGS="$BUILD_LDFLAGS"
AC_PROG_CC
# Must be GCC.
test "x$GCC" = xyes || AC_MSG_ERROR([GCC is required])
# Identify characteristics of the build architecture.
AC_SYS_LARGEFILE
# Identify characteristics of the host architecture.
AC_C_BIGENDIAN
AC_CHECK_SIZEOF(void *)
AC_CHECK_SIZEOF(long)
# Check LZO when compiling for the i386.
if test "x$host_cpu" = xi386; then
if test "x$host_m32" = x1; then
# Force 32-bit mode.
CFLAGS="$CFLAGS -m32"
LDFLAGS="$LDFLAGS -m32"
fi
# Check LZO when compiling for the i386-pc.
if test "$target_cpu"-"$platform" = i386-pc; then
# There are three possibilities. LZO version 2 installed with the name
# liblzo2, with the name liblzo, and LZO version 1.
AC_CHECK_LIB(lzo2, __lzo_init_v2, [LIBLZO="-llzo2"],
@ -193,6 +146,100 @@ AC_SUBST(LIBCURSES)
# Check for headers.
AC_CHECK_HEADERS(ncurses/curses.h ncurses.h curses.h)
#
# Check for target programs.
#
# For cross-compiling.
if test "x$target" != "x$host"; then
# XXX this depends on the implementation of autoconf!
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(TARGET_CC)
# Test the C compiler for the target environment.
tmp_CC="$CC"
tmp_CFLAGS="$CFLAGS"
tmp_LDFLAGS="$LDFLAGS"
tmp_CPPFLAGS="$CPPFLAGS"
CC="$TARGET_CC"
CFLAGS="$TARGET_CFLAGS"
CPPFLAGS="$TARGET_CPPFLAGS"
LDFLAGS="$TARGET_LDFLAGS"
if test "x$TARGET_CFLAGS" = x; then
# debug flags.
TARGET_CFLAGS="-Wall -W -Wshadow -Wpointer-arith -Wmissing-prototypes \
-Wundef -Wstrict-prototypes -g"
# optimization flags.
AC_CACHE_CHECK([whether optimization for size works], size_flag, [
CFLAGS=-Os
AC_TRY_COMPILE(, , size_flag=yes, size_flag=no)
])
if test "x$size_flag" = xyes; then
TARGET_CFLAGS="$TARGET_CFLAGS -Os"
else
TARGET_CFLAGS="$TARGET_CFLAGS -O2 -fno-strength-reduce -fno-unroll-loops"
fi
# Force no alignment to save space on i386.
if test "x$target_cpu" = xi386; then
AC_CACHE_CHECK([whether -falign-loops works], [falign_loop_flag], [
CFLAGS="-falign-loops=1"
AC_TRY_COMPILE(, , [falign_loop_flag=yes], [falign_loop_flag=no])
])
if test "x$falign_loop_flag" = 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
fi
fi
if test "x$target_m32" = x1; then
# Force 32-bit mode.
TARGET_CFLAGS="$TARGET_CFLAGS -m32"
TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
fi
AC_SUBST(TARGET_CFLAGS)
AC_SUBST(TARGET_CPPFLAGS)
AC_SUBST(TARGET_LDFLAGS)
# Defined in aclocal.m4.
grub_PROG_OBJCOPY_ABSOLUTE
grub_ASM_USCORE
if test "x$target_cpu" = xi386; then
grub_CHECK_START_SYMBOL
grub_CHECK_BSS_START_SYMBOL
grub_CHECK_END_SYMBOL
grub_I386_ASM_PREFIX_REQUIREMENT
grub_I386_ASM_ADDR32
grub_I386_ASM_ABSOLUTE_WITHOUT_ASTERISK
grub_I386_CHECK_REGPARM_BUG
else
AC_DEFINE([NESTED_FUNC_ATTR], [], [Catch gcc bug])
fi
# Restore the flags.
CC="$tmp_CC"
CFLAGS="$tmp_CFLAGS"
@ -207,8 +254,8 @@ AC_ARG_ENABLE([mm-debug],
[Define to 1 if you enable memory manager debugging.])])
# Output files.
AC_CONFIG_LINKS([include/grub/cpu:include/grub/$host_cpu
include/grub/machine:include/grub/$host_cpu/$platform])
AC_CONFIG_LINKS([include/grub/cpu:include/grub/$target_cpu
include/grub/machine:include/grub/$target_cpu/$platform])
AC_CONFIG_FILES([Makefile gensymlist.sh genkernsyms.sh])
AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
AC_OUTPUT

View file

@ -1,6 +1,6 @@
#! /usr/bin/ruby -w
#
# Copyright (C) 2002,2003,2004,2005 Free Software Foundation, Inc.
# Copyright (C) 2002,2003,2004,2005,2006 Free Software Foundation, Inc.
#
# This genmk.rb is free software; the author
# gives unlimited permission to copy and/or distribute it,
@ -60,22 +60,22 @@ MOSTLYCLEANFILES += #{deps_str}
$(OBJCOPY) -O binary -R .note -R .comment $< $@
#{exe}: #{objs_str}
$(CC) -o $@ $^ $(LDFLAGS) $(#{prefix}_LDFLAGS)
$(TARGET_CC) -o $@ $^ $(TARGET_LDFLAGS) $(#{prefix}_LDFLAGS)
" + objs.collect_with_index do |obj, i|
src = sources[i]
fake_obj = File.basename(src).suffix('o')
dep = deps[i]
flag = if /\.c$/ =~ src then 'CFLAGS' else 'ASFLAGS' end
flag = if /\.c$/ =~ src then 'TARGET_CFLAGS' else 'TARGET_ASFLAGS' end
extra_flags = if /\.S$/ =~ src then '-DASM_FILE=1' else '' end
dir = File.dirname(src)
"#{obj}: #{src}
$(CC) -I#{dir} -I$(srcdir)/#{dir} $(CPPFLAGS) #{extra_flags} $(#{flag}) $(#{prefix}_#{flag}) -c -o $@ $<
$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(#{flag}) $(#{prefix}_#{flag}) -c -o $@ $<
#{dep}: #{src}
set -e; \
$(CC) -I#{dir} -I$(srcdir)/#{dir} $(CPPFLAGS) #{extra_flags} $(#{flag}) $(#{prefix}_#{flag}) -M $< \
$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(#{flag}) $(#{prefix}_#{flag}) -M $< \
| sed 's,#{Regexp.quote(fake_obj)}[ :]*,#{obj} $@ : ,g' > $@; \
[ -s $@ ] || rm -f $@
@ -121,15 +121,15 @@ UNDSYMFILES += #{undsym}
#{@name}: #{pre_obj} #{mod_obj}
-rm -f $@
$(CC) $(#{prefix}_LDFLAGS) $(LDFLAGS) -Wl,-r,-d -o $@ $^
$(TARGET_CC) $(#{prefix}_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ $^
$(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
#{pre_obj}: #{objs_str}
-rm -f $@
$(CC) $(#{prefix}_LDFLAGS) $(LDFLAGS) -Wl,-r,-d -o $@ $^
$(TARGET_CC) $(#{prefix}_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ $^
#{mod_obj}: #{mod_src}
$(CC) $(CPPFLAGS) $(CFLAGS) $(#{prefix}_CFLAGS) -c -o $@ $<
$(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(#{prefix}_CFLAGS) -c -o $@ $<
#{mod_src}: moddep.lst genmodsrc.sh
sh $(srcdir)/genmodsrc.sh '#{mod_name}' $< > $@ || (rm -f $@; exit 1)
@ -149,15 +149,15 @@ endif
command = 'cmd-' + obj.suffix('lst')
fs = 'fs-' + obj.suffix('lst')
dep = deps[i]
flag = if /\.c$/ =~ src then 'CFLAGS' else 'ASFLAGS' end
flag = if /\.c$/ =~ src then 'TARGET_CFLAGS' else 'TARGET_ASFLAGS' end
dir = File.dirname(src)
"#{obj}: #{src}
$(CC) -I#{dir} -I$(srcdir)/#{dir} $(CPPFLAGS) $(#{flag}) $(#{prefix}_#{flag}) -c -o $@ $<
$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) $(#{flag}) $(#{prefix}_#{flag}) -c -o $@ $<
#{dep}: #{src}
set -e; \
$(CC) -I#{dir} -I$(srcdir)/#{dir} $(CPPFLAGS) $(#{flag}) $(#{prefix}_#{flag}) -M $< \
$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) $(#{flag}) $(#{prefix}_#{flag}) -M $< \
| sed 's,#{Regexp.quote(fake_obj)}[ :]*,#{obj} $@ : ,g' > $@; \
[ -s $@ ] || rm -f $@
@ -169,12 +169,12 @@ FSFILES += #{fs}
#{command}: #{src} gencmdlist.sh
set -e; \
$(CC) -I#{dir} -I$(srcdir)/#{dir} $(CPPFLAGS) $(#{flag}) $(#{prefix}_#{flag}) -E $< \
$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) $(#{flag}) $(#{prefix}_#{flag}) -E $< \
| sh $(srcdir)/gencmdlist.sh #{symbolic_name} > $@ || (rm -f $@; exit 1)
#{fs}: #{src} genfslist.sh
set -e; \
$(CC) -I#{dir} -I$(srcdir)/#{dir} $(CPPFLAGS) $(#{flag}) $(#{prefix}_#{flag}) -E $< \
$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) $(#{flag}) $(#{prefix}_#{flag}) -E $< \
| sh $(srcdir)/genfslist.sh #{symbolic_name} > $@ || (rm -f $@; exit 1)
@ -204,7 +204,7 @@ class Utility
MOSTLYCLEANFILES += #{deps_str}
#{@name}: #{objs_str}
$(BUILD_CC) -o $@ $^ $(BUILD_LDFLAGS) $(#{prefix}_LDFLAGS)
$(CC) -o $@ $^ $(LDFLAGS) $(#{prefix}_LDFLAGS)
" + objs.collect_with_index do |obj, i|
src = sources[i]
@ -213,11 +213,11 @@ MOSTLYCLEANFILES += #{deps_str}
dir = File.dirname(src)
"#{obj}: #{src}
$(BUILD_CC) -I#{dir} -I$(srcdir)/#{dir} $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(#{prefix}_CFLAGS) -c -o $@ $<
$(CC) -I#{dir} -I$(srcdir)/#{dir} $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(#{prefix}_CFLAGS) -c -o $@ $<
#{dep}: #{src}
set -e; \
$(BUILD_CC) -I#{dir} -I$(srcdir)/#{dir} $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(#{prefix}_CFLAGS) -M $< \
$(CC) -I#{dir} -I$(srcdir)/#{dir} $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(#{prefix}_CFLAGS) -M $< \
| sed 's,#{Regexp.quote(fake_obj)}[ :]*,#{obj} $@ : ,g' > $@; \
[ -s $@ ] || rm -f $@
@ -249,7 +249,7 @@ class Program
MOSTLYCLEANFILES += #{deps_str}
#{@name}: #{objs_str}
$(CC) -o $@ $^ $(LDFLAGS) $(#{prefix}_LDFLAGS)
$(TARGET_CC) -o $@ $^ $(TARGET_LDFLAGS) $(#{prefix}_LDFLAGS)
" + objs.collect_with_index do |obj, i|
src = sources[i]
@ -258,11 +258,11 @@ MOSTLYCLEANFILES += #{deps_str}
dir = File.dirname(src)
"#{obj}: #{src}
$(CC) -I#{dir} -I$(srcdir)/#{dir} $(CPPFLAGS) $(CFLAGS) $(#{prefix}_CFLAGS) -c -o $@ $<
$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(#{prefix}_CFLAGS) -c -o $@ $<
#{dep}: #{src}
set -e; \
$(CC) -I#{dir} -I$(srcdir)/#{dir} $(CPPFLAGS) $(CFLAGS) $(#{prefix}_CFLAGS) -M $< \
$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(#{prefix}_CFLAGS) -M $< \
| sed 's,#{Regexp.quote(fake_obj)}[ :]*,#{obj} $@ : ,g' > $@; \
[ -s $@ ] || rm -f $@

62
genmoddep.awk Normal file
View file

@ -0,0 +1,62 @@
#! /usr/bin/awk -f
#
# Copyright (C) 2006 Free Software Foundation, Inc.
#
# This genmoddep.awk 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.
# Read defined symbols from stdin.
BEGIN {
while (getline <"/dev/stdin") {
symtab[$1] = $2
}
}
# The first line contains a module name.
FNR == 1 {
module = $1
next
};
# The rest is undefined symbols.
{
if ($1 in symtab) {
modtab[module] = modtab[module] " " symtab[$1];
}
else {
printf "%s in %s is not defined\n", $1, module >"/dev/stderr";
error++;
exit;
}
}
# Output the result.
END {
if (error == 1)
exit 1;
for (mod in modtab) {
# Remove duplications.
split(modtab[mod], depmods, " ");
for (depmod in uniqmods) {
delete uniqmods[depmod];
}
for (i in depmods) {
depmod = depmods[i];
# Ignore kernel, as always loaded.
if (depmod != "kernel")
uniqmods[depmod] = 1;
}
modlist = ""
for (depmod in uniqmods) {
modlist = modlist " " depmod;
}
printf "%s:%s\n", mod, modlist;
}
}

View file

@ -1,6 +1,6 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2002 Free Software Foundation, Inc.
* Copyright (C) 2002,2006 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
@ -21,12 +21,12 @@
#define GRUB_TYPES_CPU_HEADER 1
/* The size of void *. */
#define GRUB_HOST_SIZEOF_VOID_P 4
#define GRUB_TARGET_SIZEOF_VOID_P 4
/* The size of long. */
#define GRUB_HOST_SIZEOF_LONG 4
#define GRUB_TARGET_SIZEOF_LONG 4
/* i386 is little-endian. */
#undef GRUB_HOST_WORDS_BIGENDIAN
#undef GRUB_TARGET_WORDS_BIGENDIAN
#endif /* ! GRUB_TYPES_CPU_HEADER */

View file

@ -1,6 +1,6 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2002, 2004 Free Software Foundation, Inc.
* Copyright (C) 2002,2004,2006 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
@ -21,13 +21,13 @@
#define GRUB_TYPES_CPU_HEADER 1
/* The size of void *. */
#define GRUB_HOST_SIZEOF_VOID_P 4
#define GRUB_TARGET_SIZEOF_VOID_P 4
/* The size of long. */
#define GRUB_HOST_SIZEOF_LONG 4
#define GRUB_TARGET_SIZEOF_LONG 4
/* powerpc is big-endian. */
#define GRUB_HOST_WORDS_BIGENDIAN 1
#define GRUB_TARGET_WORDS_BIGENDIAN 1
#endif /* ! GRUB_TYPES_CPU_HEADER */

View file

@ -1,6 +1,6 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2002, 2004 Free Software Foundation, Inc.
* Copyright (C) 2002,2004,2006 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
@ -21,13 +21,13 @@
#define GRUB_TYPES_CPU_HEADER 1
/* The size of void *. */
#define GRUB_HOST_SIZEOF_VOID_P 8
#define GRUB_TARGET_SIZEOF_VOID_P 8
/* The size of long. */
#define GRUB_HOST_SIZEOF_LONG 8
#define GRUB_TARGET_SIZEOF_LONG 8
/* sparc64 is big-endian. */
#define GRUB_HOST_WORDS_BIGENDIAN 1
#define GRUB_TARGET_WORDS_BIGENDIAN 1
#endif /* ! GRUB_TYPES_CPU_HEADER */

View file

@ -1,6 +1,6 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2002, 2005 Free Software Foundation, Inc.
* Copyright (C) 2002,2005,2006 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -32,9 +32,9 @@
# undef GRUB_CPU_WORDS_BIGENDIAN
# endif
#else /* ! GRUB_UTIL */
# define GRUB_CPU_SIZEOF_VOID_P GRUB_HOST_SIZEOF_VOID_P
# define GRUB_CPU_SIZEOF_LONG GRUB_HOST_SIZEOF_LONG
# ifdef GRUB_HOST_WORDS_BIGENDIAN
# define GRUB_CPU_SIZEOF_VOID_P GRUB_TARGET_SIZEOF_VOID_P
# define GRUB_CPU_SIZEOF_LONG GRUB_TARGET_SIZEOF_LONG
# ifdef GRUB_TARGET_WORDS_BIGENDIAN
# define GRUB_CPU_WORDS_BIGENDIAN 1
# else
# undef GRUB_CPU_WORDS_BIGENDIAN
@ -69,7 +69,7 @@ typedef unsigned long long grub_uint64_t;
#endif
/* Misc types. */
#if GRUB_HOST_SIZEOF_VOID_P == 8
#if SIZEOF_VOID_P == 8
typedef grub_uint64_t grub_host_addr_t;
typedef grub_uint64_t grub_host_off_t;
typedef grub_uint64_t grub_host_size_t;

View file

@ -30,7 +30,7 @@
#include <grub/env.h>
#include <grub/cache.h>
#if GRUB_HOST_SIZEOF_VOID_P == 4
#if GRUB_CPU_SIZEOF_VOID_P == 4
typedef Elf32_Word Elf_Word;
typedef Elf32_Addr Elf_Addr;
@ -41,7 +41,7 @@ typedef Elf32_Sym Elf_Sym;
# define ELF_ST_BIND(val) ELF32_ST_BIND (val)
# define ELF_ST_TYPE(val) ELF32_ST_TYPE (val)
#elif GRUB_HOST_SIZEOF_VOID_P == 8
#elif GRUB_CPU_SIZEOF_VOID_P == 8
typedef Elf64_Word Elf_Word;
typedef Elf64_Addr Elf_Addr;

View file

@ -61,7 +61,7 @@ grub_efi_allocate_pages (grub_efi_physical_address_t address,
grub_efi_status_t status;
grub_efi_boot_services_t *b;
#if GRUB_HOST_SIZEOF_VOID_P < 8
#if GRUB_CPU_SIZEOF_VOID_P < 8
/* Limit the memory access to less than 4GB for 32-bit platforms. */
if (address > 0xffffffff)
return 0;
@ -220,7 +220,7 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map,
desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size))
{
if (desc->type == GRUB_EFI_CONVENTIONAL_MEMORY
#if GRUB_HOST_SIZEOF_VOID_P < 8
#if GRUB_CPU_SIZEOF_VOID_P < 8
&& desc->physical_start <= 0xffffffff
#endif
&& desc->physical_start + PAGES_TO_BYTES (desc->num_pages) > 0x100000
@ -236,7 +236,7 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map,
desc->physical_start = 0x100000;
}
#if GRUB_HOST_SIZEOF_VOID_P < 8
#if GRUB_CPU_SIZEOF_VOID_P < 8
if (BYTES_TO_PAGES (filtered_desc->physical_start)
+ filtered_desc->num_pages
> BYTES_TO_PAGES (0x100000000LL))

View file

@ -1,279 +0,0 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2002 Free Software Foundation, Inc.
*
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#define BUF_SIZE 1024
#define SYMTAB_SIZE 509
struct symbol
{
const char *name;
const char *mod;
struct symbol *next;
};
struct module
{
const char *name;
struct module *next;
};
static char buf[BUF_SIZE];
static struct symbol *symtab[SYMTAB_SIZE];
static void
err (const char *fmt, ...)
{
va_list ap;
fprintf (stderr, "genmoddep: error: ");
va_start (ap, fmt);
vfprintf (stderr, fmt, ap);
va_end (ap);
fputc ('\n', stderr);
exit (1);
}
static void *
xmalloc (size_t size)
{
void *p;
p = malloc (size);
if (! p)
err ("out of memory");
return p;
}
static char *
xstrdup (const char *str)
{
char *s;
size_t len;
len = strlen (str);
s = (char *) xmalloc (len + 1);
memcpy (s, str, len + 1);
return s;
}
static void
chomp (char *str)
{
int end;
end = strlen (str) - 1;
if (end < 0)
err ("empty string");
if (str[end] == '\n')
str[end] = '\0';
}
static unsigned
symbol_hash (const char *s)
{
unsigned key = 0;
while (*s)
key = key * 65599 + *s++;
return (key + (key >> 5)) % SYMTAB_SIZE;
}
static struct symbol *
get_symbol (const char *name)
{
unsigned k;
struct symbol *sym;
k = symbol_hash (name);
for (sym = symtab[k]; sym; sym = sym->next)
if (strcmp (sym->name, name) == 0)
return sym;
return 0;
}
static void
add_symbol (const char *name, const char *mod)
{
unsigned k;
struct symbol *sym;
if (get_symbol (name))
err ("duplicated symbol: %s", name);
sym = (struct symbol *) xmalloc (sizeof (*sym));
sym->name = xstrdup (name);
sym->mod = xstrdup (mod);
k = symbol_hash (name);
sym->next = symtab[k];
symtab[k] = sym;
}
static void
free_symbols (void)
{
int i;
for (i = 0; i < SYMTAB_SIZE; i++)
{
struct symbol *p, *q;
p = symtab[i];
while (p)
{
q = p->next;
free ((void *) p->name);
free ((void *) p->mod);
free (p);
p = q;
}
}
}
static void
read_defined_symbols (FILE *fp)
{
while (fgets (buf, sizeof (buf), fp))
{
char *p;
if (! *buf)
err ("empty symbol name: %s", buf);
p = strchr (buf, ' ');
if (! p)
err ("invalid line format: %s", buf);
p++;
if (! *p)
err ("empty module name: %s", buf);
*(p - 1) = '\0';
chomp (p);
add_symbol (buf, p);
}
}
static void
add_module (struct module **head, const char *name)
{
struct module *mod;
for (mod = *head; mod; mod = mod->next)
if (strcmp (mod->name, name) == 0)
return;
mod = (struct module *) xmalloc (sizeof (*mod));
mod->name = xstrdup (name);
mod->next = *head;
*head = mod;
}
static void
free_modules (struct module *head)
{
struct module *next;
while (head)
{
next = head->next;
free ((void *) head->name);
free (head);
head = next;
}
}
static void
find_dependencies (FILE *fp)
{
char *mod_name;
struct module *mod_list = 0;
struct module *mod;
if (! fgets (buf, sizeof (buf), fp) || buf[0] == '\n' || buf[0] == '\0')
err ("no module name");
chomp (buf);
mod_name = xstrdup (buf);
while (fgets (buf, sizeof (buf), fp))
{
struct symbol *sym;
chomp (buf);
sym = get_symbol (buf);
if (! sym)
err ("%s in %s is not defined", buf, mod_name);
add_module (&mod_list, sym->mod);
}
printf ("%s:", mod_name);
for (mod = mod_list; mod; mod = mod->next)
if (strcmp (mod->name, "kernel") != 0)
printf (" %s", mod->name);
putchar ('\n');
free_modules (mod_list);
}
int
main (int argc, char *argv[])
{
int i;
/* First, get defined symbols. */
read_defined_symbols (stdin);
/* Second, find the dependecies. */
for (i = 1; i < argc; i++)
{
FILE *fp;
fp = fopen (argv[i], "r");
if (! fp)
err ("cannot open %s", argv[i]);
find_dependencies (fp);
fclose (fp);
}
/* Last, free memory. */
free_symbols ();
return 0;
}

View file

@ -26,9 +26,9 @@ libdir=@libdir@
PACKAGE_NAME=@PACKAGE_NAME@
PACKAGE_TARNAME=@PACKAGE_TARNAME@
PACKAGE_VERSION=@PACKAGE_VERSION@
host_cpu=@host_cpu@
target_cpu=@target_cpu@
platform=@platform@
pkglibdir=${libdir}/${PACKAGE_TARNAME}/${host_cpu}-${platform}
pkglibdir=${libdir}/${PACKAGE_TARNAME}/${target_cpu}-${platform}
grub_setup=${sbindir}/grub-setup
grub_mkimage=${bindir}/grub-mkimage

View file

@ -28,11 +28,11 @@ libdir=@libdir@
PACKAGE_NAME=@PACKAGE_NAME@
PACKAGE_TARNAME=@PACKAGE_TARNAME@
PACKAGE_VERSION=@PACKAGE_VERSION@
host_cpu=@host_cpu@
target_cpu=@target_cpu@
platform=@platform@
pkglibdir=${libdir}/${PACKAGE_TARNAME}/${host_cpu}-${platform}
pkglibdir=${libdir}/${PACKAGE_TARNAME}/${target_cpu}-${platform}
grub_mkimage=${sbindir}/grub-mkimage
grub_mkimage=${bindir}/grub-mkimage
rootdir=
grub_prefix=/boot/grub
modules=