grub/conf/any-emu.rmk
BVK Chaitanya 0cdc2a095b 2010-03-14 BVK Chaitanya <bvk.groups@gmail.com>
GRUB shell lexer and parser improvements.

	* conf/any-emu.rmk: Build rule updates.
	* conf/common.rmk: Likewise.
	* conf/i386-coreboot.rmk: Likewise.
	* conf/i386-efi.rmk: Likewise.
	* conf/i386-ieee1275.rmk: Likewise.
	* conf/i386-pc.rmk: Likewise.
	* conf/powerpc-ieee1275.rmk: Likewise.
	* conf/x86_64-efi.rmk: Likewise.

	* configure.ac: Configure check for flex.

	* include/grub/script_sh.h (grub_script_arg_type_t): More argument
	types.
	(grub_lexer_param): Struct member updates.
	(grub_parser_param): Likewise.
	(GRUB_LEXER_TOKEN_MAX): Maximum token size.
	(GRUB_LEXER_RECORD_INCREMENT): Memory increments' size.
	(grub_script_lexer_init): Prototype update.
	(grub_script_lexer_record_start): Likewise.
	(grub_script_lexer_record_stop): Likewise.
	(grub_script_lexer_yywrap): New function prototype.
	(grub_script_lexer_fini): Likewise.
	(grub_script_execute_argument_to_string): Removed by...
	(grub_script_execute_argument_to_argv): ...better version.

	* script/execute.c (ROUND_UPTO): New macro.
	(grub_script_execute_cmdline): Out of memory fixes.
	(grub_script_execute_menuentry): Likewise.
	(grub_script_execute_argument_to_string): Removed. Update all
	users by...
	(grub_script_execute_argument_to_argv): ...better version.
	* script/function.c (grub_script_function_create): Use
	grub_script_execute_argument_to_argv instead of
	grub_script_execute_argument_to_string.

	* script/lexer.c (check_varstate): Removed.
	(check_textstate): Removed.
	(grub_script_lexer_record_start): Likewise.
	(grub_script_lexer_record_stop): Likewise.
	(recordchar): Replaced with...
	(grub_script_lexer_record): ...new function.
	(nextchar): Removed.
	(grub_script_lexer_init): Rewritten.
	(grub_script_yylex): Rewritten.
	(append_newline): New function.
	(grub_script_lexer_yywrap): New function.
	(grub_script_lexer_fini): New function.
	(grub_script_yyerror): Sets error flag.

	* script/yylex.l: New file.
	(grub_lexer_yyfree): Wrapper for flex yyffre.
	(grub_lexer_yyalloc): Likewise.
	(grub_lexer_yyrealloc): Likewise.
	* script/parser.y: Refactored.

	* script/script.c (grub_script_arg_add): Out of memory fixes.
	(grub_script_add_arglist): Likewise.
	(grub_script_create_cmdline): Likewise.
	(grub_script_create_cmdmenu): Likewise.
	(grub_script_add_cmd): Likewise.
	(grub_script_parse): Use grub_script_lexer_fini to deallocated.
	* util/grub-script-check.c (grub_script_execute_menuentry): Remove
	unnecessary code.

	* tests/grub_script_echo1.in: New testcase.
	* tests/grub_script_vars1.in: New testcase.
	* tests/grub_script_echo_keywords.in: New testcase.
2010-03-14 22:37:17 +05:30

95 lines
2.7 KiB
Makefile

# -*- makefile -*-
COMMON_LDFLAGS += -nostdlib
COMMON_CFLAGS += -nostdinc -isystem $(shell $(TARGET_CC) -print-file-name=include) -fno-builtin
util/grub-emu.c_DEPENDENCIES = grub_emu_init.h
kernel_img_RELOCATABLE = yes
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 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 util/time.c \
\
grub_emu_init.c gnulib/progname.c util/hostfs.c disk/host.c
kernel_img_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -Wno-undef -I$(srcdir)/gnulib
kernel_img_LDFLAGS = $(COMMON_LDFLAGS)
TARGET_NO_STRIP = yes
TARGET_NO_DYNAMIC_MODULES = yes
# For halt.mod.
pkglib_MODULES += halt.mod
halt_mod_SOURCES = commands/halt.c
halt_mod_CFLAGS = $(COMMON_CFLAGS)
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
ifeq ($(target_cpu), i386)
pkglib_MODULES += cpuid.mod
cpuid_mod_SOURCES = commands/i386/cpuid.c
cpuid_mod_CFLAGS = $(COMMON_CFLAGS)
cpuid_mod_LDFLAGS = $(COMMON_LDFLAGS)
endif
grub_emu_LDFLAGS = $(LIBCURSES)
ifeq ($(enable_grub_emu_usb), yes)
pkglib_MODULES += libusb.mod
libusb_mod_SOURCES = util/usb.c
libusb_mod_CFLAGS =
libusb_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For usb.mod
pkglib_MODULES += usb.mod
usb_mod_SOURCES = bus/usb/usb.c
usb_mod_CFLAGS = $(COMMON_CFLAGS)
usb_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For usbtest.mod
pkglib_MODULES += usbtest.mod
usbtest_mod_SOURCES = commands/usbtest.c
usbtest_mod_CFLAGS = $(COMMON_CFLAGS)
usbtest_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For usbms.mod
pkglib_MODULES += usbms.mod
usbms_mod_SOURCES = disk/usbms.c
usbms_mod_CFLAGS = $(COMMON_CFLAGS)
usbms_mod_LDFLAGS = $(COMMON_LDFLAGS)
grub_emu_LDFLAGS += $(LIBUSB)
endif
ifeq ($(enable_grub_emu_sdl), yes)
pkglib_MODULES += sdl.mod
sdl_mod_SOURCES = util/sdl.c
sdl_mod_CFLAGS =
sdl_mod_LDFLAGS = $(COMMON_LDFLAGS)
grub_emu_LDFLAGS += $(LIBSDL)
endif
ifeq ($(enable_grub_emu_pci), yes)
pkglib_MODULES += pci.mod
pci_mod_SOURCES = util/pci.c commands/lspci.c
pci_mod_LDFLAGS = $(COMMON_LDFLAGS)
grub_emu_LDFLAGS += $(LIBPCIACCESS)
endif
include $(srcdir)/conf/common.mk
grub_emu_init.h: genemuinitheader.sh $(pkglib_MODULES)
rm -f $@; echo $(pkglib_MODULES) | sh $(srcdir)/genemuinitheader.sh $(NM) > $@
DISTCLEANFILES += grub_emu_init.h
grub_emu_init.c: genemuinit.sh $(pkglib_MODULES)
rm -f $@; echo $(pkglib_MODULES) | sh $(srcdir)/genemuinit.sh $(NM) > $@
DISTCLEANFILES += grub_emu_init.c
CLEANFILES += grub-emu
grub-emu: $(pkglib_MODULES) $(pkglib_PROGRAMS)
$(CC) -o $@ $(pkglib_MODULES) $(pkglib_PROGRAMS) $(grub_emu_LDFLAGS) $(LDFLAGS)
GRUB_EMU=grub-emu