Build system support for grub-emu modules
This commit is contained in:
parent
c3e6233987
commit
f38873b80b
9 changed files with 114 additions and 33 deletions
|
@ -43,6 +43,7 @@ pkglibdir = $(libdir)/`echo @PACKAGE_TARNAME@/$(target_cpu)-$(platform) | sed '
|
|||
|
||||
# Internationalization library.
|
||||
LIBINTL = @LIBINTL@
|
||||
TARGET_NO_MODULES = @TARGET_NO_MODULES@
|
||||
|
||||
XGETTEXT = @XGETTEXT@
|
||||
MSGMERGE = @MSGMERGE@
|
||||
|
@ -175,10 +176,15 @@ include $(srcdir)/conf/tests.mk
|
|||
-include $(wildcard $(GRUB_CONTRIB)/*/conf/common.mk)
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET_NO_MODULES), yes)
|
||||
TARGET_CFLAGS += -DGRUB_TARGET_NO_MODULES=1
|
||||
CFLAGS += -DGRUB_TARGET_NO_MODULES=1
|
||||
endif
|
||||
|
||||
### General targets.
|
||||
|
||||
CLEANFILES += $(pkglib_DATA) $(pkgdata_DATA) po/*.mo
|
||||
ifneq ($(platform), emu)
|
||||
ifneq ($(TARGET_NO_MODULES), yes)
|
||||
pkglib_DATA += moddep.lst command.lst fs.lst partmap.lst parttool.lst handler.lst video.lst crypto.lst terminal.lst
|
||||
endif
|
||||
moddep.lst: $(DEFSYMFILES) $(UNDSYMFILES) genmoddep.awk
|
||||
|
|
|
@ -13,30 +13,33 @@ pkglib_PROGRAMS = kernel.img
|
|||
kernel_img_SOURCES = kern/device.c kern/disk.c kern/dl.c kern/env.c \
|
||||
kern/err.c kern/list.c kern/handler.c \
|
||||
kern/command.c kern/corecmd.c kern/file.c \
|
||||
kern/fs.c commands/boot.c kern/main.c kern/misc.c kern/parser.c \
|
||||
kern/fs.c kern/main.c kern/misc.c kern/parser.c \
|
||||
kern/partition.c kern/term.c \
|
||||
kern/rescue_reader.c kern/rescue_parser.c \
|
||||
\
|
||||
util/console.c util/grub-emu.c util/misc.c \
|
||||
util/hostdisk.c util/getroot.c \
|
||||
\
|
||||
grub_emu_init.c
|
||||
kernel_img_CFLAGS = $(CPPFLAGS) $(CFLAGS)
|
||||
gnulib/progname.c util/hostfs.c
|
||||
kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \
|
||||
env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \
|
||||
partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \
|
||||
list.h handler.h command.h i18n.h env_private.h
|
||||
kernel_img_CFLAGS = $(CPPFLAGS) $(CFLAGS) -Wno-undef
|
||||
kernel_img_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
TARGET_NO_STRIP = yes
|
||||
TARGET_NO_DYNAMIC_MODULES = yes
|
||||
|
||||
# progname.c always has warnings. Compile it separately.
|
||||
pkglib_MODULES += progname.mod
|
||||
progname_mod_SOURCES = gnulib/progname.c
|
||||
progname_mod_CFLAGS = $(COMMON_CFLAGS) -Wno-error
|
||||
progname_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
ifneq ($(TARGET_NO_MODULES), yes)
|
||||
kernel_img_SOURCES += symlist.c
|
||||
else
|
||||
kernel_img_SOURCES += grub_emu_init.c
|
||||
endif
|
||||
|
||||
# For hostfs.mod.
|
||||
pkglib_MODULES += hostfs.mod
|
||||
hostfs_mod_SOURCES = util/hostfs.c
|
||||
hostfs_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
hostfs_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
# For boot.mod.
|
||||
pkglib_MODULES += boot.mod
|
||||
boot_mod_SOURCES = commands/boot.c lib/i386/pc/biosnum.c
|
||||
boot_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
boot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For host.mod.
|
||||
pkglib_MODULES += host.mod
|
||||
|
@ -77,8 +80,10 @@ endif
|
|||
ifeq ($(enable_grub_emu_sdl), yes)
|
||||
pkglib_MODULES += sdl.mod
|
||||
sdl_mod_SOURCES = util/sdl.c
|
||||
sdl_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
sdl_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
grub_emu_LDFLAGS += $(LIBSDL)
|
||||
kernel_img_HEADERS += sdl.h
|
||||
endif
|
||||
|
||||
ifeq ($(enable_grub_emu_pci), yes)
|
||||
|
@ -90,6 +95,14 @@ endif
|
|||
|
||||
include $(srcdir)/conf/common.mk
|
||||
|
||||
MOSTLYCLEANFILES += symlist.c kernel_syms.lst
|
||||
DEFSYMFILES += kernel_syms.lst
|
||||
symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h gensymlist.sh
|
||||
/bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
|
||||
|
||||
kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h genkernsyms.sh
|
||||
/bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
|
||||
|
||||
grub_emu_init.h: genemuinitheader.sh $(pkglib_MODULES)
|
||||
rm -f $@; echo $(pkglib_MODULES) | sh $(srcdir)/genemuinitheader.sh $(NM) > $@
|
||||
DISTCLEANFILES += grub_emu_init.h
|
||||
|
@ -99,7 +112,12 @@ grub_emu_init.c: genemuinit.sh $(pkglib_MODULES)
|
|||
DISTCLEANFILES += grub_emu_init.c
|
||||
|
||||
CLEANFILES += grub-emu
|
||||
ifneq ($(TARGET_NO_MODULES), yes)
|
||||
grub-emu: $(pkglib_PROGRAMS)
|
||||
$(CC) -o $@ $(pkglib_PROGRAMS) $(grub_emu_LDFLAGS) $(LDFLAGS)
|
||||
else
|
||||
grub-emu: $(pkglib_MODULES) $(pkglib_PROGRAMS)
|
||||
$(CC) -o $@ $(pkglib_MODULES) $(pkglib_PROGRAMS) $(grub_emu_LDFLAGS) $(LDFLAGS)
|
||||
endif
|
||||
GRUB_EMU=grub-emu
|
||||
|
||||
|
|
16
configure.ac
16
configure.ac
|
@ -548,6 +548,10 @@ 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)])])
|
||||
|
||||
AC_ARG_ENABLE([grub-emu-modules],
|
||||
[AS_HELP_STRING([--enable-grub-emu-modules],
|
||||
[Support module loading in `grub-emu' debugging utility (default=no)])])
|
||||
|
||||
if test "$platform" = emu; then
|
||||
missing_ncurses=
|
||||
[# Check for curses libraries.]
|
||||
|
@ -566,6 +570,13 @@ 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_modules" = xyes ; then
|
||||
TARGET_NO_MODULES=no
|
||||
else
|
||||
TARGET_NO_MODULES=yes
|
||||
fi
|
||||
AC_SUBST(TARGET_NO_MODULES)
|
||||
|
||||
if test x"$enable_grub_emu_usb" = xno ; then
|
||||
grub_emu_usb_excuse="explicitly disabled"
|
||||
fi
|
||||
|
@ -733,6 +744,11 @@ echo PCI support for grub-emu: Yes
|
|||
else
|
||||
echo PCI support for grub-emu: No "($grub_emu_pci_excuse)"
|
||||
fi
|
||||
if [ x"$TARGET_NO_MODULES" = xno ]; then
|
||||
echo Module support for grub-emu: Yes
|
||||
else
|
||||
echo Module support for grub-emu: No
|
||||
fi
|
||||
fi
|
||||
if [ x"$enable_mm_debug" = xyes ]; then
|
||||
echo With memory debugging: Yes
|
||||
|
|
34
genmk.rb
34
genmk.rb
|
@ -143,7 +143,7 @@ mostlyclean-module-#{@name}.#{@rule_count}:
|
|||
MOSTLYCLEAN_MODULE_TARGETS += mostlyclean-module-#{@name}.#{@rule_count}
|
||||
UNDSYMFILES += #{undsym}
|
||||
|
||||
ifeq ($(TARGET_NO_DYNAMIC_MODULES), yes)
|
||||
ifeq ($(TARGET_NO_MODULES), yes)
|
||||
#{@name}: #{pre_obj} $(TARGET_OBJ2ELF)
|
||||
-rm -f $@
|
||||
$(TARGET_CC) $(#{prefix}_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ #{pre_obj}
|
||||
|
@ -322,28 +322,32 @@ class Program
|
|||
end
|
||||
attr_reader :dir, :name
|
||||
|
||||
def print_tail()
|
||||
prefix = @name.to_var
|
||||
print "CLEANFILES += #{@name} $(#{prefix}_OBJECTS)
|
||||
ifeq ($(#{prefix}_RELOCATABLE),yes)
|
||||
#{@name}: $(#{prefix}_DEPENDENCIES) $(#{prefix}_OBJECTS)
|
||||
$(TARGET_CC) -Wl,-r,-d -o $@ $(#{prefix}_OBJECTS) $(TARGET_LDFLAGS) $(#{prefix}_LDFLAGS)
|
||||
if test x$(TARGET_NO_STRIP) != xyes ; then $(STRIP) --strip-unneeded -K start -R .note -R .comment $@; fi
|
||||
else
|
||||
#{@name}: $(#{prefix}_DEPENDENCIES) $(#{prefix}_OBJECTS)
|
||||
$(TARGET_CC) -o $@ $(#{prefix}_OBJECTS) $(TARGET_LDFLAGS) $(#{prefix}_LDFLAGS)
|
||||
if test x$(TARGET_NO_STRIP) != xyes ; then $(STRIP) -R .rel.dyn -R .reginfo -R .note -R .comment $@; fi
|
||||
endif
|
||||
|
||||
"
|
||||
end
|
||||
|
||||
def rule(sources)
|
||||
prefix = @name.to_var
|
||||
objs = sources.collect do |src|
|
||||
raise "unknown source file `#{src}'" if /\.[cS]$/ !~ src
|
||||
prefix + '-' + src.to_obj
|
||||
end
|
||||
objs_str = objs.join(' ');
|
||||
deps = objs.collect {|obj| obj.suffix('d')}
|
||||
deps_str = deps.join(' ');
|
||||
|
||||
"CLEANFILES += #{@name} #{objs_str}
|
||||
MOSTLYCLEANFILES += #{deps_str}
|
||||
|
||||
ifeq ($(#{prefix}_RELOCATABLE),yes)
|
||||
#{@name}: $(#{prefix}_DEPENDENCIES) #{objs_str}
|
||||
$(TARGET_CC) -Wl,-r,-d -o $@ #{objs_str} $(TARGET_LDFLAGS) $(#{prefix}_LDFLAGS)
|
||||
if test x$(TARGET_NO_STRIP) != xyes ; then $(STRIP) --strip-unneeded -K start -R .note -R .comment $@; fi
|
||||
else
|
||||
#{@name}: $(#{prefix}_DEPENDENCIES) #{objs_str}
|
||||
$(TARGET_CC) -o $@ #{objs_str} $(TARGET_LDFLAGS) $(#{prefix}_LDFLAGS)
|
||||
if test x$(TARGET_NO_STRIP) != xyes ; then $(STRIP) -R .rel.dyn -R .reginfo -R .note -R .comment $@; fi
|
||||
endif
|
||||
"MOSTLYCLEANFILES += #{deps_str}
|
||||
|
||||
" + objs.collect_with_index do |obj, i|
|
||||
src = sources[i]
|
||||
|
@ -358,6 +362,7 @@ endif
|
|||
|
||||
-include #{dep}
|
||||
|
||||
#{prefix}_OBJECTS += #{obj}
|
||||
"
|
||||
end.join('')
|
||||
end
|
||||
|
@ -466,4 +471,5 @@ while l = gets
|
|||
|
||||
end
|
||||
utils.each {|util| util.print_tail()}
|
||||
programs.each {|program| program.print_tail()}
|
||||
|
||||
|
|
|
@ -32,13 +32,13 @@ FNR == 1 {
|
|||
else if ($1 != "__gnu_local_gp") {
|
||||
printf "%s in %s is not defined\n", $1, module >"/dev/stderr";
|
||||
error++;
|
||||
exit;
|
||||
# exit;
|
||||
}
|
||||
}
|
||||
|
||||
# Output the result.
|
||||
END {
|
||||
if (error == 1)
|
||||
if (error != 0)
|
||||
exit 1;
|
||||
|
||||
for (mod in modtab) {
|
||||
|
|
|
@ -91,7 +91,7 @@ grub_dl_t grub_dl_load_core (void *addr, grub_size_t size);
|
|||
int EXPORT_FUNC(grub_dl_unload) (grub_dl_t mod);
|
||||
void grub_dl_unload_unneeded (void);
|
||||
void grub_dl_unload_all (void);
|
||||
#if defined (GRUB_MACHINE_EMU) || defined (GRUB_UTIL)
|
||||
#if defined (GRUB_UTIL) || defined (GRUB_TARGET_NO_MODULES)
|
||||
#define GRUB_NO_MODULES 1
|
||||
#else
|
||||
#define GRUB_NO_MODULES 0
|
||||
|
@ -121,7 +121,7 @@ grub_err_t grub_dl_register_symbol (const char *name, void *addr,
|
|||
grub_err_t grub_arch_dl_check_header (void *ehdr);
|
||||
grub_err_t grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr);
|
||||
|
||||
#if defined (_mips) && ! defined (GRUB_UTIL) && !defined (GRUB_MACHINE_EMU)
|
||||
#if defined (_mips) && ! GRUB_NO_MODULES
|
||||
#define GRUB_LINKER_HAVE_INIT 1
|
||||
void grub_arch_dl_init_linker (void);
|
||||
#endif
|
||||
|
|
24
include/grub/sdl.h
Normal file
24
include/grub/sdl.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 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/>.
|
||||
*/
|
||||
|
||||
void EXPORT_FUNC (SDL_Quit) (void);
|
||||
void EXPORT_FUNC (SDL_SetColors) (void);
|
||||
void EXPORT_FUNC (SDL_Init) (void);
|
||||
void EXPORT_FUNC (SDL_GetError) (void);
|
||||
void EXPORT_FUNC (SDL_Flip) (void);
|
||||
void EXPORT_FUNC (SDL_SetVideoMode) (void);
|
|
@ -146,6 +146,9 @@ usage (int status)
|
|||
}
|
||||
|
||||
|
||||
void grub_hostfs_init (void);
|
||||
void grub_hostfs_fini (void);
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
|
@ -204,11 +207,14 @@ main (int argc, char *argv[])
|
|||
|
||||
signal (SIGINT, SIG_IGN);
|
||||
grub_console_init ();
|
||||
grub_hostfs_init ();
|
||||
|
||||
/* XXX: This is a bit unportable. */
|
||||
grub_util_biosdisk_init (dev_map);
|
||||
|
||||
#if GRUB_NO_MODULES
|
||||
grub_init_all ();
|
||||
#endif
|
||||
|
||||
/* Make sure that there is a root device. */
|
||||
if (! root_dev)
|
||||
|
@ -235,7 +241,10 @@ main (int argc, char *argv[])
|
|||
if (setjmp (main_env) == 0)
|
||||
grub_main ();
|
||||
|
||||
#if GRUB_NO_MODULES
|
||||
grub_fini_all ();
|
||||
#endif
|
||||
grub_hostfs_fini ();
|
||||
|
||||
grub_machine_fini ();
|
||||
|
||||
|
|
|
@ -319,10 +319,12 @@ grub_mm_init_region (void *addr __attribute__ ((unused)),
|
|||
{
|
||||
}
|
||||
|
||||
#if GRUB_NO_MODULES
|
||||
void
|
||||
grub_register_exported_symbols (void)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
grub_exit (void)
|
||||
|
|
Loading…
Reference in a new issue