Merge mainline into yeeloongfw
This commit is contained in:
commit
a6132b9f3f
172 changed files with 12449 additions and 6208 deletions
|
@ -25,6 +25,8 @@ docs/version.texi
|
||||||
*.exec
|
*.exec
|
||||||
genkernsyms.sh
|
genkernsyms.sh
|
||||||
gensymlist.sh
|
gensymlist.sh
|
||||||
|
gentrigtables
|
||||||
|
grub-bin2h
|
||||||
grub-dumpbios
|
grub-dumpbios
|
||||||
grub-editenv
|
grub-editenv
|
||||||
grub-emu
|
grub-emu
|
||||||
|
@ -40,8 +42,13 @@ grub-pe2elf
|
||||||
grub-probe
|
grub-probe
|
||||||
grub_probe_init.c
|
grub_probe_init.c
|
||||||
grub_probe_init.h
|
grub_probe_init.h
|
||||||
|
grub-reboot
|
||||||
|
grub-script-check
|
||||||
|
grub_script_check_init.c
|
||||||
|
grub_script_check_init.h
|
||||||
grub_script.tab.c
|
grub_script.tab.c
|
||||||
grub_script.tab.h
|
grub_script.tab.h
|
||||||
|
grub-set-default
|
||||||
grub-setup
|
grub-setup
|
||||||
grub_setup_init.c
|
grub_setup_init.c
|
||||||
grub_setup_init.h
|
grub_setup_init.h
|
||||||
|
@ -62,4 +69,5 @@ stamp-h
|
||||||
stamp-h1
|
stamp-h1
|
||||||
stamp-h.in
|
stamp-h.in
|
||||||
symlist.c
|
symlist.c
|
||||||
|
trigtables.c
|
||||||
update-grub_lib
|
update-grub_lib
|
||||||
|
|
697
ChangeLog
697
ChangeLog
|
@ -1,3 +1,700 @@
|
||||||
|
2010-04-05 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* loader/i386/multiboot_mbi.c (grub_multiboot_load): Correctly report
|
||||||
|
unsupported video mode types.
|
||||||
|
|
||||||
|
2010-04-05 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* kern/i386/pc/startup.S (grub_getrtsecs): Removed (dead code).
|
||||||
|
|
||||||
|
2010-04-05 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* include/grub/i386/pc/init.h (grub_get_mmap_entry): Don't export.
|
||||||
|
* conf/i386-pc.rmk (kernel_img_HEADERS): Remove machine/init.h.
|
||||||
|
|
||||||
|
2010-04-04 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Remove unused grub_vga_get_font.
|
||||||
|
|
||||||
|
* kern/i386/pc/startup.S (grub_vga_get_font): Removed.
|
||||||
|
* include/grub/i386/pc/vga.h (grub_vga_get_font): Likewise.
|
||||||
|
|
||||||
|
2010-04-03 Grégoire Sutre <gregoire.sutre@gmail.com>
|
||||||
|
|
||||||
|
* kern/misc.c: Disable the __enable_execute_stack hack for utilities.
|
||||||
|
* include/grub/misc.h: Likewise.
|
||||||
|
|
||||||
|
2010-04-03 Grégoire Sutre <gregoire.sutre@gmail.com>
|
||||||
|
|
||||||
|
* util/grub-install.in: Add `|| exit 1' to all grub-probe calls
|
||||||
|
for which failure is fatal.
|
||||||
|
|
||||||
|
2010-04-03 Grégoire Sutre <gregoire.sutre@gmail.com>
|
||||||
|
|
||||||
|
* util/grub-install.in: Use mkdir -p to create grub directory.
|
||||||
|
* util/i386/efi/grub-install.in: Likewise.
|
||||||
|
* util/ieee1275/grub-install.in: Likewise.
|
||||||
|
|
||||||
|
2010-04-03 Grégoire Sutre <gregoire.sutre@gmail.com>
|
||||||
|
|
||||||
|
* Makefile.in (LEX): new variable.
|
||||||
|
|
||||||
|
2010-04-03 Grégoire Sutre <gregoire.sutre@gmail.com>
|
||||||
|
|
||||||
|
* util/i386/efi/grub-dumpdevtree: replaced the non-portable `==' by
|
||||||
|
`=' and added double quotes on operands of this equality test.
|
||||||
|
|
||||||
|
2010-04-03 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* Makefile.in (uninstall): Remove a leftover debug echo.
|
||||||
|
Reported by: Grégoire Sutre
|
||||||
|
|
||||||
|
2010-04-03 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
MIPS multiboot2 support.
|
||||||
|
|
||||||
|
* conf/mips.rmk (pkglib_MODULES): Add multiboot2.mod.
|
||||||
|
(multiboot2_mod_SOURCES): New variable.
|
||||||
|
(multiboot2_mod_CFLAGS): Likewise.
|
||||||
|
(multiboot2_mod_LDFLAGS): Likewise.
|
||||||
|
(multiboot2_mod_ASFLAGS): Likewise.
|
||||||
|
* include/grub/i386/multiboot.h (MULTIBOOT_INITIAL_STATE): New
|
||||||
|
definition.
|
||||||
|
(MULTIBOOT_ENTRY_REGISTER): Likewise.
|
||||||
|
(MULTIBOOT_MBI_REGISTER): Likewise.
|
||||||
|
(MULTIBOOT_ARCHITECTURE_CURRENT): Likewise.
|
||||||
|
(MULTIBOOT_ELF32_MACHINE): Likewise.
|
||||||
|
(MULTIBOOT_ELF64_MACHINE): Likewise.
|
||||||
|
* include/grub/mips/multiboot.h: New file.
|
||||||
|
* include/grub/video.h (grub_video_driver_id): New type
|
||||||
|
GRUB_VIDEO_DRIVER_SM712.
|
||||||
|
(grub_video_get_info_and_fini): Export.
|
||||||
|
(grub_video_get_palette): Likewise.
|
||||||
|
(grub_video_get_driver_id): Likewise.
|
||||||
|
* include/multiboot2.h: Resynced with spec.
|
||||||
|
* loader/i386/multiboot.c: Moved from here ...
|
||||||
|
* loader/multiboot.c: ... here. All users updated.
|
||||||
|
(grub_multiboot_boot): Use platform-specific macros.
|
||||||
|
* loader/i386/multiboot_elfxx.c: Moved from here ...
|
||||||
|
* loader/multiboot_elfxx.c: ... here. All users updated.
|
||||||
|
(E_MACHINE): Use MULTIBOOT_ELF32_MACHINE and MULTIBOOT_ELF64_MACHINE.
|
||||||
|
* loader/i386/multiboot_mbi2.c (grub_multiboot_load): Check arcitecture.
|
||||||
|
* video/sm712.c (grub_video_sm712_adapter): Add missing id field.
|
||||||
|
|
||||||
|
2010-04-02 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Import gnulib argp module.
|
||||||
|
|
||||||
|
* gnulib/argp-ba.c: New file.
|
||||||
|
* gnulib/argp-eexst.c: Likewise.
|
||||||
|
* gnulib/argp-fmtstream.c: Likewise.
|
||||||
|
* gnulib/argp-fmtstream.h: Likewise.
|
||||||
|
* gnulib/argp-fs-xinl.c: Likewise.
|
||||||
|
* gnulib/argp-help.c: Likewise.
|
||||||
|
* gnulib/argp-namefrob.h: Likewise.
|
||||||
|
* gnulib/argp-parse.c: Likewise.
|
||||||
|
* gnulib/argp-pin.c: Likewise.
|
||||||
|
* gnulib/argp-pv.c: Likewise.
|
||||||
|
* gnulib/argp-pvh.c: Likewise.
|
||||||
|
* gnulib/argp-version-etc.c: Likewise.
|
||||||
|
* gnulib/argp-version-etc.h: Likewise.
|
||||||
|
* gnulib/argp-xinl.c: Likewise.
|
||||||
|
* gnulib/argp.h: Likewise.
|
||||||
|
|
||||||
|
2010-03-31 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* kern/device.c (grub_device_iterate): Clear errors after failed
|
||||||
|
opening device.
|
||||||
|
|
||||||
|
2010-03-31 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* kern/ieee1275/openfw.c (grub_children_iterate): Skip device itself if
|
||||||
|
returned by firmware.
|
||||||
|
|
||||||
|
2010-03-30 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* loader/i386/multiboot_mbi2.c (retrieve_video_parameters): Fix
|
||||||
|
compilation on coreboot and qemu
|
||||||
|
|
||||||
|
2010-03-28 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* include/multiboot2.h: Resync with spec.
|
||||||
|
|
||||||
|
2010-03-28 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Multiboot2 tag support
|
||||||
|
|
||||||
|
* conf/i386.rmk (multiboot2_mod_SOURCES): Replace
|
||||||
|
loader/i386/multiboot_mbi.c with loader/i386/multiboot_mbi2.c.
|
||||||
|
Remove loader/multiboot_loader.c.
|
||||||
|
* include/grub/i386/multiboot.h (grub_multiboot_real_boot): Removed.
|
||||||
|
(grub_multiboot2_real_boot): Likewise.
|
||||||
|
* include/grub/multiboot.h (grub_multiboot_set_accepts_video): Removed.
|
||||||
|
(grub_get_multiboot_mmap_count): New proto.
|
||||||
|
(grub_fill_multiboot_mmap): Likewise.
|
||||||
|
(grub_multiboot_set_video_mode): Likewise.
|
||||||
|
(grub_multiboot_set_console): Likewise.
|
||||||
|
(grub_multiboot_load): Likewise.
|
||||||
|
(grub_multiboot_load_elf): Likewise.
|
||||||
|
(GRUB_MULTIBOOT_CONSOLE_EGA_TEXT): New definition.
|
||||||
|
(GRUB_MULTIBOOT_CONSOLE_FRAMEBUFFER): Likewise.
|
||||||
|
* include/multiboot.h: Resynced with specification.
|
||||||
|
* include/multiboot2.h: Resynced with specification.
|
||||||
|
* loader/i386/multiboot_mbi.c (DEFAULT_VIDEO_MODE): Moved from here...
|
||||||
|
* loader/i386/multiboot.c (DEFAULT_VIDEO_MODE): ... here.
|
||||||
|
* loader/i386/multiboot_mbi.c (HAS_VGA_TEXT): Moved from here ..
|
||||||
|
* include/grub/multiboot.h (GRUB_MACHINE_HAS_VGA_TEXT): ... here. All
|
||||||
|
users updated.
|
||||||
|
* loader/i386/multiboot_mbi.c (accepts_video): Moved from here...
|
||||||
|
* loader/i386/multiboot.c (accepts_video): ... here. All users updated.
|
||||||
|
* loader/i386/multiboot_mbi.c (grub_multiboot_set_accepts_video):
|
||||||
|
Removed.
|
||||||
|
* loader/i386/multiboot_mbi.c (grub_get_multiboot_mmap_len):
|
||||||
|
Moved from here...
|
||||||
|
* loader/i386/multiboot.c (grub_get_multiboot_mmap_len): ... here.
|
||||||
|
* loader/i386/multiboot_mbi.c (grub_fill_multiboot_mmap):
|
||||||
|
Moved from here...
|
||||||
|
* loader/i386/multiboot.c (grub_fill_multiboot_mmap): ... here.
|
||||||
|
* loader/i386/multiboot_mbi.c (set_video_mode): Moved from here...
|
||||||
|
* loader/i386/multiboot.c (grub_multiboot_set_video_mode): ... here.
|
||||||
|
All users updated.
|
||||||
|
* loader/i386/multiboot_mbi2.c: New file.
|
||||||
|
|
||||||
|
2010-03-27 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Resync with gnulib.
|
||||||
|
|
||||||
|
* Makefile.in (GNULIB_CFLAGS): New variable.
|
||||||
|
* conf/common.rmk (grub_mkisofs_CFLAGS): Add GNULIB_CFLAGS.
|
||||||
|
(grub_script_check_CFLAGS): New variable.
|
||||||
|
* gnulib/alloca.h: Resync with gnulib.
|
||||||
|
* gnulib/error.c: Likewise.
|
||||||
|
* gnulib/error.h: Likewise.
|
||||||
|
* gnulib/fnmatch.c: Likewise.
|
||||||
|
* gnulib/fnmatch_loop.c: Likewise.
|
||||||
|
* gnulib/getdelim.c: Likewise.
|
||||||
|
* gnulib/getline.c: Likewise.
|
||||||
|
* gnulib/getopt.c: Likewise.
|
||||||
|
* gnulib/getopt1.c: Likewise.
|
||||||
|
* gnulib/getopt_int.h: Likewise.
|
||||||
|
* gnulib/gettext.h: Likewise.
|
||||||
|
* gnulib/progname.c: Likewise.
|
||||||
|
* gnulib/progname.h: Likewise.
|
||||||
|
|
||||||
|
2010-03-27 Grégoire Sutre <gregoire.sutre@gmail.com>
|
||||||
|
|
||||||
|
Fix a build failure (-Wundef -Werror) when ENABLE_NLS is not defined,
|
||||||
|
which is the case with --disabled-nls.
|
||||||
|
|
||||||
|
* include/grub/i18n.h: Use (defined(ENABLE_NLS)
|
||||||
|
&& ENABLE_NLS) instead of ENABLE_NLS in all #if preprocessor macros.
|
||||||
|
* util/misc.c: Likewise.
|
||||||
|
* util/mkisofs/mkisofs.c: Likewise.
|
||||||
|
* util/mkisofs/mkisofs.h: Likewise.
|
||||||
|
|
||||||
|
2010-03-27 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Simplify Apple CC support.
|
||||||
|
|
||||||
|
* commands/i386/pc/drivemap_int13h.S: Use LOCAL when possible.
|
||||||
|
Add 0 byte at the end not to have a symbol with empty target.
|
||||||
|
* mmap/i386/pc/mmap_helper.S: Likewise.
|
||||||
|
* genmk.rb: Ignore errors 2030 and 2050.
|
||||||
|
* kern/i386/pc/startup.S: Use LOCAL when possible.
|
||||||
|
|
||||||
|
2010-03-26 BVK Chaitanya <bvk.groups@gmail.com>
|
||||||
|
|
||||||
|
Testcase and the fix for final semicolon on cmdline.
|
||||||
|
|
||||||
|
* tests/grub_script_final_semicolon.in: New testcase.
|
||||||
|
* conf/tests.rmk: Rules for the new testcase.
|
||||||
|
* script/parser.y: Grammar fix.
|
||||||
|
|
||||||
|
2010-03-26 BVK Chaitanya <bvk@localhost>
|
||||||
|
|
||||||
|
Blank lines testcase for GRUB script.
|
||||||
|
|
||||||
|
* tests/grub_script_blanklines.in: New testcase.
|
||||||
|
* conf/tests.rmk: Rules for the new testcase.
|
||||||
|
|
||||||
|
2010-03-26 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Don't use __FILE__.
|
||||||
|
|
||||||
|
* genmk.rb: Add -DGRUB_FILE to all C targets.
|
||||||
|
* fs/reiserfs.c: Replace __FILE__ with GRUB_FILE.
|
||||||
|
* include/grub/list.h: Likewise.
|
||||||
|
* include/grub/misc.h: Likewise.
|
||||||
|
* include/grub/mm.h: Likewise.
|
||||||
|
* include/grub/test.h: Likewise.
|
||||||
|
* kern/mm.c: Likewise.
|
||||||
|
* lib/libgcrypt_wrap/cipher_wrap.h: Likewise.
|
||||||
|
|
||||||
|
2010-03-26 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Sunpc partitions support.
|
||||||
|
|
||||||
|
* conf/common.rmk (grub_probe_SOURCES): Add partmap/sunpc.c.
|
||||||
|
(grub_fstest_SOURCES): Likewise.
|
||||||
|
(pkglib_MODULES): Add part_sunpc.mod.
|
||||||
|
(part_sunpc_mod_SOURCES): New variable.
|
||||||
|
(part_sunpc_mod_CFLAGS): Likewise.
|
||||||
|
(part_sunpc_mod_LDFLAGS): Likewise.
|
||||||
|
* conf/i386-pc.rmk (grub_setup_SOURCES): Add partmap/sunpc.c.
|
||||||
|
* partmap/sunpc.c: New file.
|
||||||
|
|
||||||
|
2010-03-26 BVK Chaitanya <bvk@localhost>
|
||||||
|
|
||||||
|
For loop support to GRUB script.
|
||||||
|
|
||||||
|
* include/grub/script_sh.h (grub_script_cmdfor): New struct.
|
||||||
|
(grub_script_create_cmdfor): New function prototype.
|
||||||
|
(grub_script_execute_cmdfor): New function prototype.
|
||||||
|
* script/execute.c (grub_script_execute_cmdfor): New function.
|
||||||
|
* script/parser.y (command): New for command.
|
||||||
|
(forcmd): New grammar rule.
|
||||||
|
* script/script.c (grub_script_create_cmdfor): New function.
|
||||||
|
* util/grub-script-check.c (grub_script_execute_cmdfor): New
|
||||||
|
function.
|
||||||
|
* tests/grub_script_for1.in: New testcase.
|
||||||
|
* conf/tests.rmk: Rules for new testcase.
|
||||||
|
|
||||||
|
2010-03-26 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Nested partitions
|
||||||
|
|
||||||
|
* commands/blocklist.c (grub_cmd_blocklist): Don't check whether
|
||||||
|
'partition' is NULL, grub_partition_get_start already does that.
|
||||||
|
* commands/loadenv.c (check_blocklists): Likewise.
|
||||||
|
(write_blocklists): Likewise.
|
||||||
|
* conf/common.rmk (grub_probe_SOURCES): Add partmap/bsdlabel.c.
|
||||||
|
(grub_fstest_SOURCES): Likewise.
|
||||||
|
(pkglib_MODULES): Add part_bsd.mod.
|
||||||
|
(part_bsd_mod_SOURCES): New variable.
|
||||||
|
(part_bsd_mod_CFLAGS): Likewise.
|
||||||
|
(part_bsd_mod_LDFLAGS): Likewise.
|
||||||
|
* conf/i386-pc.rmk (grub_setup_SOURCES): Add partmap/bsdlabel.c.
|
||||||
|
(grub_emu_SOURCES): Likewise.
|
||||||
|
* conf/sparc64-ieee1275.rmk (grub_emu_SOURCES): Likewise.
|
||||||
|
* include/grub/bsdlabel.h: New file.
|
||||||
|
* include/grub/partition.h (grub_partition_map): Remove 'probe' and
|
||||||
|
'get_name'.
|
||||||
|
(grub_partition): Add 'parent' and 'number'. Remove 'data'.
|
||||||
|
(grub_partition_map_list): New variable.
|
||||||
|
(grub_partition_map_register): Inline.
|
||||||
|
(grub_partition_map_unregister): Likewise.
|
||||||
|
(FOR_PARTITION_MAPS): New macro.
|
||||||
|
(grub_partition_map_iterate): Removed.
|
||||||
|
(grub_partition_get_start): Handle nested partitions.
|
||||||
|
* include/grub/msdos_partition.h: Remove bsd-related entries.
|
||||||
|
(grub_pc_partition): Remove.
|
||||||
|
* kern/disk.c (grub_disk_close): Free partition data.
|
||||||
|
(grub_disk_adjust_range): Handle nested partitions.
|
||||||
|
* kern/partition.c (grub_partition_map_probe): New function.
|
||||||
|
(grub_partition_probe): Parse name to number, handle subpartitions.
|
||||||
|
(get_partmap): New function.
|
||||||
|
(grub_partition_iterate): Handle subpartitions.
|
||||||
|
(grub_partition_get_name): Likewise.
|
||||||
|
* loader/i386/pc/bsd.c (grub_bsd_get_device): Likewise.
|
||||||
|
* loader/i386/multiboot.c (grub_multiboot_get_bootdev): Likewise.
|
||||||
|
* loader/i386/pc/chainloader.c (grub_chainloader_cmd): Likewise.
|
||||||
|
* partmap/acorn.c (acorn_partition_map_iterate): Don't force raw access.
|
||||||
|
Set 'number'.
|
||||||
|
(acorn_partition_map_probe): Remove.
|
||||||
|
(acorn_partition_map_get_name): Likewise.
|
||||||
|
* partmap/amiga.c (amiga_partition_map_iterate): Don't force raw access.
|
||||||
|
Set 'number'.
|
||||||
|
Set 'index' to 0 since there can be only one partition entry per sector.
|
||||||
|
(amiga_partition_map_probe): Remove.
|
||||||
|
(amiga_partition_map_get_name): Likewise.
|
||||||
|
* partmap/apple.c (apple_partition_map_iterate): Don't force raw access.
|
||||||
|
Set 'number'.
|
||||||
|
Set 'offset' and 'index' to real positions of partitions.
|
||||||
|
(apple_partition_map_probe): Remove.
|
||||||
|
(apple_partition_map_get_name): Likewise.
|
||||||
|
* partmap/bsdlabel.c: New file.
|
||||||
|
* partmap/gpt.c (gpt_partition_map_iterate): Don't force raw access.
|
||||||
|
Set 'number'.
|
||||||
|
Allocate 'data' so it can be correctly freed.
|
||||||
|
Set 'index' to offset inside sector.
|
||||||
|
(gpt_partition_map_probe): Remove.
|
||||||
|
(gpt_partition_map_get_name): Likewise.
|
||||||
|
* partmap/msdos.c (grub_partition_parse): Remove.
|
||||||
|
(pc_partition_map_iterate): Don't force raw access.
|
||||||
|
Set 'number'.
|
||||||
|
Make 'ext_offset' a local variable.
|
||||||
|
(pc_partition_map_probe): Remove.
|
||||||
|
(pc_partition_map_get_name): Remove.
|
||||||
|
* partmap/sun.c (sun_partition_map_iterate): Don't force raw access.
|
||||||
|
Set 'number'.
|
||||||
|
(sun_partition_map_probe): Remove.
|
||||||
|
(sun_partition_map_get_name): Likewise.
|
||||||
|
* parttool/msdospart.c (grub_pcpart_boot): Handle nested partitions.
|
||||||
|
(grub_pcpart_type): Likewise.
|
||||||
|
* util/hostdisk.c (open_device): Handle new numbering scheme.
|
||||||
|
(grub_util_biosdisk_get_grub_dev): Handle nested partitions.
|
||||||
|
* util/i386/pc/grub-setup.c (setup): Handle new numbering scheme.
|
||||||
|
* util/grub-probe.c (probe_partmap): Handle nested paritions.
|
||||||
|
* util/grub-install.in: Insert all subpartition modules.
|
||||||
|
* util/ieee1275/grub-install.in: Likewise.
|
||||||
|
|
||||||
|
2010-03-24 Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
|
||||||
|
|
||||||
|
* kern/dl.c (grub_dl_resolve_symbols): Improve error message
|
||||||
|
grammar.
|
||||||
|
|
||||||
|
2010-03-24 Colin Watson <cjwatson@ubuntu.com>
|
||||||
|
|
||||||
|
* .bzrignore: Add grub-bin2h, grub-reboot, and grub-set-default.
|
||||||
|
|
||||||
|
2010-03-21 Colin Watson <cjwatson@ubuntu.com>
|
||||||
|
|
||||||
|
* util/grub-install.in: Copy .mo files from @datadir@/locale, to
|
||||||
|
match where 'make install' puts them.
|
||||||
|
* util/i386/efi/grub-install.in: Likewise.
|
||||||
|
|
||||||
|
2010-03-19 Colin Watson <cjwatson@ubuntu.com>
|
||||||
|
|
||||||
|
* .bzrignore: Add gentrigtables, grub-script-check,
|
||||||
|
grub_script_check_init.c, grub_script_check_init.h, and
|
||||||
|
trigtables.c.
|
||||||
|
|
||||||
|
2010-03-18 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* kern/parser.c: Indented.
|
||||||
|
|
||||||
|
2010-03-17 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* term/i386/pc/vesafb.c: Removed (orphaned, deprecated and broken).
|
||||||
|
|
||||||
|
2010-03-17 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* video/fb/fbblit.c (grub_video_fbblit_blend_XXXA8888_1bit): Handle
|
||||||
|
alpha_mask_size == 0 case.
|
||||||
|
|
||||||
|
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 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Remove some redundancy in build system.
|
||||||
|
|
||||||
|
* Makefile.in (TARGET_CFLAGS): Add -ffreestanding.
|
||||||
|
(TARGET_ASFLAGS): Add -nostdinc -fno-builtin.
|
||||||
|
(TARGET_LDFLAGS): Add -nostdlib.
|
||||||
|
(TARGET_IMG_LDFLAGS): Likewise.
|
||||||
|
* commands/lsmmap.c (grub_cmd_lsmmap) [GRUB_MACHINE_EMU]: Don't do
|
||||||
|
anything since mmap isn't available.
|
||||||
|
* conf/any-emu.rmk (kernel_img_SOURCES): Remove commands/boot.c.
|
||||||
|
Add util/time.c.
|
||||||
|
(pkglib_MODULES): Remove reboot.mod.
|
||||||
|
(reboot_mod_SOURCES): Removed.
|
||||||
|
(reboot_mod_CFLAGS): Likewise.
|
||||||
|
(reboot_mod_LDFLAGS): Likewise.
|
||||||
|
* conf/common.rmk (script/lexer.c_DEPENDENCIES): New variable.
|
||||||
|
(MOSTLYCLEANFILES): Add symlist.c kernel_syms.lst.
|
||||||
|
(DEFSYMFILES): Add kernel_syms.lst.
|
||||||
|
(kernel_img_HEADERS): Add common headers.
|
||||||
|
(symlist.c): New target.
|
||||||
|
(kernel_syms.lst): Likewise.
|
||||||
|
(pkglib_MODULES): Add memdisk.mod.
|
||||||
|
(memdisk_mod_SOURCES): New variable.
|
||||||
|
(memdisk_mod_CFLAGS): Likewise.
|
||||||
|
(memdisk_mod_LDFLAGS): Likewise.
|
||||||
|
(pkglib_MODULES): Add reboot.mod.
|
||||||
|
(reboot_mod_SOURCES): New variable.
|
||||||
|
(reboot_mod_CFLAGS): Likewise.
|
||||||
|
(reboot_mod_LDFLAGS): Likewise.
|
||||||
|
(pkglib_MODULES): Add date.mod.
|
||||||
|
(date_mod_SOURCES): New variable.
|
||||||
|
(date_mod_CFLAGS): Likewise.
|
||||||
|
(date_mod_LDFLAGS): Likewise.
|
||||||
|
(pkglib_MODULES): Add datehook.mod.
|
||||||
|
(datehook_mod_SOURCES): New variable.
|
||||||
|
(datehook_mod_CFLAGS): Likewise.
|
||||||
|
(datehook_mod_LDFLAGS): Likewise.
|
||||||
|
(pkglib_MODULES): Add lsmmap.mod.
|
||||||
|
(lsmmap_mod_SOURCES): New variable.
|
||||||
|
(lsmmap_mod_CFLAGS): Likewise.
|
||||||
|
(lsmmap_mod_LDFLAGS): Likewise.
|
||||||
|
(pkglib_MODULES): Add boot.mod.
|
||||||
|
(boot_mod_SOURCES): New variable.
|
||||||
|
(boot_mod_CFLAGS): Likewise.
|
||||||
|
(boot_mod_LDFLAGS): Likewise.
|
||||||
|
* conf/i386-coreboot.rmk: Removed redundant parts.
|
||||||
|
* conf/i386-ieee1275.rmk: Likewise.
|
||||||
|
* conf/i386-pc.rmk: Likewise.
|
||||||
|
* conf/mips-yeeloong.rmk: Likewise.
|
||||||
|
* conf/mips.rmk: Likewise.
|
||||||
|
* conf/powerpc-ieee1275.rmk: Likewise.
|
||||||
|
* conf/sparc64-ieee1275.rmk: Likewise.
|
||||||
|
* conf/x86_64-efi.rmk: Likewise.
|
||||||
|
* conf/i386-coreboot.rmk: Moved qemu parts ..
|
||||||
|
* conf/i386-qemu.rmk: ... here
|
||||||
|
* conf/i386-efi.rmk: Moved common parts to...
|
||||||
|
* conf/x86-efi.rmk: ... here.
|
||||||
|
* conf/i386.rmk: Added modules common to all x86 variants.
|
||||||
|
* configure.ac: Add -m32/-m64 to TARGET_ASFLAGS.
|
||||||
|
* disk/memdisk.c: Remove grub/machine/kernel.h.
|
||||||
|
* gensymlist.sh.in: Include symbol.h.
|
||||||
|
* hook/datehook.c: Correct module name.
|
||||||
|
* include/grub/datetime.h (grub_get_datetime) [GRUB_MACHINE_EMU]: Export.
|
||||||
|
(grub_set_datetime) [GRUB_MACHINE_EMU]: Likewise.
|
||||||
|
* include/grub/i386/efi/serial.h: New file.
|
||||||
|
* include/grub/x86_64/efi/serial.h: Likewise.
|
||||||
|
* util/time.c: Likewise.
|
||||||
|
* video/ieee1275.c (grub_video_ieee1275_setup): Handle 64-bit void *.
|
||||||
|
|
||||||
|
2010-03-14 Colin King <colin.king@ubuntu.com>
|
||||||
|
2010-03-14 Colin Watson <cjwatson@ubuntu.com>
|
||||||
|
|
||||||
|
Shrink the pre-partition-table part of boot.img by eight bytes.
|
||||||
|
|
||||||
|
* boot/i386/pc/boot.S (ERR): New macro.
|
||||||
|
(chs_mode): Use ERR.
|
||||||
|
(geometry_error): Likewise.
|
||||||
|
(hd_probe_error): Remove. This is only used once, so we wrwite
|
||||||
|
it inline instead.
|
||||||
|
(read_error): Instead of printing read_error_string, just set up
|
||||||
|
%si and fall through to ...
|
||||||
|
(error_message): ... this new function, also used by ERR.
|
||||||
|
|
||||||
|
2010-03-14 Colin Watson <cjwatson@ubuntu.com>
|
||||||
|
|
||||||
|
Speed up consecutive hostdisk operations on the same device.
|
||||||
|
|
||||||
|
* util/hostdisk.c (struct grub_util_biosdisk_data): New structure.
|
||||||
|
(grub_util_biosdisk_open): Initialise disk->data.
|
||||||
|
(struct linux_partition_cache): New structure.
|
||||||
|
(linux_find_partition): Cache partition start positions; these are
|
||||||
|
expensive to compute on every read and write.
|
||||||
|
(open_device): Cache open file descriptor in disk->data, so that we
|
||||||
|
don't have to reopen it and flush the buffer cache for consecutive
|
||||||
|
operations on the same device.
|
||||||
|
(grub_util_biosdisk_close): New function.
|
||||||
|
(grub_util_biosdisk_dev): Set `close' member.
|
||||||
|
|
||||||
|
* conf/common.rmk (grub_probe_SOURCES): Add kern/list.c.
|
||||||
|
* conf/i386-efi.rmk (grub_setup_SOURCES): Likewise.
|
||||||
|
* conf/i386-pc.rmk (grub_setup_SOURCES): Likewise.
|
||||||
|
* conf/sparc64-ieee1275.rmk (grub_setup_SOURCES): Likewise.
|
||||||
|
* conf/x86_64-efi.rmk (grub_setup_SOURCES): Likewise.
|
||||||
|
|
||||||
|
2010-03-14 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Compile parts of grub-emu as modules.
|
||||||
|
|
||||||
|
* Makefile.in (TARGET_CPPFLAGS) [emu]: Remove -nostdinc -isystem.
|
||||||
|
(pkglib_DATA) [emu]: Remove moddep.lst command.lst fs.lst
|
||||||
|
partmap.lst parttool.lst handler.lst video.lst crypto.lst terminal.lst.
|
||||||
|
(all-local): Add $(GRUB_EMU).
|
||||||
|
(install-local): Install $(GRUB_EMU).
|
||||||
|
(uninstall): Uninstall $(GRUB_EMU).
|
||||||
|
* commands/parttool.c: Replace GRUB_UTIL with GRUB_NO_MODULES.
|
||||||
|
* kern/dl.c: Likewise.
|
||||||
|
* commands/sleep.c: Not include machine/time.h.
|
||||||
|
* conf/any-emu.rmk (COMMON_LDFLAGS): New variable.
|
||||||
|
(COMMON_CFLAGS): Likewise.
|
||||||
|
(sbin_UTILITIES): Remove grub-emu.
|
||||||
|
(grub_emu_SOURCES): Removed.
|
||||||
|
(kernel_img_RELOCATABLE): New variable.
|
||||||
|
(pkglib_PROGRAMS): Add kernel.img.
|
||||||
|
(kernel_img_SOURCES): New variable
|
||||||
|
(kernel_img_CFLAGS): Likewise.
|
||||||
|
(kernel_img_LDFLAGS): Likewise.
|
||||||
|
(TARGET_NO_STRIP): Likewise.
|
||||||
|
(TARGET_NO_DYNAMIC_MODULES): Likewise.
|
||||||
|
(pkglib_MODULES): Add progname.mod, hostfs.mod, host.mod, reboot.mod,
|
||||||
|
halt.mod, cpuid.mod, usb.mod, sdl.mod and pci.mod.
|
||||||
|
(grub-emu): New target.
|
||||||
|
(GRUB_EMU): New variable.
|
||||||
|
* configure.ac: Whitelist -emu as possible x86_64 architecture.
|
||||||
|
* efiemu/main.c: Replace GRUB_UTIL with GRUB_MACHINE_EMU.
|
||||||
|
* loader/xnu.c: Likewise.
|
||||||
|
* include/grub/pci.h: Likewise.
|
||||||
|
* genemuinit.sh: New file.
|
||||||
|
* genemuinitheader.sh: Likewise.
|
||||||
|
* genmk.rb: Don't strip if TARGET_NO_STRIP is yes.
|
||||||
|
Support TARGET_NO_DYNAMIC_MODULES.
|
||||||
|
* include/grub/dl.h (GRUB_NO_MODULES): New variable.
|
||||||
|
* commands/search.c: Fix GRUB_MOD_INIT and GRUB_MOD_FINI arguments.
|
||||||
|
* disk/loopback.c: Likewise.
|
||||||
|
* font/font_cmd.c: Likewise.
|
||||||
|
* partmap/acorn.c: Likewise.
|
||||||
|
* partmap/amiga.c: Likewise.
|
||||||
|
* partmap/apple.c: Likewise.
|
||||||
|
* partmap/gpt.c: Likewise.
|
||||||
|
* partmap/msdos.c: Likewise.
|
||||||
|
* partmap/sun.c: Likewise.
|
||||||
|
* parttool/msdospart.c: Likewise.
|
||||||
|
* term/gfxterm.c: Likewise.
|
||||||
|
* video/bitmap.c: Likewise.
|
||||||
|
* video/readers/jpeg.c: Likewise.
|
||||||
|
* video/readers/png.c: Likewise.
|
||||||
|
* video/readers/tga.c: Likewise.
|
||||||
|
* video/video.c: Likewise.
|
||||||
|
* util/grub-emu.c (read_command_list): Removed.
|
||||||
|
(main): Don't call util_init_nls.
|
||||||
|
* util/misc.c (grub_err_printf) [!GRUB_UTIL]: Removed.
|
||||||
|
(grub_util_init_nls) [!GRUB_UTIL]: Likewise.
|
||||||
|
|
||||||
|
2010-03-14 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* conf/powerpc-ieee1275.rmk (pkglib_MODULES): Add datetime.mod,
|
||||||
|
date.mod, datehook.mod.
|
||||||
|
(datetime_mod_SOURCES): New variable.
|
||||||
|
(datetime_mod_CFLAGS): Likewise.
|
||||||
|
(datetime_mod_LDFLAGS): Likewise.
|
||||||
|
(date_mod_SOURCES): Likewise.
|
||||||
|
(date_mod_CFLAGS): Likewise.
|
||||||
|
(date_mod_LDFLAGS): Likewise.
|
||||||
|
(datehook_mod_SOURCES): Likewise.
|
||||||
|
(datehook_mod_CFLAGS): Likewise.
|
||||||
|
(datehook_mod_LDFLAGS): Likewise.
|
||||||
|
* conf/sparc64-ieee1275.rmk: Likewise.
|
||||||
|
* lib/ieee1275/datetime.c: New file.
|
||||||
|
|
||||||
|
2010-03-14 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* conf/powerpc-ieee1275.rmk (pkglib_MODULES): Add ieee1275_fb.mod.
|
||||||
|
(ieee1275_fb_mod_SOURCES): New variable.
|
||||||
|
(ieee1275_fb_mod_CFLAGS): Likewise.
|
||||||
|
(ieee1275_fb_mod_LDFLAGS): Likewise.
|
||||||
|
* include/grub/ieee1275/ieee1275.h (grub_ieee1275_devices_iterate):
|
||||||
|
New proto.
|
||||||
|
* kern/ieee1275/init.c (HEAP_MAX_SIZE): Increased.
|
||||||
|
(HEAP_MAX_ADDR): Likewise.
|
||||||
|
* kern/ieee1275/openfw.c (grub_children_iterate): Don't skip empty
|
||||||
|
type.
|
||||||
|
Correct stop condition.
|
||||||
|
(grub_ieee1275_devices_iterate): New function.
|
||||||
|
* video/ieee1275.c: New file.
|
||||||
|
|
||||||
|
2010-03-14 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Merge sparc grub-mkimage into generic grub-mkimage and a.out support.
|
||||||
|
|
||||||
|
* boot/sparc64/ieee1275/boot.S (boot_continue): Use SCRATCH_PAD_BOOT
|
||||||
|
as scratch.
|
||||||
|
* boot/sparc64/ieee1275/diskboot.S (after_info_block): Use
|
||||||
|
SCRATCH_PAD_DISKBOOT as scratch.
|
||||||
|
(bootit): Pass Openfirmware pointer in %o4.
|
||||||
|
* conf/sparc64-ieee1275.rmk (kernel_img_LDFLAGS): Link at 0x4400 instead
|
||||||
|
of 0x200000.
|
||||||
|
(grub_mkimage_SOURCES): Replace util/sparc64/ieee1275/grub-mkimage.c
|
||||||
|
with util/grub-mkrawimage.c.
|
||||||
|
* configure.ac: Handle GRUB_MACHINE_SPARC64 and GRUB_MACHINE_MIPS.
|
||||||
|
* include/grub/aout.h (AOUT_MID_SUN): New definition.
|
||||||
|
(grub_aout_get_type) [GRUB_UTIL]: Removed.
|
||||||
|
(grub_aout_load) [GRUB_UTIL]: Likewise.
|
||||||
|
* include/grub/kernel.h (grub_modules_get_end): New proto.
|
||||||
|
* include/grub/sparc64/ieee1275/boot.h (SCRATCH_PAD): Removed.
|
||||||
|
(SCRATCH_PAD_BOOT): New definition.
|
||||||
|
(SCRATCH_PAD_DISKBOOT): Likewise.
|
||||||
|
(GRUB_BOOT_MACHINE_IMAGE_ADDRESS): Set to 0x4400.
|
||||||
|
* include/grub/sparc64/ieee1275/ieee1275.h
|
||||||
|
(grub_ieee1275_original_stack): New variable
|
||||||
|
* include/grub/sparc64/ieee1275/kernel.h (GRUB_KERNEL_MACHINE_RAW_SIZE):
|
||||||
|
New definition
|
||||||
|
(GRUB_KERNEL_MACHINE_STACK_SIZE): Likewise.
|
||||||
|
(GRUB_PLATFORM_IMAGE_FORMATS): Likewise.
|
||||||
|
(GRUB_PLATFORM_IMAGE_DEFAULT_FORMAT): Likewise.
|
||||||
|
(GRUB_PLATFORM_IMAGE_DEFAULT): Likewise.
|
||||||
|
(GRUB_PLATFORM_IMAGE_RAW): Likewise.
|
||||||
|
(GRUB_PLATFORM_IMAGE_AOUT): Likewise.
|
||||||
|
(grub_platform_image_format_t): New type.
|
||||||
|
* kern/mips/yeeloong/init.c (grub_modules_get_end): Move from here ...
|
||||||
|
* kern/main.c (grub_modules_get_end)
|
||||||
|
[GRUB_MACHINE_MIPS_YEELOONG || GRUB_MACHINE_SPARC64]: ... here.
|
||||||
|
* kern/sparc64/ieee1275/crt0.S: Store firmware entry point in %o0.
|
||||||
|
(codestart): Switch stacks.
|
||||||
|
* kern/sparc64/ieee1275/init.c (grub_ieee1275_original_stack): New
|
||||||
|
variable.
|
||||||
|
(grub_heap_init): Use grub_modules_get_end.
|
||||||
|
* loader/sparc64/ieee1275/linux.c (grub_linux_boot): Restore original
|
||||||
|
stack.
|
||||||
|
* util/grub-mkrawimage.c (generate_image): Support sparc64.
|
||||||
|
(main): Likewise.
|
||||||
|
* util/sparc64/ieee1275/grub-mkimage.c: Removed.
|
||||||
|
|
||||||
|
2010-03-14 Thorsten Glaser <tg@mirbsd.org>
|
||||||
|
|
||||||
|
* util/grub-mkrescue.in: Base ISO UUID on UTC.
|
||||||
|
|
||||||
|
2010-03-08 Matt Kraai <kraai@ftbfs.org>
|
||||||
|
|
||||||
|
* util/i386/pc/grub-setup.c (setup): Fix a grammatical error (Debian
|
||||||
|
bug #559005).
|
||||||
|
|
||||||
2010-03-07 Vladimir Serbinenko <phcoder@gmail.com>
|
2010-03-07 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* genmoddep.awk: Output all missing symbols and not only first.
|
* genmoddep.awk: Output all missing symbols and not only first.
|
||||||
|
|
19
Makefile.in
19
Makefile.in
|
@ -79,21 +79,22 @@ LIBS = @LIBS@ $(LIBINTL)
|
||||||
|
|
||||||
CC = @CC@
|
CC = @CC@
|
||||||
CFLAGS = @CFLAGS@
|
CFLAGS = @CFLAGS@
|
||||||
|
GNULIB_CFLAGS = -Wno-undef -D_GL_UNUSED="__attribute__ ((unused))"
|
||||||
ASFLAGS = @ASFLAGS@
|
ASFLAGS = @ASFLAGS@
|
||||||
LDFLAGS = @LDFLAGS@ $(LIBS)
|
LDFLAGS = @LDFLAGS@ $(LIBS)
|
||||||
CPPFLAGS = @CPPFLAGS@ -I$(builddir) -I$(builddir)/include -I$(srcdir)/gnulib -I$(srcdir)/include -Wall -W \
|
CPPFLAGS = @CPPFLAGS@ -I$(builddir) -I$(builddir)/include -I$(srcdir)/gnulib -I$(srcdir)/include -Wall -W \
|
||||||
-DGRUB_LIBDIR=\"$(pkglibdir)\" -DLOCALEDIR=\"$(localedir)\"
|
-DGRUB_LIBDIR=\"$(pkglibdir)\" -DLOCALEDIR=\"$(localedir)\"
|
||||||
TARGET_CC = @TARGET_CC@
|
TARGET_CC = @TARGET_CC@
|
||||||
TARGET_CFLAGS = @TARGET_CFLAGS@
|
TARGET_CFLAGS = -ffreestanding @TARGET_CFLAGS@
|
||||||
TARGET_ASFLAGS = @TARGET_ASFLAGS@
|
TARGET_ASFLAGS = -nostdinc -fno-builtin @TARGET_ASFLAGS@
|
||||||
TARGET_MODULE_FORMAT = @TARGET_MODULE_FORMAT@
|
TARGET_MODULE_FORMAT = @TARGET_MODULE_FORMAT@
|
||||||
TARGET_APPLE_CC = @TARGET_APPLE_CC@
|
TARGET_APPLE_CC = @TARGET_APPLE_CC@
|
||||||
OBJCONV = @OBJCONV@
|
OBJCONV = @OBJCONV@
|
||||||
TARGET_CPPFLAGS = @TARGET_CPPFLAGS@ -I$(srcdir)/include -I$(builddir) -I$(builddir)/include \
|
TARGET_CPPFLAGS = @TARGET_CPPFLAGS@ -I$(srcdir)/include -I$(builddir) -I$(builddir)/include \
|
||||||
-Wall -W
|
-Wall -W
|
||||||
TARGET_LDFLAGS = @TARGET_LDFLAGS@
|
TARGET_LDFLAGS = -nostdlib @TARGET_LDFLAGS@
|
||||||
TARGET_IMG_LDSCRIPT = @TARGET_IMG_LDSCRIPT@
|
TARGET_IMG_LDSCRIPT = @TARGET_IMG_LDSCRIPT@
|
||||||
TARGET_IMG_LDFLAGS = @TARGET_IMG_LDFLAGS@
|
TARGET_IMG_LDFLAGS = -nostdlib @TARGET_IMG_LDFLAGS@
|
||||||
TARGET_IMG_CFLAGS = @TARGET_IMG_CFLAGS@
|
TARGET_IMG_CFLAGS = @TARGET_IMG_CFLAGS@
|
||||||
TARGET_OBJ2ELF = @TARGET_OBJ2ELF@
|
TARGET_OBJ2ELF = @TARGET_OBJ2ELF@
|
||||||
EXEEXT = @EXEEXT@
|
EXEEXT = @EXEEXT@
|
||||||
|
@ -116,6 +117,7 @@ LIBCURSES = @LIBCURSES@
|
||||||
LIBUSB = @LIBUSB@
|
LIBUSB = @LIBUSB@
|
||||||
LIBSDL = @LIBSDL@
|
LIBSDL = @LIBSDL@
|
||||||
LIBPCIACCESS = @LIBPCIACCESS@
|
LIBPCIACCESS = @LIBPCIACCESS@
|
||||||
|
LEX = @LEX@
|
||||||
YACC = @YACC@
|
YACC = @YACC@
|
||||||
FONT_SOURCE = @FONT_SOURCE@
|
FONT_SOURCE = @FONT_SOURCE@
|
||||||
|
|
||||||
|
@ -178,7 +180,9 @@ endif
|
||||||
### General targets.
|
### General targets.
|
||||||
|
|
||||||
CLEANFILES += $(pkglib_DATA) $(pkgdata_DATA) po/*.mo
|
CLEANFILES += $(pkglib_DATA) $(pkgdata_DATA) po/*.mo
|
||||||
|
ifneq ($(platform), emu)
|
||||||
pkglib_DATA += moddep.lst command.lst fs.lst partmap.lst parttool.lst handler.lst video.lst crypto.lst terminal.lst
|
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
|
moddep.lst: $(DEFSYMFILES) $(UNDSYMFILES) genmoddep.awk
|
||||||
cat $(DEFSYMFILES) /dev/null \
|
cat $(DEFSYMFILES) /dev/null \
|
||||||
| $(AWK) -f $(srcdir)/genmoddep.awk $(UNDSYMFILES) > $@ \
|
| $(AWK) -f $(srcdir)/genmoddep.awk $(UNDSYMFILES) > $@ \
|
||||||
|
@ -279,7 +283,7 @@ build_env.mk: Makefile
|
||||||
) > $@
|
) > $@
|
||||||
pkglib_BUILDDIR += config.h grub_script.tab.h
|
pkglib_BUILDDIR += config.h grub_script.tab.h
|
||||||
|
|
||||||
all-local: $(PROGRAMS) $(PKGLIB) $(PKGDATA) $(SCRIPTS) $(INFOS) $(MKFILES) $(foreach lang, $(LINGUAS), po/$(lang).mo)
|
all-local: $(PROGRAMS) $(GRUB_EMU) $(PKGLIB) $(PKGDATA) $(SCRIPTS) $(INFOS) $(MKFILES) $(foreach lang, $(LINGUAS), po/$(lang).mo)
|
||||||
|
|
||||||
install: install-local
|
install: install-local
|
||||||
|
|
||||||
|
@ -300,7 +304,7 @@ install-local: all
|
||||||
$(INSTALL_DATA) $$dir$$file $(DESTDIR)$(pkgdatadir)/$$dest; \
|
$(INSTALL_DATA) $$dir$$file $(DESTDIR)$(pkgdatadir)/$$dest; \
|
||||||
done
|
done
|
||||||
$(SHELL) $(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(mandir)/man1
|
$(SHELL) $(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(mandir)/man1
|
||||||
@list='$(bin_UTILITIES)'; for file in $$list; do \
|
@list='$(bin_UTILITIES) $(GRUB_EMU)'; for file in $$list; do \
|
||||||
if test -f "$$file"; then dir=; else dir="$(srcdir)/"; fi; \
|
if test -f "$$file"; then dir=; else dir="$(srcdir)/"; fi; \
|
||||||
dest="`echo $$file | sed 's,.*/,,' | sed '$(transform)'`"; \
|
dest="`echo $$file | sed 's,.*/,,' | sed '$(transform)'`"; \
|
||||||
$(INSTALL_PROGRAM) $$dir$$file $(DESTDIR)$(bindir)/$$dest; \
|
$(INSTALL_PROGRAM) $$dir$$file $(DESTDIR)$(bindir)/$$dest; \
|
||||||
|
@ -376,7 +380,7 @@ uninstall:
|
||||||
dest="`echo $$file | sed 's,.*/,,'`"; \
|
dest="`echo $$file | sed 's,.*/,,'`"; \
|
||||||
rm -f $(DESTDIR)$(pkgdatadir)/$$dest; \
|
rm -f $(DESTDIR)$(pkgdatadir)/$$dest; \
|
||||||
done
|
done
|
||||||
@list='$(bin_UTILITIES) $(bin_SCRIPTS)'; for file in $$list; do \
|
@list='$(bin_UTILITIES) $(bin_SCRIPTS) $(GRUB_EMU)'; for file in $$list; do \
|
||||||
dest="`echo $$file | sed 's,.*/,,' | sed '$(transform)'`"; \
|
dest="`echo $$file | sed 's,.*/,,' | sed '$(transform)'`"; \
|
||||||
rm -f $(DESTDIR)$(bindir)/$$dest; \
|
rm -f $(DESTDIR)$(bindir)/$$dest; \
|
||||||
rm -f $(DESTDIR)$(mandir)/man1/$$dest.1; \
|
rm -f $(DESTDIR)$(mandir)/man1/$$dest.1; \
|
||||||
|
@ -393,7 +397,6 @@ uninstall:
|
||||||
@list='$(lib_SCRIPTS)'; \
|
@list='$(lib_SCRIPTS)'; \
|
||||||
for file in $$list; do \
|
for file in $$list; do \
|
||||||
dest="`echo $$file | sed 's,.*/,,'`"; \
|
dest="`echo $$file | sed 's,.*/,,'`"; \
|
||||||
echo rm -f $(DESTDIR)$(libdir)/$$dest; \
|
|
||||||
rm -f $(DESTDIR)$(libdir)/grub/$$dest; \
|
rm -f $(DESTDIR)$(libdir)/grub/$$dest; \
|
||||||
done
|
done
|
||||||
@list='$(info_INFOS)'; \
|
@list='$(info_INFOS)'; \
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
/* Print message string */
|
/* Print message string */
|
||||||
#define MSG(x) movw $x, %si; call LOCAL(message)
|
#define MSG(x) movw $x, %si; call LOCAL(message)
|
||||||
|
#define ERR(x) movw $x, %si; jmp LOCAL(error_message)
|
||||||
|
|
||||||
.file "boot.S"
|
.file "boot.S"
|
||||||
|
|
||||||
|
@ -233,7 +234,7 @@ LOCAL(chs_mode):
|
||||||
jz LOCAL(floppy_probe)
|
jz LOCAL(floppy_probe)
|
||||||
|
|
||||||
/* Nope, we definitely have a hard disk, and we're screwed. */
|
/* Nope, we definitely have a hard disk, and we're screwed. */
|
||||||
jmp LOCAL(hd_probe_error)
|
ERR(hd_probe_error_string)
|
||||||
|
|
||||||
LOCAL(final_init):
|
LOCAL(final_init):
|
||||||
/* set the mode to zero */
|
/* set the mode to zero */
|
||||||
|
@ -360,22 +361,15 @@ LOCAL(copy_buffer):
|
||||||
* BIOS Geometry translation error (past the end of the disk geometry!).
|
* BIOS Geometry translation error (past the end of the disk geometry!).
|
||||||
*/
|
*/
|
||||||
LOCAL(geometry_error):
|
LOCAL(geometry_error):
|
||||||
MSG(geometry_error_string)
|
ERR(geometry_error_string)
|
||||||
jmp LOCAL(general_error)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Disk probe failure.
|
|
||||||
*/
|
|
||||||
LOCAL(hd_probe_error):
|
|
||||||
MSG(hd_probe_error_string)
|
|
||||||
jmp LOCAL(general_error)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read error on the disk.
|
* Read error on the disk.
|
||||||
*/
|
*/
|
||||||
LOCAL(read_error):
|
LOCAL(read_error):
|
||||||
MSG(read_error_string)
|
movw $read_error_string, %si
|
||||||
|
LOCAL(error_message):
|
||||||
|
call LOCAL(message)
|
||||||
LOCAL(general_error):
|
LOCAL(general_error):
|
||||||
MSG(general_error_string)
|
MSG(general_error_string)
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,7 @@ prom_call:
|
||||||
|
|
||||||
boot_continue:
|
boot_continue:
|
||||||
mov %o7, PIC_REG /* PIC base */
|
mov %o7, PIC_REG /* PIC base */
|
||||||
sethi %hi(SCRATCH_PAD), %l1 /* OF argument slots */
|
sethi %hi(SCRATCH_PAD_BOOT), %l1 /* OF argument slots */
|
||||||
|
|
||||||
/* Find the /chosen node so we can fetch the stdout handle,
|
/* Find the /chosen node so we can fetch the stdout handle,
|
||||||
* and thus perform console output.
|
* and thus perform console output.
|
||||||
|
|
|
@ -81,7 +81,7 @@ prom_call:
|
||||||
|
|
||||||
|
|
||||||
after_info_block:
|
after_info_block:
|
||||||
sethi %hi(SCRATCH_PAD), %l1 /* OF argument slots */
|
sethi %hi(SCRATCH_PAD_DISKBOOT), %l1 /* OF argument slots */
|
||||||
|
|
||||||
GET_ABS(notification_string, %o2)
|
GET_ABS(notification_string, %o2)
|
||||||
call console_write
|
call console_write
|
||||||
|
@ -129,7 +129,7 @@ bootit:
|
||||||
mov NOTIFICATION_DONE_LEN, %o3
|
mov NOTIFICATION_DONE_LEN, %o3
|
||||||
sethi %hi(GRUB_BOOT_MACHINE_IMAGE_ADDRESS), %o2
|
sethi %hi(GRUB_BOOT_MACHINE_IMAGE_ADDRESS), %o2
|
||||||
jmpl %o2 + %lo(GRUB_BOOT_MACHINE_IMAGE_ADDRESS), %o7
|
jmpl %o2 + %lo(GRUB_BOOT_MACHINE_IMAGE_ADDRESS), %o7
|
||||||
mov CIF_REG, %o0
|
mov CIF_REG, %o4
|
||||||
1: ba,a 1b
|
1: ba,a 1b
|
||||||
|
|
||||||
lastlist:
|
lastlist:
|
||||||
|
|
|
@ -90,8 +90,7 @@ grub_cmd_blocklist (grub_command_t cmd __attribute__ ((unused)),
|
||||||
return grub_error (GRUB_ERR_BAD_DEVICE,
|
return grub_error (GRUB_ERR_BAD_DEVICE,
|
||||||
"this command is available only for disk devices");
|
"this command is available only for disk devices");
|
||||||
|
|
||||||
if (file->device->disk->partition)
|
part_start = grub_partition_get_start (file->device->disk->partition);
|
||||||
part_start = grub_partition_get_start (file->device->disk->partition);
|
|
||||||
|
|
||||||
file->read_hook = read_blocklist;
|
file->read_hook = read_blocklist;
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#include <grub/symbol.h>
|
#include <grub/symbol.h>
|
||||||
|
|
||||||
#define INT13H_OFFSET(x) ((x) - EXT_C(grub_drivemap_handler))
|
#define INT13H_OFFSET(x) ((x) - LOCAL (base))
|
||||||
|
|
||||||
.code16
|
.code16
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
/* The replacement int13 handler. Preserve all registers. */
|
/* The replacement int13 handler. Preserve all registers. */
|
||||||
FUNCTION(grub_drivemap_handler)
|
FUNCTION(grub_drivemap_handler)
|
||||||
|
LOCAL (base):
|
||||||
/* Save %dx for future restore. */
|
/* Save %dx for future restore. */
|
||||||
push %dx
|
push %dx
|
||||||
/* Push flags. Used to simulate interrupt with original flags. */
|
/* Push flags. Used to simulate interrupt with original flags. */
|
||||||
|
@ -35,12 +36,7 @@ FUNCTION(grub_drivemap_handler)
|
||||||
/* Map the drive number (always in DL). */
|
/* Map the drive number (always in DL). */
|
||||||
push %ax
|
push %ax
|
||||||
push %bx
|
push %bx
|
||||||
#ifdef APPLE_CC
|
movw $INT13H_OFFSET(LOCAL (mapstart)), %bx
|
||||||
grub_drivemap_mapstart_ofs = INT13H_OFFSET(EXT_C(grub_drivemap_mapstart))
|
|
||||||
movw $grub_drivemap_mapstart_ofs, %bx
|
|
||||||
#else
|
|
||||||
movw $INT13H_OFFSET(EXT_C(grub_drivemap_mapstart)), %bx
|
|
||||||
#endif
|
|
||||||
|
|
||||||
more_remaining:
|
more_remaining:
|
||||||
movw %cs:(%bx), %ax
|
movw %cs:(%bx), %ax
|
||||||
|
@ -66,12 +62,7 @@ not_found:
|
||||||
popf
|
popf
|
||||||
pushf
|
pushf
|
||||||
|
|
||||||
#ifdef APPLE_CC
|
lcall *%cs:INT13H_OFFSET (LOCAL (oldhandler))
|
||||||
grub_drivemap_oldhandler_ofs = INT13H_OFFSET (EXT_C (grub_drivemap_oldhandler))
|
|
||||||
lcall *%cs:grub_drivemap_oldhandler_ofs
|
|
||||||
#else
|
|
||||||
lcall *%cs:INT13H_OFFSET (EXT_C (grub_drivemap_oldhandler))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
push %bp
|
push %bp
|
||||||
mov %sp, %bp
|
mov %sp, %bp
|
||||||
|
@ -94,11 +85,7 @@ norestore:
|
||||||
popf
|
popf
|
||||||
pushf
|
pushf
|
||||||
|
|
||||||
#ifdef APPLE_CC
|
lcall *%cs:INT13H_OFFSET (LOCAL (oldhandler))
|
||||||
lcall *%cs:grub_drivemap_oldhandler_ofs
|
|
||||||
#else
|
|
||||||
lcall *%cs:INT13H_OFFSET (EXT_C (grub_drivemap_oldhandler))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
push %bp
|
push %bp
|
||||||
mov %sp, %bp
|
mov %sp, %bp
|
||||||
|
@ -111,9 +98,13 @@ norestore:
|
||||||
/* Far pointer to the old handler. Stored as a CS:IP in the style of real-mode
|
/* Far pointer to the old handler. Stored as a CS:IP in the style of real-mode
|
||||||
IVT entries (thus PI:SC in mem). */
|
IVT entries (thus PI:SC in mem). */
|
||||||
VARIABLE(grub_drivemap_oldhandler)
|
VARIABLE(grub_drivemap_oldhandler)
|
||||||
|
LOCAL (oldhandler):
|
||||||
.word 0x0, 0x0
|
.word 0x0, 0x0
|
||||||
|
|
||||||
/* This label MUST be at the end of the copied block, since the installer code
|
/* This label MUST be at the end of the copied block, since the installer code
|
||||||
reserves additional space for mappings at runtime and copies them over it. */
|
reserves additional space for mappings at runtime and copies them over it. */
|
||||||
.align 2
|
.align 2
|
||||||
|
|
||||||
VARIABLE(grub_drivemap_mapstart)
|
VARIABLE(grub_drivemap_mapstart)
|
||||||
|
LOCAL (mapstart):
|
||||||
|
.byte 0
|
||||||
|
|
|
@ -235,10 +235,8 @@ check_blocklists (grub_envblk_t envblk, struct blocklist *blocklists,
|
||||||
/* One more sanity check. Re-read all sectors by blocklists, and compare
|
/* One more sanity check. Re-read all sectors by blocklists, and compare
|
||||||
those with the data read via a file. */
|
those with the data read via a file. */
|
||||||
disk = file->device->disk;
|
disk = file->device->disk;
|
||||||
if (disk->partition)
|
|
||||||
part_start = grub_partition_get_start (disk->partition);
|
part_start = grub_partition_get_start (disk->partition);
|
||||||
else
|
|
||||||
part_start = 0;
|
|
||||||
|
|
||||||
buf = grub_envblk_buffer (envblk);
|
buf = grub_envblk_buffer (envblk);
|
||||||
for (p = blocklists, index = 0; p; index += p->length, p = p->next)
|
for (p = blocklists, index = 0; p; index += p->length, p = p->next)
|
||||||
|
@ -268,10 +266,7 @@ write_blocklists (grub_envblk_t envblk, struct blocklist *blocklists,
|
||||||
|
|
||||||
buf = grub_envblk_buffer (envblk);
|
buf = grub_envblk_buffer (envblk);
|
||||||
disk = file->device->disk;
|
disk = file->device->disk;
|
||||||
if (disk->partition)
|
part_start = grub_partition_get_start (disk->partition);
|
||||||
part_start = grub_partition_get_start (disk->partition);
|
|
||||||
else
|
|
||||||
part_start = 0;
|
|
||||||
|
|
||||||
index = 0;
|
index = 0;
|
||||||
for (p = blocklists; p; index += p->length, p = p->next)
|
for (p = blocklists; p; index += p->length, p = p->next)
|
||||||
|
|
|
@ -16,7 +16,9 @@
|
||||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef GRUB_MACHINE_EMU
|
||||||
#include <grub/machine/memory.h>
|
#include <grub/machine/memory.h>
|
||||||
|
#endif
|
||||||
#include <grub/dl.h>
|
#include <grub/dl.h>
|
||||||
#include <grub/misc.h>
|
#include <grub/misc.h>
|
||||||
#include <grub/command.h>
|
#include <grub/command.h>
|
||||||
|
@ -34,7 +36,9 @@ grub_cmd_lsmmap (grub_command_t cmd __attribute__ ((unused)),
|
||||||
(long long) addr, (long long) size, type);
|
(long long) addr, (long long) size, type);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#ifndef GRUB_MACHINE_EMU
|
||||||
grub_machine_mmap_iterate (hook);
|
grub_machine_mmap_iterate (hook);
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,7 +175,7 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)),
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Load modules. */
|
/* Load modules. */
|
||||||
#ifndef GRUB_UTIL
|
#if GRUB_NO_MODULES
|
||||||
{
|
{
|
||||||
const char *prefix;
|
const char *prefix;
|
||||||
prefix = grub_env_get ("prefix");
|
prefix = grub_env_get ("prefix");
|
||||||
|
|
|
@ -149,11 +149,11 @@ grub_cmd_do_search (grub_command_t cmd __attribute__ ((unused)), int argc,
|
||||||
static grub_command_t cmd;
|
static grub_command_t cmd;
|
||||||
|
|
||||||
#ifdef DO_SEARCH_FILE
|
#ifdef DO_SEARCH_FILE
|
||||||
GRUB_MOD_INIT(search_file)
|
GRUB_MOD_INIT(search_fs_file)
|
||||||
#elif defined (DO_SEARCH_FS_UUID)
|
#elif defined (DO_SEARCH_FS_UUID)
|
||||||
GRUB_MOD_INIT(search_fs_uuid)
|
GRUB_MOD_INIT(search_fs_uuid)
|
||||||
#else
|
#else
|
||||||
GRUB_MOD_INIT(search_fs_label)
|
GRUB_MOD_INIT(search_label)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
cmd =
|
cmd =
|
||||||
|
@ -163,11 +163,11 @@ GRUB_MOD_INIT(search_fs_label)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DO_SEARCH_FILE
|
#ifdef DO_SEARCH_FILE
|
||||||
GRUB_MOD_FINI(search_file)
|
GRUB_MOD_FINI(search_fs_file)
|
||||||
#elif defined (DO_SEARCH_FS_UUID)
|
#elif defined (DO_SEARCH_FS_UUID)
|
||||||
GRUB_MOD_FINI(search_fs_uuid)
|
GRUB_MOD_FINI(search_fs_uuid)
|
||||||
#else
|
#else
|
||||||
GRUB_MOD_FINI(search_fs_label)
|
GRUB_MOD_FINI(search_label)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
grub_unregister_command (cmd);
|
grub_unregister_command (cmd);
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#include <grub/time.h>
|
#include <grub/time.h>
|
||||||
#include <grub/types.h>
|
#include <grub/types.h>
|
||||||
#include <grub/misc.h>
|
#include <grub/misc.h>
|
||||||
#include <grub/machine/time.h>
|
|
||||||
#include <grub/extcmd.h>
|
#include <grub/extcmd.h>
|
||||||
#include <grub/i18n.h>
|
#include <grub/i18n.h>
|
||||||
|
|
||||||
|
|
166
conf/any-emu.rmk
166
conf/any-emu.rmk
|
@ -1,129 +1,95 @@
|
||||||
# -*- makefile -*-
|
# -*- makefile -*-
|
||||||
|
|
||||||
# Used by various components. These rules need to precede them.
|
COMMON_LDFLAGS += -nostdlib
|
||||||
script/lexer.c_DEPENDENCIES = grub_script.tab.h
|
COMMON_CFLAGS += -nostdinc -isystem $(shell $(TARGET_CC) -print-file-name=include) -fno-builtin
|
||||||
|
|
||||||
sbin_UTILITIES += grub-emu
|
|
||||||
util/grub-emu.c_DEPENDENCIES = grub_emu_init.h
|
util/grub-emu.c_DEPENDENCIES = grub_emu_init.h
|
||||||
grub_emu_SOURCES = commands/minicmd.c commands/cat.c commands/cmp.c \
|
kernel_img_RELOCATABLE = yes
|
||||||
commands/configfile.c commands/echo.c commands/help.c \
|
pkglib_PROGRAMS = kernel.img
|
||||||
commands/handler.c commands/ls.c commands/test.c \
|
kernel_img_SOURCES = kern/device.c kern/disk.c kern/dl.c kern/env.c \
|
||||||
commands/search_wrap.c commands/search_file.c \
|
kern/err.c kern/list.c kern/handler.c kern/command.c \
|
||||||
commands/search_label.c commands/search_uuid.c \
|
kern/corecmd.c kern/file.c kern/fs.c kern/main.c kern/misc.c \
|
||||||
commands/blocklist.c commands/hexdump.c \
|
kern/parser.c kern/partition.c kern/term.c \
|
||||||
lib/hexdump.c commands/halt.c commands/reboot.c \
|
|
||||||
lib/envblk.c commands/loadenv.c \
|
|
||||||
commands/gptsync.c commands/probe.c commands/xnu_uuid.c \
|
|
||||||
commands/password.c commands/keystatus.c \
|
|
||||||
disk/host.c disk/loopback.c disk/scsi.c \
|
|
||||||
fs/fshelp.c \
|
|
||||||
\
|
|
||||||
io/gzio.c \
|
|
||||||
kern/device.c kern/disk.c kern/dl.c kern/elf.c kern/env.c \
|
|
||||||
kern/err.c kern/list.c kern/handler.c \
|
|
||||||
kern/command.c kern/corecmd.c commands/extcmd.c kern/file.c \
|
|
||||||
kern/fs.c commands/boot.c kern/main.c kern/misc.c kern/parser.c \
|
|
||||||
kern/partition.c kern/term.c \
|
|
||||||
kern/rescue_reader.c kern/rescue_parser.c \
|
kern/rescue_reader.c kern/rescue_parser.c \
|
||||||
lib/arg.c normal/cmdline.c normal/datetime.c normal/misc.c \
|
\
|
||||||
normal/handler.c normal/auth.c lib/crypto.c normal/autofs.c \
|
util/console.c util/grub-emu.c util/misc.c util/hostdisk.c \
|
||||||
normal/completion.c normal/main.c normal/color.c \
|
util/getroot.c util/time.c \
|
||||||
normal/menu.c normal/menu_entry.c \
|
\
|
||||||
normal/menu_text.c normal/crypto.c normal/term.c \
|
grub_emu_init.c gnulib/progname.c util/hostfs.c disk/host.c
|
||||||
commands/terminal.c normal/context.c lib/charset.c \
|
kernel_img_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -Wno-undef -I$(srcdir)/gnulib
|
||||||
script/main.c script/execute.c script/function.c \
|
kernel_img_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
script/lexer.c script/script.c grub_script.tab.c \
|
TARGET_NO_STRIP = yes
|
||||||
partmap/amiga.c partmap/apple.c partmap/msdos.c partmap/sun.c \
|
TARGET_NO_DYNAMIC_MODULES = yes
|
||||||
partmap/acorn.c partmap/gpt.c \
|
|
||||||
\
|
|
||||||
fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \
|
|
||||||
fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \
|
|
||||||
fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \
|
|
||||||
fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c \
|
|
||||||
fs/befs.c fs/befs_be.c fs/tar.c \
|
|
||||||
\
|
|
||||||
video/video.c video/fb/video_fb.c video/fb/fbblit.c \
|
|
||||||
video/fb/fbfill.c video/fb/fbutil.c commands/videotest.c \
|
|
||||||
video/bitmap.c video/bitmap_scale.c video/readers/tga.c \
|
|
||||||
video/readers/jpeg.c video/readers/png.c font/font_cmd.c \
|
|
||||||
font/font.c term/gfxterm.c io/bufio.c \
|
|
||||||
\
|
|
||||||
gfxmenu/gfxmenu.c gfxmenu/model.c gfxmenu/view.c \
|
|
||||||
gfxmenu/icon_manager.c gfxmenu/theme_loader.c \
|
|
||||||
gfxmenu/widget-box.c gfxmenu/gui_canvas.c \
|
|
||||||
gfxmenu/gui_circular_progress.c gfxmenu/gui_box.c \
|
|
||||||
gfxmenu/gui_label.c gfxmenu/gui_list.c gfxmenu/gui_image.c \
|
|
||||||
gfxmenu/gui_progress_bar.c gfxmenu/gui_util.c \
|
|
||||||
gfxmenu/gui_string_util.c gfxmenu/named_colors.c trigtables.c \
|
|
||||||
\
|
|
||||||
util/console.c util/hostfs.c util/grub-emu.c util/misc.c \
|
|
||||||
util/hostdisk.c util/getroot.c \
|
|
||||||
\
|
|
||||||
disk/raid.c disk/raid5_recover.c disk/raid6_recover.c \
|
|
||||||
disk/mdraid_linux.c disk/dmraid_nvidia.c disk/lvm.c \
|
|
||||||
commands/parttool.c parttool/msdospart.c \
|
|
||||||
lib/libgcrypt-grub/cipher/md5.c \
|
|
||||||
grub_emu_init.c gnulib/progname.c
|
|
||||||
grub_emu_CFLAGS += -Wno-missing-field-initializers -Wno-error -I$(srcdir)/lib/libgcrypt_wrap
|
|
||||||
|
|
||||||
|
# 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)
|
ifeq ($(target_cpu), i386)
|
||||||
grub_emu_SOURCES += commands/i386/cpuid.c
|
pkglib_MODULES += cpuid.mod
|
||||||
|
cpuid_mod_SOURCES = commands/i386/cpuid.c
|
||||||
|
cpuid_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
cpuid_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
grub_emu_LDFLAGS = $(LIBCURSES)
|
grub_emu_LDFLAGS = $(LIBCURSES)
|
||||||
|
|
||||||
ifeq ($(enable_grub_emu_usb), yes)
|
ifeq ($(enable_grub_emu_usb), yes)
|
||||||
grub_emu_SOURCES += disk/usbms.c util/usb.c bus/usb/usb.c \
|
pkglib_MODULES += libusb.mod
|
||||||
commands/usbtest.c
|
libusb_mod_SOURCES = util/usb.c
|
||||||
grub_emu_LDFLAGS += $(LIBCURSES) $(LIBUSB)
|
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
|
endif
|
||||||
|
|
||||||
ifeq ($(enable_grub_emu_sdl), yes)
|
ifeq ($(enable_grub_emu_sdl), yes)
|
||||||
grub_emu_SOURCES += util/sdl.c
|
pkglib_MODULES += sdl.mod
|
||||||
|
sdl_mod_SOURCES = util/sdl.c
|
||||||
|
sdl_mod_CFLAGS =
|
||||||
|
sdl_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
grub_emu_LDFLAGS += $(LIBSDL)
|
grub_emu_LDFLAGS += $(LIBSDL)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(enable_grub_emu_pci), yes)
|
ifeq ($(enable_grub_emu_pci), yes)
|
||||||
grub_emu_SOURCES += util/pci.c commands/lspci.c
|
pkglib_MODULES += pci.mod
|
||||||
|
pci_mod_SOURCES = util/pci.c commands/lspci.c
|
||||||
|
pci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
grub_emu_LDFLAGS += $(LIBPCIACCESS)
|
grub_emu_LDFLAGS += $(LIBPCIACCESS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
grub_emu_init.lst: geninit.sh $(filter-out grub_emu_init.c,$(grub_emu_SOURCES))
|
include $(srcdir)/conf/common.mk
|
||||||
rm -f $@; grep GRUB_MOD_INIT $(filter %.c,$^) /dev/null > $@
|
|
||||||
DISTCLEANFILES += grub_emu_init.lst
|
|
||||||
|
|
||||||
grub_emu_init.h: grub_emu_init.lst $(filter-out grub_emu_init.c,$(grub_emu_SOURCES)) geninitheader.sh
|
grub_emu_init.h: genemuinitheader.sh $(pkglib_MODULES)
|
||||||
rm -f $@; sh $(srcdir)/geninitheader.sh $< > $@
|
rm -f $@; echo $(pkglib_MODULES) | sh $(srcdir)/genemuinitheader.sh $(NM) > $@
|
||||||
DISTCLEANFILES += grub_emu_init.h
|
DISTCLEANFILES += grub_emu_init.h
|
||||||
|
|
||||||
grub_emu_init.c: grub_emu_init.lst $(filter-out grub_emu_init.c,$(grub_emu_SOURCES)) geninit.sh grub_emu_init.h
|
grub_emu_init.c: genemuinit.sh $(pkglib_MODULES)
|
||||||
rm -f $@; sh $(srcdir)/geninit.sh $< $(filter %.c,$^) > $@
|
rm -f $@; echo $(pkglib_MODULES) | sh $(srcdir)/genemuinit.sh $(NM) > $@
|
||||||
DISTCLEANFILES += grub_emu_init.c
|
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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# FIXME: this could be shared with common.rmk
|
|
||||||
|
|
||||||
trigtables.c: gentrigtables
|
|
||||||
./gentrigtables > $@
|
|
||||||
DISTCLEANFILES += trigtables.c
|
|
||||||
gentrigtables: gentrigtables.c
|
|
||||||
$(CC) -o $@ $^ $(CPPFLAGS) -lm
|
|
||||||
DISTCLEANFILES += gentrigtables
|
|
||||||
|
|
||||||
# For grub-mkfont.
|
|
||||||
ifeq ($(enable_grub_mkfont), yes)
|
|
||||||
bin_UTILITIES += grub-mkfont
|
|
||||||
grub_mkfont_SOURCES = gnulib/progname.c util/grub-mkfont.c util/misc.c
|
|
||||||
grub_mkfont_CFLAGS = $(freetype_cflags)
|
|
||||||
grub_mkfont_LDFLAGS = $(freetype_libs)
|
|
||||||
endif
|
|
||||||
|
|
||||||
grub_script.tab.c grub_script.tab.h: script/parser.y
|
|
||||||
$(YACC) -d -p grub_script_yy -b grub_script $(srcdir)/script/parser.y
|
|
||||||
DISTCLEANFILES += grub_script.tab.c grub_script.tab.h
|
|
||||||
|
|
||||||
bin_UTILITIES += grub-bin2h
|
|
||||||
grub_bin2h_SOURCES = gnulib/progname.c util/bin2h.c
|
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
# -*- makefile -*-
|
# -*- makefile -*-
|
||||||
|
|
||||||
|
# Used by various components. These rules need to precede them.
|
||||||
|
script/lexer.c_DEPENDENCIES = grub_script.tab.h
|
||||||
|
|
||||||
sbin_UTILITIES += grub-mkdevicemap
|
sbin_UTILITIES += grub-mkdevicemap
|
||||||
grub_mkdevicemap_SOURCES = gnulib/progname.c util/grub-mkdevicemap.c \
|
grub_mkdevicemap_SOURCES = gnulib/progname.c util/grub-mkdevicemap.c \
|
||||||
util/deviceiter.c \
|
util/deviceiter.c \
|
||||||
|
@ -24,7 +27,7 @@ util/grub-probe.c_DEPENDENCIES = grub_probe_init.h
|
||||||
grub_probe_SOURCES = gnulib/progname.c util/grub-probe.c \
|
grub_probe_SOURCES = gnulib/progname.c util/grub-probe.c \
|
||||||
util/hostdisk.c util/misc.c util/getroot.c \
|
util/hostdisk.c util/misc.c util/getroot.c \
|
||||||
kern/device.c kern/disk.c kern/err.c kern/misc.c \
|
kern/device.c kern/disk.c kern/err.c kern/misc.c \
|
||||||
kern/parser.c kern/partition.c kern/file.c \
|
kern/parser.c kern/partition.c kern/file.c kern/list.c \
|
||||||
\
|
\
|
||||||
fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \
|
fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \
|
||||||
fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \
|
fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \
|
||||||
|
@ -32,7 +35,8 @@ grub_probe_SOURCES = gnulib/progname.c util/grub-probe.c \
|
||||||
fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c \
|
fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c \
|
||||||
fs/befs.c fs/befs_be.c fs/tar.c \
|
fs/befs.c fs/befs_be.c fs/tar.c \
|
||||||
\
|
\
|
||||||
partmap/msdos.c partmap/apple.c partmap/sun.c partmap/gpt.c\
|
partmap/msdos.c partmap/bsdlabel.c partmap/apple.c \
|
||||||
|
partmap/sun.c partmap/sunpc.c partmap/gpt.c \
|
||||||
kern/fs.c kern/env.c fs/fshelp.c \
|
kern/fs.c kern/env.c fs/fshelp.c \
|
||||||
disk/raid.c disk/mdraid_linux.c disk/lvm.c grub_probe_init.c
|
disk/raid.c disk/mdraid_linux.c disk/lvm.c grub_probe_init.c
|
||||||
|
|
||||||
|
@ -52,7 +56,7 @@ grub_mkisofs_SOURCES = util/mkisofs/eltorito.c \
|
||||||
gnulib/error.c gnulib/progname.c
|
gnulib/error.c gnulib/progname.c
|
||||||
grub_mkisofs_CFLAGS = -D_FILE_OFFSET_BITS=64 \
|
grub_mkisofs_CFLAGS = -D_FILE_OFFSET_BITS=64 \
|
||||||
-I$(srcdir)/util/mkisofs/include \
|
-I$(srcdir)/util/mkisofs/include \
|
||||||
-Wno-all -Werror
|
-Wno-all -Werror $(GNULIB_CFLAGS)
|
||||||
|
|
||||||
# For grub-fstest.
|
# For grub-fstest.
|
||||||
util/grub-fstest.c_DEPENDENCIES = grub_fstest_init.h
|
util/grub-fstest.c_DEPENDENCIES = grub_fstest_init.h
|
||||||
|
@ -69,8 +73,8 @@ grub_fstest_SOURCES = gnulib/progname.c util/grub-fstest.c util/hostfs.c \
|
||||||
fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c fs/befs.c \
|
fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c fs/befs.c \
|
||||||
fs/befs_be.c fs/tar.c \
|
fs/befs_be.c fs/tar.c \
|
||||||
\
|
\
|
||||||
kern/partition.c partmap/msdos.c partmap/apple.c partmap/sun.c \
|
kern/partition.c partmap/msdos.c partmap/bsdlabel.c \
|
||||||
partmap/gpt.c \
|
partmap/apple.c partmap/sun.c partmap/sunpc.c partmap/gpt.c \
|
||||||
kern/fs.c kern/env.c fs/fshelp.c disk/raid.c \
|
kern/fs.c kern/env.c fs/fshelp.c disk/raid.c \
|
||||||
disk/raid5_recover.c disk/raid6_recover.c \
|
disk/raid5_recover.c disk/raid6_recover.c \
|
||||||
disk/mdraid_linux.c disk/dmraid_nvidia.c disk/lvm.c \
|
disk/mdraid_linux.c disk/dmraid_nvidia.c disk/lvm.c \
|
||||||
|
@ -91,6 +95,13 @@ grub_mkrelpath_SOURCES = gnulib/progname.c util/grub-mkrelpath.c util/misc.c
|
||||||
bin_UTILITIES += grub-bin2h
|
bin_UTILITIES += grub-bin2h
|
||||||
grub_bin2h_SOURCES = gnulib/progname.c util/bin2h.c
|
grub_bin2h_SOURCES = gnulib/progname.c util/bin2h.c
|
||||||
|
|
||||||
|
# For the lexer.
|
||||||
|
grub_script.yy.c grub_script.yy.h: script/yylex.l
|
||||||
|
$(LEX) -o grub_script.yy.c --header-file=grub_script.yy.h $(srcdir)/script/yylex.l
|
||||||
|
sed -i 's/^#include.*\(<stdio\.h>\|<string\.h>\|<errno\.h>\|<stdlib\.h>\|<unistd\.h>\)//g' grub_script.yy.h
|
||||||
|
sed -i 's/^#include.*\(<stdio\.h>\|<string\.h>\|<errno\.h>\|<stdlib\.h>\|<unistd\.h>\)//g' grub_script.yy.c
|
||||||
|
DISTCLEANFILES += grub_script.yy.c grub_script.yy.h
|
||||||
|
|
||||||
# For grub-script-check.
|
# For grub-script-check.
|
||||||
bin_UTILITIES += grub-script-check
|
bin_UTILITIES += grub-script-check
|
||||||
util/grub-script-check.c_DEPENDENCIES = grub_script_check_init.h
|
util/grub-script-check.c_DEPENDENCIES = grub_script_check_init.h
|
||||||
|
@ -98,7 +109,23 @@ grub_script_check_SOURCES = gnulib/progname.c gnulib/getdelim.c gnulib/getline.c
|
||||||
util/grub-script-check.c util/misc.c \
|
util/grub-script-check.c util/misc.c \
|
||||||
script/main.c script/script.c script/function.c script/lexer.c \
|
script/main.c script/script.c script/function.c script/lexer.c \
|
||||||
kern/handler.c kern/err.c kern/parser.c kern/list.c \
|
kern/handler.c kern/err.c kern/parser.c kern/list.c \
|
||||||
kern/misc.c kern/env.c grub_script_check_init.c grub_script.tab.c
|
kern/misc.c kern/env.c grub_script_check_init.c grub_script.tab.c \
|
||||||
|
grub_script.yy.c
|
||||||
|
grub_script_check_CFLAGS = $(GNULIB_CFLAGS)
|
||||||
|
MOSTLYCLEANFILES += symlist.c kernel_syms.lst
|
||||||
|
DEFSYMFILES += kernel_syms.lst
|
||||||
|
|
||||||
|
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 \
|
||||||
|
machine/memory.h machine/loader.h machine/kernel.h \
|
||||||
|
list.h handler.h command.h i18n.h env_private.h
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
# For the parser.
|
# For the parser.
|
||||||
grub_script.tab.c grub_script.tab.h: script/parser.y
|
grub_script.tab.c grub_script.tab.h: script/parser.y
|
||||||
|
@ -377,6 +404,16 @@ part_gpt_mod_SOURCES = partmap/gpt.c
|
||||||
part_gpt_mod_CFLAGS = $(COMMON_CFLAGS)
|
part_gpt_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
part_gpt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
part_gpt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
pkglib_MODULES += part_bsd.mod
|
||||||
|
part_bsd_mod_SOURCES = partmap/bsdlabel.c
|
||||||
|
part_bsd_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
part_bsd_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
pkglib_MODULES += part_sunpc.mod
|
||||||
|
part_sunpc_mod_SOURCES = partmap/sunpc.c
|
||||||
|
part_sunpc_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
part_sunpc_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
# Special disk structures and generic drivers
|
# Special disk structures and generic drivers
|
||||||
|
|
||||||
pkglib_MODULES += raid.mod raid5rec.mod raid6rec.mod mdraid.mod dm_nv.mod \
|
pkglib_MODULES += raid.mod raid5rec.mod raid6rec.mod mdraid.mod dm_nv.mod \
|
||||||
|
@ -617,7 +654,7 @@ normal_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
# For sh.mod.
|
# For sh.mod.
|
||||||
sh_mod_SOURCES = script/main.c script/script.c script/execute.c \
|
sh_mod_SOURCES = script/main.c script/script.c script/execute.c \
|
||||||
script/function.c script/lexer.c grub_script.tab.c
|
script/function.c script/lexer.c grub_script.tab.c grub_script.yy.c
|
||||||
sh_mod_CFLAGS = $(COMMON_CFLAGS)
|
sh_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
sh_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
sh_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
@ -775,6 +812,42 @@ password_pbkdf2_mod_SOURCES = commands/password_pbkdf2.c
|
||||||
password_pbkdf2_mod_CFLAGS = $(COMMON_CFLAGS)
|
password_pbkdf2_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
password_pbkdf2_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
password_pbkdf2_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For memdisk.mod.
|
||||||
|
pkglib_MODULES += memdisk.mod
|
||||||
|
memdisk_mod_SOURCES = disk/memdisk.c
|
||||||
|
memdisk_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
memdisk_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For reboot.mod.
|
||||||
|
pkglib_MODULES += reboot.mod
|
||||||
|
reboot_mod_SOURCES = commands/reboot.c
|
||||||
|
reboot_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
reboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For date.mod
|
||||||
|
pkglib_MODULES += date.mod
|
||||||
|
date_mod_SOURCES = commands/date.c
|
||||||
|
date_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
date_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For datehook.mod
|
||||||
|
pkglib_MODULES += datehook.mod
|
||||||
|
datehook_mod_SOURCES = hook/datehook.c
|
||||||
|
datehook_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
datehook_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For lsmmap.mod
|
||||||
|
pkglib_MODULES += lsmmap.mod
|
||||||
|
lsmmap_mod_SOURCES = commands/lsmmap.c
|
||||||
|
lsmmap_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
lsmmap_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)
|
||||||
|
|
||||||
bin_UTILITIES += grub-mkpasswd-pbkdf2
|
bin_UTILITIES += grub-mkpasswd-pbkdf2
|
||||||
grub_mkpasswd_pbkdf2_SOURCES = gnulib/progname.c gnulib/getdelim.c gnulib/getline.c util/grub-mkpasswd-pbkdf2.c lib/crypto.c lib/libgcrypt-grub/cipher/sha512.c lib/pbkdf2.c util/misc.c kern/err.c
|
grub_mkpasswd_pbkdf2_SOURCES = gnulib/progname.c gnulib/getdelim.c gnulib/getline.c util/grub-mkpasswd-pbkdf2.c lib/crypto.c lib/libgcrypt-grub/cipher/sha512.c lib/pbkdf2.c util/misc.c kern/err.c
|
||||||
grub_mkpasswd_pbkdf2_CFLAGS += -Wno-missing-field-initializers -Wno-error -I$(srcdir)/lib/libgcrypt_wrap -DGRUB_MKPASSWD=1
|
grub_mkpasswd_pbkdf2_CFLAGS += -Wno-missing-field-initializers -Wno-error -I$(srcdir)/lib/libgcrypt_wrap -DGRUB_MKPASSWD=1
|
||||||
|
|
|
@ -1,18 +1,11 @@
|
||||||
# -*- makefile -*-
|
# -*- makefile -*-
|
||||||
|
|
||||||
COMMON_ASFLAGS = -nostdinc -fno-builtin -m32
|
COMMON_CFLAGS = -mrtd -mregparm=3
|
||||||
COMMON_CFLAGS = -fno-builtin -mrtd -mregparm=3 -m32
|
|
||||||
COMMON_LDFLAGS = -m32 -nostdlib
|
|
||||||
|
|
||||||
# Used by various components. These rules need to precede them.
|
|
||||||
script/lexer.c_DEPENDENCIES = grub_script.tab.h
|
|
||||||
|
|
||||||
# Images.
|
# Images.
|
||||||
|
|
||||||
GRUB_KERNEL_MACHINE_LINK_ADDR = 0x8200
|
GRUB_KERNEL_MACHINE_LINK_ADDR = 0x8200
|
||||||
|
|
||||||
ifeq ($(platform), coreboot)
|
|
||||||
|
|
||||||
pkglib_PROGRAMS += kernel.img
|
pkglib_PROGRAMS += kernel.img
|
||||||
kernel_img_SOURCES = kern/i386/coreboot/startup.S \
|
kernel_img_SOURCES = kern/i386/coreboot/startup.S \
|
||||||
kern/i386/misc.S \
|
kern/i386/misc.S \
|
||||||
|
@ -31,74 +24,10 @@ kernel_img_SOURCES = kern/i386/coreboot/startup.S \
|
||||||
kern/env.c \
|
kern/env.c \
|
||||||
term/i386/pc/vga_text.c term/i386/vga_common.c \
|
term/i386/pc/vga_text.c term/i386/vga_common.c \
|
||||||
symlist.c
|
symlist.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 \
|
|
||||||
machine/boot.h machine/console.h machine/init.h \
|
|
||||||
machine/memory.h machine/loader.h list.h handler.h command.h i18n.h \
|
|
||||||
env_private.h
|
|
||||||
kernel_img_CFLAGS = $(COMMON_CFLAGS)
|
kernel_img_CFLAGS = $(COMMON_CFLAGS)
|
||||||
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
||||||
kernel_img_LDFLAGS = $(COMMON_LDFLAGS) -Wl,-N,-S,-Ttext,$(GRUB_KERNEL_MACHINE_LINK_ADDR),-Bstatic
|
kernel_img_LDFLAGS = $(COMMON_LDFLAGS) -Wl,-N,-S,-Ttext,$(GRUB_KERNEL_MACHINE_LINK_ADDR),-Bstatic
|
||||||
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(platform), qemu)
|
|
||||||
|
|
||||||
GRUB_BOOT_MACHINE_LINK_ADDR = 0xffe00
|
|
||||||
|
|
||||||
pkglib_IMAGES += boot.img
|
|
||||||
boot_img_SOURCES = boot/i386/qemu/boot.S
|
|
||||||
boot_img_ASFLAGS = $(COMMON_ASFLAGS) -DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)
|
|
||||||
boot_img_LDFLAGS = $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)$(GRUB_BOOT_MACHINE_LINK_ADDR)
|
|
||||||
boot_img_FORMAT = binary
|
|
||||||
|
|
||||||
bin_UTILITIES += grub-mkimage
|
|
||||||
grub_mkimage_SOURCES = util/grub-mkrawimage.c util/misc.c \
|
|
||||||
util/resolve.c gnulib/progname.c
|
|
||||||
grub_mkimage_CFLAGS = -DGRUB_KERNEL_MACHINE_LINK_ADDR=$(GRUB_KERNEL_MACHINE_LINK_ADDR)
|
|
||||||
util/grub-mkrawimage.c_DEPENDENCIES = Makefile
|
|
||||||
|
|
||||||
|
|
||||||
pkglib_IMAGES += kernel.img
|
|
||||||
kernel_img_SOURCES = kern/i386/qemu/startup.S \
|
|
||||||
kern/i386/misc.S \
|
|
||||||
kern/i386/coreboot/init.c \
|
|
||||||
kern/i386/qemu/mmap.c \
|
|
||||||
kern/i386/halt.c \
|
|
||||||
kern/main.c kern/device.c \
|
|
||||||
kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
|
|
||||||
kern/misc.c kern/mm.c kern/term.c \
|
|
||||||
kern/rescue_parser.c kern/rescue_reader.c \
|
|
||||||
kern/time.c kern/list.c kern/handler.c kern/command.c kern/corecmd.c \
|
|
||||||
kern/$(target_cpu)/dl.c kern/parser.c kern/partition.c \
|
|
||||||
kern/i386/tsc.c kern/i386/pit.c \
|
|
||||||
kern/generic/rtc_get_time_ms.c \
|
|
||||||
kern/generic/millisleep.c \
|
|
||||||
kern/env.c \
|
|
||||||
term/i386/pc/vga_text.c term/i386/vga_common.c \
|
|
||||||
symlist.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 \
|
|
||||||
machine/boot.h machine/console.h machine/init.h \
|
|
||||||
machine/memory.h machine/loader.h list.h handler.h command.h i18n.h \
|
|
||||||
env_private.h
|
|
||||||
kernel_img_CFLAGS = $(COMMON_CFLAGS) -DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)
|
|
||||||
kernel_img_ASFLAGS = $(COMMON_ASFLAGS) -DGRUB_KERNEL_MACHINE_LINK_ADDR=$(GRUB_KERNEL_MACHINE_LINK_ADDR)
|
|
||||||
kernel_img_LDFLAGS = $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)$(GRUB_KERNEL_MACHINE_LINK_ADDR)
|
|
||||||
kernel_img_FORMAT = binary
|
|
||||||
endif
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
sbin_SCRIPTS += grub-install
|
sbin_SCRIPTS += grub-install
|
||||||
grub_install_SOURCES = util/grub-install.in
|
grub_install_SOURCES = util/grub-install.in
|
||||||
|
|
||||||
|
@ -106,17 +35,7 @@ bin_SCRIPTS += grub-mkrescue
|
||||||
grub_mkrescue_SOURCES = util/grub-mkrescue.in
|
grub_mkrescue_SOURCES = util/grub-mkrescue.in
|
||||||
|
|
||||||
# Modules.
|
# Modules.
|
||||||
pkglib_MODULES = linux.mod \
|
pkglib_MODULES = linux.mod aout.mod halt.mod datetime.mod mmap.mod
|
||||||
aout.mod play.mod serial.mod \
|
|
||||||
memdisk.mod pci.mod lspci.mod reboot.mod \
|
|
||||||
halt.mod datetime.mod date.mod datehook.mod \
|
|
||||||
lsmmap.mod mmap.mod
|
|
||||||
|
|
||||||
# For boot.mod.
|
|
||||||
pkglib_MODULES += boot.mod
|
|
||||||
boot_mod_SOURCES = commands/boot.c
|
|
||||||
boot_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
boot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For mmap.mod.
|
# For mmap.mod.
|
||||||
mmap_mod_SOURCES = mmap/mmap.c mmap/i386/uppermem.c mmap/i386/mmap.c
|
mmap_mod_SOURCES = mmap/mmap.c mmap/i386/uppermem.c mmap/i386/mmap.c
|
||||||
|
@ -129,21 +48,11 @@ linux_mod_SOURCES = loader/i386/linux.c
|
||||||
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
# For reboot.mod.
|
|
||||||
reboot_mod_SOURCES = commands/reboot.c
|
|
||||||
reboot_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
reboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For halt.mod.
|
# For halt.mod.
|
||||||
halt_mod_SOURCES = commands/halt.c
|
halt_mod_SOURCES = commands/halt.c
|
||||||
halt_mod_CFLAGS = $(COMMON_CFLAGS)
|
halt_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
# For serial.mod.
|
|
||||||
serial_mod_SOURCES = term/serial.c
|
|
||||||
serial_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
serial_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For aout.mod.
|
# For aout.mod.
|
||||||
aout_mod_SOURCES = loader/aout.c
|
aout_mod_SOURCES = loader/aout.c
|
||||||
aout_mod_CFLAGS = $(COMMON_CFLAGS)
|
aout_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
@ -156,45 +65,10 @@ bsd_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
bsd_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
bsd_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
bsd_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
bsd_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||||
|
|
||||||
# For play.mod.
|
|
||||||
play_mod_SOURCES = commands/i386/pc/play.c
|
|
||||||
play_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
play_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For memdisk.mod.
|
|
||||||
memdisk_mod_SOURCES = disk/memdisk.c
|
|
||||||
memdisk_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
memdisk_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For pci.mod
|
|
||||||
pci_mod_SOURCES = bus/pci.c
|
|
||||||
pci_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
pci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For lspci.mod
|
|
||||||
lspci_mod_SOURCES = commands/lspci.c
|
|
||||||
lspci_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
lspci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For datetime.mod
|
# For datetime.mod
|
||||||
datetime_mod_SOURCES = lib/cmos_datetime.c
|
datetime_mod_SOURCES = lib/cmos_datetime.c
|
||||||
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
|
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
# For date.mod
|
|
||||||
date_mod_SOURCES = commands/date.c
|
|
||||||
date_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
date_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For datehook.mod
|
|
||||||
datehook_mod_SOURCES = hook/datehook.c
|
|
||||||
datehook_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
datehook_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For lsmmap.mod
|
|
||||||
lsmmap_mod_SOURCES = commands/lsmmap.c
|
|
||||||
lsmmap_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
lsmmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
include $(srcdir)/conf/i386.mk
|
include $(srcdir)/conf/i386.mk
|
||||||
include $(srcdir)/conf/common.mk
|
include $(srcdir)/conf/common.mk
|
||||||
|
|
|
@ -1,166 +1,5 @@
|
||||||
# -*- makefile -*-
|
# -*- makefile -*-
|
||||||
|
|
||||||
COMMON_ASFLAGS = -nostdinc -fno-builtin -m32
|
COMMON_LDFLAGS = -melf_i386
|
||||||
COMMON_CFLAGS = -fno-builtin -m32
|
|
||||||
COMMON_LDFLAGS = -melf_i386 -nostdlib
|
|
||||||
|
|
||||||
# Used by various components. These rules need to precede them.
|
include $(srcdir)/conf/x86-efi.mk
|
||||||
script/lexer.c_DEPENDENCIES = grub_script.tab.h
|
|
||||||
|
|
||||||
# Utilities.
|
|
||||||
bin_UTILITIES = grub-mkimage
|
|
||||||
|
|
||||||
# For grub-mkimage.
|
|
||||||
grub_mkimage_SOURCES = gnulib/progname.c util/i386/efi/grub-mkimage.c \
|
|
||||||
util/misc.c util/resolve.c
|
|
||||||
util/i386/efi/grub-mkimage.c_DEPENDENCIES = Makefile
|
|
||||||
|
|
||||||
# For grub-setup.
|
|
||||||
#grub_setup_SOURCES = util/i386/pc/grub-setup.c util/hostdisk.c \
|
|
||||||
# util/misc.c util/getroot.c kern/device.c kern/disk.c \
|
|
||||||
# kern/err.c kern/misc.c fs/fat.c fs/ext2.c fs/xfs.c fs/affs.c \
|
|
||||||
# fs/sfs.c kern/parser.c kern/partition.c partmap/msdos.c \
|
|
||||||
# fs/ufs.c fs/ufs2.c fs/minix.c fs/hfs.c fs/jfs.c fs/hfsplus.c kern/file.c \
|
|
||||||
# kern/fs.c kern/env.c fs/fshelp.c
|
|
||||||
|
|
||||||
# Scripts.
|
|
||||||
sbin_SCRIPTS = grub-install
|
|
||||||
|
|
||||||
# For grub-install.
|
|
||||||
grub_install_SOURCES = util/i386/efi/grub-install.in
|
|
||||||
|
|
||||||
# Modules.
|
|
||||||
pkglib_PROGRAMS = kernel.img
|
|
||||||
pkglib_MODULES = chain.mod appleldr.mod \
|
|
||||||
linux.mod halt.mod reboot.mod pci.mod lspci.mod \
|
|
||||||
datetime.mod date.mod datehook.mod loadbios.mod \
|
|
||||||
fixvideo.mod mmap.mod acpi.mod
|
|
||||||
|
|
||||||
# For kernel.img.
|
|
||||||
kernel_img_RELOCATABLE = yes
|
|
||||||
kernel_img_SOURCES = kern/i386/efi/startup.S kern/main.c kern/device.c \
|
|
||||||
kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
|
|
||||||
kern/misc.c kern/mm.c kern/term.c \
|
|
||||||
kern/rescue_parser.c kern/rescue_reader.c \
|
|
||||||
kern/$(target_cpu)/dl.c kern/i386/efi/init.c kern/parser.c kern/partition.c \
|
|
||||||
kern/env.c symlist.c kern/efi/efi.c kern/efi/init.c kern/efi/mm.c \
|
|
||||||
term/efi/console.c disk/efi/efidisk.c \
|
|
||||||
kern/time.c kern/list.c kern/handler.c kern/command.c kern/corecmd.c \
|
|
||||||
kern/i386/tsc.c kern/i386/pit.c \
|
|
||||||
kern/generic/rtc_get_time_ms.c \
|
|
||||||
kern/generic/millisleep.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 \
|
|
||||||
efi/efi.h efi/time.h efi/disk.h i386/pit.h list.h handler.h command.h \
|
|
||||||
i18n.h env_private.h
|
|
||||||
kernel_img_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
kernel_img_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
MOSTLYCLEANFILES += symlist.c
|
|
||||||
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)
|
|
||||||
|
|
||||||
# For boot.mod.
|
|
||||||
pkglib_MODULES += boot.mod
|
|
||||||
boot_mod_SOURCES = commands/boot.c
|
|
||||||
boot_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
boot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For acpi.mod.
|
|
||||||
acpi_mod_SOURCES = commands/acpi.c commands/efi/acpi.c
|
|
||||||
acpi_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
acpi_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For mmap.mod.
|
|
||||||
mmap_mod_SOURCES = mmap/mmap.c mmap/i386/uppermem.c mmap/i386/mmap.c \
|
|
||||||
mmap/efi/mmap.c
|
|
||||||
mmap_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
mmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For chain.mod.
|
|
||||||
chain_mod_SOURCES = loader/efi/chainloader.c
|
|
||||||
chain_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
chain_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For appleldr.mod.
|
|
||||||
appleldr_mod_SOURCES = loader/efi/appleloader.c
|
|
||||||
appleldr_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
appleldr_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For linux.mod.
|
|
||||||
linux_mod_SOURCES = loader/i386/efi/linux.c
|
|
||||||
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For halt.mod.
|
|
||||||
halt_mod_SOURCES = commands/halt.c
|
|
||||||
halt_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For reboot.mod.
|
|
||||||
reboot_mod_SOURCES = commands/reboot.c
|
|
||||||
reboot_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
reboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For pci.mod
|
|
||||||
pci_mod_SOURCES = bus/pci.c
|
|
||||||
pci_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
pci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For lspci.mod
|
|
||||||
lspci_mod_SOURCES = commands/lspci.c
|
|
||||||
lspci_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
lspci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For datetime.mod
|
|
||||||
datetime_mod_SOURCES = lib/efi/datetime.c
|
|
||||||
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For date.mod
|
|
||||||
date_mod_SOURCES = commands/date.c
|
|
||||||
date_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
date_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For datehook.mod
|
|
||||||
datehook_mod_SOURCES = hook/datehook.c
|
|
||||||
datehook_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
datehook_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For loadbios.mod
|
|
||||||
loadbios_mod_SOURCES = commands/efi/loadbios.c
|
|
||||||
loadbios_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
loadbios_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For fixvideo.mod
|
|
||||||
fixvideo_mod_SOURCES = commands/efi/fixvideo.c
|
|
||||||
fixvideo_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
fixvideo_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
pkglib_MODULES += efi_uga.mod
|
|
||||||
efi_uga_mod_SOURCES = video/efi_uga.c
|
|
||||||
efi_uga_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
efi_uga_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
pkglib_MODULES += efi_gop.mod
|
|
||||||
efi_gop_mod_SOURCES = video/efi_gop.c
|
|
||||||
efi_gop_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
efi_gop_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
pkglib_MODULES += xnu.mod
|
|
||||||
xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/i386/efi/xnu.c \
|
|
||||||
loader/macho32.c loader/macho64.c loader/macho.c loader/xnu.c
|
|
||||||
xnu_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
xnu_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
xnu_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
|
|
||||||
include $(srcdir)/conf/i386.mk
|
|
||||||
include $(srcdir)/conf/common.mk
|
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
# -*- makefile -*-
|
# -*- makefile -*-
|
||||||
|
|
||||||
COMMON_ASFLAGS = -m32 -nostdinc -fno-builtin
|
COMMON_CFLAGS = -mrtd -mregparm=3
|
||||||
COMMON_CFLAGS = -ffreestanding -mrtd -mregparm=3
|
|
||||||
COMMON_LDFLAGS = -nostdlib
|
|
||||||
|
|
||||||
# Used by various components. These rules need to precede them.
|
|
||||||
script/lexer.c_DEPENDENCIES = grub_script.tab.h
|
|
||||||
|
|
||||||
# Images.
|
# Images.
|
||||||
pkglib_PROGRAMS = kernel.img
|
pkglib_PROGRAMS = kernel.img
|
||||||
|
@ -29,24 +24,11 @@ kernel_img_SOURCES = kern/i386/ieee1275/startup.S \
|
||||||
term/ieee1275/ofconsole.c \
|
term/ieee1275/ofconsole.c \
|
||||||
disk/ieee1275/ofdisk.c \
|
disk/ieee1275/ofdisk.c \
|
||||||
symlist.c
|
symlist.c
|
||||||
kernel_img_HEADERS = cache.h device.h disk.h dl.h elf.h elfload.h \
|
kernel_img_HEADERS += ieee1275/ieee1275.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 \
|
|
||||||
ieee1275/ieee1275.h machine/kernel.h machine/loader.h machine/memory.h \
|
|
||||||
list.h handler.h command.h i18n.h env_private.h
|
|
||||||
kernel_img_CFLAGS = $(COMMON_CFLAGS)
|
kernel_img_CFLAGS = $(COMMON_CFLAGS)
|
||||||
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
||||||
kernel_img_LDFLAGS = $(COMMON_LDFLAGS) -Wl,-N,-S,-Ttext,0x10000,-Bstatic
|
kernel_img_LDFLAGS = $(COMMON_LDFLAGS) -Wl,-N,-S,-Ttext,0x10000,-Bstatic
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
# Scripts.
|
# Scripts.
|
||||||
sbin_SCRIPTS = grub-install
|
sbin_SCRIPTS = grub-install
|
||||||
|
|
||||||
|
@ -54,16 +36,10 @@ sbin_SCRIPTS = grub-install
|
||||||
grub_install_SOURCES = util/ieee1275/grub-install.in
|
grub_install_SOURCES = util/ieee1275/grub-install.in
|
||||||
|
|
||||||
# Modules.
|
# Modules.
|
||||||
pkglib_MODULES = halt.mod reboot.mod suspend.mod \
|
pkglib_MODULES = halt.mod suspend.mod \
|
||||||
aout.mod serial.mod linux.mod \
|
aout.mod linux.mod \
|
||||||
nand.mod memdisk.mod pci.mod lspci.mod datetime.mod \
|
nand.mod datetime.mod \
|
||||||
date.mod datehook.mod lsmmap.mod mmap.mod
|
mmap.mod
|
||||||
|
|
||||||
# For boot.mod.
|
|
||||||
pkglib_MODULES += boot.mod
|
|
||||||
boot_mod_SOURCES = commands/boot.c
|
|
||||||
boot_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
boot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For mmap.mod.
|
# For mmap.mod.
|
||||||
mmap_mod_SOURCES = mmap/mmap.c mmap/i386/uppermem.c mmap/i386/mmap.c
|
mmap_mod_SOURCES = mmap/mmap.c mmap/i386/uppermem.c mmap/i386/mmap.c
|
||||||
|
@ -81,21 +57,11 @@ suspend_mod_SOURCES = commands/ieee1275/suspend.c
|
||||||
suspend_mod_CFLAGS = $(COMMON_CFLAGS)
|
suspend_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
suspend_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
suspend_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
# For reboot.mod
|
|
||||||
reboot_mod_SOURCES = commands/reboot.c
|
|
||||||
reboot_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
reboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For halt.mod
|
# For halt.mod
|
||||||
halt_mod_SOURCES = commands/halt.c
|
halt_mod_SOURCES = commands/halt.c
|
||||||
halt_mod_CFLAGS = $(COMMON_CFLAGS)
|
halt_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
# For serial.mod.
|
|
||||||
serial_mod_SOURCES = term/serial.c
|
|
||||||
serial_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
serial_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For linux.mod.
|
# For linux.mod.
|
||||||
linux_mod_SOURCES = loader/i386/ieee1275/linux.c
|
linux_mod_SOURCES = loader/i386/ieee1275/linux.c
|
||||||
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
@ -106,40 +72,10 @@ nand_mod_SOURCES = disk/ieee1275/nand.c
|
||||||
nand_mod_CFLAGS = $(COMMON_CFLAGS)
|
nand_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
nand_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
nand_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
# For memdisk.mod.
|
|
||||||
memdisk_mod_SOURCES = disk/memdisk.c
|
|
||||||
memdisk_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
memdisk_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For pci.mod
|
|
||||||
pci_mod_SOURCES = bus/pci.c
|
|
||||||
pci_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
pci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For lspci.mod
|
|
||||||
lspci_mod_SOURCES = commands/lspci.c
|
|
||||||
lspci_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
lspci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For datetime.mod
|
# For datetime.mod
|
||||||
datetime_mod_SOURCES = lib/cmos_datetime.c
|
datetime_mod_SOURCES = lib/cmos_datetime.c
|
||||||
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
|
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
# For date.mod
|
|
||||||
date_mod_SOURCES = commands/date.c
|
|
||||||
date_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
date_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For datehook.mod
|
|
||||||
datehook_mod_SOURCES = hook/datehook.c
|
|
||||||
datehook_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
datehook_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For lsmmap.mod
|
|
||||||
lsmmap_mod_SOURCES = commands/lsmmap.c
|
|
||||||
lsmmap_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
lsmmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
include $(srcdir)/conf/i386.mk
|
include $(srcdir)/conf/i386.mk
|
||||||
include $(srcdir)/conf/common.mk
|
include $(srcdir)/conf/common.mk
|
||||||
|
|
102
conf/i386-pc.rmk
102
conf/i386-pc.rmk
|
@ -2,12 +2,7 @@
|
||||||
|
|
||||||
GRUB_KERNEL_MACHINE_LINK_ADDR = 0x8200
|
GRUB_KERNEL_MACHINE_LINK_ADDR = 0x8200
|
||||||
|
|
||||||
COMMON_ASFLAGS = -nostdinc -fno-builtin -m32
|
COMMON_CFLAGS = -mrtd -mregparm=3
|
||||||
COMMON_CFLAGS = -fno-builtin -mrtd -mregparm=3 -m32
|
|
||||||
COMMON_LDFLAGS = -m32 -nostdlib
|
|
||||||
|
|
||||||
# Used by various components. These rules need to precede them.
|
|
||||||
script/lexer.c_DEPENDENCIES = grub_script.tab.h
|
|
||||||
|
|
||||||
# Images.
|
# Images.
|
||||||
pkglib_IMAGES = boot.img cdboot.img diskboot.img kernel.img lnxboot.img \
|
pkglib_IMAGES = boot.img cdboot.img diskboot.img kernel.img lnxboot.img \
|
||||||
|
@ -59,27 +54,13 @@ kernel_img_SOURCES = kern/i386/pc/startup.S \
|
||||||
kern/env.c \
|
kern/env.c \
|
||||||
term/i386/pc/console.c term/i386/vga_common.c \
|
term/i386/pc/console.c term/i386/vga_common.c \
|
||||||
symlist.c
|
symlist.c
|
||||||
kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \
|
kernel_img_HEADERS += machine/biosdisk.h machine/vga.h machine/vbe.h \
|
||||||
env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \
|
machine/pxe.h i386/pit.h
|
||||||
partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \
|
|
||||||
machine/biosdisk.h machine/boot.h machine/console.h machine/init.h \
|
|
||||||
machine/memory.h machine/loader.h machine/vga.h machine/vbe.h \
|
|
||||||
machine/kernel.h machine/pxe.h i386/pit.h list.h handler.h command.h \
|
|
||||||
i18n.h env_private.h
|
|
||||||
kernel_img_CFLAGS = $(COMMON_CFLAGS) $(TARGET_IMG_CFLAGS)
|
kernel_img_CFLAGS = $(COMMON_CFLAGS) $(TARGET_IMG_CFLAGS)
|
||||||
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
||||||
kernel_img_LDFLAGS = $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)$(GRUB_KERNEL_MACHINE_LINK_ADDR) $(COMMON_CFLAGS)
|
kernel_img_LDFLAGS = $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)$(GRUB_KERNEL_MACHINE_LINK_ADDR) $(COMMON_CFLAGS)
|
||||||
kernel_img_FORMAT = binary
|
kernel_img_FORMAT = binary
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
# Utilities.
|
# Utilities.
|
||||||
bin_UTILITIES = grub-mkimage
|
bin_UTILITIES = grub-mkimage
|
||||||
sbin_UTILITIES = grub-setup
|
sbin_UTILITIES = grub-setup
|
||||||
|
@ -96,18 +77,20 @@ grub_setup_SOURCES = gnulib/progname.c \
|
||||||
util/i386/pc/grub-setup.c util/hostdisk.c \
|
util/i386/pc/grub-setup.c util/hostdisk.c \
|
||||||
util/misc.c util/getroot.c kern/device.c kern/disk.c \
|
util/misc.c util/getroot.c kern/device.c kern/disk.c \
|
||||||
kern/err.c kern/misc.c kern/parser.c kern/partition.c \
|
kern/err.c kern/misc.c kern/parser.c kern/partition.c \
|
||||||
kern/file.c kern/fs.c kern/env.c fs/fshelp.c \
|
kern/file.c kern/fs.c kern/env.c kern/list.c \
|
||||||
|
fs/fshelp.c \
|
||||||
\
|
\
|
||||||
fs/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c \
|
fs/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c \
|
||||||
fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \
|
fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \
|
||||||
fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \
|
fs/ntfs.c fs/ntfscomp.c fs/reiserfs.c fs/sfs.c \
|
||||||
fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c \
|
fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c \
|
||||||
fs/befs.c fs/befs_be.c fs/tar.c \
|
fs/befs.c fs/befs_be.c fs/tar.c \
|
||||||
\
|
\
|
||||||
partmap/msdos.c partmap/gpt.c \
|
partmap/msdos.c partmap/bsdlabel.c partmap/sunpc.c \
|
||||||
|
partmap/gpt.c \
|
||||||
\
|
\
|
||||||
disk/raid.c disk/mdraid_linux.c disk/lvm.c \
|
disk/raid.c disk/mdraid_linux.c disk/lvm.c \
|
||||||
util/raid.c util/lvm.c \
|
util/raid.c util/lvm.c \
|
||||||
grub_setup_init.c
|
grub_setup_init.c
|
||||||
|
|
||||||
sbin_SCRIPTS += grub-install
|
sbin_SCRIPTS += grub-install
|
||||||
|
@ -117,20 +100,14 @@ bin_SCRIPTS += grub-mkrescue
|
||||||
grub_mkrescue_SOURCES = util/grub-mkrescue.in
|
grub_mkrescue_SOURCES = util/grub-mkrescue.in
|
||||||
|
|
||||||
pkglib_MODULES = biosdisk.mod chain.mod \
|
pkglib_MODULES = biosdisk.mod chain.mod \
|
||||||
reboot.mod halt.mod \
|
halt.mod \
|
||||||
vbe.mod vbetest.mod vbeinfo.mod play.mod serial.mod \
|
vbe.mod vbetest.mod vbeinfo.mod \
|
||||||
vga.mod memdisk.mod pci.mod lspci.mod \
|
vga.mod \
|
||||||
aout.mod bsd.mod pxe.mod pxecmd.mod datetime.mod date.mod \
|
aout.mod bsd.mod pxe.mod pxecmd.mod datetime.mod \
|
||||||
datehook.mod lsmmap.mod ata_pthru.mod hdparm.mod \
|
ata_pthru.mod hdparm.mod \
|
||||||
usb.mod uhci.mod ohci.mod usbtest.mod usbms.mod usb_keyboard.mod \
|
usb.mod uhci.mod ohci.mod usbtest.mod usbms.mod usb_keyboard.mod \
|
||||||
efiemu.mod mmap.mod acpi.mod drivemap.mod
|
efiemu.mod mmap.mod acpi.mod drivemap.mod
|
||||||
|
|
||||||
# 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 drivemap.mod.
|
# For drivemap.mod.
|
||||||
drivemap_mod_SOURCES = commands/i386/pc/drivemap.c \
|
drivemap_mod_SOURCES = commands/i386/pc/drivemap.c \
|
||||||
commands/i386/pc/drivemap_int13h.S
|
commands/i386/pc/drivemap_int13h.S
|
||||||
|
@ -187,21 +164,11 @@ xnu_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
xnu_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
xnu_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
xnu_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
xnu_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||||
|
|
||||||
# For reboot.mod.
|
|
||||||
reboot_mod_SOURCES = commands/reboot.c
|
|
||||||
reboot_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
reboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For halt.mod.
|
# For halt.mod.
|
||||||
halt_mod_SOURCES = commands/i386/pc/halt.c
|
halt_mod_SOURCES = commands/i386/pc/halt.c
|
||||||
halt_mod_CFLAGS = $(COMMON_CFLAGS)
|
halt_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
# For serial.mod.
|
|
||||||
serial_mod_SOURCES = term/serial.c
|
|
||||||
serial_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
serial_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For vbe.mod.
|
# For vbe.mod.
|
||||||
vbe_mod_SOURCES = video/i386/pc/vbe.c
|
vbe_mod_SOURCES = video/i386/pc/vbe.c
|
||||||
vbe_mod_CFLAGS = $(COMMON_CFLAGS)
|
vbe_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
@ -217,31 +184,11 @@ vbetest_mod_SOURCES = commands/i386/pc/vbetest.c
|
||||||
vbetest_mod_CFLAGS = $(COMMON_CFLAGS)
|
vbetest_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
vbetest_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
vbetest_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
# For play.mod.
|
|
||||||
play_mod_SOURCES = commands/i386/pc/play.c
|
|
||||||
play_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
play_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For vga.mod.
|
# For vga.mod.
|
||||||
vga_mod_SOURCES = term/i386/pc/vga.c
|
vga_mod_SOURCES = term/i386/pc/vga.c
|
||||||
vga_mod_CFLAGS = $(COMMON_CFLAGS)
|
vga_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
vga_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
vga_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
# For memdisk.mod.
|
|
||||||
memdisk_mod_SOURCES = disk/memdisk.c
|
|
||||||
memdisk_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
memdisk_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For pci.mod
|
|
||||||
pci_mod_SOURCES = bus/pci.c
|
|
||||||
pci_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
pci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For lspci.mod
|
|
||||||
lspci_mod_SOURCES = commands/lspci.c
|
|
||||||
lspci_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
lspci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For aout.mod
|
# For aout.mod
|
||||||
aout_mod_SOURCES = loader/aout.c
|
aout_mod_SOURCES = loader/aout.c
|
||||||
aout_mod_CFLAGS = $(COMMON_CFLAGS)
|
aout_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
@ -298,21 +245,6 @@ datetime_mod_SOURCES = lib/cmos_datetime.c
|
||||||
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
|
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
# For date.mod
|
|
||||||
date_mod_SOURCES = commands/date.c
|
|
||||||
date_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
date_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For datehook.mod
|
|
||||||
datehook_mod_SOURCES = hook/datehook.c
|
|
||||||
datehook_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
datehook_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For lsmmap.mod
|
|
||||||
lsmmap_mod_SOURCES = commands/lsmmap.c
|
|
||||||
lsmmap_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
lsmmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For ata_pthru.mod.
|
# For ata_pthru.mod.
|
||||||
ata_pthru_mod_SOURCES = disk/ata_pthru.c
|
ata_pthru_mod_SOURCES = disk/ata_pthru.c
|
||||||
ata_pthru_mod_CFLAGS = $(COMMON_CFLAGS)
|
ata_pthru_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
|
|
@ -1,2 +1,88 @@
|
||||||
# -*- makefile -*-
|
# -*- makefile -*-
|
||||||
include $(srcdir)/conf/i386-coreboot.mk
|
|
||||||
|
COMMON_CFLAGS = -mrtd -mregparm=3
|
||||||
|
|
||||||
|
# Images.
|
||||||
|
|
||||||
|
GRUB_KERNEL_MACHINE_LINK_ADDR = 0x8200
|
||||||
|
GRUB_BOOT_MACHINE_LINK_ADDR = 0xffe00
|
||||||
|
|
||||||
|
pkglib_IMAGES += boot.img
|
||||||
|
boot_img_SOURCES = boot/i386/qemu/boot.S
|
||||||
|
boot_img_ASFLAGS = $(COMMON_ASFLAGS) -DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)
|
||||||
|
boot_img_LDFLAGS = $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)$(GRUB_BOOT_MACHINE_LINK_ADDR)
|
||||||
|
boot_img_FORMAT = binary
|
||||||
|
|
||||||
|
bin_UTILITIES += grub-mkimage
|
||||||
|
grub_mkimage_SOURCES = util/grub-mkrawimage.c util/misc.c \
|
||||||
|
util/resolve.c gnulib/progname.c
|
||||||
|
grub_mkimage_CFLAGS = -DGRUB_KERNEL_MACHINE_LINK_ADDR=$(GRUB_KERNEL_MACHINE_LINK_ADDR)
|
||||||
|
util/grub-mkrawimage.c_DEPENDENCIES = Makefile
|
||||||
|
|
||||||
|
pkglib_IMAGES += kernel.img
|
||||||
|
kernel_img_SOURCES = kern/i386/qemu/startup.S \
|
||||||
|
kern/i386/misc.S \
|
||||||
|
kern/i386/coreboot/init.c \
|
||||||
|
kern/i386/qemu/mmap.c \
|
||||||
|
kern/i386/halt.c \
|
||||||
|
kern/main.c kern/device.c \
|
||||||
|
kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
|
||||||
|
kern/misc.c kern/mm.c kern/term.c \
|
||||||
|
kern/rescue_parser.c kern/rescue_reader.c \
|
||||||
|
kern/time.c kern/list.c kern/handler.c kern/command.c kern/corecmd.c \
|
||||||
|
kern/$(target_cpu)/dl.c kern/parser.c kern/partition.c \
|
||||||
|
kern/i386/tsc.c kern/i386/pit.c \
|
||||||
|
kern/generic/rtc_get_time_ms.c \
|
||||||
|
kern/generic/millisleep.c \
|
||||||
|
kern/env.c \
|
||||||
|
term/i386/pc/vga_text.c term/i386/vga_common.c \
|
||||||
|
symlist.c
|
||||||
|
kernel_img_CFLAGS = $(COMMON_CFLAGS) -DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)
|
||||||
|
kernel_img_ASFLAGS = $(COMMON_ASFLAGS) -DGRUB_KERNEL_MACHINE_LINK_ADDR=$(GRUB_KERNEL_MACHINE_LINK_ADDR)
|
||||||
|
kernel_img_LDFLAGS = $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)$(GRUB_KERNEL_MACHINE_LINK_ADDR)
|
||||||
|
kernel_img_FORMAT = binary
|
||||||
|
|
||||||
|
sbin_SCRIPTS += grub-install
|
||||||
|
grub_install_SOURCES = util/grub-install.in
|
||||||
|
|
||||||
|
bin_SCRIPTS += grub-mkrescue
|
||||||
|
grub_mkrescue_SOURCES = util/grub-mkrescue.in
|
||||||
|
|
||||||
|
# Modules.
|
||||||
|
pkglib_MODULES = linux.mod aout.mod halt.mod datetime.mod mmap.mod
|
||||||
|
|
||||||
|
# For mmap.mod.
|
||||||
|
mmap_mod_SOURCES = mmap/mmap.c mmap/i386/uppermem.c mmap/i386/mmap.c
|
||||||
|
mmap_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
mmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
mmap_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||||
|
|
||||||
|
# For linux.mod.
|
||||||
|
linux_mod_SOURCES = loader/i386/linux.c
|
||||||
|
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For halt.mod.
|
||||||
|
halt_mod_SOURCES = commands/halt.c
|
||||||
|
halt_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For aout.mod.
|
||||||
|
aout_mod_SOURCES = loader/aout.c
|
||||||
|
aout_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
aout_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For bsd.mod
|
||||||
|
pkglib_MODULES += bsd.mod
|
||||||
|
bsd_mod_SOURCES = loader/i386/bsd.c loader/i386/bsd32.c loader/i386/bsd64.c loader/i386/bsd_helper.S loader/i386/bsd_trampoline.S
|
||||||
|
bsd_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
bsd_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
bsd_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||||
|
|
||||||
|
# For datetime.mod
|
||||||
|
datetime_mod_SOURCES = lib/cmos_datetime.c
|
||||||
|
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
include $(srcdir)/conf/i386.mk
|
||||||
|
include $(srcdir)/conf/common.mk
|
||||||
|
|
|
@ -33,17 +33,38 @@ setpci_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
setpci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
setpci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
pkglib_MODULES += multiboot.mod
|
pkglib_MODULES += multiboot.mod
|
||||||
multiboot_mod_SOURCES = loader/i386/multiboot.c \
|
multiboot_mod_SOURCES = loader/multiboot.c loader/i386/multiboot_mbi.c
|
||||||
loader/i386/multiboot_mbi.c \
|
|
||||||
loader/multiboot_loader.c
|
|
||||||
multiboot_mod_CFLAGS = $(COMMON_CFLAGS)
|
multiboot_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
multiboot_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
multiboot_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||||
|
|
||||||
pkglib_MODULES += multiboot2.mod
|
pkglib_MODULES += multiboot2.mod
|
||||||
multiboot2_mod_SOURCES = loader/i386/multiboot.c \
|
multiboot2_mod_SOURCES = loader/multiboot.c loader/multiboot_mbi2.c
|
||||||
loader/i386/multiboot_mbi.c \
|
|
||||||
loader/multiboot_loader.c
|
|
||||||
multiboot2_mod_CFLAGS = $(COMMON_CFLAGS) -DGRUB_USE_MULTIBOOT2
|
multiboot2_mod_CFLAGS = $(COMMON_CFLAGS) -DGRUB_USE_MULTIBOOT2
|
||||||
multiboot2_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
multiboot2_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
multiboot2_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
multiboot2_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||||
|
|
||||||
|
# For serial.mod.
|
||||||
|
pkglib_MODULES += serial.mod
|
||||||
|
serial_mod_SOURCES = term/serial.c
|
||||||
|
serial_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
serial_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For pci.mod
|
||||||
|
pkglib_MODULES += pci.mod
|
||||||
|
pci_mod_SOURCES = bus/pci.c
|
||||||
|
pci_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
pci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For lspci.mod
|
||||||
|
pkglib_MODULES += lspci.mod
|
||||||
|
lspci_mod_SOURCES = commands/lspci.c
|
||||||
|
lspci_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
lspci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For play.mod.
|
||||||
|
pkglib_MODULES += play.mod
|
||||||
|
play_mod_SOURCES = commands/i386/pc/play.c
|
||||||
|
play_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
play_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@ target_machine=yeeloong
|
||||||
COMMON_CFLAGS += -march=mips3
|
COMMON_CFLAGS += -march=mips3
|
||||||
COMMON_ASFLAGS += -march=mips3
|
COMMON_ASFLAGS += -march=mips3
|
||||||
|
|
||||||
kernel_img_HEADERS += bitmap.h video.h gfxterm.h font.h bitmap_scale.h bufio.h \
|
kernel_img_HEADERS += pci.h bitmap.h video.h gfxterm.h font.h \
|
||||||
cs5536.h
|
bitmap_scale.h bufio.h cs5536.h
|
||||||
|
|
||||||
include $(srcdir)/conf/mips.mk
|
include $(srcdir)/conf/mips.mk
|
||||||
|
|
||||||
|
@ -74,18 +74,6 @@ datetime_mod_SOURCES = lib/cmos_datetime.c
|
||||||
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
|
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
# For date.mod
|
|
||||||
pkglib_MODULES += date.mod
|
|
||||||
date_mod_SOURCES = commands/date.c
|
|
||||||
date_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
date_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For datehook.mod
|
|
||||||
pkglib_MODULES += datehook.mod
|
|
||||||
datehook_mod_SOURCES = hook/datehook.c
|
|
||||||
datehook_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
datehook_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For lsspd.mod
|
# For lsspd.mod
|
||||||
pkglib_MODULES += lsspd.mod
|
pkglib_MODULES += lsspd.mod
|
||||||
lsspd_mod_SOURCES = commands/mips/yeeloong/lsspd.c
|
lsspd_mod_SOURCES = commands/mips/yeeloong/lsspd.c
|
||||||
|
@ -104,12 +92,5 @@ halt_mod_SOURCES = commands/halt.c
|
||||||
halt_mod_CFLAGS = $(COMMON_CFLAGS)
|
halt_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
# For reboot.mod.
|
|
||||||
pkglib_MODULES += reboot.mod
|
|
||||||
reboot_mod_SOURCES = commands/reboot.c
|
|
||||||
reboot_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
reboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
sbin_SCRIPTS += grub-install
|
sbin_SCRIPTS += grub-install
|
||||||
grub_install_SOURCES = util/grub-install.in
|
grub_install_SOURCES = util/grub-install.in
|
||||||
|
|
||||||
|
|
|
@ -1,33 +1,10 @@
|
||||||
|
|
||||||
# -*- makefile -*-
|
# -*- makefile -*-
|
||||||
|
|
||||||
COMMON_ASFLAGS += -nostdinc
|
COMMON_CFLAGS += -mexplicit-relocs -mflush-func=grub_cpu_flush_cache
|
||||||
COMMON_CFLAGS += -ffreestanding -mexplicit-relocs -mflush-func=grub_cpu_flush_cache
|
|
||||||
COMMON_LDFLAGS += -nostdlib
|
|
||||||
|
|
||||||
# Used by various components. These rules need to precede them.
|
|
||||||
script/lexer.c_DEPENDENCIES = grub_script.tab.h
|
|
||||||
|
|
||||||
# Images.
|
# Images.
|
||||||
|
kernel_img_HEADERS += cpu/libgcc.h cpu/cache.h
|
||||||
MOSTLYCLEANFILES += symlist.c kernel_syms.lst
|
|
||||||
DEFSYMFILES += kernel_syms.lst
|
|
||||||
|
|
||||||
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 misc.h mm.h net.h parser.h reader.h \
|
|
||||||
symbol.h term.h time.h types.h loader.h partition.h \
|
|
||||||
msdos_partition.h machine/kernel.h handler.h list.h \
|
|
||||||
command.h machine/memory.h cpu/libgcc.h cpu/cache.h i18n.h env_private.h
|
|
||||||
|
|
||||||
ifeq ($(platform), yeeloong)
|
|
||||||
kernel_img_HEADERS += pci.h
|
|
||||||
endif
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
# Scripts.
|
# Scripts.
|
||||||
sbin_SCRIPTS =
|
sbin_SCRIPTS =
|
||||||
|
@ -40,26 +17,6 @@ grub_mkimage_SOURCES = gnulib/progname.c util/grub-mkrawimage.c util/misc.c \
|
||||||
grub_mkimage_CFLAGS = -DGRUB_KERNEL_MACHINE_LINK_ADDR=$(LINK_BASE)
|
grub_mkimage_CFLAGS = -DGRUB_KERNEL_MACHINE_LINK_ADDR=$(LINK_BASE)
|
||||||
util/grub-mkrawimage.c_DEPENDENCIES = Makefile
|
util/grub-mkrawimage.c_DEPENDENCIES = Makefile
|
||||||
|
|
||||||
# Modules.
|
|
||||||
pkglib_MODULES = memdisk.mod \
|
|
||||||
lsmmap.mod
|
|
||||||
|
|
||||||
# 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 memdisk.mod.
|
|
||||||
memdisk_mod_SOURCES = disk/memdisk.c
|
|
||||||
memdisk_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
memdisk_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For lsmmap.mod
|
|
||||||
lsmmap_mod_SOURCES = commands/lsmmap.c
|
|
||||||
lsmmap_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
lsmmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For serial.mod.
|
# For serial.mod.
|
||||||
pkglib_MODULES += serial.mod
|
pkglib_MODULES += serial.mod
|
||||||
serial_mod_SOURCES = term/serial.c
|
serial_mod_SOURCES = term/serial.c
|
||||||
|
@ -73,4 +30,11 @@ relocator_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
relocator_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
relocator_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||||
relocator_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
relocator_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
pkglib_MODULES += multiboot2.mod
|
||||||
|
multiboot2_mod_SOURCES = loader/multiboot.c \
|
||||||
|
loader/multiboot_mbi2.c
|
||||||
|
multiboot2_mod_CFLAGS = $(COMMON_CFLAGS) -DGRUB_USE_MULTIBOOT2
|
||||||
|
multiboot2_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
multiboot2_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||||
|
|
||||||
include $(srcdir)/conf/common.mk
|
include $(srcdir)/conf/common.mk
|
||||||
|
|
|
@ -1,29 +1,9 @@
|
||||||
|
|
||||||
# -*- makefile -*-
|
# -*- makefile -*-
|
||||||
|
|
||||||
COMMON_ASFLAGS = -nostdinc -D__ASSEMBLY__
|
|
||||||
COMMON_CFLAGS = -ffreestanding
|
|
||||||
COMMON_LDFLAGS += -nostdlib
|
|
||||||
|
|
||||||
# Used by various components. These rules need to precede them.
|
|
||||||
script/lexer.c_DEPENDENCIES = grub_script.tab.h
|
|
||||||
|
|
||||||
# Images.
|
# Images.
|
||||||
|
|
||||||
MOSTLYCLEANFILES += symlist.c kernel_syms.lst
|
kernel_img_HEADERS += cpu/libgcc.h ieee1275/ieee1275.h
|
||||||
DEFSYMFILES += kernel_syms.lst
|
|
||||||
|
|
||||||
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 misc.h mm.h net.h parser.h reader.h \
|
|
||||||
symbol.h term.h time.h types.h powerpc/libgcc.h loader.h partition.h \
|
|
||||||
msdos_partition.h ieee1275/ieee1275.h machine/kernel.h handler.h list.h \
|
|
||||||
command.h i18n.h env_private.h
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
# Programs
|
# Programs
|
||||||
pkglib_PROGRAMS = kernel.img
|
pkglib_PROGRAMS = kernel.img
|
||||||
|
@ -57,47 +37,33 @@ grub_install_SOURCES = util/ieee1275/grub-install.in
|
||||||
grub_mkrescue_SOURCES = util/powerpc/ieee1275/grub-mkrescue.in
|
grub_mkrescue_SOURCES = util/powerpc/ieee1275/grub-mkrescue.in
|
||||||
|
|
||||||
# Modules.
|
# Modules.
|
||||||
pkglib_MODULES = halt.mod \
|
pkglib_MODULES += ieee1275_fb.mod
|
||||||
linux.mod \
|
ieee1275_fb_mod_SOURCES = video/ieee1275.c
|
||||||
reboot.mod \
|
ieee1275_fb_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
suspend.mod \
|
ieee1275_fb_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
memdisk.mod \
|
|
||||||
lsmmap.mod
|
|
||||||
|
|
||||||
# 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 linux.mod.
|
# For linux.mod.
|
||||||
|
pkglib_MODULES += linux.mod
|
||||||
linux_mod_SOURCES = loader/powerpc/ieee1275/linux.c
|
linux_mod_SOURCES = loader/powerpc/ieee1275/linux.c
|
||||||
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
# For suspend.mod
|
# For suspend.mod
|
||||||
|
pkglib_MODULES += suspend.mod
|
||||||
suspend_mod_SOURCES = commands/ieee1275/suspend.c
|
suspend_mod_SOURCES = commands/ieee1275/suspend.c
|
||||||
suspend_mod_CFLAGS = $(COMMON_CFLAGS)
|
suspend_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
suspend_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
suspend_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
# For reboot.mod
|
|
||||||
reboot_mod_SOURCES = commands/reboot.c
|
|
||||||
reboot_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
reboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For halt.mod
|
# For halt.mod
|
||||||
|
pkglib_MODULES += halt.mod
|
||||||
halt_mod_SOURCES = commands/halt.c
|
halt_mod_SOURCES = commands/halt.c
|
||||||
halt_mod_CFLAGS = $(COMMON_CFLAGS)
|
halt_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
# For memdisk.mod.
|
# For datetime.mod
|
||||||
memdisk_mod_SOURCES = disk/memdisk.c
|
pkglib_MODULES += datetime.mod
|
||||||
memdisk_mod_CFLAGS = $(COMMON_CFLAGS)
|
datetime_mod_SOURCES = lib/ieee1275/datetime.c
|
||||||
memdisk_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
# For lsmmap.mod
|
|
||||||
lsmmap_mod_SOURCES = commands/lsmmap.c
|
|
||||||
lsmmap_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
lsmmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
include $(srcdir)/conf/common.mk
|
include $(srcdir)/conf/common.mk
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
|
|
||||||
# -*- makefile -*-
|
# -*- makefile -*-
|
||||||
|
|
||||||
COMMON_ASFLAGS = -nostdinc -m64
|
COMMON_CFLAGS = -mno-app-regs
|
||||||
COMMON_CFLAGS = -ffreestanding -m64 -mno-app-regs
|
COMMON_LDFLAGS = -melf64_sparc -mno-relax
|
||||||
COMMON_LDFLAGS = -melf64_sparc -nostdlib -mno-relax
|
|
||||||
|
|
||||||
# Used by various components. These rules need to precede them.
|
|
||||||
script/lexer.c_DEPENDENCIES = grub_script.tab.h
|
|
||||||
|
|
||||||
# Images.
|
# Images.
|
||||||
pkglib_IMAGES = boot.img diskboot.img kernel.img
|
pkglib_IMAGES = boot.img diskboot.img kernel.img
|
||||||
|
@ -23,15 +19,7 @@ diskboot_img_ASFLAGS = $(COMMON_ASFLAGS)
|
||||||
diskboot_img_LDFLAGS = $(COMMON_LDFLAGS) -Wl,-N,-Ttext,0x4200
|
diskboot_img_LDFLAGS = $(COMMON_LDFLAGS) -Wl,-N,-Ttext,0x4200
|
||||||
diskboot_img_FORMAT = binary
|
diskboot_img_FORMAT = binary
|
||||||
|
|
||||||
MOSTLYCLEANFILES += symlist.c kernel_syms.lst
|
kernel_img_HEADERS += cpu/libgcc.h ieee1275/ieee1275.h cpu/ieee1275/ieee1275.h
|
||||||
DEFSYMFILES += kernel_syms.lst
|
|
||||||
|
|
||||||
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 \
|
|
||||||
sparc64/libgcc.h ieee1275/ieee1275.h machine/kernel.h \
|
|
||||||
sparc64/ieee1275/ieee1275.h env_private.h
|
|
||||||
kernel_img_SOURCES = kern/sparc64/ieee1275/crt0.S kern/ieee1275/cmain.c \
|
kernel_img_SOURCES = kern/sparc64/ieee1275/crt0.S kern/ieee1275/cmain.c \
|
||||||
kern/ieee1275/ieee1275.c kern/main.c kern/device.c \
|
kern/ieee1275/ieee1275.c kern/main.c kern/device.c \
|
||||||
kern/disk.c kern/dl.c kern/err.c kern/file.c kern/fs.c \
|
kern/disk.c kern/dl.c kern/err.c kern/file.c kern/fs.c \
|
||||||
|
@ -48,21 +36,15 @@ kernel_img_SOURCES = kern/sparc64/ieee1275/crt0.S kern/ieee1275/cmain.c \
|
||||||
symlist.c kern/$(target_cpu)/cache.S
|
symlist.c kern/$(target_cpu)/cache.S
|
||||||
kernel_img_CFLAGS = $(COMMON_CFLAGS)
|
kernel_img_CFLAGS = $(COMMON_CFLAGS)
|
||||||
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
||||||
kernel_img_LDFLAGS = -nostdlib -Wl,-N,-Ttext,0x200000,-Bstatic,-melf64_sparc -static-libgcc -lgcc
|
kernel_img_LDFLAGS = -nostdlib -Wl,-N,-Ttext,0x4400,-Bstatic,-melf64_sparc -static-libgcc -lgcc
|
||||||
kernel_img_FORMAT = binary
|
kernel_img_FORMAT = binary
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
# Utilities.
|
# Utilities.
|
||||||
bin_UTILITIES = grub-mkimage
|
bin_UTILITIES = grub-mkimage
|
||||||
sbin_UTILITIES = grub-setup grub-ofpathname
|
sbin_UTILITIES = grub-setup grub-ofpathname
|
||||||
|
|
||||||
# For grub-mkimage.
|
# For grub-mkimage.
|
||||||
grub_mkimage_SOURCES = util/sparc64/ieee1275/grub-mkimage.c util/misc.c \
|
grub_mkimage_SOURCES = util/grub-mkrawimage.c util/misc.c \
|
||||||
util/resolve.c gnulib/progname.c
|
util/resolve.c gnulib/progname.c
|
||||||
|
|
||||||
# For grub-setup.
|
# For grub-setup.
|
||||||
|
@ -70,7 +52,8 @@ util/sparc64/ieee1275/grub-setup.c_DEPENDENCIES = grub_setup_init.h
|
||||||
grub_setup_SOURCES = util/sparc64/ieee1275/grub-setup.c util/hostdisk.c \
|
grub_setup_SOURCES = util/sparc64/ieee1275/grub-setup.c util/hostdisk.c \
|
||||||
util/misc.c util/getroot.c kern/device.c kern/disk.c \
|
util/misc.c util/getroot.c kern/device.c kern/disk.c \
|
||||||
kern/err.c kern/misc.c kern/parser.c kern/partition.c \
|
kern/err.c kern/misc.c kern/parser.c kern/partition.c \
|
||||||
kern/file.c kern/fs.c kern/env.c fs/fshelp.c \
|
kern/file.c kern/fs.c kern/env.c kern/list.c \
|
||||||
|
fs/fshelp.c \
|
||||||
\
|
\
|
||||||
fs/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c \
|
fs/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c \
|
||||||
fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \
|
fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \
|
||||||
|
@ -78,11 +61,11 @@ grub_setup_SOURCES = util/sparc64/ieee1275/grub-setup.c util/hostdisk.c \
|
||||||
fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c \
|
fs/ufs.c fs/ufs2.c fs/xfs.c fs/afs.c fs/afs_be.c \
|
||||||
fs/befs.c fs/befs_be.c fs/tar.c \
|
fs/befs.c fs/befs_be.c fs/tar.c \
|
||||||
\
|
\
|
||||||
partmap/amiga.c partmap/apple.c partmap/msdos.c \
|
partmap/amiga.c partmap/apple.c partmap/msdos.c \
|
||||||
partmap/sun.c partmap/acorn.c \
|
partmap/bsdlabel.c partmap/sun.c partmap/acorn.c \
|
||||||
\
|
\
|
||||||
disk/raid.c disk/mdraid_linux.c disk/lvm.c \
|
disk/raid.c disk/mdraid_linux.c disk/lvm.c \
|
||||||
util/raid.c util/lvm.c gnulib/progname.c \
|
util/raid.c util/lvm.c gnulib/progname.c \
|
||||||
grub_setup_init.c
|
grub_setup_init.c
|
||||||
|
|
||||||
# For grub-ofpathname.
|
# For grub-ofpathname.
|
||||||
|
@ -96,41 +79,27 @@ sbin_SCRIPTS = grub-install
|
||||||
grub_install_SOURCES = util/grub-install.in
|
grub_install_SOURCES = util/grub-install.in
|
||||||
|
|
||||||
# Modules.
|
# Modules.
|
||||||
pkglib_MODULES = halt.mod \
|
pkglib_MODULES += ieee1275_fb.mod
|
||||||
linux.mod \
|
ieee1275_fb_mod_SOURCES = video/ieee1275.c
|
||||||
reboot.mod \
|
ieee1275_fb_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
memdisk.mod \
|
ieee1275_fb_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
lsmmap.mod
|
|
||||||
|
|
||||||
# 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 linux.mod.
|
# For linux.mod.
|
||||||
|
pkglib_MODULES += linux.mod
|
||||||
linux_mod_SOURCES = loader/sparc64/ieee1275/linux.c
|
linux_mod_SOURCES = loader/sparc64/ieee1275/linux.c
|
||||||
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
# For reboot.mod.
|
|
||||||
reboot_mod_SOURCES = commands/reboot.c
|
|
||||||
reboot_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
reboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For halt.mod.
|
# For halt.mod.
|
||||||
|
pkglib_MODULES += halt.mod
|
||||||
halt_mod_SOURCES = commands/halt.c
|
halt_mod_SOURCES = commands/halt.c
|
||||||
halt_mod_CFLAGS = $(COMMON_CFLAGS)
|
halt_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
# For memdisk.mod.
|
# For datetime.mod
|
||||||
memdisk_mod_SOURCES = disk/memdisk.c
|
pkglib_MODULES += datetime.mod
|
||||||
memdisk_mod_CFLAGS = $(COMMON_CFLAGS)
|
datetime_mod_SOURCES = lib/ieee1275/datetime.c
|
||||||
memdisk_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
# For lsmmap.mod
|
|
||||||
lsmmap_mod_SOURCES = commands/lsmmap.c
|
|
||||||
lsmmap_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
lsmmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
include $(srcdir)/conf/common.mk
|
include $(srcdir)/conf/common.mk
|
||||||
|
|
|
@ -37,12 +37,40 @@ example_scripted_test_SOURCES = tests/example_scripted_test.in
|
||||||
check_SCRIPTS += example_grub_script_test
|
check_SCRIPTS += example_grub_script_test
|
||||||
example_grub_script_test_SOURCES = tests/example_grub_script_test.in
|
example_grub_script_test_SOURCES = tests/example_grub_script_test.in
|
||||||
|
|
||||||
|
#
|
||||||
|
# Rules for real tests
|
||||||
|
#
|
||||||
|
|
||||||
|
check_SCRIPTS += grub_script_echo1
|
||||||
|
grub_script_echo1_SOURCES = tests/grub_script_echo1.in
|
||||||
|
|
||||||
|
check_SCRIPTS += grub_script_echo_keywords
|
||||||
|
grub_script_echo_keywords_SOURCES = tests/grub_script_echo_keywords.in
|
||||||
|
|
||||||
|
check_SCRIPTS += grub_script_vars1
|
||||||
|
grub_script_vars1_SOURCES = tests/grub_script_vars1.in
|
||||||
|
|
||||||
|
check_SCRIPTS += grub_script_for1
|
||||||
|
grub_script_for1_SOURCES = tests/grub_script_for1.in
|
||||||
|
|
||||||
|
check_SCRIPTS += grub_script_blanklines
|
||||||
|
grub_script_blanklines_SOURCES = tests/grub_script_blanklines.in
|
||||||
|
|
||||||
|
check_SCRIPTS += grub_script_final_semicolon
|
||||||
|
grub_script_final_semicolon_SOURCES = tests/grub_script_final_semicolon.in
|
||||||
|
|
||||||
# List of tests to execute on "make check"
|
# List of tests to execute on "make check"
|
||||||
SCRIPTED_TESTS = example_scripted_test
|
# SCRIPTED_TESTS = example_scripted_test
|
||||||
SCRIPTED_TESTS += example_grub_script_test
|
# SCRIPTED_TESTS += example_grub_script_test
|
||||||
UNIT_TESTS = example_unit_test
|
# UNIT_TESTS = example_unit_test
|
||||||
FUNCTIONAL_TESTS = example_functional_test.mod
|
# FUNCTIONAL_TESTS = example_functional_test.mod
|
||||||
|
|
||||||
|
SCRIPTED_TESTS = grub_script_echo1
|
||||||
|
SCRIPTED_TESTS += grub_script_echo_keywords
|
||||||
|
SCRIPTED_TESTS += grub_script_vars1
|
||||||
|
SCRIPTED_TESTS += grub_script_for1
|
||||||
|
SCRIPTED_TESTS += grub_script_blanklines
|
||||||
|
SCRIPTED_TESTS += grub_script_final_semicolon
|
||||||
|
|
||||||
# dependencies between tests and testing-tools
|
# dependencies between tests and testing-tools
|
||||||
$(SCRIPTED_TESTS): grub-shell grub-shell-tester
|
$(SCRIPTED_TESTS): grub-shell grub-shell-tester
|
||||||
|
|
113
conf/x86-efi.rmk
Normal file
113
conf/x86-efi.rmk
Normal file
|
@ -0,0 +1,113 @@
|
||||||
|
# -*- makefile -*-
|
||||||
|
|
||||||
|
# Utilities.
|
||||||
|
bin_UTILITIES = grub-mkimage
|
||||||
|
|
||||||
|
# For grub-mkimage.
|
||||||
|
grub_mkimage_SOURCES = gnulib/progname.c util/i386/efi/grub-mkimage.c \
|
||||||
|
util/misc.c util/resolve.c
|
||||||
|
util/i386/efi/grub-mkimage.c_DEPENDENCIES = Makefile
|
||||||
|
|
||||||
|
# Scripts.
|
||||||
|
sbin_SCRIPTS = grub-install
|
||||||
|
|
||||||
|
# For grub-install.
|
||||||
|
grub_install_SOURCES = util/i386/efi/grub-install.in
|
||||||
|
|
||||||
|
# Modules.
|
||||||
|
pkglib_PROGRAMS = kernel.img
|
||||||
|
pkglib_MODULES = chain.mod appleldr.mod \
|
||||||
|
linux.mod halt.mod \
|
||||||
|
datetime.mod loadbios.mod \
|
||||||
|
fixvideo.mod mmap.mod acpi.mod
|
||||||
|
|
||||||
|
# For kernel.img.
|
||||||
|
kernel_img_RELOCATABLE = yes
|
||||||
|
kernel_img_SOURCES = kern/$(target_cpu)/efi/startup.S kern/main.c kern/device.c \
|
||||||
|
kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
|
||||||
|
kern/misc.c kern/mm.c kern/term.c \
|
||||||
|
kern/rescue_parser.c kern/rescue_reader.c \
|
||||||
|
kern/$(target_cpu)/dl.c kern/i386/efi/init.c kern/parser.c kern/partition.c \
|
||||||
|
kern/env.c symlist.c kern/efi/efi.c kern/efi/init.c kern/efi/mm.c \
|
||||||
|
term/efi/console.c disk/efi/efidisk.c \
|
||||||
|
kern/time.c kern/list.c kern/handler.c kern/command.c kern/corecmd.c \
|
||||||
|
kern/i386/tsc.c kern/i386/pit.c \
|
||||||
|
kern/generic/rtc_get_time_ms.c \
|
||||||
|
kern/generic/millisleep.c
|
||||||
|
ifeq ($(target_cpu),x86_64)
|
||||||
|
kernel_img_SOURCES += kern/x86_64/efi/callwrap.S
|
||||||
|
endif
|
||||||
|
kernel_img_HEADERS += efi/efi.h efi/time.h efi/disk.h i386/pit.h
|
||||||
|
kernel_img_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
||||||
|
kernel_img_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For acpi.mod.
|
||||||
|
acpi_mod_SOURCES = commands/acpi.c commands/efi/acpi.c
|
||||||
|
acpi_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
acpi_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For mmap.mod.
|
||||||
|
mmap_mod_SOURCES = mmap/mmap.c mmap/i386/uppermem.c mmap/i386/mmap.c \
|
||||||
|
mmap/efi/mmap.c
|
||||||
|
mmap_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
mmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For chain.mod.
|
||||||
|
chain_mod_SOURCES = loader/efi/chainloader.c
|
||||||
|
chain_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
chain_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For appleldr.mod.
|
||||||
|
appleldr_mod_SOURCES = loader/efi/appleloader.c
|
||||||
|
appleldr_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
appleldr_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For linux.mod.
|
||||||
|
linux_mod_SOURCES = loader/i386/efi/linux.c
|
||||||
|
ifeq ($(target_cpu), x86_64)
|
||||||
|
linux_mod_SOURCES += loader/i386/linux_trampoline.S
|
||||||
|
endif
|
||||||
|
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
linux_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||||
|
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For halt.mod.
|
||||||
|
halt_mod_SOURCES = commands/halt.c
|
||||||
|
halt_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For datetime.mod
|
||||||
|
datetime_mod_SOURCES = lib/efi/datetime.c
|
||||||
|
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For loadbios.mod
|
||||||
|
loadbios_mod_SOURCES = commands/efi/loadbios.c
|
||||||
|
loadbios_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
loadbios_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
# For fixvideo.mod
|
||||||
|
fixvideo_mod_SOURCES = commands/efi/fixvideo.c
|
||||||
|
fixvideo_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
fixvideo_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
pkglib_MODULES += efi_uga.mod
|
||||||
|
efi_uga_mod_SOURCES = video/efi_uga.c
|
||||||
|
efi_uga_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
efi_uga_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
pkglib_MODULES += efi_gop.mod
|
||||||
|
efi_gop_mod_SOURCES = video/efi_gop.c
|
||||||
|
efi_gop_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
efi_gop_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
|
||||||
|
pkglib_MODULES += xnu.mod
|
||||||
|
xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/i386/efi/xnu.c \
|
||||||
|
loader/macho32.c loader/macho64.c loader/macho.c loader/xnu.c
|
||||||
|
xnu_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||||
|
xnu_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||||
|
xnu_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
||||||
|
|
||||||
|
include $(srcdir)/conf/i386.mk
|
||||||
|
include $(srcdir)/conf/common.mk
|
|
@ -1,166 +1,5 @@
|
||||||
# -*- makefile -*-
|
# -*- makefile -*-
|
||||||
|
|
||||||
COMMON_ASFLAGS = -nostdinc -fno-builtin -m64
|
COMMON_LDFLAGS = -melf_x86_64
|
||||||
COMMON_CFLAGS = -fno-builtin -m64
|
|
||||||
COMMON_LDFLAGS = -melf_x86_64 -nostdlib
|
|
||||||
|
|
||||||
# Used by various components. These rules need to precede them.
|
include $(srcdir)/conf/x86-efi.mk
|
||||||
script/lexer.c_DEPENDENCIES = grub_script.tab.h
|
|
||||||
|
|
||||||
# Utilities.
|
|
||||||
bin_UTILITIES = grub-mkimage
|
|
||||||
|
|
||||||
# For grub-mkimage.
|
|
||||||
grub_mkimage_SOURCES = gnulib/progname.c util/i386/efi/grub-mkimage.c \
|
|
||||||
util/misc.c util/resolve.c
|
|
||||||
|
|
||||||
# For grub-setup.
|
|
||||||
#grub_setup_SOURCES = util/i386/pc/grub-setup.c util/hostdisk.c \
|
|
||||||
# util/misc.c util/getroot.c kern/device.c kern/disk.c \
|
|
||||||
# kern/err.c kern/misc.c fs/fat.c fs/ext2.c fs/xfs.c fs/affs.c \
|
|
||||||
# fs/sfs.c kern/parser.c kern/partition.c partmap/msdos.c \
|
|
||||||
# fs/ufs.c fs/ufs2.c fs/minix.c fs/hfs.c fs/jfs.c fs/hfsplus.c kern/file.c \
|
|
||||||
# kern/fs.c kern/env.c fs/fshelp.c
|
|
||||||
|
|
||||||
# Scripts.
|
|
||||||
sbin_SCRIPTS = grub-install
|
|
||||||
|
|
||||||
# For grub-install.
|
|
||||||
grub_install_SOURCES = util/i386/efi/grub-install.in
|
|
||||||
|
|
||||||
# Modules.
|
|
||||||
pkglib_PROGRAMS = kernel.img
|
|
||||||
pkglib_MODULES = chain.mod appleldr.mod \
|
|
||||||
halt.mod reboot.mod linux.mod pci.mod lspci.mod \
|
|
||||||
datetime.mod date.mod datehook.mod loadbios.mod \
|
|
||||||
fixvideo.mod mmap.mod acpi.mod
|
|
||||||
|
|
||||||
# For kernel.img.
|
|
||||||
kernel_img_RELOCATABLE = yes
|
|
||||||
kernel_img_SOURCES = kern/x86_64/efi/startup.S kern/x86_64/efi/callwrap.S \
|
|
||||||
kern/main.c kern/device.c \
|
|
||||||
kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
|
|
||||||
kern/misc.c kern/mm.c kern/term.c \
|
|
||||||
kern/rescue_parser.c kern/rescue_reader.c \
|
|
||||||
kern/$(target_cpu)/dl.c kern/i386/efi/init.c kern/parser.c kern/partition.c \
|
|
||||||
kern/env.c symlist.c kern/efi/efi.c kern/efi/init.c kern/efi/mm.c \
|
|
||||||
kern/time.c kern/list.c kern/handler.c kern/command.c kern/corecmd.c \
|
|
||||||
kern/i386/tsc.c kern/i386/pit.c \
|
|
||||||
kern/generic/millisleep.c kern/generic/rtc_get_time_ms.c \
|
|
||||||
term/efi/console.c disk/efi/efidisk.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 \
|
|
||||||
efi/efi.h efi/time.h efi/disk.h machine/loader.h i386/pit.h list.h \
|
|
||||||
handler.h command.h i18n.h env_private.h
|
|
||||||
kernel_img_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
kernel_img_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
MOSTLYCLEANFILES += symlist.c
|
|
||||||
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)
|
|
||||||
|
|
||||||
# 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 acpi.mod.
|
|
||||||
acpi_mod_SOURCES = commands/acpi.c commands/efi/acpi.c
|
|
||||||
acpi_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
acpi_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For mmap.mod.
|
|
||||||
mmap_mod_SOURCES = mmap/mmap.c mmap/i386/uppermem.c mmap/i386/mmap.c \
|
|
||||||
mmap/efi/mmap.c
|
|
||||||
mmap_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
mmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For chain.mod.
|
|
||||||
chain_mod_SOURCES = loader/efi/chainloader.c
|
|
||||||
chain_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
chain_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For appleldr.mod.
|
|
||||||
appleldr_mod_SOURCES = loader/efi/appleloader.c
|
|
||||||
appleldr_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
appleldr_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For linux.mod.
|
|
||||||
linux_mod_SOURCES = loader/i386/efi/linux.c loader/i386/linux_trampoline.S
|
|
||||||
linux_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
linux_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For halt.mod.
|
|
||||||
halt_mod_SOURCES = commands/halt.c
|
|
||||||
halt_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For reboot.mod.
|
|
||||||
reboot_mod_SOURCES = commands/reboot.c
|
|
||||||
reboot_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
reboot_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For pci.mod
|
|
||||||
pci_mod_SOURCES = bus/pci.c
|
|
||||||
pci_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
pci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For lspci.mod
|
|
||||||
lspci_mod_SOURCES = commands/lspci.c
|
|
||||||
lspci_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
lspci_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For datetime.mod
|
|
||||||
datetime_mod_SOURCES = lib/efi/datetime.c
|
|
||||||
datetime_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For date.mod
|
|
||||||
date_mod_SOURCES = commands/date.c
|
|
||||||
date_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
date_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For datehook.mod
|
|
||||||
datehook_mod_SOURCES = hook/datehook.c
|
|
||||||
datehook_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
datehook_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For loadbios.mod
|
|
||||||
loadbios_mod_SOURCES = commands/efi/loadbios.c
|
|
||||||
loadbios_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
loadbios_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
# For fixvideo.mod
|
|
||||||
fixvideo_mod_SOURCES = commands/efi/fixvideo.c
|
|
||||||
fixvideo_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
fixvideo_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
pkglib_MODULES += efi_uga.mod
|
|
||||||
efi_uga_mod_SOURCES = video/efi_uga.c
|
|
||||||
efi_uga_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
efi_uga_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
pkglib_MODULES += efi_gop.mod
|
|
||||||
efi_gop_mod_SOURCES = video/efi_gop.c
|
|
||||||
efi_gop_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
efi_gop_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
|
|
||||||
pkglib_MODULES += xnu.mod
|
|
||||||
xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/i386/efi/xnu.c \
|
|
||||||
loader/macho32.c loader/macho64.c loader/macho.c loader/xnu.c
|
|
||||||
xnu_mod_CFLAGS = $(COMMON_CFLAGS)
|
|
||||||
xnu_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
|
||||||
xnu_mod_ASFLAGS = $(COMMON_ASFLAGS)
|
|
||||||
|
|
||||||
include $(srcdir)/conf/i386.mk
|
|
||||||
include $(srcdir)/conf/common.mk
|
|
||||||
|
|
19
configure.ac
19
configure.ac
|
@ -91,6 +91,7 @@ fi
|
||||||
if test -z "$target_alias"; then
|
if test -z "$target_alias"; then
|
||||||
case "$target_cpu"-"$platform" in
|
case "$target_cpu"-"$platform" in
|
||||||
x86_64-efi) ;;
|
x86_64-efi) ;;
|
||||||
|
x86_64-emu) ;;
|
||||||
x86_64-*) target_cpu=i386 ;;
|
x86_64-*) target_cpu=i386 ;;
|
||||||
powerpc64-ieee1275) target_cpu=powerpc ;;
|
powerpc64-ieee1275) target_cpu=powerpc ;;
|
||||||
esac
|
esac
|
||||||
|
@ -139,9 +140,14 @@ case "$platform" in
|
||||||
qemu) machine_CFLAGS="-DGRUB_MACHINE_QEMU=1" ;;
|
qemu) machine_CFLAGS="-DGRUB_MACHINE_QEMU=1" ;;
|
||||||
pc) machine_CFLAGS="-DGRUB_MACHINE_PCBIOS=1" ;;
|
pc) machine_CFLAGS="-DGRUB_MACHINE_PCBIOS=1" ;;
|
||||||
emu) machine_CFLAGS="-DGRUB_MACHINE_EMU=1" ;;
|
emu) machine_CFLAGS="-DGRUB_MACHINE_EMU=1" ;;
|
||||||
yeeloong) machine_CFLAGS="-DGRUB_MACHINE_MIPS_YEELOONG=1 -DGRUB_MACHINE_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
|
yeeloong) machine_CFLAGS="-DGRUB_MACHINE_MIPS_YEELOONG=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
|
||||||
qemu-mips) machine_CFLAGS="-DGRUB_MACHINE_MIPS_QEMU_MIPS=1 -DGRUB_MACHINE_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
|
qemu-mips) machine_CFLAGS="-DGRUB_MACHINE_MIPS_QEMU_MIPS=1 -DGRUB_MACHINE_MIPS_BONITO=1" ;;
|
||||||
esac
|
esac
|
||||||
|
case "$target_cpu" in
|
||||||
|
mips) machine_CFLAGS="$machine_CFLAGS -DGRUB_MACHINE_MIPS=1" ;;
|
||||||
|
sparc64) machine_CFLAGS="$machine_CFLAGS -DGRUB_MACHINE_SPARC64=1" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
CFLAGS="$CFLAGS $machine_CFLAGS"
|
CFLAGS="$CFLAGS $machine_CFLAGS"
|
||||||
TARGET_ASFLAGS="$TARGET_ASFLAGS $machine_CFLAGS"
|
TARGET_ASFLAGS="$TARGET_ASFLAGS $machine_CFLAGS"
|
||||||
TARGET_CFLAGS="$TARGET_CFLAGS $machine_CFLAGS"
|
TARGET_CFLAGS="$TARGET_CFLAGS $machine_CFLAGS"
|
||||||
|
@ -164,6 +170,11 @@ if test "x$CMP" = x; then
|
||||||
AC_MSG_ERROR([cmp is not found])
|
AC_MSG_ERROR([cmp is not found])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
AC_CHECK_PROGS([LEX], [flex])
|
||||||
|
if test "x$LEX" = x; then
|
||||||
|
AC_MSG_ERROR([flex is not found])
|
||||||
|
fi
|
||||||
|
|
||||||
AC_CHECK_PROGS([YACC], [bison])
|
AC_CHECK_PROGS([YACC], [bison])
|
||||||
if test "x$YACC" = x; then
|
if test "x$YACC" = x; then
|
||||||
AC_MSG_ERROR([bison is not found])
|
AC_MSG_ERROR([bison is not found])
|
||||||
|
@ -353,6 +364,7 @@ AC_MSG_RESULT([$TARGET_OBJ2ELF])
|
||||||
if test "x$target_m32" = x1; then
|
if test "x$target_m32" = x1; then
|
||||||
# Force 32-bit mode.
|
# Force 32-bit mode.
|
||||||
TARGET_CFLAGS="$TARGET_CFLAGS -m32"
|
TARGET_CFLAGS="$TARGET_CFLAGS -m32"
|
||||||
|
TARGET_ASFLAGS="$TARGET_CFLAGS -m32"
|
||||||
TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
|
TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
|
||||||
TARGET_MODULE_FORMAT="elf32"
|
TARGET_MODULE_FORMAT="elf32"
|
||||||
fi
|
fi
|
||||||
|
@ -360,6 +372,7 @@ fi
|
||||||
if test "x$target_m64" = x1; then
|
if test "x$target_m64" = x1; then
|
||||||
# Force 64-bit mode.
|
# Force 64-bit mode.
|
||||||
TARGET_CFLAGS="$TARGET_CFLAGS -m64"
|
TARGET_CFLAGS="$TARGET_CFLAGS -m64"
|
||||||
|
TARGET_ASFLAGS="$TARGET_ASFLAGS -m64"
|
||||||
TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
|
TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
|
||||||
TARGET_MODULE_FORMAT="elf64"
|
TARGET_MODULE_FORMAT="elf64"
|
||||||
fi
|
fi
|
||||||
|
@ -517,6 +530,7 @@ enable_efiemu=no
|
||||||
fi
|
fi
|
||||||
AC_SUBST([enable_efiemu])
|
AC_SUBST([enable_efiemu])
|
||||||
|
|
||||||
|
if test "$platform" != emu; then
|
||||||
AC_CACHE_CHECK([whether -nostdinc -isystem works], [grub_cv_cc_isystem], [
|
AC_CACHE_CHECK([whether -nostdinc -isystem works], [grub_cv_cc_isystem], [
|
||||||
SAVED_CPPFLAGS="$CPPFLAGS"
|
SAVED_CPPFLAGS="$CPPFLAGS"
|
||||||
CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
|
CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
|
||||||
|
@ -530,6 +544,7 @@ int va_arg_func (int fixed, va_list args);]], [[]])],
|
||||||
if test x"$grub_cv_cc_isystem" = xyes ; then
|
if test x"$grub_cv_cc_isystem" = xyes ; then
|
||||||
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
|
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Restore the flags.
|
# Restore the flags.
|
||||||
CC="$tmp_CC"
|
CC="$tmp_CC"
|
||||||
|
|
|
@ -242,7 +242,7 @@ static struct grub_disk_dev grub_loopback_dev =
|
||||||
|
|
||||||
static grub_extcmd_t cmd;
|
static grub_extcmd_t cmd;
|
||||||
|
|
||||||
GRUB_MOD_INIT(loop)
|
GRUB_MOD_INIT(loopback)
|
||||||
{
|
{
|
||||||
cmd = grub_register_extcmd ("loopback", grub_cmd_loopback,
|
cmd = grub_register_extcmd ("loopback", grub_cmd_loopback,
|
||||||
GRUB_COMMAND_FLAG_BOTH,
|
GRUB_COMMAND_FLAG_BOTH,
|
||||||
|
@ -251,7 +251,7 @@ GRUB_MOD_INIT(loop)
|
||||||
grub_disk_dev_register (&grub_loopback_dev);
|
grub_disk_dev_register (&grub_loopback_dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
GRUB_MOD_FINI(loop)
|
GRUB_MOD_FINI(loopback)
|
||||||
{
|
{
|
||||||
grub_unregister_extcmd (cmd);
|
grub_unregister_extcmd (cmd);
|
||||||
grub_disk_dev_unregister (&grub_loopback_dev);
|
grub_disk_dev_unregister (&grub_loopback_dev);
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#include <grub/misc.h>
|
#include <grub/misc.h>
|
||||||
#include <grub/mm.h>
|
#include <grub/mm.h>
|
||||||
#include <grub/types.h>
|
#include <grub/types.h>
|
||||||
#include <grub/machine/kernel.h>
|
|
||||||
|
|
||||||
static char *memdisk_addr;
|
static char *memdisk_addr;
|
||||||
static grub_off_t memdisk_size = 0;
|
static grub_off_t memdisk_size = 0;
|
||||||
|
|
|
@ -265,7 +265,7 @@ grub_efiemu_autocore (void)
|
||||||
grub_free (filename);
|
grub_free (filename);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
#ifndef GRUB_UTIL
|
#ifndef GRUB_MACHINE_EMU
|
||||||
err = grub_machine_efiemu_init_tables ();
|
err = grub_machine_efiemu_init_tables ();
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
@ -313,7 +313,7 @@ grub_cmd_efiemu_load (grub_command_t cmd __attribute__ ((unused)),
|
||||||
err = grub_efiemu_load_file (args[0]);
|
err = grub_efiemu_load_file (args[0]);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
#ifndef GRUB_UTIL
|
#ifndef GRUB_MACHINE_EMU
|
||||||
err = grub_machine_efiemu_init_tables ();
|
err = grub_machine_efiemu_init_tables ();
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
|
@ -281,7 +281,7 @@ grub_efiemu_mmap_init (void)
|
||||||
// the place for memory used by efiemu itself
|
// the place for memory used by efiemu itself
|
||||||
mmap_reserved_size = GRUB_EFI_MAX_MEMORY_TYPE + 1;
|
mmap_reserved_size = GRUB_EFI_MAX_MEMORY_TYPE + 1;
|
||||||
|
|
||||||
#ifndef GRUB_UTIL
|
#ifndef GRUB_MACHINE_EMU
|
||||||
grub_machine_mmap_iterate (bounds_hook);
|
grub_machine_mmap_iterate (bounds_hook);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -394,7 +394,7 @@ grub_efiemu_mmap_fill (void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef GRUB_UTIL
|
#ifndef GRUB_MACHINE_EMU
|
||||||
grub_machine_mmap_iterate (fill_hook);
|
grub_machine_mmap_iterate (fill_hook);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ lsfonts_command (grub_command_t cmd __attribute__ ((unused)),
|
||||||
|
|
||||||
static grub_command_t cmd_loadfont, cmd_lsfonts;
|
static grub_command_t cmd_loadfont, cmd_lsfonts;
|
||||||
|
|
||||||
GRUB_MOD_INIT(font_manager)
|
GRUB_MOD_INIT(font)
|
||||||
{
|
{
|
||||||
grub_font_loader_init ();
|
grub_font_loader_init ();
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ GRUB_MOD_INIT(font_manager)
|
||||||
0, "List the loaded fonts.");
|
0, "List the loaded fonts.");
|
||||||
}
|
}
|
||||||
|
|
||||||
GRUB_MOD_FINI(font_manager)
|
GRUB_MOD_FINI(font)
|
||||||
{
|
{
|
||||||
/* TODO: Determine way to free allocated resources.
|
/* TODO: Determine way to free allocated resources.
|
||||||
Warning: possible pointer references could be in use. */
|
Warning: possible pointer references could be in use. */
|
||||||
|
|
|
@ -62,7 +62,7 @@
|
||||||
|
|
||||||
static grub_dl_t my_mod;
|
static grub_dl_t my_mod;
|
||||||
|
|
||||||
#define assert(boolean) real_assert (boolean, __FILE__, __LINE__)
|
#define assert(boolean) real_assert (boolean, GRUB_FILE, __LINE__)
|
||||||
static inline void
|
static inline void
|
||||||
real_assert (int boolean, const char *file, const int line)
|
real_assert (int boolean, const char *file, const int line)
|
||||||
{
|
{
|
||||||
|
|
72
genemuinit.sh
Normal file
72
genemuinit.sh
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
#! /bin/sh
|
||||||
|
#
|
||||||
|
# Copyright (C) 2002,2005,2007 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This gensymlist.sh 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.
|
||||||
|
|
||||||
|
nm="$1"
|
||||||
|
shift
|
||||||
|
|
||||||
|
cat <<EOF
|
||||||
|
/* This file is automatically generated by geninit.sh. DO NOT EDIT! */
|
||||||
|
/*
|
||||||
|
* GRUB -- GRand Unified Bootloader
|
||||||
|
* Copyright (C) 2002,2005,2007 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 "grub_emu_init.h"
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat <<EOF
|
||||||
|
void
|
||||||
|
grub_init_all (void)
|
||||||
|
{
|
||||||
|
EOF
|
||||||
|
|
||||||
|
read mods
|
||||||
|
for line in $mods; do
|
||||||
|
if ${nm} --defined-only -P -p ${line} | grep grub_mod_init > /dev/null; then
|
||||||
|
echo "grub_${line}_init ();" | sed 's,\.mod,,g;'
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
cat <<EOF
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat <<EOF
|
||||||
|
void
|
||||||
|
grub_fini_all (void)
|
||||||
|
{
|
||||||
|
EOF
|
||||||
|
|
||||||
|
for line in $mods; do
|
||||||
|
if ${nm} --defined-only -P -p ${line} | grep grub_mod_fini > /dev/null; then
|
||||||
|
echo "grub_${line}_fini ();" | sed 's,\.mod,,g;'
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
cat <<EOF
|
||||||
|
}
|
||||||
|
EOF
|
52
genemuinitheader.sh
Normal file
52
genemuinitheader.sh
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
#! /bin/sh
|
||||||
|
#
|
||||||
|
# Copyright (C) 2005,2007 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This gensymlist.sh 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.
|
||||||
|
|
||||||
|
nm="$1"
|
||||||
|
shift
|
||||||
|
|
||||||
|
cat <<EOF
|
||||||
|
/* This file is automatically generated by gensymlist.sh. DO NOT EDIT! */
|
||||||
|
/*
|
||||||
|
* GRUB -- GRand Unified Bootloader
|
||||||
|
* Copyright (C) 2005,2007 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat <<EOF
|
||||||
|
void grub_init_all (void);
|
||||||
|
void grub_fini_all (void);
|
||||||
|
EOF
|
||||||
|
|
||||||
|
read mods
|
||||||
|
for line in $mods; do
|
||||||
|
if ${nm} --defined-only -P -p ${line} | grep grub_mod_init > /dev/null; then
|
||||||
|
echo "void grub_${line}_init (void);" | sed 's,\.mod,,g;'
|
||||||
|
fi
|
||||||
|
if ${nm} --defined-only -P -p ${line} | grep grub_mod_fini > /dev/null; then
|
||||||
|
echo "void grub_${line}_fini (void);" | sed 's,\.mod,,g;'
|
||||||
|
fi
|
||||||
|
done
|
26
genmk.rb
26
genmk.rb
|
@ -91,7 +91,7 @@ endif
|
||||||
dir = File.dirname(src)
|
dir = File.dirname(src)
|
||||||
|
|
||||||
"#{obj}: #{src} $(#{src}_DEPENDENCIES)
|
"#{obj}: #{src} $(#{src}_DEPENDENCIES)
|
||||||
$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -MD -c -o $@ $<
|
$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -DGRUB_FILE=\\\"#{src}\\\" -MD -c -o $@ $<
|
||||||
-include #{dep}
|
-include #{dep}
|
||||||
|
|
||||||
"
|
"
|
||||||
|
@ -143,27 +143,35 @@ mostlyclean-module-#{@name}.#{@rule_count}:
|
||||||
MOSTLYCLEAN_MODULE_TARGETS += mostlyclean-module-#{@name}.#{@rule_count}
|
MOSTLYCLEAN_MODULE_TARGETS += mostlyclean-module-#{@name}.#{@rule_count}
|
||||||
UNDSYMFILES += #{undsym}
|
UNDSYMFILES += #{undsym}
|
||||||
|
|
||||||
|
ifeq ($(TARGET_NO_DYNAMIC_MODULES), yes)
|
||||||
|
#{@name}: #{pre_obj} $(TARGET_OBJ2ELF)
|
||||||
|
-rm -f $@
|
||||||
|
$(TARGET_CC) $(#{prefix}_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ #{pre_obj}
|
||||||
|
if test ! -z \"$(TARGET_OBJ2ELF)\"; then ./$(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi
|
||||||
|
if test x$(TARGET_NO_STRIP) != xyes ; then $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -K _grub_mod_init -K _grub_mod_fini -R .note -R .comment $@; fi
|
||||||
|
else
|
||||||
ifneq ($(TARGET_APPLE_CC),1)
|
ifneq ($(TARGET_APPLE_CC),1)
|
||||||
#{@name}: #{pre_obj} #{mod_obj} $(TARGET_OBJ2ELF)
|
#{@name}: #{pre_obj} #{mod_obj} $(TARGET_OBJ2ELF)
|
||||||
-rm -f $@
|
-rm -f $@
|
||||||
$(TARGET_CC) $(#{prefix}_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ #{pre_obj} #{mod_obj}
|
$(TARGET_CC) $(#{prefix}_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ #{pre_obj} #{mod_obj}
|
||||||
if test ! -z \"$(TARGET_OBJ2ELF)\"; then ./$(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi
|
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 $@
|
if test x$(TARGET_NO_STRIP) != xyes ; then $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -K _grub_mod_init -K _grub_mod_fini -R .note -R .comment $@; fi
|
||||||
else
|
else
|
||||||
#{@name}: #{pre_obj} #{mod_obj} $(TARGET_OBJ2ELF)
|
#{@name}: #{pre_obj} #{mod_obj} $(TARGET_OBJ2ELF)
|
||||||
-rm -f $@
|
-rm -f $@
|
||||||
-rm -f $@.bin
|
-rm -f $@.bin
|
||||||
$(TARGET_CC) $(#{prefix}_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@.bin #{pre_obj} #{mod_obj}
|
$(TARGET_CC) $(#{prefix}_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@.bin #{pre_obj} #{mod_obj}
|
||||||
$(OBJCONV) -f$(TARGET_MODULE_FORMAT) -nr:_grub_mod_init:grub_mod_init -nr:_grub_mod_fini:grub_mod_fini -wd1106 -nu -nd $@.bin $@
|
$(OBJCONV) -f$(TARGET_MODULE_FORMAT) -nr:_grub_mod_init:grub_mod_init -nr:_grub_mod_fini:grub_mod_fini -wd1106 -ew2030 -ew2050 -nu -nd $@.bin $@
|
||||||
-rm -f $@.bin
|
-rm -f $@.bin
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
#{pre_obj}: $(#{prefix}_DEPENDENCIES) #{objs_str}
|
#{pre_obj}: $(#{prefix}_DEPENDENCIES) #{objs_str}
|
||||||
-rm -f $@
|
-rm -f $@
|
||||||
$(TARGET_CC) $(#{prefix}_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ #{objs_str}
|
$(TARGET_CC) $(#{prefix}_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ #{objs_str}
|
||||||
|
|
||||||
#{mod_obj}: #{mod_src}
|
#{mod_obj}: #{mod_src}
|
||||||
$(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(#{prefix}_CFLAGS) -c -o $@ $<
|
$(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(#{prefix}_CFLAGS) -DGRUB_FILE=\\\"#{mod_src}\\\" -c -o $@ $<
|
||||||
|
|
||||||
#{mod_src}: $(builddir)/moddep.lst $(srcdir)/genmodsrc.sh
|
#{mod_src}: $(builddir)/moddep.lst $(srcdir)/genmodsrc.sh
|
||||||
sh $(srcdir)/genmodsrc.sh '#{mod_name}' $< > $@ || (rm -f $@; exit 1)
|
sh $(srcdir)/genmodsrc.sh '#{mod_name}' $< > $@ || (rm -f $@; exit 1)
|
||||||
|
@ -197,7 +205,7 @@ endif
|
||||||
dir = File.dirname(src)
|
dir = File.dirname(src)
|
||||||
|
|
||||||
"#{obj}: #{src} $(#{src}_DEPENDENCIES)
|
"#{obj}: #{src} $(#{src}_DEPENDENCIES)
|
||||||
$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -MD -c -o $@ $<
|
$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -DGRUB_FILE=\\\"#{src}\\\" -MD -c -o $@ $<
|
||||||
-include #{dep}
|
-include #{dep}
|
||||||
|
|
||||||
clean-module-#{extra_target}.#{@rule_count}:
|
clean-module-#{extra_target}.#{@rule_count}:
|
||||||
|
@ -299,7 +307,7 @@ MOSTLYCLEAN_UTILITY_TARGETS += mostlyclean-utility-#{@name}.#{@rule_count}
|
||||||
dir = File.dirname(src)
|
dir = File.dirname(src)
|
||||||
|
|
||||||
"#{obj}: #{src} $(#{src}_DEPENDENCIES)
|
"#{obj}: #{src} $(#{src}_DEPENDENCIES)
|
||||||
$(CC) -I#{dir} -I$(srcdir)/#{dir} $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(#{prefix}_CFLAGS) -MD -c -o $@ $<
|
$(CC) -I#{dir} -I$(srcdir)/#{dir} $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(#{prefix}_CFLAGS) -DGRUB_FILE=\\\"#{src}\\\" -MD -c -o $@ $<
|
||||||
-include #{dep}
|
-include #{dep}
|
||||||
|
|
||||||
"
|
"
|
||||||
|
@ -330,11 +338,11 @@ MOSTLYCLEANFILES += #{deps_str}
|
||||||
ifeq ($(#{prefix}_RELOCATABLE),yes)
|
ifeq ($(#{prefix}_RELOCATABLE),yes)
|
||||||
#{@name}: $(#{prefix}_DEPENDENCIES) #{objs_str}
|
#{@name}: $(#{prefix}_DEPENDENCIES) #{objs_str}
|
||||||
$(TARGET_CC) -Wl,-r,-d -o $@ #{objs_str} $(TARGET_LDFLAGS) $(#{prefix}_LDFLAGS)
|
$(TARGET_CC) -Wl,-r,-d -o $@ #{objs_str} $(TARGET_LDFLAGS) $(#{prefix}_LDFLAGS)
|
||||||
$(STRIP) --strip-unneeded -K start -R .note -R .comment $@
|
if test x$(TARGET_NO_STRIP) != xyes ; then $(STRIP) --strip-unneeded -K start -R .note -R .comment $@; fi
|
||||||
else
|
else
|
||||||
#{@name}: $(#{prefix}_DEPENDENCIES) #{objs_str}
|
#{@name}: $(#{prefix}_DEPENDENCIES) #{objs_str}
|
||||||
$(TARGET_CC) -o $@ #{objs_str} $(TARGET_LDFLAGS) $(#{prefix}_LDFLAGS)
|
$(TARGET_CC) -o $@ #{objs_str} $(TARGET_LDFLAGS) $(#{prefix}_LDFLAGS)
|
||||||
$(STRIP) -R .rel.dyn -R .reginfo -R .note -R .comment $@
|
if test x$(TARGET_NO_STRIP) != xyes ; then $(STRIP) -R .rel.dyn -R .reginfo -R .note -R .comment $@; fi
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" + objs.collect_with_index do |obj, i|
|
" + objs.collect_with_index do |obj, i|
|
||||||
|
@ -346,7 +354,7 @@ endif
|
||||||
dir = File.dirname(src)
|
dir = File.dirname(src)
|
||||||
|
|
||||||
"#{obj}: #{src} $(#{src}_DEPENDENCIES)
|
"#{obj}: #{src} $(#{src}_DEPENDENCIES)
|
||||||
$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -MD -c -o $@ $<
|
$(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -DGRUB_FILE=\\\"#{src}\\\" -MD -c -o $@ $<
|
||||||
|
|
||||||
-include #{dep}
|
-include #{dep}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ cat <<EOF
|
||||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <grub/symbol.h>
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
for i in $*; do
|
for i in $*; do
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* Memory allocation on the stack.
|
/* Memory allocation on the stack.
|
||||||
|
|
||||||
Copyright (C) 1995, 1999, 2001-2004, 2006-2008 Free Software
|
Copyright (C) 1995, 1999, 2001-2004, 2006-2010 Free Software Foundation,
|
||||||
Foundation, Inc.
|
Inc.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it
|
This program is free software; you can redistribute it and/or modify it
|
||||||
under the terms of the GNU General Public License as published
|
under the terms of the GNU General Public License as published
|
||||||
|
|
34
gnulib/argp-ba.c
Normal file
34
gnulib/argp-ba.c
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
/* Default definition for ARGP_PROGRAM_BUG_ADDRESS.
|
||||||
|
Copyright (C) 1996, 1997, 1999, 2009, 2010 Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||||
|
|
||||||
|
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 3 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, see <http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
/* If set by the user program, it should point to string that is the
|
||||||
|
bug-reporting address for the program. It will be printed by argp_help if
|
||||||
|
the ARGP_HELP_BUG_ADDR flag is set (as it is by various standard help
|
||||||
|
messages), embedded in a sentence that says something like `Report bugs to
|
||||||
|
ADDR.'. */
|
||||||
|
const char *argp_program_bug_address
|
||||||
|
/* This variable should be zero-initialized. On most systems, putting it into
|
||||||
|
BSS is sufficient. Not so on MacOS X 10.3 and 10.4, see
|
||||||
|
<http://lists.gnu.org/archive/html/bug-gnulib/2009-01/msg00329.html>
|
||||||
|
<http://lists.gnu.org/archive/html/bug-gnulib/2009-08/msg00096.html>. */
|
||||||
|
#if defined __ELF__
|
||||||
|
/* On ELF systems, variables in BSS behave well. */
|
||||||
|
#else
|
||||||
|
= (const char *) 0
|
||||||
|
#endif
|
||||||
|
;
|
30
gnulib/argp-eexst.c
Normal file
30
gnulib/argp-eexst.c
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
/* Default definition for ARGP_ERR_EXIT_STATUS
|
||||||
|
Copyright (C) 1997, 2009, 2010 Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||||
|
|
||||||
|
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 3 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, see <http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <sysexits.h>
|
||||||
|
|
||||||
|
#include "argp.h"
|
||||||
|
|
||||||
|
/* The exit status that argp will use when exiting due to a parsing error.
|
||||||
|
If not defined or set by the user program, this defaults to EX_USAGE from
|
||||||
|
<sysexits.h>. */
|
||||||
|
error_t argp_err_exit_status = EX_USAGE;
|
435
gnulib/argp-fmtstream.c
Normal file
435
gnulib/argp-fmtstream.c
Normal file
|
@ -0,0 +1,435 @@
|
||||||
|
/* Word-wrapping and line-truncating streams
|
||||||
|
Copyright (C) 1997-1999, 2001-2003, 2005, 2009-2010 Free Software
|
||||||
|
Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||||
|
|
||||||
|
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 3 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, see <http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
/* This package emulates glibc `line_wrap_stream' semantics for systems that
|
||||||
|
don't have that. */
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#include "argp-fmtstream.h"
|
||||||
|
#include "argp-namefrob.h"
|
||||||
|
|
||||||
|
#ifndef ARGP_FMTSTREAM_USE_LINEWRAP
|
||||||
|
|
||||||
|
#ifndef isblank
|
||||||
|
#define isblank(ch) ((ch)==' ' || (ch)=='\t')
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined _LIBC && defined USE_IN_LIBIO
|
||||||
|
# include <wchar.h>
|
||||||
|
# include <libio/libioP.h>
|
||||||
|
# define __vsnprintf(s, l, f, a) _IO_vsnprintf (s, l, f, a)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define INIT_BUF_SIZE 200
|
||||||
|
#define PRINTF_SIZE_GUESS 150
|
||||||
|
|
||||||
|
/* Return an argp_fmtstream that outputs to STREAM, and which prefixes lines
|
||||||
|
written on it with LMARGIN spaces and limits them to RMARGIN columns
|
||||||
|
total. If WMARGIN >= 0, words that extend past RMARGIN are wrapped by
|
||||||
|
replacing the whitespace before them with a newline and WMARGIN spaces.
|
||||||
|
Otherwise, chars beyond RMARGIN are simply dropped until a newline.
|
||||||
|
Returns NULL if there was an error. */
|
||||||
|
argp_fmtstream_t
|
||||||
|
__argp_make_fmtstream (FILE *stream,
|
||||||
|
size_t lmargin, size_t rmargin, ssize_t wmargin)
|
||||||
|
{
|
||||||
|
argp_fmtstream_t fs;
|
||||||
|
|
||||||
|
fs = (struct argp_fmtstream *) malloc (sizeof (struct argp_fmtstream));
|
||||||
|
if (fs != NULL)
|
||||||
|
{
|
||||||
|
fs->stream = stream;
|
||||||
|
|
||||||
|
fs->lmargin = lmargin;
|
||||||
|
fs->rmargin = rmargin;
|
||||||
|
fs->wmargin = wmargin;
|
||||||
|
fs->point_col = 0;
|
||||||
|
fs->point_offs = 0;
|
||||||
|
|
||||||
|
fs->buf = (char *) malloc (INIT_BUF_SIZE);
|
||||||
|
if (! fs->buf)
|
||||||
|
{
|
||||||
|
free (fs);
|
||||||
|
fs = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fs->p = fs->buf;
|
||||||
|
fs->end = fs->buf + INIT_BUF_SIZE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return fs;
|
||||||
|
}
|
||||||
|
#if 0
|
||||||
|
/* Not exported. */
|
||||||
|
#ifdef weak_alias
|
||||||
|
weak_alias (__argp_make_fmtstream, argp_make_fmtstream)
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Flush FS to its stream, and free it (but don't close the stream). */
|
||||||
|
void
|
||||||
|
__argp_fmtstream_free (argp_fmtstream_t fs)
|
||||||
|
{
|
||||||
|
__argp_fmtstream_update (fs);
|
||||||
|
if (fs->p > fs->buf)
|
||||||
|
{
|
||||||
|
#ifdef USE_IN_LIBIO
|
||||||
|
__fxprintf (fs->stream, "%.*s", (int) (fs->p - fs->buf), fs->buf);
|
||||||
|
#else
|
||||||
|
fwrite_unlocked (fs->buf, 1, fs->p - fs->buf, fs->stream);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
free (fs->buf);
|
||||||
|
free (fs);
|
||||||
|
}
|
||||||
|
#if 0
|
||||||
|
/* Not exported. */
|
||||||
|
#ifdef weak_alias
|
||||||
|
weak_alias (__argp_fmtstream_free, argp_fmtstream_free)
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Process FS's buffer so that line wrapping is done from POINT_OFFS to the
|
||||||
|
end of its buffer. This code is mostly from glibc stdio/linewrap.c. */
|
||||||
|
void
|
||||||
|
__argp_fmtstream_update (argp_fmtstream_t fs)
|
||||||
|
{
|
||||||
|
char *buf, *nl;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
/* Scan the buffer for newlines. */
|
||||||
|
buf = fs->buf + fs->point_offs;
|
||||||
|
while (buf < fs->p)
|
||||||
|
{
|
||||||
|
size_t r;
|
||||||
|
|
||||||
|
if (fs->point_col == 0 && fs->lmargin != 0)
|
||||||
|
{
|
||||||
|
/* We are starting a new line. Print spaces to the left margin. */
|
||||||
|
const size_t pad = fs->lmargin;
|
||||||
|
if (fs->p + pad < fs->end)
|
||||||
|
{
|
||||||
|
/* We can fit in them in the buffer by moving the
|
||||||
|
buffer text up and filling in the beginning. */
|
||||||
|
memmove (buf + pad, buf, fs->p - buf);
|
||||||
|
fs->p += pad; /* Compensate for bigger buffer. */
|
||||||
|
memset (buf, ' ', pad); /* Fill in the spaces. */
|
||||||
|
buf += pad; /* Don't bother searching them. */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* No buffer space for spaces. Must flush. */
|
||||||
|
size_t i;
|
||||||
|
for (i = 0; i < pad; i++)
|
||||||
|
{
|
||||||
|
#ifdef USE_IN_LIBIO
|
||||||
|
if (_IO_fwide (fs->stream, 0) > 0)
|
||||||
|
putwc_unlocked (L' ', fs->stream);
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
putc_unlocked (' ', fs->stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fs->point_col = pad;
|
||||||
|
}
|
||||||
|
|
||||||
|
len = fs->p - buf;
|
||||||
|
nl = memchr (buf, '\n', len);
|
||||||
|
|
||||||
|
if (fs->point_col < 0)
|
||||||
|
fs->point_col = 0;
|
||||||
|
|
||||||
|
if (!nl)
|
||||||
|
{
|
||||||
|
/* The buffer ends in a partial line. */
|
||||||
|
|
||||||
|
if (fs->point_col + len < fs->rmargin)
|
||||||
|
{
|
||||||
|
/* The remaining buffer text is a partial line and fits
|
||||||
|
within the maximum line width. Advance point for the
|
||||||
|
characters to be written and stop scanning. */
|
||||||
|
fs->point_col += len;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
/* Set the end-of-line pointer for the code below to
|
||||||
|
the end of the buffer. */
|
||||||
|
nl = fs->p;
|
||||||
|
}
|
||||||
|
else if (fs->point_col + (nl - buf) < (ssize_t) fs->rmargin)
|
||||||
|
{
|
||||||
|
/* The buffer contains a full line that fits within the maximum
|
||||||
|
line width. Reset point and scan the next line. */
|
||||||
|
fs->point_col = 0;
|
||||||
|
buf = nl + 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This line is too long. */
|
||||||
|
r = fs->rmargin - 1;
|
||||||
|
|
||||||
|
if (fs->wmargin < 0)
|
||||||
|
{
|
||||||
|
/* Truncate the line by overwriting the excess with the
|
||||||
|
newline and anything after it in the buffer. */
|
||||||
|
if (nl < fs->p)
|
||||||
|
{
|
||||||
|
memmove (buf + (r - fs->point_col), nl, fs->p - nl);
|
||||||
|
fs->p -= buf + (r - fs->point_col) - nl;
|
||||||
|
/* Reset point for the next line and start scanning it. */
|
||||||
|
fs->point_col = 0;
|
||||||
|
buf += r + 1; /* Skip full line plus \n. */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* The buffer ends with a partial line that is beyond the
|
||||||
|
maximum line width. Advance point for the characters
|
||||||
|
written, and discard those past the max from the buffer. */
|
||||||
|
fs->point_col += len;
|
||||||
|
fs->p -= fs->point_col - r;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Do word wrap. Go to the column just past the maximum line
|
||||||
|
width and scan back for the beginning of the word there.
|
||||||
|
Then insert a line break. */
|
||||||
|
|
||||||
|
char *p, *nextline;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
p = buf + (r + 1 - fs->point_col);
|
||||||
|
while (p >= buf && !isblank ((unsigned char) *p))
|
||||||
|
--p;
|
||||||
|
nextline = p + 1; /* This will begin the next line. */
|
||||||
|
|
||||||
|
if (nextline > buf)
|
||||||
|
{
|
||||||
|
/* Swallow separating blanks. */
|
||||||
|
if (p >= buf)
|
||||||
|
do
|
||||||
|
--p;
|
||||||
|
while (p >= buf && isblank ((unsigned char) *p));
|
||||||
|
nl = p + 1; /* The newline will replace the first blank. */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* A single word that is greater than the maximum line width.
|
||||||
|
Oh well. Put it on an overlong line by itself. */
|
||||||
|
p = buf + (r + 1 - fs->point_col);
|
||||||
|
/* Find the end of the long word. */
|
||||||
|
if (p < nl)
|
||||||
|
do
|
||||||
|
++p;
|
||||||
|
while (p < nl && !isblank ((unsigned char) *p));
|
||||||
|
if (p == nl)
|
||||||
|
{
|
||||||
|
/* It already ends a line. No fussing required. */
|
||||||
|
fs->point_col = 0;
|
||||||
|
buf = nl + 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
/* We will move the newline to replace the first blank. */
|
||||||
|
nl = p;
|
||||||
|
/* Swallow separating blanks. */
|
||||||
|
do
|
||||||
|
++p;
|
||||||
|
while (isblank ((unsigned char) *p));
|
||||||
|
/* The next line will start here. */
|
||||||
|
nextline = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Note: There are a bunch of tests below for
|
||||||
|
NEXTLINE == BUF + LEN + 1; this case is where NL happens to fall
|
||||||
|
at the end of the buffer, and NEXTLINE is in fact empty (and so
|
||||||
|
we need not be careful to maintain its contents). */
|
||||||
|
|
||||||
|
if ((nextline == buf + len + 1
|
||||||
|
? fs->end - nl < fs->wmargin + 1
|
||||||
|
: nextline - (nl + 1) < fs->wmargin)
|
||||||
|
&& fs->p > nextline)
|
||||||
|
{
|
||||||
|
/* The margin needs more blanks than we removed. */
|
||||||
|
if (fs->end - fs->p > fs->wmargin + 1)
|
||||||
|
/* Make some space for them. */
|
||||||
|
{
|
||||||
|
size_t mv = fs->p - nextline;
|
||||||
|
memmove (nl + 1 + fs->wmargin, nextline, mv);
|
||||||
|
nextline = nl + 1 + fs->wmargin;
|
||||||
|
len = nextline + mv - buf;
|
||||||
|
*nl++ = '\n';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
/* Output the first line so we can use the space. */
|
||||||
|
{
|
||||||
|
#ifdef _LIBC
|
||||||
|
__fxprintf (fs->stream, "%.*s\n",
|
||||||
|
(int) (nl - fs->buf), fs->buf);
|
||||||
|
#else
|
||||||
|
if (nl > fs->buf)
|
||||||
|
fwrite_unlocked (fs->buf, 1, nl - fs->buf, fs->stream);
|
||||||
|
putc_unlocked ('\n', fs->stream);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
len += buf - fs->buf;
|
||||||
|
nl = buf = fs->buf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
/* We can fit the newline and blanks in before
|
||||||
|
the next word. */
|
||||||
|
*nl++ = '\n';
|
||||||
|
|
||||||
|
if (nextline - nl >= fs->wmargin
|
||||||
|
|| (nextline == buf + len + 1 && fs->end - nextline >= fs->wmargin))
|
||||||
|
/* Add blanks up to the wrap margin column. */
|
||||||
|
for (i = 0; i < fs->wmargin; ++i)
|
||||||
|
*nl++ = ' ';
|
||||||
|
else
|
||||||
|
for (i = 0; i < fs->wmargin; ++i)
|
||||||
|
#ifdef USE_IN_LIBIO
|
||||||
|
if (_IO_fwide (fs->stream, 0) > 0)
|
||||||
|
putwc_unlocked (L' ', fs->stream);
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
putc_unlocked (' ', fs->stream);
|
||||||
|
|
||||||
|
/* Copy the tail of the original buffer into the current buffer
|
||||||
|
position. */
|
||||||
|
if (nl < nextline)
|
||||||
|
memmove (nl, nextline, buf + len - nextline);
|
||||||
|
len -= nextline - buf;
|
||||||
|
|
||||||
|
/* Continue the scan on the remaining lines in the buffer. */
|
||||||
|
buf = nl;
|
||||||
|
|
||||||
|
/* Restore bufp to include all the remaining text. */
|
||||||
|
fs->p = nl + len;
|
||||||
|
|
||||||
|
/* Reset the counter of what has been output this line. If wmargin
|
||||||
|
is 0, we want to avoid the lmargin getting added, so we set
|
||||||
|
point_col to a magic value of -1 in that case. */
|
||||||
|
fs->point_col = fs->wmargin ? fs->wmargin : -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Remember that we've scanned as far as the end of the buffer. */
|
||||||
|
fs->point_offs = fs->p - fs->buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ensure that FS has space for AMOUNT more bytes in its buffer, either by
|
||||||
|
growing the buffer, or by flushing it. True is returned iff we succeed. */
|
||||||
|
int
|
||||||
|
__argp_fmtstream_ensure (struct argp_fmtstream *fs, size_t amount)
|
||||||
|
{
|
||||||
|
if ((size_t) (fs->end - fs->p) < amount)
|
||||||
|
{
|
||||||
|
ssize_t wrote;
|
||||||
|
|
||||||
|
/* Flush FS's buffer. */
|
||||||
|
__argp_fmtstream_update (fs);
|
||||||
|
|
||||||
|
#ifdef _LIBC
|
||||||
|
__fxprintf (fs->stream, "%.*s", (int) (fs->p - fs->buf), fs->buf);
|
||||||
|
wrote = fs->p - fs->buf;
|
||||||
|
#else
|
||||||
|
wrote = fwrite_unlocked (fs->buf, 1, fs->p - fs->buf, fs->stream);
|
||||||
|
#endif
|
||||||
|
if (wrote == fs->p - fs->buf)
|
||||||
|
{
|
||||||
|
fs->p = fs->buf;
|
||||||
|
fs->point_offs = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fs->p -= wrote;
|
||||||
|
fs->point_offs -= wrote;
|
||||||
|
memmove (fs->buf, fs->buf + wrote, fs->p - fs->buf);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((size_t) (fs->end - fs->buf) < amount)
|
||||||
|
/* Gotta grow the buffer. */
|
||||||
|
{
|
||||||
|
size_t old_size = fs->end - fs->buf;
|
||||||
|
size_t new_size = old_size + amount;
|
||||||
|
char *new_buf;
|
||||||
|
|
||||||
|
if (new_size < old_size || ! (new_buf = realloc (fs->buf, new_size)))
|
||||||
|
{
|
||||||
|
__set_errno (ENOMEM);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
fs->buf = new_buf;
|
||||||
|
fs->end = new_buf + new_size;
|
||||||
|
fs->p = fs->buf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ssize_t
|
||||||
|
__argp_fmtstream_printf (struct argp_fmtstream *fs, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
int out;
|
||||||
|
size_t avail;
|
||||||
|
size_t size_guess = PRINTF_SIZE_GUESS; /* How much space to reserve. */
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
if (! __argp_fmtstream_ensure (fs, size_guess))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
va_start (args, fmt);
|
||||||
|
avail = fs->end - fs->p;
|
||||||
|
out = __vsnprintf (fs->p, avail, fmt, args);
|
||||||
|
va_end (args);
|
||||||
|
if ((size_t) out >= avail)
|
||||||
|
size_guess = out + 1;
|
||||||
|
}
|
||||||
|
while ((size_t) out >= avail);
|
||||||
|
|
||||||
|
fs->p += out;
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
#if 0
|
||||||
|
/* Not exported. */
|
||||||
|
#ifdef weak_alias
|
||||||
|
weak_alias (__argp_fmtstream_printf, argp_fmtstream_printf)
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* !ARGP_FMTSTREAM_USE_LINEWRAP */
|
354
gnulib/argp-fmtstream.h
Normal file
354
gnulib/argp-fmtstream.h
Normal file
|
@ -0,0 +1,354 @@
|
||||||
|
/* Word-wrapping and line-truncating streams.
|
||||||
|
Copyright (C) 1997, 2006-2010 Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||||
|
|
||||||
|
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 3 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, see <http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
/* This package emulates glibc `line_wrap_stream' semantics for systems that
|
||||||
|
don't have that. If the system does have it, it is just a wrapper for
|
||||||
|
that. This header file is only used internally while compiling argp, and
|
||||||
|
shouldn't be installed. */
|
||||||
|
|
||||||
|
#ifndef _ARGP_FMTSTREAM_H
|
||||||
|
#define _ARGP_FMTSTREAM_H
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#ifndef __attribute__
|
||||||
|
/* The __attribute__ feature is available in gcc versions 2.5 and later.
|
||||||
|
The __-protected variants of the attributes 'format' and 'printf' are
|
||||||
|
accepted by gcc versions 2.6.4 (effectively 2.7) and later.
|
||||||
|
We enable __attribute__ only if these are supported too, because
|
||||||
|
gnulib and libintl do '#define printf __printf__' when they override
|
||||||
|
the 'printf' function. */
|
||||||
|
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
|
||||||
|
# define __attribute__(Spec) /* empty */
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (_LIBC - 0 && !defined (USE_IN_LIBIO)) \
|
||||||
|
|| (defined (__GNU_LIBRARY__) && defined (HAVE_LINEWRAP_H))
|
||||||
|
/* line_wrap_stream is available, so use that. */
|
||||||
|
#define ARGP_FMTSTREAM_USE_LINEWRAP
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ARGP_FMTSTREAM_USE_LINEWRAP
|
||||||
|
/* Just be a simple wrapper for line_wrap_stream; the semantics are
|
||||||
|
*slightly* different, as line_wrap_stream doesn't actually make a new
|
||||||
|
object, it just modifies the given stream (reversibly) to do
|
||||||
|
line-wrapping. Since we control who uses this code, it doesn't matter. */
|
||||||
|
|
||||||
|
#include <linewrap.h>
|
||||||
|
|
||||||
|
typedef FILE *argp_fmtstream_t;
|
||||||
|
|
||||||
|
#define argp_make_fmtstream line_wrap_stream
|
||||||
|
#define __argp_make_fmtstream line_wrap_stream
|
||||||
|
#define argp_fmtstream_free line_unwrap_stream
|
||||||
|
#define __argp_fmtstream_free line_unwrap_stream
|
||||||
|
|
||||||
|
#define __argp_fmtstream_putc(fs,ch) putc(ch,fs)
|
||||||
|
#define argp_fmtstream_putc(fs,ch) putc(ch,fs)
|
||||||
|
#define __argp_fmtstream_puts(fs,str) fputs(str,fs)
|
||||||
|
#define argp_fmtstream_puts(fs,str) fputs(str,fs)
|
||||||
|
#define __argp_fmtstream_write(fs,str,len) fwrite(str,1,len,fs)
|
||||||
|
#define argp_fmtstream_write(fs,str,len) fwrite(str,1,len,fs)
|
||||||
|
#define __argp_fmtstream_printf fprintf
|
||||||
|
#define argp_fmtstream_printf fprintf
|
||||||
|
|
||||||
|
#define __argp_fmtstream_lmargin line_wrap_lmargin
|
||||||
|
#define argp_fmtstream_lmargin line_wrap_lmargin
|
||||||
|
#define __argp_fmtstream_set_lmargin line_wrap_set_lmargin
|
||||||
|
#define argp_fmtstream_set_lmargin line_wrap_set_lmargin
|
||||||
|
#define __argp_fmtstream_rmargin line_wrap_rmargin
|
||||||
|
#define argp_fmtstream_rmargin line_wrap_rmargin
|
||||||
|
#define __argp_fmtstream_set_rmargin line_wrap_set_rmargin
|
||||||
|
#define argp_fmtstream_set_rmargin line_wrap_set_rmargin
|
||||||
|
#define __argp_fmtstream_wmargin line_wrap_wmargin
|
||||||
|
#define argp_fmtstream_wmargin line_wrap_wmargin
|
||||||
|
#define __argp_fmtstream_set_wmargin line_wrap_set_wmargin
|
||||||
|
#define argp_fmtstream_set_wmargin line_wrap_set_wmargin
|
||||||
|
#define __argp_fmtstream_point line_wrap_point
|
||||||
|
#define argp_fmtstream_point line_wrap_point
|
||||||
|
|
||||||
|
#else /* !ARGP_FMTSTREAM_USE_LINEWRAP */
|
||||||
|
/* Guess we have to define our own version. */
|
||||||
|
|
||||||
|
struct argp_fmtstream
|
||||||
|
{
|
||||||
|
FILE *stream; /* The stream we're outputting to. */
|
||||||
|
|
||||||
|
size_t lmargin, rmargin; /* Left and right margins. */
|
||||||
|
ssize_t wmargin; /* Margin to wrap to, or -1 to truncate. */
|
||||||
|
|
||||||
|
/* Point in buffer to which we've processed for wrapping, but not output. */
|
||||||
|
size_t point_offs;
|
||||||
|
/* Output column at POINT_OFFS, or -1 meaning 0 but don't add lmargin. */
|
||||||
|
ssize_t point_col;
|
||||||
|
|
||||||
|
char *buf; /* Output buffer. */
|
||||||
|
char *p; /* Current end of text in BUF. */
|
||||||
|
char *end; /* Absolute end of BUF. */
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct argp_fmtstream *argp_fmtstream_t;
|
||||||
|
|
||||||
|
/* Return an argp_fmtstream that outputs to STREAM, and which prefixes lines
|
||||||
|
written on it with LMARGIN spaces and limits them to RMARGIN columns
|
||||||
|
total. If WMARGIN >= 0, words that extend past RMARGIN are wrapped by
|
||||||
|
replacing the whitespace before them with a newline and WMARGIN spaces.
|
||||||
|
Otherwise, chars beyond RMARGIN are simply dropped until a newline.
|
||||||
|
Returns NULL if there was an error. */
|
||||||
|
extern argp_fmtstream_t __argp_make_fmtstream (FILE *__stream,
|
||||||
|
size_t __lmargin,
|
||||||
|
size_t __rmargin,
|
||||||
|
ssize_t __wmargin);
|
||||||
|
extern argp_fmtstream_t argp_make_fmtstream (FILE *__stream,
|
||||||
|
size_t __lmargin,
|
||||||
|
size_t __rmargin,
|
||||||
|
ssize_t __wmargin);
|
||||||
|
|
||||||
|
/* Flush __FS to its stream, and free it (but don't close the stream). */
|
||||||
|
extern void __argp_fmtstream_free (argp_fmtstream_t __fs);
|
||||||
|
extern void argp_fmtstream_free (argp_fmtstream_t __fs);
|
||||||
|
|
||||||
|
extern ssize_t __argp_fmtstream_printf (argp_fmtstream_t __fs,
|
||||||
|
const char *__fmt, ...)
|
||||||
|
__attribute__ ((__format__ (printf, 2, 3)));
|
||||||
|
extern ssize_t argp_fmtstream_printf (argp_fmtstream_t __fs,
|
||||||
|
const char *__fmt, ...)
|
||||||
|
__attribute__ ((__format__ (printf, 2, 3)));
|
||||||
|
|
||||||
|
#if _LIBC || !defined __OPTIMIZE__
|
||||||
|
extern int __argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch);
|
||||||
|
extern int argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch);
|
||||||
|
|
||||||
|
extern int __argp_fmtstream_puts (argp_fmtstream_t __fs, const char *__str);
|
||||||
|
extern int argp_fmtstream_puts (argp_fmtstream_t __fs, const char *__str);
|
||||||
|
|
||||||
|
extern size_t __argp_fmtstream_write (argp_fmtstream_t __fs,
|
||||||
|
const char *__str, size_t __len);
|
||||||
|
extern size_t argp_fmtstream_write (argp_fmtstream_t __fs,
|
||||||
|
const char *__str, size_t __len);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Access macros for various bits of state. */
|
||||||
|
#define argp_fmtstream_lmargin(__fs) ((__fs)->lmargin)
|
||||||
|
#define argp_fmtstream_rmargin(__fs) ((__fs)->rmargin)
|
||||||
|
#define argp_fmtstream_wmargin(__fs) ((__fs)->wmargin)
|
||||||
|
#define __argp_fmtstream_lmargin argp_fmtstream_lmargin
|
||||||
|
#define __argp_fmtstream_rmargin argp_fmtstream_rmargin
|
||||||
|
#define __argp_fmtstream_wmargin argp_fmtstream_wmargin
|
||||||
|
|
||||||
|
#if _LIBC || !defined __OPTIMIZE__
|
||||||
|
/* Set __FS's left margin to LMARGIN and return the old value. */
|
||||||
|
extern size_t argp_fmtstream_set_lmargin (argp_fmtstream_t __fs,
|
||||||
|
size_t __lmargin);
|
||||||
|
extern size_t __argp_fmtstream_set_lmargin (argp_fmtstream_t __fs,
|
||||||
|
size_t __lmargin);
|
||||||
|
|
||||||
|
/* Set __FS's right margin to __RMARGIN and return the old value. */
|
||||||
|
extern size_t argp_fmtstream_set_rmargin (argp_fmtstream_t __fs,
|
||||||
|
size_t __rmargin);
|
||||||
|
extern size_t __argp_fmtstream_set_rmargin (argp_fmtstream_t __fs,
|
||||||
|
size_t __rmargin);
|
||||||
|
|
||||||
|
/* Set __FS's wrap margin to __WMARGIN and return the old value. */
|
||||||
|
extern size_t argp_fmtstream_set_wmargin (argp_fmtstream_t __fs,
|
||||||
|
size_t __wmargin);
|
||||||
|
extern size_t __argp_fmtstream_set_wmargin (argp_fmtstream_t __fs,
|
||||||
|
size_t __wmargin);
|
||||||
|
|
||||||
|
/* Return the column number of the current output point in __FS. */
|
||||||
|
extern size_t argp_fmtstream_point (argp_fmtstream_t __fs);
|
||||||
|
extern size_t __argp_fmtstream_point (argp_fmtstream_t __fs);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Internal routines. */
|
||||||
|
extern void _argp_fmtstream_update (argp_fmtstream_t __fs);
|
||||||
|
extern void __argp_fmtstream_update (argp_fmtstream_t __fs);
|
||||||
|
extern int _argp_fmtstream_ensure (argp_fmtstream_t __fs, size_t __amount);
|
||||||
|
extern int __argp_fmtstream_ensure (argp_fmtstream_t __fs, size_t __amount);
|
||||||
|
|
||||||
|
#ifdef __OPTIMIZE__
|
||||||
|
/* Inline versions of above routines. */
|
||||||
|
|
||||||
|
#if !_LIBC
|
||||||
|
#define __argp_fmtstream_putc argp_fmtstream_putc
|
||||||
|
#define __argp_fmtstream_puts argp_fmtstream_puts
|
||||||
|
#define __argp_fmtstream_write argp_fmtstream_write
|
||||||
|
#define __argp_fmtstream_set_lmargin argp_fmtstream_set_lmargin
|
||||||
|
#define __argp_fmtstream_set_rmargin argp_fmtstream_set_rmargin
|
||||||
|
#define __argp_fmtstream_set_wmargin argp_fmtstream_set_wmargin
|
||||||
|
#define __argp_fmtstream_point argp_fmtstream_point
|
||||||
|
#define __argp_fmtstream_update _argp_fmtstream_update
|
||||||
|
#define __argp_fmtstream_ensure _argp_fmtstream_ensure
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ARGP_FS_EI
|
||||||
|
# ifdef __GNUC__
|
||||||
|
/* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
|
||||||
|
inline semantics, unless -fgnu89-inline is used. It defines a macro
|
||||||
|
__GNUC_STDC_INLINE__ to indicate this situation or a macro
|
||||||
|
__GNUC_GNU_INLINE__ to indicate the opposite situation.
|
||||||
|
|
||||||
|
GCC 4.2 with -std=c99 or -std=gnu99 implements the GNU C inline
|
||||||
|
semantics but warns, unless -fgnu89-inline is used:
|
||||||
|
warning: C99 inline functions are not supported; using GNU89
|
||||||
|
warning: to disable this warning use -fgnu89-inline or the gnu_inline function attribute
|
||||||
|
It defines a macro __GNUC_GNU_INLINE__ to indicate this situation.
|
||||||
|
|
||||||
|
Whereas Apple GCC 4.0.1 build 5479 without -std=c99 or -std=gnu99
|
||||||
|
implements the GNU C inline semantics and defines the macro
|
||||||
|
__GNUC_GNU_INLINE__, but it does not warn and does not support
|
||||||
|
__attribute__ ((__gnu_inline__)).
|
||||||
|
|
||||||
|
All in all, these are the possible combinations. For every compiler,
|
||||||
|
we need to choose ARGP_FS_EI so that the corresponding table cell
|
||||||
|
contains an "ok".
|
||||||
|
|
||||||
|
\ ARGP_FS_EI inline extern extern
|
||||||
|
\ inline inline
|
||||||
|
CC \ __attribute__
|
||||||
|
((gnu_inline))
|
||||||
|
|
||||||
|
gcc 4.3.0 error ok ok
|
||||||
|
gcc 4.3.0 -std=gnu99 -fgnu89-inline error ok ok
|
||||||
|
gcc 4.3.0 -std=gnu99 ok error ok
|
||||||
|
|
||||||
|
gcc 4.2.2 error ok ok
|
||||||
|
gcc 4.2.2 -std=gnu99 -fgnu89-inline error ok ok
|
||||||
|
gcc 4.2.2 -std=gnu99 error warning ok
|
||||||
|
|
||||||
|
gcc 4.1.2 error ok warning
|
||||||
|
gcc 4.1.2 -std=gnu99 error ok warning
|
||||||
|
|
||||||
|
Apple gcc 4.0.1 error ok warning
|
||||||
|
Apple gcc 4.0.1 -std=gnu99 ok error warning
|
||||||
|
*/
|
||||||
|
# if defined __GNUC_STDC_INLINE__
|
||||||
|
# define ARGP_FS_EI inline
|
||||||
|
# elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)
|
||||||
|
# define ARGP_FS_EI extern inline __attribute__ ((__gnu_inline__))
|
||||||
|
# else
|
||||||
|
# define ARGP_FS_EI extern inline
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
/* With other compilers, assume the ISO C99 meaning of 'inline', if
|
||||||
|
the compiler supports 'inline' at all. */
|
||||||
|
# define ARGP_FS_EI inline
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ARGP_FS_EI size_t
|
||||||
|
__argp_fmtstream_write (argp_fmtstream_t __fs,
|
||||||
|
const char *__str, size_t __len)
|
||||||
|
{
|
||||||
|
if (__fs->p + __len <= __fs->end || __argp_fmtstream_ensure (__fs, __len))
|
||||||
|
{
|
||||||
|
memcpy (__fs->p, __str, __len);
|
||||||
|
__fs->p += __len;
|
||||||
|
return __len;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ARGP_FS_EI int
|
||||||
|
__argp_fmtstream_puts (argp_fmtstream_t __fs, const char *__str)
|
||||||
|
{
|
||||||
|
size_t __len = strlen (__str);
|
||||||
|
if (__len)
|
||||||
|
{
|
||||||
|
size_t __wrote = __argp_fmtstream_write (__fs, __str, __len);
|
||||||
|
return __wrote == __len ? 0 : -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ARGP_FS_EI int
|
||||||
|
__argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch)
|
||||||
|
{
|
||||||
|
if (__fs->p < __fs->end || __argp_fmtstream_ensure (__fs, 1))
|
||||||
|
return *__fs->p++ = __ch;
|
||||||
|
else
|
||||||
|
return EOF;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set __FS's left margin to __LMARGIN and return the old value. */
|
||||||
|
ARGP_FS_EI size_t
|
||||||
|
__argp_fmtstream_set_lmargin (argp_fmtstream_t __fs, size_t __lmargin)
|
||||||
|
{
|
||||||
|
size_t __old;
|
||||||
|
if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
|
||||||
|
__argp_fmtstream_update (__fs);
|
||||||
|
__old = __fs->lmargin;
|
||||||
|
__fs->lmargin = __lmargin;
|
||||||
|
return __old;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set __FS's right margin to __RMARGIN and return the old value. */
|
||||||
|
ARGP_FS_EI size_t
|
||||||
|
__argp_fmtstream_set_rmargin (argp_fmtstream_t __fs, size_t __rmargin)
|
||||||
|
{
|
||||||
|
size_t __old;
|
||||||
|
if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
|
||||||
|
__argp_fmtstream_update (__fs);
|
||||||
|
__old = __fs->rmargin;
|
||||||
|
__fs->rmargin = __rmargin;
|
||||||
|
return __old;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set FS's wrap margin to __WMARGIN and return the old value. */
|
||||||
|
ARGP_FS_EI size_t
|
||||||
|
__argp_fmtstream_set_wmargin (argp_fmtstream_t __fs, size_t __wmargin)
|
||||||
|
{
|
||||||
|
size_t __old;
|
||||||
|
if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
|
||||||
|
__argp_fmtstream_update (__fs);
|
||||||
|
__old = __fs->wmargin;
|
||||||
|
__fs->wmargin = __wmargin;
|
||||||
|
return __old;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return the column number of the current output point in __FS. */
|
||||||
|
ARGP_FS_EI size_t
|
||||||
|
__argp_fmtstream_point (argp_fmtstream_t __fs)
|
||||||
|
{
|
||||||
|
if ((size_t) (__fs->p - __fs->buf) > __fs->point_offs)
|
||||||
|
__argp_fmtstream_update (__fs);
|
||||||
|
return __fs->point_col >= 0 ? __fs->point_col : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !_LIBC
|
||||||
|
#undef __argp_fmtstream_putc
|
||||||
|
#undef __argp_fmtstream_puts
|
||||||
|
#undef __argp_fmtstream_write
|
||||||
|
#undef __argp_fmtstream_set_lmargin
|
||||||
|
#undef __argp_fmtstream_set_rmargin
|
||||||
|
#undef __argp_fmtstream_set_wmargin
|
||||||
|
#undef __argp_fmtstream_point
|
||||||
|
#undef __argp_fmtstream_update
|
||||||
|
#undef __argp_fmtstream_ensure
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __OPTIMIZE__ */
|
||||||
|
|
||||||
|
#endif /* ARGP_FMTSTREAM_USE_LINEWRAP */
|
||||||
|
|
||||||
|
#endif /* argp-fmtstream.h */
|
42
gnulib/argp-fs-xinl.c
Normal file
42
gnulib/argp-fs-xinl.c
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
/* Real definitions for extern inline functions in argp-fmtstream.h
|
||||||
|
Copyright (C) 1997, 2003, 2004, 2009, 2010 Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||||
|
|
||||||
|
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 3 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, see <http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define ARGP_FS_EI
|
||||||
|
#undef __OPTIMIZE__
|
||||||
|
#define __OPTIMIZE__ 1
|
||||||
|
#include "argp-fmtstream.h"
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/* Not exported. */
|
||||||
|
/* Add weak aliases. */
|
||||||
|
#if _LIBC - 0 && !defined (ARGP_FMTSTREAM_USE_LINEWRAP) && defined (weak_alias)
|
||||||
|
|
||||||
|
weak_alias (__argp_fmtstream_putc, argp_fmtstream_putc)
|
||||||
|
weak_alias (__argp_fmtstream_puts, argp_fmtstream_puts)
|
||||||
|
weak_alias (__argp_fmtstream_write, argp_fmtstream_write)
|
||||||
|
weak_alias (__argp_fmtstream_set_lmargin, argp_fmtstream_set_lmargin)
|
||||||
|
weak_alias (__argp_fmtstream_set_rmargin, argp_fmtstream_set_rmargin)
|
||||||
|
weak_alias (__argp_fmtstream_set_wmargin, argp_fmtstream_set_wmargin)
|
||||||
|
weak_alias (__argp_fmtstream_point, argp_fmtstream_point)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
1951
gnulib/argp-help.c
Normal file
1951
gnulib/argp-help.c
Normal file
File diff suppressed because it is too large
Load diff
157
gnulib/argp-namefrob.h
Normal file
157
gnulib/argp-namefrob.h
Normal file
|
@ -0,0 +1,157 @@
|
||||||
|
/* Name frobnication for compiling argp outside of glibc
|
||||||
|
Copyright (C) 1997, 2003, 2007, 2009, 2010 Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||||
|
|
||||||
|
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 3 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, see <http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
#if !_LIBC
|
||||||
|
/* This code is written for inclusion in gnu-libc, and uses names in the
|
||||||
|
namespace reserved for libc. If we're not compiling in libc, define those
|
||||||
|
names to be the normal ones instead. */
|
||||||
|
|
||||||
|
/* argp-parse functions */
|
||||||
|
#undef __argp_parse
|
||||||
|
#define __argp_parse argp_parse
|
||||||
|
#undef __option_is_end
|
||||||
|
#define __option_is_end _option_is_end
|
||||||
|
#undef __option_is_short
|
||||||
|
#define __option_is_short _option_is_short
|
||||||
|
#undef __argp_input
|
||||||
|
#define __argp_input _argp_input
|
||||||
|
|
||||||
|
/* argp-help functions */
|
||||||
|
#undef __argp_help
|
||||||
|
#define __argp_help argp_help
|
||||||
|
#undef __argp_error
|
||||||
|
#define __argp_error argp_error
|
||||||
|
#undef __argp_failure
|
||||||
|
#define __argp_failure argp_failure
|
||||||
|
#undef __argp_state_help
|
||||||
|
#define __argp_state_help argp_state_help
|
||||||
|
#undef __argp_usage
|
||||||
|
#define __argp_usage argp_usage
|
||||||
|
|
||||||
|
/* argp-fmtstream functions */
|
||||||
|
#undef __argp_make_fmtstream
|
||||||
|
#define __argp_make_fmtstream argp_make_fmtstream
|
||||||
|
#undef __argp_fmtstream_free
|
||||||
|
#define __argp_fmtstream_free argp_fmtstream_free
|
||||||
|
#undef __argp_fmtstream_putc
|
||||||
|
#define __argp_fmtstream_putc argp_fmtstream_putc
|
||||||
|
#undef __argp_fmtstream_puts
|
||||||
|
#define __argp_fmtstream_puts argp_fmtstream_puts
|
||||||
|
#undef __argp_fmtstream_write
|
||||||
|
#define __argp_fmtstream_write argp_fmtstream_write
|
||||||
|
#undef __argp_fmtstream_printf
|
||||||
|
#define __argp_fmtstream_printf argp_fmtstream_printf
|
||||||
|
#undef __argp_fmtstream_set_lmargin
|
||||||
|
#define __argp_fmtstream_set_lmargin argp_fmtstream_set_lmargin
|
||||||
|
#undef __argp_fmtstream_set_rmargin
|
||||||
|
#define __argp_fmtstream_set_rmargin argp_fmtstream_set_rmargin
|
||||||
|
#undef __argp_fmtstream_set_wmargin
|
||||||
|
#define __argp_fmtstream_set_wmargin argp_fmtstream_set_wmargin
|
||||||
|
#undef __argp_fmtstream_point
|
||||||
|
#define __argp_fmtstream_point argp_fmtstream_point
|
||||||
|
#undef __argp_fmtstream_update
|
||||||
|
#define __argp_fmtstream_update _argp_fmtstream_update
|
||||||
|
#undef __argp_fmtstream_ensure
|
||||||
|
#define __argp_fmtstream_ensure _argp_fmtstream_ensure
|
||||||
|
#undef __argp_fmtstream_lmargin
|
||||||
|
#define __argp_fmtstream_lmargin argp_fmtstream_lmargin
|
||||||
|
#undef __argp_fmtstream_rmargin
|
||||||
|
#define __argp_fmtstream_rmargin argp_fmtstream_rmargin
|
||||||
|
#undef __argp_fmtstream_wmargin
|
||||||
|
#define __argp_fmtstream_wmargin argp_fmtstream_wmargin
|
||||||
|
|
||||||
|
/* normal libc functions we call */
|
||||||
|
#undef __flockfile
|
||||||
|
#define __flockfile flockfile
|
||||||
|
#undef __funlockfile
|
||||||
|
#define __funlockfile funlockfile
|
||||||
|
#undef __mempcpy
|
||||||
|
#define __mempcpy mempcpy
|
||||||
|
#undef __sleep
|
||||||
|
#define __sleep sleep
|
||||||
|
#undef __strcasecmp
|
||||||
|
#define __strcasecmp strcasecmp
|
||||||
|
#undef __strchrnul
|
||||||
|
#define __strchrnul strchrnul
|
||||||
|
#undef __strerror_r
|
||||||
|
#define __strerror_r strerror_r
|
||||||
|
#undef __strndup
|
||||||
|
#define __strndup strndup
|
||||||
|
#undef __vsnprintf
|
||||||
|
#define __vsnprintf vsnprintf
|
||||||
|
|
||||||
|
#if defined(HAVE_DECL_CLEARERR_UNLOCKED) && !HAVE_DECL_CLEARERR_UNLOCKED
|
||||||
|
# define clearerr_unlocked(x) clearerr (x)
|
||||||
|
#endif
|
||||||
|
#if defined(HAVE_DECL_FEOF_UNLOCKED) && !HAVE_DECL_FEOF_UNLOCKED
|
||||||
|
# define feof_unlocked(x) feof (x)
|
||||||
|
# endif
|
||||||
|
#if defined(HAVE_DECL_FERROR_UNLOCKED) && !HAVE_DECL_FERROR_UNLOCKED
|
||||||
|
# define ferror_unlocked(x) ferror (x)
|
||||||
|
# endif
|
||||||
|
#if defined(HAVE_DECL_FFLUSH_UNLOCKED) && !HAVE_DECL_FFLUSH_UNLOCKED
|
||||||
|
# define fflush_unlocked(x) fflush (x)
|
||||||
|
# endif
|
||||||
|
#if defined(HAVE_DECL_FGETS_UNLOCKED) && !HAVE_DECL_FGETS_UNLOCKED
|
||||||
|
# define fgets_unlocked(x,y,z) fgets (x,y,z)
|
||||||
|
# endif
|
||||||
|
#if defined(HAVE_DECL_FPUTC_UNLOCKED) && !HAVE_DECL_FPUTC_UNLOCKED
|
||||||
|
# define fputc_unlocked(x,y) fputc (x,y)
|
||||||
|
# endif
|
||||||
|
#if defined(HAVE_DECL_FPUTS_UNLOCKED) && !HAVE_DECL_FPUTS_UNLOCKED
|
||||||
|
# define fputs_unlocked(x,y) fputs (x,y)
|
||||||
|
# endif
|
||||||
|
#if defined(HAVE_DECL_FREAD_UNLOCKED) && !HAVE_DECL_FREAD_UNLOCKED
|
||||||
|
# define fread_unlocked(w,x,y,z) fread (w,x,y,z)
|
||||||
|
# endif
|
||||||
|
#if defined(HAVE_DECL_FWRITE_UNLOCKED) && !HAVE_DECL_FWRITE_UNLOCKED
|
||||||
|
# define fwrite_unlocked(w,x,y,z) fwrite (w,x,y,z)
|
||||||
|
# endif
|
||||||
|
#if defined(HAVE_DECL_GETC_UNLOCKED) && !HAVE_DECL_GETC_UNLOCKED
|
||||||
|
# define getc_unlocked(x) getc (x)
|
||||||
|
# endif
|
||||||
|
#if defined(HAVE_DECL_GETCHAR_UNLOCKED) && !HAVE_DECL_GETCHAR_UNLOCKED
|
||||||
|
# define getchar_unlocked() getchar ()
|
||||||
|
# endif
|
||||||
|
#if defined(HAVE_DECL_PUTC_UNLOCKED) && !HAVE_DECL_PUTC_UNLOCKED
|
||||||
|
# define putc_unlocked(x,y) putc (x,y)
|
||||||
|
# endif
|
||||||
|
#if defined(HAVE_DECL_PUTCHAR_UNLOCKED) && !HAVE_DECL_PUTCHAR_UNLOCKED
|
||||||
|
# define putchar_unlocked(x) putchar (x)
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#endif /* !_LIBC */
|
||||||
|
|
||||||
|
#ifndef __set_errno
|
||||||
|
#define __set_errno(e) (errno = (e))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined GNULIB_ARGP_DISABLE_DIRNAME
|
||||||
|
# define __argp_base_name(arg) arg
|
||||||
|
#elif defined GNULIB_ARGP_EXTERN_BASENAME
|
||||||
|
extern char *__argp_base_name (const char *arg);
|
||||||
|
#else
|
||||||
|
# include "dirname.h"
|
||||||
|
# define __argp_base_name last_component
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined _LIBC || HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
|
||||||
|
# define __argp_short_program_name() (program_invocation_short_name)
|
||||||
|
#else
|
||||||
|
extern char *__argp_short_program_name (void);
|
||||||
|
#endif
|
952
gnulib/argp-parse.c
Normal file
952
gnulib/argp-parse.c
Normal file
|
@ -0,0 +1,952 @@
|
||||||
|
/* Hierarchial argument parsing, layered over getopt
|
||||||
|
Copyright (C) 1995-2000, 2002-2004, 2009-2010 Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||||
|
|
||||||
|
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 3 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, see <http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <alloca.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <getopt.h>
|
||||||
|
#include <getopt_int.h>
|
||||||
|
|
||||||
|
#ifdef _LIBC
|
||||||
|
# include <libintl.h>
|
||||||
|
# undef dgettext
|
||||||
|
# define dgettext(domain, msgid) \
|
||||||
|
INTUSE(__dcgettext) (domain, msgid, LC_MESSAGES)
|
||||||
|
#else
|
||||||
|
# include "gettext.h"
|
||||||
|
#endif
|
||||||
|
#define N_(msgid) msgid
|
||||||
|
|
||||||
|
#include "argp.h"
|
||||||
|
#include "argp-namefrob.h"
|
||||||
|
|
||||||
|
#define alignof(type) offsetof (struct { char c; type x; }, x)
|
||||||
|
#define alignto(n, d) ((((n) + (d) - 1) / (d)) * (d))
|
||||||
|
|
||||||
|
/* Getopt return values. */
|
||||||
|
#define KEY_END (-1) /* The end of the options. */
|
||||||
|
#define KEY_ARG 1 /* A non-option argument. */
|
||||||
|
#define KEY_ERR '?' /* An error parsing the options. */
|
||||||
|
|
||||||
|
/* The meta-argument used to prevent any further arguments being interpreted
|
||||||
|
as options. */
|
||||||
|
#define QUOTE "--"
|
||||||
|
|
||||||
|
/* The number of bits we steal in a long-option value for our own use. */
|
||||||
|
#define GROUP_BITS CHAR_BIT
|
||||||
|
|
||||||
|
/* The number of bits available for the user value. */
|
||||||
|
#define USER_BITS ((sizeof ((struct option *)0)->val * CHAR_BIT) - GROUP_BITS)
|
||||||
|
#define USER_MASK ((1 << USER_BITS) - 1)
|
||||||
|
|
||||||
|
/* EZ alias for ARGP_ERR_UNKNOWN. */
|
||||||
|
#define EBADKEY ARGP_ERR_UNKNOWN
|
||||||
|
|
||||||
|
/* Default options. */
|
||||||
|
|
||||||
|
/* When argp is given the --HANG switch, _ARGP_HANG is set and argp will sleep
|
||||||
|
for one second intervals, decrementing _ARGP_HANG until it's zero. Thus
|
||||||
|
you can force the program to continue by attaching a debugger and setting
|
||||||
|
it to 0 yourself. */
|
||||||
|
static volatile int _argp_hang;
|
||||||
|
|
||||||
|
#define OPT_PROGNAME -2
|
||||||
|
#define OPT_USAGE -3
|
||||||
|
#define OPT_HANG -4
|
||||||
|
|
||||||
|
static const struct argp_option argp_default_options[] =
|
||||||
|
{
|
||||||
|
{"help", '?', 0, 0, N_("give this help list"), -1},
|
||||||
|
{"usage", OPT_USAGE, 0, 0, N_("give a short usage message"), 0},
|
||||||
|
{"program-name",OPT_PROGNAME,N_("NAME"), OPTION_HIDDEN, N_("set the program name"), 0},
|
||||||
|
{"HANG", OPT_HANG, N_("SECS"), OPTION_ARG_OPTIONAL | OPTION_HIDDEN,
|
||||||
|
N_("hang for SECS seconds (default 3600)"), 0},
|
||||||
|
{NULL, 0, 0, 0, NULL, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
static error_t
|
||||||
|
argp_default_parser (int key, char *arg, struct argp_state *state)
|
||||||
|
{
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
case '?':
|
||||||
|
__argp_state_help (state, state->out_stream, ARGP_HELP_STD_HELP);
|
||||||
|
break;
|
||||||
|
case OPT_USAGE:
|
||||||
|
__argp_state_help (state, state->out_stream,
|
||||||
|
ARGP_HELP_USAGE | ARGP_HELP_EXIT_OK);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OPT_PROGNAME: /* Set the program name. */
|
||||||
|
#if defined _LIBC || HAVE_DECL_PROGRAM_INVOCATION_NAME
|
||||||
|
program_invocation_name = arg;
|
||||||
|
#endif
|
||||||
|
/* [Note that some systems only have PROGRAM_INVOCATION_SHORT_NAME (aka
|
||||||
|
__PROGNAME), in which case, PROGRAM_INVOCATION_NAME is just defined
|
||||||
|
to be that, so we have to be a bit careful here.] */
|
||||||
|
|
||||||
|
/* Update what we use for messages. */
|
||||||
|
state->name = __argp_base_name (arg);
|
||||||
|
|
||||||
|
#if defined _LIBC || HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
|
||||||
|
program_invocation_short_name = state->name;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if ((state->flags & (ARGP_PARSE_ARGV0 | ARGP_NO_ERRS))
|
||||||
|
== ARGP_PARSE_ARGV0)
|
||||||
|
/* Update what getopt uses too. */
|
||||||
|
state->argv[0] = arg;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OPT_HANG:
|
||||||
|
_argp_hang = atoi (arg ? arg : "3600");
|
||||||
|
while (_argp_hang-- > 0)
|
||||||
|
__sleep (1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return EBADKEY;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct argp argp_default_argp =
|
||||||
|
{argp_default_options, &argp_default_parser, NULL, NULL, NULL, NULL, "libc"};
|
||||||
|
|
||||||
|
|
||||||
|
static const struct argp_option argp_version_options[] =
|
||||||
|
{
|
||||||
|
{"version", 'V', 0, 0, N_("print program version"), -1},
|
||||||
|
{NULL, 0, 0, 0, NULL, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
static error_t
|
||||||
|
argp_version_parser (int key, char *arg, struct argp_state *state)
|
||||||
|
{
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
case 'V':
|
||||||
|
if (argp_program_version_hook)
|
||||||
|
(*argp_program_version_hook) (state->out_stream, state);
|
||||||
|
else if (argp_program_version)
|
||||||
|
fprintf (state->out_stream, "%s\n", argp_program_version);
|
||||||
|
else
|
||||||
|
__argp_error (state, dgettext (state->root_argp->argp_domain,
|
||||||
|
"(PROGRAM ERROR) No version known!?"));
|
||||||
|
if (! (state->flags & ARGP_NO_EXIT))
|
||||||
|
exit (0);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return EBADKEY;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct argp argp_version_argp =
|
||||||
|
{argp_version_options, &argp_version_parser, NULL, NULL, NULL, NULL, "libc"};
|
||||||
|
|
||||||
|
/* Returns the offset into the getopt long options array LONG_OPTIONS of a
|
||||||
|
long option with called NAME, or -1 if none is found. Passing NULL as
|
||||||
|
NAME will return the number of options. */
|
||||||
|
static int
|
||||||
|
find_long_option (struct option *long_options, const char *name)
|
||||||
|
{
|
||||||
|
struct option *l = long_options;
|
||||||
|
while (l->name != NULL)
|
||||||
|
if (name != NULL && strcmp (l->name, name) == 0)
|
||||||
|
return l - long_options;
|
||||||
|
else
|
||||||
|
l++;
|
||||||
|
if (name == NULL)
|
||||||
|
return l - long_options;
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* The state of a `group' during parsing. Each group corresponds to a
|
||||||
|
particular argp structure from the tree of such descending from the top
|
||||||
|
level argp passed to argp_parse. */
|
||||||
|
struct group
|
||||||
|
{
|
||||||
|
/* This group's parsing function. */
|
||||||
|
argp_parser_t parser;
|
||||||
|
|
||||||
|
/* Which argp this group is from. */
|
||||||
|
const struct argp *argp;
|
||||||
|
|
||||||
|
/* Points to the point in SHORT_OPTS corresponding to the end of the short
|
||||||
|
options for this group. We use it to determine from which group a
|
||||||
|
particular short options is from. */
|
||||||
|
char *short_end;
|
||||||
|
|
||||||
|
/* The number of non-option args sucessfully handled by this parser. */
|
||||||
|
unsigned args_processed;
|
||||||
|
|
||||||
|
/* This group's parser's parent's group. */
|
||||||
|
struct group *parent;
|
||||||
|
unsigned parent_index; /* And the our position in the parent. */
|
||||||
|
|
||||||
|
/* These fields are swapped into and out of the state structure when
|
||||||
|
calling this group's parser. */
|
||||||
|
void *input, **child_inputs;
|
||||||
|
void *hook;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Call GROUP's parser with KEY and ARG, swapping any group-specific info
|
||||||
|
from STATE before calling, and back into state afterwards. If GROUP has
|
||||||
|
no parser, EBADKEY is returned. */
|
||||||
|
static error_t
|
||||||
|
group_parse (struct group *group, struct argp_state *state, int key, char *arg)
|
||||||
|
{
|
||||||
|
if (group->parser)
|
||||||
|
{
|
||||||
|
error_t err;
|
||||||
|
state->hook = group->hook;
|
||||||
|
state->input = group->input;
|
||||||
|
state->child_inputs = group->child_inputs;
|
||||||
|
state->arg_num = group->args_processed;
|
||||||
|
err = (*group->parser)(key, arg, state);
|
||||||
|
group->hook = state->hook;
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return EBADKEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct parser
|
||||||
|
{
|
||||||
|
const struct argp *argp;
|
||||||
|
|
||||||
|
/* SHORT_OPTS is the getopt short options string for the union of all the
|
||||||
|
groups of options. */
|
||||||
|
char *short_opts;
|
||||||
|
/* LONG_OPTS is the array of getop long option structures for the union of
|
||||||
|
all the groups of options. */
|
||||||
|
struct option *long_opts;
|
||||||
|
/* OPT_DATA is the getopt data used for the re-entrant getopt. */
|
||||||
|
struct _getopt_data opt_data;
|
||||||
|
|
||||||
|
/* States of the various parsing groups. */
|
||||||
|
struct group *groups;
|
||||||
|
/* The end of the GROUPS array. */
|
||||||
|
struct group *egroup;
|
||||||
|
/* An vector containing storage for the CHILD_INPUTS field in all groups. */
|
||||||
|
void **child_inputs;
|
||||||
|
|
||||||
|
/* True if we think using getopt is still useful; if false, then
|
||||||
|
remaining arguments are just passed verbatim with ARGP_KEY_ARG. This is
|
||||||
|
cleared whenever getopt returns KEY_END, but may be set again if the user
|
||||||
|
moves the next argument pointer backwards. */
|
||||||
|
int try_getopt;
|
||||||
|
|
||||||
|
/* State block supplied to parsing routines. */
|
||||||
|
struct argp_state state;
|
||||||
|
|
||||||
|
/* Memory used by this parser. */
|
||||||
|
void *storage;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* The next usable entries in the various parser tables being filled in by
|
||||||
|
convert_options. */
|
||||||
|
struct parser_convert_state
|
||||||
|
{
|
||||||
|
struct parser *parser;
|
||||||
|
char *short_end;
|
||||||
|
struct option *long_end;
|
||||||
|
void **child_inputs_end;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Converts all options in ARGP (which is put in GROUP) and ancestors
|
||||||
|
into getopt options stored in SHORT_OPTS and LONG_OPTS; SHORT_END and
|
||||||
|
CVT->LONG_END are the points at which new options are added. Returns the
|
||||||
|
next unused group entry. CVT holds state used during the conversion. */
|
||||||
|
static struct group *
|
||||||
|
convert_options (const struct argp *argp,
|
||||||
|
struct group *parent, unsigned parent_index,
|
||||||
|
struct group *group, struct parser_convert_state *cvt)
|
||||||
|
{
|
||||||
|
/* REAL is the most recent non-alias value of OPT. */
|
||||||
|
const struct argp_option *real = argp->options;
|
||||||
|
const struct argp_child *children = argp->children;
|
||||||
|
|
||||||
|
if (real || argp->parser)
|
||||||
|
{
|
||||||
|
const struct argp_option *opt;
|
||||||
|
|
||||||
|
if (real)
|
||||||
|
for (opt = real; !__option_is_end (opt); opt++)
|
||||||
|
{
|
||||||
|
if (! (opt->flags & OPTION_ALIAS))
|
||||||
|
/* OPT isn't an alias, so we can use values from it. */
|
||||||
|
real = opt;
|
||||||
|
|
||||||
|
if (! (real->flags & OPTION_DOC))
|
||||||
|
/* A real option (not just documentation). */
|
||||||
|
{
|
||||||
|
if (__option_is_short (opt))
|
||||||
|
/* OPT can be used as a short option. */
|
||||||
|
{
|
||||||
|
*cvt->short_end++ = opt->key;
|
||||||
|
if (real->arg)
|
||||||
|
{
|
||||||
|
*cvt->short_end++ = ':';
|
||||||
|
if (real->flags & OPTION_ARG_OPTIONAL)
|
||||||
|
*cvt->short_end++ = ':';
|
||||||
|
}
|
||||||
|
*cvt->short_end = '\0'; /* keep 0 terminated */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opt->name
|
||||||
|
&& find_long_option (cvt->parser->long_opts, opt->name) < 0)
|
||||||
|
/* OPT can be used as a long option. */
|
||||||
|
{
|
||||||
|
cvt->long_end->name = opt->name;
|
||||||
|
cvt->long_end->has_arg =
|
||||||
|
(real->arg
|
||||||
|
? (real->flags & OPTION_ARG_OPTIONAL
|
||||||
|
? optional_argument
|
||||||
|
: required_argument)
|
||||||
|
: no_argument);
|
||||||
|
cvt->long_end->flag = 0;
|
||||||
|
/* we add a disambiguating code to all the user's
|
||||||
|
values (which is removed before we actually call
|
||||||
|
the function to parse the value); this means that
|
||||||
|
the user loses use of the high 8 bits in all his
|
||||||
|
values (the sign of the lower bits is preserved
|
||||||
|
however)... */
|
||||||
|
cvt->long_end->val =
|
||||||
|
((opt->key ? opt->key : real->key) & USER_MASK)
|
||||||
|
+ (((group - cvt->parser->groups) + 1) << USER_BITS);
|
||||||
|
|
||||||
|
/* Keep the LONG_OPTS list terminated. */
|
||||||
|
(++cvt->long_end)->name = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
group->parser = argp->parser;
|
||||||
|
group->argp = argp;
|
||||||
|
group->short_end = cvt->short_end;
|
||||||
|
group->args_processed = 0;
|
||||||
|
group->parent = parent;
|
||||||
|
group->parent_index = parent_index;
|
||||||
|
group->input = 0;
|
||||||
|
group->hook = 0;
|
||||||
|
group->child_inputs = 0;
|
||||||
|
|
||||||
|
if (children)
|
||||||
|
/* Assign GROUP's CHILD_INPUTS field some space from
|
||||||
|
CVT->child_inputs_end.*/
|
||||||
|
{
|
||||||
|
unsigned num_children = 0;
|
||||||
|
while (children[num_children].argp)
|
||||||
|
num_children++;
|
||||||
|
group->child_inputs = cvt->child_inputs_end;
|
||||||
|
cvt->child_inputs_end += num_children;
|
||||||
|
}
|
||||||
|
|
||||||
|
parent = group++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
parent = 0;
|
||||||
|
|
||||||
|
if (children)
|
||||||
|
{
|
||||||
|
unsigned index = 0;
|
||||||
|
while (children->argp)
|
||||||
|
group =
|
||||||
|
convert_options (children++->argp, parent, index++, group, cvt);
|
||||||
|
}
|
||||||
|
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Find the merged set of getopt options, with keys appropiately prefixed. */
|
||||||
|
static void
|
||||||
|
parser_convert (struct parser *parser, const struct argp *argp, int flags)
|
||||||
|
{
|
||||||
|
struct parser_convert_state cvt;
|
||||||
|
|
||||||
|
cvt.parser = parser;
|
||||||
|
cvt.short_end = parser->short_opts;
|
||||||
|
cvt.long_end = parser->long_opts;
|
||||||
|
cvt.child_inputs_end = parser->child_inputs;
|
||||||
|
|
||||||
|
if (flags & ARGP_IN_ORDER)
|
||||||
|
*cvt.short_end++ = '-';
|
||||||
|
else if (flags & ARGP_NO_ARGS)
|
||||||
|
*cvt.short_end++ = '+';
|
||||||
|
*cvt.short_end = '\0';
|
||||||
|
|
||||||
|
cvt.long_end->name = NULL;
|
||||||
|
|
||||||
|
parser->argp = argp;
|
||||||
|
|
||||||
|
if (argp)
|
||||||
|
parser->egroup = convert_options (argp, 0, 0, parser->groups, &cvt);
|
||||||
|
else
|
||||||
|
parser->egroup = parser->groups; /* No parsers at all! */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Lengths of various parser fields which we will allocated. */
|
||||||
|
struct parser_sizes
|
||||||
|
{
|
||||||
|
size_t short_len; /* Getopt short options string. */
|
||||||
|
size_t long_len; /* Getopt long options vector. */
|
||||||
|
size_t num_groups; /* Group structures we allocate. */
|
||||||
|
size_t num_child_inputs; /* Child input slots. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* For ARGP, increments the NUM_GROUPS field in SZS by the total number of
|
||||||
|
argp structures descended from it, and the SHORT_LEN & LONG_LEN fields by
|
||||||
|
the maximum lengths of the resulting merged getopt short options string and
|
||||||
|
long-options array, respectively. */
|
||||||
|
static void
|
||||||
|
calc_sizes (const struct argp *argp, struct parser_sizes *szs)
|
||||||
|
{
|
||||||
|
const struct argp_child *child = argp->children;
|
||||||
|
const struct argp_option *opt = argp->options;
|
||||||
|
|
||||||
|
if (opt || argp->parser)
|
||||||
|
{
|
||||||
|
szs->num_groups++;
|
||||||
|
if (opt)
|
||||||
|
{
|
||||||
|
int num_opts = 0;
|
||||||
|
while (!__option_is_end (opt++))
|
||||||
|
num_opts++;
|
||||||
|
szs->short_len += num_opts * 3; /* opt + up to 2 `:'s */
|
||||||
|
szs->long_len += num_opts;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (child)
|
||||||
|
while (child->argp)
|
||||||
|
{
|
||||||
|
calc_sizes ((child++)->argp, szs);
|
||||||
|
szs->num_child_inputs++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initializes PARSER to parse ARGP in a manner described by FLAGS. */
|
||||||
|
static error_t
|
||||||
|
parser_init (struct parser *parser, const struct argp *argp,
|
||||||
|
int argc, char **argv, int flags, void *input)
|
||||||
|
{
|
||||||
|
error_t err = 0;
|
||||||
|
struct group *group;
|
||||||
|
struct parser_sizes szs;
|
||||||
|
struct _getopt_data opt_data = _GETOPT_DATA_INITIALIZER;
|
||||||
|
char *storage;
|
||||||
|
size_t glen, gsum;
|
||||||
|
size_t clen, csum;
|
||||||
|
size_t llen, lsum;
|
||||||
|
size_t slen, ssum;
|
||||||
|
|
||||||
|
szs.short_len = (flags & ARGP_NO_ARGS) ? 0 : 1;
|
||||||
|
szs.long_len = 0;
|
||||||
|
szs.num_groups = 0;
|
||||||
|
szs.num_child_inputs = 0;
|
||||||
|
|
||||||
|
if (argp)
|
||||||
|
calc_sizes (argp, &szs);
|
||||||
|
|
||||||
|
/* Lengths of the various bits of storage used by PARSER. */
|
||||||
|
glen = (szs.num_groups + 1) * sizeof (struct group);
|
||||||
|
clen = szs.num_child_inputs * sizeof (void *);
|
||||||
|
llen = (szs.long_len + 1) * sizeof (struct option);
|
||||||
|
slen = szs.short_len + 1;
|
||||||
|
|
||||||
|
/* Sums of previous lengths, properly aligned. There's no need to
|
||||||
|
align gsum, since struct group is aligned at least as strictly as
|
||||||
|
void * (since it contains a void * member). And there's no need
|
||||||
|
to align lsum, since struct option is aligned at least as
|
||||||
|
strictly as char. */
|
||||||
|
gsum = glen;
|
||||||
|
csum = alignto (gsum + clen, alignof (struct option));
|
||||||
|
lsum = csum + llen;
|
||||||
|
ssum = lsum + slen;
|
||||||
|
|
||||||
|
parser->storage = malloc (ssum);
|
||||||
|
if (! parser->storage)
|
||||||
|
return ENOMEM;
|
||||||
|
|
||||||
|
storage = parser->storage;
|
||||||
|
parser->groups = parser->storage;
|
||||||
|
parser->child_inputs = (void **) (storage + gsum);
|
||||||
|
parser->long_opts = (struct option *) (storage + csum);
|
||||||
|
parser->short_opts = storage + lsum;
|
||||||
|
parser->opt_data = opt_data;
|
||||||
|
|
||||||
|
memset (parser->child_inputs, 0, clen);
|
||||||
|
parser_convert (parser, argp, flags);
|
||||||
|
|
||||||
|
memset (&parser->state, 0, sizeof (struct argp_state));
|
||||||
|
parser->state.root_argp = parser->argp;
|
||||||
|
parser->state.argc = argc;
|
||||||
|
parser->state.argv = argv;
|
||||||
|
parser->state.flags = flags;
|
||||||
|
parser->state.err_stream = stderr;
|
||||||
|
parser->state.out_stream = stdout;
|
||||||
|
parser->state.next = 0; /* Tell getopt to initialize. */
|
||||||
|
parser->state.pstate = parser;
|
||||||
|
|
||||||
|
parser->try_getopt = 1;
|
||||||
|
|
||||||
|
/* Call each parser for the first time, giving it a chance to propagate
|
||||||
|
values to child parsers. */
|
||||||
|
if (parser->groups < parser->egroup)
|
||||||
|
parser->groups->input = input;
|
||||||
|
for (group = parser->groups;
|
||||||
|
group < parser->egroup && (!err || err == EBADKEY);
|
||||||
|
group++)
|
||||||
|
{
|
||||||
|
if (group->parent)
|
||||||
|
/* If a child parser, get the initial input value from the parent. */
|
||||||
|
group->input = group->parent->child_inputs[group->parent_index];
|
||||||
|
|
||||||
|
if (!group->parser
|
||||||
|
&& group->argp->children && group->argp->children->argp)
|
||||||
|
/* For the special case where no parsing function is supplied for an
|
||||||
|
argp, propagate its input to its first child, if any (this just
|
||||||
|
makes very simple wrapper argps more convenient). */
|
||||||
|
group->child_inputs[0] = group->input;
|
||||||
|
|
||||||
|
err = group_parse (group, &parser->state, ARGP_KEY_INIT, 0);
|
||||||
|
}
|
||||||
|
if (err == EBADKEY)
|
||||||
|
err = 0; /* Some parser didn't understand. */
|
||||||
|
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
if (parser->state.flags & ARGP_NO_ERRS)
|
||||||
|
{
|
||||||
|
parser->opt_data.opterr = 0;
|
||||||
|
if (parser->state.flags & ARGP_PARSE_ARGV0)
|
||||||
|
/* getopt always skips ARGV[0], so we have to fake it out. As long
|
||||||
|
as OPTERR is 0, then it shouldn't actually try to access it. */
|
||||||
|
parser->state.argv--, parser->state.argc++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
parser->opt_data.opterr = 1; /* Print error messages. */
|
||||||
|
|
||||||
|
if (parser->state.argv == argv && argv[0])
|
||||||
|
/* There's an argv[0]; use it for messages. */
|
||||||
|
parser->state.name = __argp_base_name (argv[0]);
|
||||||
|
else
|
||||||
|
parser->state.name = __argp_short_program_name ();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Free any storage consumed by PARSER (but not PARSER itself). */
|
||||||
|
static error_t
|
||||||
|
parser_finalize (struct parser *parser,
|
||||||
|
error_t err, int arg_ebadkey, int *end_index)
|
||||||
|
{
|
||||||
|
struct group *group;
|
||||||
|
|
||||||
|
if (err == EBADKEY && arg_ebadkey)
|
||||||
|
/* Suppress errors generated by unparsed arguments. */
|
||||||
|
err = 0;
|
||||||
|
|
||||||
|
if (! err)
|
||||||
|
{
|
||||||
|
if (parser->state.next == parser->state.argc)
|
||||||
|
/* We successfully parsed all arguments! Call all the parsers again,
|
||||||
|
just a few more times... */
|
||||||
|
{
|
||||||
|
for (group = parser->groups;
|
||||||
|
group < parser->egroup && (!err || err==EBADKEY);
|
||||||
|
group++)
|
||||||
|
if (group->args_processed == 0)
|
||||||
|
err = group_parse (group, &parser->state, ARGP_KEY_NO_ARGS, 0);
|
||||||
|
for (group = parser->egroup - 1;
|
||||||
|
group >= parser->groups && (!err || err==EBADKEY);
|
||||||
|
group--)
|
||||||
|
err = group_parse (group, &parser->state, ARGP_KEY_END, 0);
|
||||||
|
|
||||||
|
if (err == EBADKEY)
|
||||||
|
err = 0; /* Some parser didn't understand. */
|
||||||
|
|
||||||
|
/* Tell the user that all arguments are parsed. */
|
||||||
|
if (end_index)
|
||||||
|
*end_index = parser->state.next;
|
||||||
|
}
|
||||||
|
else if (end_index)
|
||||||
|
/* Return any remaining arguments to the user. */
|
||||||
|
*end_index = parser->state.next;
|
||||||
|
else
|
||||||
|
/* No way to return the remaining arguments, they must be bogus. */
|
||||||
|
{
|
||||||
|
if (!(parser->state.flags & ARGP_NO_ERRS)
|
||||||
|
&& parser->state.err_stream)
|
||||||
|
fprintf (parser->state.err_stream,
|
||||||
|
dgettext (parser->argp->argp_domain,
|
||||||
|
"%s: Too many arguments\n"),
|
||||||
|
parser->state.name);
|
||||||
|
err = EBADKEY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Okay, we're all done, with either an error or success; call the parsers
|
||||||
|
to indicate which one. */
|
||||||
|
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
/* Maybe print an error message. */
|
||||||
|
if (err == EBADKEY)
|
||||||
|
/* An appropriate message describing what the error was should have
|
||||||
|
been printed earlier. */
|
||||||
|
__argp_state_help (&parser->state, parser->state.err_stream,
|
||||||
|
ARGP_HELP_STD_ERR);
|
||||||
|
|
||||||
|
/* Since we didn't exit, give each parser an error indication. */
|
||||||
|
for (group = parser->groups; group < parser->egroup; group++)
|
||||||
|
group_parse (group, &parser->state, ARGP_KEY_ERROR, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
/* Notify parsers of success, and propagate back values from parsers. */
|
||||||
|
{
|
||||||
|
/* We pass over the groups in reverse order so that child groups are
|
||||||
|
given a chance to do there processing before passing back a value to
|
||||||
|
the parent. */
|
||||||
|
for (group = parser->egroup - 1
|
||||||
|
; group >= parser->groups && (!err || err == EBADKEY)
|
||||||
|
; group--)
|
||||||
|
err = group_parse (group, &parser->state, ARGP_KEY_SUCCESS, 0);
|
||||||
|
if (err == EBADKEY)
|
||||||
|
err = 0; /* Some parser didn't understand. */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Call parsers once more, to do any final cleanup. Errors are ignored. */
|
||||||
|
for (group = parser->egroup - 1; group >= parser->groups; group--)
|
||||||
|
group_parse (group, &parser->state, ARGP_KEY_FINI, 0);
|
||||||
|
|
||||||
|
if (err == EBADKEY)
|
||||||
|
err = EINVAL;
|
||||||
|
|
||||||
|
free (parser->storage);
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Call the user parsers to parse the non-option argument VAL, at the current
|
||||||
|
position, returning any error. The state NEXT pointer is assumed to have
|
||||||
|
been adjusted (by getopt) to point after this argument; this function will
|
||||||
|
adjust it correctly to reflect however many args actually end up being
|
||||||
|
consumed. */
|
||||||
|
static error_t
|
||||||
|
parser_parse_arg (struct parser *parser, char *val)
|
||||||
|
{
|
||||||
|
/* Save the starting value of NEXT, first adjusting it so that the arg
|
||||||
|
we're parsing is again the front of the arg vector. */
|
||||||
|
int index = --parser->state.next;
|
||||||
|
error_t err = EBADKEY;
|
||||||
|
struct group *group;
|
||||||
|
int key = 0; /* Which of ARGP_KEY_ARG[S] we used. */
|
||||||
|
|
||||||
|
/* Try to parse the argument in each parser. */
|
||||||
|
for (group = parser->groups
|
||||||
|
; group < parser->egroup && err == EBADKEY
|
||||||
|
; group++)
|
||||||
|
{
|
||||||
|
parser->state.next++; /* For ARGP_KEY_ARG, consume the arg. */
|
||||||
|
key = ARGP_KEY_ARG;
|
||||||
|
err = group_parse (group, &parser->state, key, val);
|
||||||
|
|
||||||
|
if (err == EBADKEY)
|
||||||
|
/* This parser doesn't like ARGP_KEY_ARG; try ARGP_KEY_ARGS instead. */
|
||||||
|
{
|
||||||
|
parser->state.next--; /* For ARGP_KEY_ARGS, put back the arg. */
|
||||||
|
key = ARGP_KEY_ARGS;
|
||||||
|
err = group_parse (group, &parser->state, key, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! err)
|
||||||
|
{
|
||||||
|
if (key == ARGP_KEY_ARGS)
|
||||||
|
/* The default for ARGP_KEY_ARGS is to assume that if NEXT isn't
|
||||||
|
changed by the user, *all* arguments should be considered
|
||||||
|
consumed. */
|
||||||
|
parser->state.next = parser->state.argc;
|
||||||
|
|
||||||
|
if (parser->state.next > index)
|
||||||
|
/* Remember that we successfully processed a non-option
|
||||||
|
argument -- but only if the user hasn't gotten tricky and set
|
||||||
|
the clock back. */
|
||||||
|
(--group)->args_processed += (parser->state.next - index);
|
||||||
|
else
|
||||||
|
/* The user wants to reparse some args, give getopt another try. */
|
||||||
|
parser->try_getopt = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Call the user parsers to parse the option OPT, with argument VAL, at the
|
||||||
|
current position, returning any error. */
|
||||||
|
static error_t
|
||||||
|
parser_parse_opt (struct parser *parser, int opt, char *val)
|
||||||
|
{
|
||||||
|
/* The group key encoded in the high bits; 0 for short opts or
|
||||||
|
group_number + 1 for long opts. */
|
||||||
|
int group_key = opt >> USER_BITS;
|
||||||
|
error_t err = EBADKEY;
|
||||||
|
|
||||||
|
if (group_key == 0)
|
||||||
|
/* A short option. By comparing OPT's position in SHORT_OPTS to the
|
||||||
|
various starting positions in each group's SHORT_END field, we can
|
||||||
|
determine which group OPT came from. */
|
||||||
|
{
|
||||||
|
struct group *group;
|
||||||
|
char *short_index = strchr (parser->short_opts, opt);
|
||||||
|
|
||||||
|
if (short_index)
|
||||||
|
for (group = parser->groups; group < parser->egroup; group++)
|
||||||
|
if (group->short_end > short_index)
|
||||||
|
{
|
||||||
|
err = group_parse (group, &parser->state, opt,
|
||||||
|
parser->opt_data.optarg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
/* A long option. We use shifts instead of masking for extracting
|
||||||
|
the user value in order to preserve the sign. */
|
||||||
|
err =
|
||||||
|
group_parse (&parser->groups[group_key - 1], &parser->state,
|
||||||
|
(opt << GROUP_BITS) >> GROUP_BITS,
|
||||||
|
parser->opt_data.optarg);
|
||||||
|
|
||||||
|
if (err == EBADKEY)
|
||||||
|
/* At least currently, an option not recognized is an error in the
|
||||||
|
parser, because we pre-compute which parser is supposed to deal
|
||||||
|
with each option. */
|
||||||
|
{
|
||||||
|
static const char bad_key_err[] =
|
||||||
|
N_("(PROGRAM ERROR) Option should have been recognized!?");
|
||||||
|
if (group_key == 0)
|
||||||
|
__argp_error (&parser->state, "-%c: %s", opt,
|
||||||
|
dgettext (parser->argp->argp_domain, bad_key_err));
|
||||||
|
else
|
||||||
|
{
|
||||||
|
struct option *long_opt = parser->long_opts;
|
||||||
|
while (long_opt->val != opt && long_opt->name)
|
||||||
|
long_opt++;
|
||||||
|
__argp_error (&parser->state, "--%s: %s",
|
||||||
|
long_opt->name ? long_opt->name : "???",
|
||||||
|
dgettext (parser->argp->argp_domain, bad_key_err));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Parse the next argument in PARSER (as indicated by PARSER->state.next).
|
||||||
|
Any error from the parsers is returned, and *ARGP_EBADKEY indicates
|
||||||
|
whether a value of EBADKEY is due to an unrecognized argument (which is
|
||||||
|
generally not fatal). */
|
||||||
|
static error_t
|
||||||
|
parser_parse_next (struct parser *parser, int *arg_ebadkey)
|
||||||
|
{
|
||||||
|
int opt;
|
||||||
|
error_t err = 0;
|
||||||
|
|
||||||
|
if (parser->state.quoted && parser->state.next < parser->state.quoted)
|
||||||
|
/* The next argument pointer has been moved to before the quoted
|
||||||
|
region, so pretend we never saw the quoting `--', and give getopt
|
||||||
|
another chance. If the user hasn't removed it, getopt will just
|
||||||
|
process it again. */
|
||||||
|
parser->state.quoted = 0;
|
||||||
|
|
||||||
|
if (parser->try_getopt && !parser->state.quoted)
|
||||||
|
/* Give getopt a chance to parse this. */
|
||||||
|
{
|
||||||
|
/* Put it back in OPTIND for getopt. */
|
||||||
|
parser->opt_data.optind = parser->state.next;
|
||||||
|
/* Distinguish KEY_ERR from a real option. */
|
||||||
|
parser->opt_data.optopt = KEY_END;
|
||||||
|
if (parser->state.flags & ARGP_LONG_ONLY)
|
||||||
|
opt = _getopt_long_only_r (parser->state.argc, parser->state.argv,
|
||||||
|
parser->short_opts, parser->long_opts, 0,
|
||||||
|
&parser->opt_data);
|
||||||
|
else
|
||||||
|
opt = _getopt_long_r (parser->state.argc, parser->state.argv,
|
||||||
|
parser->short_opts, parser->long_opts, 0,
|
||||||
|
&parser->opt_data);
|
||||||
|
/* And see what getopt did. */
|
||||||
|
parser->state.next = parser->opt_data.optind;
|
||||||
|
|
||||||
|
if (opt == KEY_END)
|
||||||
|
/* Getopt says there are no more options, so stop using
|
||||||
|
getopt; we'll continue if necessary on our own. */
|
||||||
|
{
|
||||||
|
parser->try_getopt = 0;
|
||||||
|
if (parser->state.next > 1
|
||||||
|
&& strcmp (parser->state.argv[parser->state.next - 1], QUOTE)
|
||||||
|
== 0)
|
||||||
|
/* Not only is this the end of the options, but it's a
|
||||||
|
`quoted' region, which may have args that *look* like
|
||||||
|
options, so we definitely shouldn't try to use getopt past
|
||||||
|
here, whatever happens. */
|
||||||
|
parser->state.quoted = parser->state.next;
|
||||||
|
}
|
||||||
|
else if (opt == KEY_ERR && parser->opt_data.optopt != KEY_END)
|
||||||
|
/* KEY_ERR can have the same value as a valid user short
|
||||||
|
option, but in the case of a real error, getopt sets OPTOPT
|
||||||
|
to the offending character, which can never be KEY_END. */
|
||||||
|
{
|
||||||
|
*arg_ebadkey = 0;
|
||||||
|
return EBADKEY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
opt = KEY_END;
|
||||||
|
|
||||||
|
if (opt == KEY_END)
|
||||||
|
{
|
||||||
|
/* We're past what getopt considers the options. */
|
||||||
|
if (parser->state.next >= parser->state.argc
|
||||||
|
|| (parser->state.flags & ARGP_NO_ARGS))
|
||||||
|
/* Indicate that we're done. */
|
||||||
|
{
|
||||||
|
*arg_ebadkey = 1;
|
||||||
|
return EBADKEY;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
/* A non-option arg; simulate what getopt might have done. */
|
||||||
|
{
|
||||||
|
opt = KEY_ARG;
|
||||||
|
parser->opt_data.optarg = parser->state.argv[parser->state.next++];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opt == KEY_ARG)
|
||||||
|
/* A non-option argument; try each parser in turn. */
|
||||||
|
err = parser_parse_arg (parser, parser->opt_data.optarg);
|
||||||
|
else
|
||||||
|
err = parser_parse_opt (parser, opt, parser->opt_data.optarg);
|
||||||
|
|
||||||
|
if (err == EBADKEY)
|
||||||
|
*arg_ebadkey = (opt == KEY_END || opt == KEY_ARG);
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Parse the options strings in ARGC & ARGV according to the argp in ARGP.
|
||||||
|
FLAGS is one of the ARGP_ flags above. If END_INDEX is non-NULL, the
|
||||||
|
index in ARGV of the first unparsed option is returned in it. If an
|
||||||
|
unknown option is present, EINVAL is returned; if some parser routine
|
||||||
|
returned a non-zero value, it is returned; otherwise 0 is returned. */
|
||||||
|
error_t
|
||||||
|
__argp_parse (const struct argp *argp, int argc, char **argv, unsigned flags,
|
||||||
|
int *end_index, void *input)
|
||||||
|
{
|
||||||
|
error_t err;
|
||||||
|
struct parser parser;
|
||||||
|
|
||||||
|
/* If true, then err == EBADKEY is a result of a non-option argument failing
|
||||||
|
to be parsed (which in some cases isn't actually an error). */
|
||||||
|
int arg_ebadkey = 0;
|
||||||
|
|
||||||
|
#ifndef _LIBC
|
||||||
|
if (!(flags & ARGP_PARSE_ARGV0))
|
||||||
|
{
|
||||||
|
#ifdef HAVE_DECL_PROGRAM_INVOCATION_NAME
|
||||||
|
if (!program_invocation_name)
|
||||||
|
program_invocation_name = argv[0];
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
|
||||||
|
if (!program_invocation_short_name)
|
||||||
|
program_invocation_short_name = __argp_base_name (argv[0]);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (! (flags & ARGP_NO_HELP))
|
||||||
|
/* Add our own options. */
|
||||||
|
{
|
||||||
|
struct argp_child *child = alloca (4 * sizeof (struct argp_child));
|
||||||
|
struct argp *top_argp = alloca (sizeof (struct argp));
|
||||||
|
|
||||||
|
/* TOP_ARGP has no options, it just serves to group the user & default
|
||||||
|
argps. */
|
||||||
|
memset (top_argp, 0, sizeof (*top_argp));
|
||||||
|
top_argp->children = child;
|
||||||
|
|
||||||
|
memset (child, 0, 4 * sizeof (struct argp_child));
|
||||||
|
|
||||||
|
if (argp)
|
||||||
|
(child++)->argp = argp;
|
||||||
|
(child++)->argp = &argp_default_argp;
|
||||||
|
if (argp_program_version || argp_program_version_hook)
|
||||||
|
(child++)->argp = &argp_version_argp;
|
||||||
|
child->argp = 0;
|
||||||
|
|
||||||
|
argp = top_argp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Construct a parser for these arguments. */
|
||||||
|
err = parser_init (&parser, argp, argc, argv, flags, input);
|
||||||
|
|
||||||
|
if (! err)
|
||||||
|
/* Parse! */
|
||||||
|
{
|
||||||
|
while (! err)
|
||||||
|
err = parser_parse_next (&parser, &arg_ebadkey);
|
||||||
|
err = parser_finalize (&parser, err, arg_ebadkey, end_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
#ifdef weak_alias
|
||||||
|
weak_alias (__argp_parse, argp_parse)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Return the input field for ARGP in the parser corresponding to STATE; used
|
||||||
|
by the help routines. */
|
||||||
|
void *
|
||||||
|
__argp_input (const struct argp *argp, const struct argp_state *state)
|
||||||
|
{
|
||||||
|
if (state)
|
||||||
|
{
|
||||||
|
struct group *group;
|
||||||
|
struct parser *parser = state->pstate;
|
||||||
|
|
||||||
|
for (group = parser->groups; group < parser->egroup; group++)
|
||||||
|
if (group->argp == argp)
|
||||||
|
return group->input;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#ifdef weak_alias
|
||||||
|
weak_alias (__argp_input, _argp_input)
|
||||||
|
#endif
|
27
gnulib/argp-pin.c
Normal file
27
gnulib/argp-pin.c
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
/* Full and short program names for argp module
|
||||||
|
Copyright (C) 2005, 2009, 2010 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 3 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, see <http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_PROGRAM_INVOCATION_SHORT_NAME
|
||||||
|
char *program_invocation_short_name = 0;
|
||||||
|
#endif
|
||||||
|
#ifndef HAVE_PROGRAM_INVOCATION_NAME
|
||||||
|
char *program_invocation_name = 0;
|
||||||
|
#endif
|
||||||
|
|
34
gnulib/argp-pv.c
Normal file
34
gnulib/argp-pv.c
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
/* Default definition for ARGP_PROGRAM_VERSION.
|
||||||
|
Copyright (C) 1996, 1997, 1999, 2006, 2009, 2010 Free Software Foundation,
|
||||||
|
Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||||
|
|
||||||
|
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 3 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, see <http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
/* If set by the user program to a non-zero value, then a default option
|
||||||
|
--version is added (unless the ARGP_NO_HELP flag is used), which will
|
||||||
|
print this string followed by a newline and exit (unless the
|
||||||
|
ARGP_NO_EXIT flag is used). Overridden by ARGP_PROGRAM_VERSION_HOOK. */
|
||||||
|
const char *argp_program_version
|
||||||
|
/* This variable should be zero-initialized. On most systems, putting it into
|
||||||
|
BSS is sufficient. Not so on MacOS X 10.3 and 10.4, see
|
||||||
|
<http://lists.gnu.org/archive/html/bug-gnulib/2009-01/msg00329.html>
|
||||||
|
<http://lists.gnu.org/archive/html/bug-gnulib/2009-08/msg00096.html>. */
|
||||||
|
#if defined __ELF__
|
||||||
|
/* On ELF systems, variables in BSS behave well. */
|
||||||
|
#else
|
||||||
|
= (const char *) 0
|
||||||
|
#endif
|
||||||
|
;
|
31
gnulib/argp-pvh.c
Normal file
31
gnulib/argp-pvh.c
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
/* Default definition for ARGP_PROGRAM_VERSION_HOOK.
|
||||||
|
Copyright (C) 1996, 1997, 1999, 2004, 2009, 2010 Free Software Foundation,
|
||||||
|
Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||||
|
|
||||||
|
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 3 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, see <http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "argp.h"
|
||||||
|
|
||||||
|
/* If set by the user program to a non-zero value, then a default option
|
||||||
|
--version is added (unless the ARGP_NO_HELP flag is used), which calls
|
||||||
|
this function with a stream to print the version to and a pointer to the
|
||||||
|
current parsing state, and then exits (unless the ARGP_NO_EXIT flag is
|
||||||
|
used). This variable takes precedent over ARGP_PROGRAM_VERSION. */
|
||||||
|
void (*argp_program_version_hook) (FILE *stream, struct argp_state *state) = NULL;
|
38
gnulib/argp-version-etc.c
Normal file
38
gnulib/argp-version-etc.c
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
/* Version hook for Argp.
|
||||||
|
Copyright (C) 2009, 2010 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 3 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, see <http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
#include <version-etc.h>
|
||||||
|
#include <argp.h>
|
||||||
|
#include <argp-version-etc.h>
|
||||||
|
|
||||||
|
static const char *program_canonical_name;
|
||||||
|
static const char * const *program_authors;
|
||||||
|
|
||||||
|
static void
|
||||||
|
version_etc_hook (FILE *stream, struct argp_state *state)
|
||||||
|
{
|
||||||
|
version_etc_ar (stream, program_canonical_name, PACKAGE_NAME, VERSION,
|
||||||
|
program_authors);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
argp_version_setup (const char *name, const char * const *authors)
|
||||||
|
{
|
||||||
|
argp_program_version_hook = version_etc_hook;
|
||||||
|
program_canonical_name = name;
|
||||||
|
program_authors = authors;
|
||||||
|
}
|
40
gnulib/argp-version-etc.h
Normal file
40
gnulib/argp-version-etc.h
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
/* Version hook for Argp.
|
||||||
|
Copyright (C) 2009, 2010 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 3 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, see <http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
#ifndef _ARGP_VERSION_ETC_H
|
||||||
|
#define _ARGP_VERSION_ETC_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Setup standard display of the version information for the `--version'
|
||||||
|
option. NAME is the canonical program name, and AUTHORS is a NULL-
|
||||||
|
terminated array of author names. At least one author name must be
|
||||||
|
given.
|
||||||
|
|
||||||
|
If NAME is NULL, the package name (as given by the PACKAGE macro)
|
||||||
|
is asumed to be the name of the program.
|
||||||
|
|
||||||
|
This function is intended to be called before argp_parse().
|
||||||
|
*/
|
||||||
|
extern void argp_version_setup (const char *name, const char * const *authors);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _ARGP_VERSION_ETC_H */
|
42
gnulib/argp-xinl.c
Normal file
42
gnulib/argp-xinl.c
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
/* Real definitions for extern inline functions in argp.h
|
||||||
|
Copyright (C) 1997, 1998, 2004, 2009, 2010 Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||||
|
|
||||||
|
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 3 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, see <http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined _LIBC || defined HAVE_FEATURES_H
|
||||||
|
# include <features.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __USE_EXTERN_INLINES
|
||||||
|
# define __USE_EXTERN_INLINES 1
|
||||||
|
#endif
|
||||||
|
#define ARGP_EI
|
||||||
|
#undef __OPTIMIZE__
|
||||||
|
#define __OPTIMIZE__ 1
|
||||||
|
#include "argp.h"
|
||||||
|
|
||||||
|
/* Add weak aliases. */
|
||||||
|
#if _LIBC - 0 && defined (weak_alias)
|
||||||
|
|
||||||
|
weak_alias (__argp_usage, argp_usage)
|
||||||
|
weak_alias (__option_is_short, _option_is_short)
|
||||||
|
weak_alias (__option_is_end, _option_is_end)
|
||||||
|
|
||||||
|
#endif
|
645
gnulib/argp.h
Normal file
645
gnulib/argp.h
Normal file
|
@ -0,0 +1,645 @@
|
||||||
|
/* Hierarchial argument parsing, layered over getopt.
|
||||||
|
Copyright (C) 1995-1999, 2003-2010 Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
Written by Miles Bader <miles@gnu.ai.mit.edu>.
|
||||||
|
|
||||||
|
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 3 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, see <http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
#ifndef _ARGP_H
|
||||||
|
#define _ARGP_H
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <getopt.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
|
#define __need_error_t
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#ifndef __THROW
|
||||||
|
# define __THROW
|
||||||
|
#endif
|
||||||
|
#ifndef __NTH
|
||||||
|
# define __NTH(fct) fct __THROW
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __attribute__
|
||||||
|
/* The __attribute__ feature is available in gcc versions 2.5 and later.
|
||||||
|
The __-protected variants of the attributes 'format' and 'printf' are
|
||||||
|
accepted by gcc versions 2.6.4 (effectively 2.7) and later.
|
||||||
|
We enable __attribute__ only if these are supported too, because
|
||||||
|
gnulib and libintl do '#define printf __printf__' when they override
|
||||||
|
the 'printf' function. */
|
||||||
|
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
|
||||||
|
# define __attribute__(Spec) /* empty */
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* GCC 2.95 and later have "__restrict"; C99 compilers have
|
||||||
|
"restrict", and "configure" may have defined "restrict".
|
||||||
|
Other compilers use __restrict, __restrict__, and _Restrict, and
|
||||||
|
'configure' might #define 'restrict' to those words. */
|
||||||
|
#ifndef __restrict
|
||||||
|
# if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__))
|
||||||
|
# if 199901L <= __STDC_VERSION__
|
||||||
|
# define __restrict restrict
|
||||||
|
# else
|
||||||
|
# define __restrict
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __error_t_defined
|
||||||
|
typedef int error_t;
|
||||||
|
# define __error_t_defined
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* A description of a particular option. A pointer to an array of
|
||||||
|
these is passed in the OPTIONS field of an argp structure. Each option
|
||||||
|
entry can correspond to one long option and/or one short option; more
|
||||||
|
names for the same option can be added by following an entry in an option
|
||||||
|
array with options having the OPTION_ALIAS flag set. */
|
||||||
|
struct argp_option
|
||||||
|
{
|
||||||
|
/* The long option name. For more than one name for the same option, you
|
||||||
|
can use following options with the OPTION_ALIAS flag set. */
|
||||||
|
const char *name;
|
||||||
|
|
||||||
|
/* What key is returned for this option. If > 0 and printable, then it's
|
||||||
|
also accepted as a short option. */
|
||||||
|
int key;
|
||||||
|
|
||||||
|
/* If non-NULL, this is the name of the argument associated with this
|
||||||
|
option, which is required unless the OPTION_ARG_OPTIONAL flag is set. */
|
||||||
|
const char *arg;
|
||||||
|
|
||||||
|
/* OPTION_ flags. */
|
||||||
|
int flags;
|
||||||
|
|
||||||
|
/* The doc string for this option. If both NAME and KEY are 0, This string
|
||||||
|
will be printed outdented from the normal option column, making it
|
||||||
|
useful as a group header (it will be the first thing printed in its
|
||||||
|
group); in this usage, it's conventional to end the string with a `:'.
|
||||||
|
|
||||||
|
Write the initial value as N_("TEXT") if you want xgettext to collect
|
||||||
|
it into a POT file. */
|
||||||
|
const char *doc;
|
||||||
|
|
||||||
|
/* The group this option is in. In a long help message, options are sorted
|
||||||
|
alphabetically within each group, and the groups presented in the order
|
||||||
|
0, 1, 2, ..., n, -m, ..., -2, -1. Every entry in an options array with
|
||||||
|
if this field 0 will inherit the group number of the previous entry, or
|
||||||
|
zero if it's the first one, unless its a group header (NAME and KEY both
|
||||||
|
0), in which case, the previous entry + 1 is the default. Automagic
|
||||||
|
options such as --help are put into group -1. */
|
||||||
|
int group;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* The argument associated with this option is optional. */
|
||||||
|
#define OPTION_ARG_OPTIONAL 0x1
|
||||||
|
|
||||||
|
/* This option isn't displayed in any help messages. */
|
||||||
|
#define OPTION_HIDDEN 0x2
|
||||||
|
|
||||||
|
/* This option is an alias for the closest previous non-alias option. This
|
||||||
|
means that it will be displayed in the same help entry, and will inherit
|
||||||
|
fields other than NAME and KEY from the aliased option. */
|
||||||
|
#define OPTION_ALIAS 0x4
|
||||||
|
|
||||||
|
/* This option isn't actually an option (and so should be ignored by the
|
||||||
|
actual option parser), but rather an arbitrary piece of documentation that
|
||||||
|
should be displayed in much the same manner as the options. If this flag
|
||||||
|
is set, then the option NAME field is displayed unmodified (e.g., no `--'
|
||||||
|
prefix is added) at the left-margin (where a *short* option would normally
|
||||||
|
be displayed), and the documentation string in the normal place. The NAME
|
||||||
|
field will be translated using gettext, unless OPTION_NO_TRANS is set (see
|
||||||
|
below). For purposes of sorting, any leading whitespace and punctuation is
|
||||||
|
ignored, except that if the first non-whitespace character is not `-', this
|
||||||
|
entry is displayed after all options (and OPTION_DOC entries with a leading
|
||||||
|
`-') in the same group. */
|
||||||
|
#define OPTION_DOC 0x8
|
||||||
|
|
||||||
|
/* This option shouldn't be included in `long' usage messages (but is still
|
||||||
|
included in help messages). This is mainly intended for options that are
|
||||||
|
completely documented in an argp's ARGS_DOC field, in which case including
|
||||||
|
the option in the generic usage list would be redundant. For instance,
|
||||||
|
if ARGS_DOC is "FOO BAR\n-x BLAH", and the `-x' option's purpose is to
|
||||||
|
distinguish these two cases, -x should probably be marked
|
||||||
|
OPTION_NO_USAGE. */
|
||||||
|
#define OPTION_NO_USAGE 0x10
|
||||||
|
|
||||||
|
/* Valid only in conjunction with OPTION_DOC. This option disables translation
|
||||||
|
of option name. */
|
||||||
|
#define OPTION_NO_TRANS 0x20
|
||||||
|
|
||||||
|
|
||||||
|
struct argp; /* fwd declare this type */
|
||||||
|
struct argp_state; /* " */
|
||||||
|
struct argp_child; /* " */
|
||||||
|
|
||||||
|
/* The type of a pointer to an argp parsing function. */
|
||||||
|
typedef error_t (*argp_parser_t) (int key, char *arg,
|
||||||
|
struct argp_state *state);
|
||||||
|
|
||||||
|
/* What to return for unrecognized keys. For special ARGP_KEY_ keys, such
|
||||||
|
returns will simply be ignored. For user keys, this error will be turned
|
||||||
|
into EINVAL (if the call to argp_parse is such that errors are propagated
|
||||||
|
back to the user instead of exiting); returning EINVAL itself would result
|
||||||
|
in an immediate stop to parsing in *all* cases. */
|
||||||
|
#define ARGP_ERR_UNKNOWN E2BIG /* Hurd should never need E2BIG. XXX */
|
||||||
|
|
||||||
|
/* Special values for the KEY argument to an argument parsing function.
|
||||||
|
ARGP_ERR_UNKNOWN should be returned if they aren't understood.
|
||||||
|
|
||||||
|
The sequence of keys to a parsing function is either (where each
|
||||||
|
uppercased word should be prefixed by `ARGP_KEY_' and opt is a user key):
|
||||||
|
|
||||||
|
INIT opt... NO_ARGS END SUCCESS -- No non-option arguments at all
|
||||||
|
or INIT (opt | ARG)... END SUCCESS -- All non-option args parsed
|
||||||
|
or INIT (opt | ARG)... SUCCESS -- Some non-option arg unrecognized
|
||||||
|
|
||||||
|
The third case is where every parser returned ARGP_KEY_UNKNOWN for an
|
||||||
|
argument, in which case parsing stops at that argument (returning the
|
||||||
|
unparsed arguments to the caller of argp_parse if requested, or stopping
|
||||||
|
with an error message if not).
|
||||||
|
|
||||||
|
If an error occurs (either detected by argp, or because the parsing
|
||||||
|
function returned an error value), then the parser is called with
|
||||||
|
ARGP_KEY_ERROR, and no further calls are made. */
|
||||||
|
|
||||||
|
/* This is not an option at all, but rather a command line argument. If a
|
||||||
|
parser receiving this key returns success, the fact is recorded, and the
|
||||||
|
ARGP_KEY_NO_ARGS case won't be used. HOWEVER, if while processing the
|
||||||
|
argument, a parser function decrements the NEXT field of the state it's
|
||||||
|
passed, the option won't be considered processed; this is to allow you to
|
||||||
|
actually modify the argument (perhaps into an option), and have it
|
||||||
|
processed again. */
|
||||||
|
#define ARGP_KEY_ARG 0
|
||||||
|
/* There are remaining arguments not parsed by any parser, which may be found
|
||||||
|
starting at (STATE->argv + STATE->next). If success is returned, but
|
||||||
|
STATE->next left untouched, it's assumed that all arguments were consume,
|
||||||
|
otherwise, the parser should adjust STATE->next to reflect any arguments
|
||||||
|
consumed. */
|
||||||
|
#define ARGP_KEY_ARGS 0x1000006
|
||||||
|
/* There are no more command line arguments at all. */
|
||||||
|
#define ARGP_KEY_END 0x1000001
|
||||||
|
/* Because it's common to want to do some special processing if there aren't
|
||||||
|
any non-option args, user parsers are called with this key if they didn't
|
||||||
|
successfully process any non-option arguments. Called just before
|
||||||
|
ARGP_KEY_END (where more general validity checks on previously parsed
|
||||||
|
arguments can take place). */
|
||||||
|
#define ARGP_KEY_NO_ARGS 0x1000002
|
||||||
|
/* Passed in before any parsing is done. Afterwards, the values of each
|
||||||
|
element of the CHILD_INPUT field, if any, in the state structure is
|
||||||
|
copied to each child's state to be the initial value of the INPUT field. */
|
||||||
|
#define ARGP_KEY_INIT 0x1000003
|
||||||
|
/* Use after all other keys, including SUCCESS & END. */
|
||||||
|
#define ARGP_KEY_FINI 0x1000007
|
||||||
|
/* Passed in when parsing has successfully been completed (even if there are
|
||||||
|
still arguments remaining). */
|
||||||
|
#define ARGP_KEY_SUCCESS 0x1000004
|
||||||
|
/* Passed in if an error occurs. */
|
||||||
|
#define ARGP_KEY_ERROR 0x1000005
|
||||||
|
|
||||||
|
/* An argp structure contains a set of options declarations, a function to
|
||||||
|
deal with parsing one, documentation string, a possible vector of child
|
||||||
|
argp's, and perhaps a function to filter help output. When actually
|
||||||
|
parsing options, getopt is called with the union of all the argp
|
||||||
|
structures chained together through their CHILD pointers, with conflicts
|
||||||
|
being resolved in favor of the first occurrence in the chain. */
|
||||||
|
struct argp
|
||||||
|
{
|
||||||
|
/* An array of argp_option structures, terminated by an entry with both
|
||||||
|
NAME and KEY having a value of 0. */
|
||||||
|
const struct argp_option *options;
|
||||||
|
|
||||||
|
/* What to do with an option from this structure. KEY is the key
|
||||||
|
associated with the option, and ARG is any associated argument (NULL if
|
||||||
|
none was supplied). If KEY isn't understood, ARGP_ERR_UNKNOWN should be
|
||||||
|
returned. If a non-zero, non-ARGP_ERR_UNKNOWN value is returned, then
|
||||||
|
parsing is stopped immediately, and that value is returned from
|
||||||
|
argp_parse(). For special (non-user-supplied) values of KEY, see the
|
||||||
|
ARGP_KEY_ definitions below. */
|
||||||
|
argp_parser_t parser;
|
||||||
|
|
||||||
|
/* A string describing what other arguments are wanted by this program. It
|
||||||
|
is only used by argp_usage to print the `Usage:' message. If it
|
||||||
|
contains newlines, the strings separated by them are considered
|
||||||
|
alternative usage patterns, and printed on separate lines (lines after
|
||||||
|
the first are prefix by ` or: ' instead of `Usage:'). */
|
||||||
|
const char *args_doc;
|
||||||
|
|
||||||
|
/* If non-NULL, a string containing extra text to be printed before and
|
||||||
|
after the options in a long help message (separated by a vertical tab
|
||||||
|
`\v' character).
|
||||||
|
Write the initial value as N_("BEFORE-TEXT") "\v" N_("AFTER-TEXT") if
|
||||||
|
you want xgettext to collect the two pieces of text into a POT file. */
|
||||||
|
const char *doc;
|
||||||
|
|
||||||
|
/* A vector of argp_children structures, terminated by a member with a 0
|
||||||
|
argp field, pointing to child argps should be parsed with this one. Any
|
||||||
|
conflicts are resolved in favor of this argp, or early argps in the
|
||||||
|
CHILDREN list. This field is useful if you use libraries that supply
|
||||||
|
their own argp structure, which you want to use in conjunction with your
|
||||||
|
own. */
|
||||||
|
const struct argp_child *children;
|
||||||
|
|
||||||
|
/* If non-zero, this should be a function to filter the output of help
|
||||||
|
messages. KEY is either a key from an option, in which case TEXT is
|
||||||
|
that option's help text, or a special key from the ARGP_KEY_HELP_
|
||||||
|
defines, below, describing which other help text TEXT is. The function
|
||||||
|
should return either TEXT, if it should be used as-is, a replacement
|
||||||
|
string, which should be malloced, and will be freed by argp, or NULL,
|
||||||
|
meaning `print nothing'. The value for TEXT is *after* any translation
|
||||||
|
has been done, so if any of the replacement text also needs translation,
|
||||||
|
that should be done by the filter function. INPUT is either the input
|
||||||
|
supplied to argp_parse, or NULL, if argp_help was called directly. */
|
||||||
|
char *(*help_filter) (int __key, const char *__text, void *__input);
|
||||||
|
|
||||||
|
/* If non-zero the strings used in the argp library are translated using
|
||||||
|
the domain described by this string. Otherwise the currently installed
|
||||||
|
default domain is used. */
|
||||||
|
const char *argp_domain;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Possible KEY arguments to a help filter function. */
|
||||||
|
#define ARGP_KEY_HELP_PRE_DOC 0x2000001 /* Help text preceeding options. */
|
||||||
|
#define ARGP_KEY_HELP_POST_DOC 0x2000002 /* Help text following options. */
|
||||||
|
#define ARGP_KEY_HELP_HEADER 0x2000003 /* Option header string. */
|
||||||
|
#define ARGP_KEY_HELP_EXTRA 0x2000004 /* After all other documentation;
|
||||||
|
TEXT is NULL for this key. */
|
||||||
|
/* Explanatory note emitted when duplicate option arguments have been
|
||||||
|
suppressed. */
|
||||||
|
#define ARGP_KEY_HELP_DUP_ARGS_NOTE 0x2000005
|
||||||
|
#define ARGP_KEY_HELP_ARGS_DOC 0x2000006 /* Argument doc string. */
|
||||||
|
|
||||||
|
/* When an argp has a non-zero CHILDREN field, it should point to a vector of
|
||||||
|
argp_child structures, each of which describes a subsidiary argp. */
|
||||||
|
struct argp_child
|
||||||
|
{
|
||||||
|
/* The child parser. */
|
||||||
|
const struct argp *argp;
|
||||||
|
|
||||||
|
/* Flags for this child. */
|
||||||
|
int flags;
|
||||||
|
|
||||||
|
/* If non-zero, an optional header to be printed in help output before the
|
||||||
|
child options. As a side-effect, a non-zero value forces the child
|
||||||
|
options to be grouped together; to achieve this effect without actually
|
||||||
|
printing a header string, use a value of "". */
|
||||||
|
const char *header;
|
||||||
|
|
||||||
|
/* Where to group the child options relative to the other (`consolidated')
|
||||||
|
options in the parent argp; the values are the same as the GROUP field
|
||||||
|
in argp_option structs, but all child-groupings follow parent options at
|
||||||
|
a particular group level. If both this field and HEADER are zero, then
|
||||||
|
they aren't grouped at all, but rather merged with the parent options
|
||||||
|
(merging the child's grouping levels with the parents). */
|
||||||
|
int group;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Parsing state. This is provided to parsing functions called by argp,
|
||||||
|
which may examine and, as noted, modify fields. */
|
||||||
|
struct argp_state
|
||||||
|
{
|
||||||
|
/* The top level ARGP being parsed. */
|
||||||
|
const struct argp *root_argp;
|
||||||
|
|
||||||
|
/* The argument vector being parsed. May be modified. */
|
||||||
|
int argc;
|
||||||
|
char **argv;
|
||||||
|
|
||||||
|
/* The index in ARGV of the next arg that to be parsed. May be modified. */
|
||||||
|
int next;
|
||||||
|
|
||||||
|
/* The flags supplied to argp_parse. May be modified. */
|
||||||
|
unsigned flags;
|
||||||
|
|
||||||
|
/* While calling a parsing function with a key of ARGP_KEY_ARG, this is the
|
||||||
|
number of the current arg, starting at zero, and incremented after each
|
||||||
|
such call returns. At all other times, this is the number of such
|
||||||
|
arguments that have been processed. */
|
||||||
|
unsigned arg_num;
|
||||||
|
|
||||||
|
/* If non-zero, the index in ARGV of the first argument following a special
|
||||||
|
`--' argument (which prevents anything following being interpreted as an
|
||||||
|
option). Only set once argument parsing has proceeded past this point. */
|
||||||
|
int quoted;
|
||||||
|
|
||||||
|
/* An arbitrary pointer passed in from the user. */
|
||||||
|
void *input;
|
||||||
|
/* Values to pass to child parsers. This vector will be the same length as
|
||||||
|
the number of children for the current parser. */
|
||||||
|
void **child_inputs;
|
||||||
|
|
||||||
|
/* For the parser's use. Initialized to 0. */
|
||||||
|
void *hook;
|
||||||
|
|
||||||
|
/* The name used when printing messages. This is initialized to ARGV[0],
|
||||||
|
or PROGRAM_INVOCATION_NAME if that is unavailable. */
|
||||||
|
char *name;
|
||||||
|
|
||||||
|
/* Streams used when argp prints something. */
|
||||||
|
FILE *err_stream; /* For errors; initialized to stderr. */
|
||||||
|
FILE *out_stream; /* For information; initialized to stdout. */
|
||||||
|
|
||||||
|
void *pstate; /* Private, for use by argp. */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Flags for argp_parse (note that the defaults are those that are
|
||||||
|
convenient for program command line parsing): */
|
||||||
|
|
||||||
|
/* Don't ignore the first element of ARGV. Normally (and always unless
|
||||||
|
ARGP_NO_ERRS is set) the first element of the argument vector is
|
||||||
|
skipped for option parsing purposes, as it corresponds to the program name
|
||||||
|
in a command line. */
|
||||||
|
#define ARGP_PARSE_ARGV0 0x01
|
||||||
|
|
||||||
|
/* Don't print error messages for unknown options to stderr; unless this flag
|
||||||
|
is set, ARGP_PARSE_ARGV0 is ignored, as ARGV[0] is used as the program
|
||||||
|
name in the error messages. This flag implies ARGP_NO_EXIT (on the
|
||||||
|
assumption that silent exiting upon errors is bad behaviour). */
|
||||||
|
#define ARGP_NO_ERRS 0x02
|
||||||
|
|
||||||
|
/* Don't parse any non-option args. Normally non-option args are parsed by
|
||||||
|
calling the parse functions with a key of ARGP_KEY_ARG, and the actual arg
|
||||||
|
as the value. Since it's impossible to know which parse function wants to
|
||||||
|
handle it, each one is called in turn, until one returns 0 or an error
|
||||||
|
other than ARGP_ERR_UNKNOWN; if an argument is handled by no one, the
|
||||||
|
argp_parse returns prematurely (but with a return value of 0). If all
|
||||||
|
args have been parsed without error, all parsing functions are called one
|
||||||
|
last time with a key of ARGP_KEY_END. This flag needn't normally be set,
|
||||||
|
as the normal behavior is to stop parsing as soon as some argument can't
|
||||||
|
be handled. */
|
||||||
|
#define ARGP_NO_ARGS 0x04
|
||||||
|
|
||||||
|
/* Parse options and arguments in the same order they occur on the command
|
||||||
|
line -- normally they're rearranged so that all options come first. */
|
||||||
|
#define ARGP_IN_ORDER 0x08
|
||||||
|
|
||||||
|
/* Don't provide the standard long option --help, which causes usage and
|
||||||
|
option help information to be output to stdout, and exit (0) called. */
|
||||||
|
#define ARGP_NO_HELP 0x10
|
||||||
|
|
||||||
|
/* Don't exit on errors (they may still result in error messages). */
|
||||||
|
#define ARGP_NO_EXIT 0x20
|
||||||
|
|
||||||
|
/* Use the gnu getopt `long-only' rules for parsing arguments. */
|
||||||
|
#define ARGP_LONG_ONLY 0x40
|
||||||
|
|
||||||
|
/* Turns off any message-printing/exiting options. */
|
||||||
|
#define ARGP_SILENT (ARGP_NO_EXIT | ARGP_NO_ERRS | ARGP_NO_HELP)
|
||||||
|
|
||||||
|
/* Parse the options strings in ARGC & ARGV according to the options in ARGP.
|
||||||
|
FLAGS is one of the ARGP_ flags above. If ARG_INDEX is non-NULL, the
|
||||||
|
index in ARGV of the first unparsed option is returned in it. If an
|
||||||
|
unknown option is present, ARGP_ERR_UNKNOWN is returned; if some parser
|
||||||
|
routine returned a non-zero value, it is returned; otherwise 0 is
|
||||||
|
returned. This function may also call exit unless the ARGP_NO_HELP flag
|
||||||
|
is set. INPUT is a pointer to a value to be passed in to the parser. */
|
||||||
|
extern error_t argp_parse (const struct argp *__restrict __argp,
|
||||||
|
int /*argc*/, char **__restrict /*argv*/,
|
||||||
|
unsigned __flags, int *__restrict __arg_index,
|
||||||
|
void *__restrict __input);
|
||||||
|
extern error_t __argp_parse (const struct argp *__restrict __argp,
|
||||||
|
int /*argc*/, char **__restrict /*argv*/,
|
||||||
|
unsigned __flags, int *__restrict __arg_index,
|
||||||
|
void *__restrict __input);
|
||||||
|
|
||||||
|
/* Global variables. */
|
||||||
|
|
||||||
|
/* GNULIB makes sure both program_invocation_name and
|
||||||
|
program_invocation_short_name are available */
|
||||||
|
#ifdef GNULIB_PROGRAM_INVOCATION_NAME
|
||||||
|
extern char *program_invocation_name;
|
||||||
|
# undef HAVE_DECL_PROGRAM_INVOCATION_NAME
|
||||||
|
# define HAVE_DECL_PROGRAM_INVOCATION_NAME 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef GNULIB_PROGRAM_INVOCATION_SHORT_NAME
|
||||||
|
extern char *program_invocation_short_name;
|
||||||
|
# undef HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
|
||||||
|
# define HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* If defined or set by the user program to a non-zero value, then a default
|
||||||
|
option --version is added (unless the ARGP_NO_HELP flag is used), which
|
||||||
|
will print this string followed by a newline and exit (unless the
|
||||||
|
ARGP_NO_EXIT flag is used). Overridden by ARGP_PROGRAM_VERSION_HOOK. */
|
||||||
|
extern const char *argp_program_version;
|
||||||
|
|
||||||
|
/* If defined or set by the user program to a non-zero value, then a default
|
||||||
|
option --version is added (unless the ARGP_NO_HELP flag is used), which
|
||||||
|
calls this function with a stream to print the version to and a pointer to
|
||||||
|
the current parsing state, and then exits (unless the ARGP_NO_EXIT flag is
|
||||||
|
used). This variable takes precedent over ARGP_PROGRAM_VERSION. */
|
||||||
|
extern void (*argp_program_version_hook) (FILE *__restrict __stream,
|
||||||
|
struct argp_state *__restrict
|
||||||
|
__state);
|
||||||
|
|
||||||
|
/* If defined or set by the user program, it should point to string that is
|
||||||
|
the bug-reporting address for the program. It will be printed by
|
||||||
|
argp_help if the ARGP_HELP_BUG_ADDR flag is set (as it is by various
|
||||||
|
standard help messages), embedded in a sentence that says something like
|
||||||
|
`Report bugs to ADDR.'. */
|
||||||
|
extern const char *argp_program_bug_address;
|
||||||
|
|
||||||
|
/* The exit status that argp will use when exiting due to a parsing error.
|
||||||
|
If not defined or set by the user program, this defaults to EX_USAGE from
|
||||||
|
<sysexits.h>. */
|
||||||
|
extern error_t argp_err_exit_status;
|
||||||
|
|
||||||
|
/* Flags for argp_help. */
|
||||||
|
#define ARGP_HELP_USAGE 0x01 /* a Usage: message. */
|
||||||
|
#define ARGP_HELP_SHORT_USAGE 0x02 /* " but don't actually print options. */
|
||||||
|
#define ARGP_HELP_SEE 0x04 /* a `Try ... for more help' message. */
|
||||||
|
#define ARGP_HELP_LONG 0x08 /* a long help message. */
|
||||||
|
#define ARGP_HELP_PRE_DOC 0x10 /* doc string preceding long help. */
|
||||||
|
#define ARGP_HELP_POST_DOC 0x20 /* doc string following long help. */
|
||||||
|
#define ARGP_HELP_DOC (ARGP_HELP_PRE_DOC | ARGP_HELP_POST_DOC)
|
||||||
|
#define ARGP_HELP_BUG_ADDR 0x40 /* bug report address */
|
||||||
|
#define ARGP_HELP_LONG_ONLY 0x80 /* modify output appropriately to
|
||||||
|
reflect ARGP_LONG_ONLY mode. */
|
||||||
|
|
||||||
|
/* These ARGP_HELP flags are only understood by argp_state_help. */
|
||||||
|
#define ARGP_HELP_EXIT_ERR 0x100 /* Call exit(1) instead of returning. */
|
||||||
|
#define ARGP_HELP_EXIT_OK 0x200 /* Call exit(0) instead of returning. */
|
||||||
|
|
||||||
|
/* The standard thing to do after a program command line parsing error, if an
|
||||||
|
error message has already been printed. */
|
||||||
|
#define ARGP_HELP_STD_ERR \
|
||||||
|
(ARGP_HELP_SEE | ARGP_HELP_EXIT_ERR)
|
||||||
|
/* The standard thing to do after a program command line parsing error, if no
|
||||||
|
more specific error message has been printed. */
|
||||||
|
#define ARGP_HELP_STD_USAGE \
|
||||||
|
(ARGP_HELP_SHORT_USAGE | ARGP_HELP_SEE | ARGP_HELP_EXIT_ERR)
|
||||||
|
/* The standard thing to do in response to a --help option. */
|
||||||
|
#define ARGP_HELP_STD_HELP \
|
||||||
|
(ARGP_HELP_SHORT_USAGE | ARGP_HELP_LONG | ARGP_HELP_EXIT_OK \
|
||||||
|
| ARGP_HELP_DOC | ARGP_HELP_BUG_ADDR)
|
||||||
|
|
||||||
|
/* Output a usage message for ARGP to STREAM. FLAGS are from the set
|
||||||
|
ARGP_HELP_*. */
|
||||||
|
extern void argp_help (const struct argp *__restrict __argp,
|
||||||
|
FILE *__restrict __stream,
|
||||||
|
unsigned __flags, char *__restrict __name);
|
||||||
|
extern void __argp_help (const struct argp *__restrict __argp,
|
||||||
|
FILE *__restrict __stream, unsigned __flags,
|
||||||
|
char *__name);
|
||||||
|
|
||||||
|
/* The following routines are intended to be called from within an argp
|
||||||
|
parsing routine (thus taking an argp_state structure as the first
|
||||||
|
argument). They may or may not print an error message and exit, depending
|
||||||
|
on the flags in STATE -- in any case, the caller should be prepared for
|
||||||
|
them *not* to exit, and should return an appropiate error after calling
|
||||||
|
them. [argp_usage & argp_error should probably be called argp_state_...,
|
||||||
|
but they're used often enough that they should be short] */
|
||||||
|
|
||||||
|
/* Output, if appropriate, a usage message for STATE to STREAM. FLAGS are
|
||||||
|
from the set ARGP_HELP_*. */
|
||||||
|
extern void argp_state_help (const struct argp_state *__restrict __state,
|
||||||
|
FILE *__restrict __stream,
|
||||||
|
unsigned int __flags);
|
||||||
|
extern void __argp_state_help (const struct argp_state *__restrict __state,
|
||||||
|
FILE *__restrict __stream,
|
||||||
|
unsigned int __flags);
|
||||||
|
|
||||||
|
#if _LIBC || !defined __USE_EXTERN_INLINES
|
||||||
|
/* Possibly output the standard usage message for ARGP to stderr and exit. */
|
||||||
|
extern void argp_usage (const struct argp_state *__state);
|
||||||
|
extern void __argp_usage (const struct argp_state *__state);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* If appropriate, print the printf string FMT and following args, preceded
|
||||||
|
by the program name and `:', to stderr, and followed by a `Try ... --help'
|
||||||
|
message, then exit (1). */
|
||||||
|
extern void argp_error (const struct argp_state *__restrict __state,
|
||||||
|
const char *__restrict __fmt, ...)
|
||||||
|
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||||
|
extern void __argp_error (const struct argp_state *__restrict __state,
|
||||||
|
const char *__restrict __fmt, ...)
|
||||||
|
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||||
|
|
||||||
|
/* Similar to the standard gnu error-reporting function error(), but will
|
||||||
|
respect the ARGP_NO_EXIT and ARGP_NO_ERRS flags in STATE, and will print
|
||||||
|
to STATE->err_stream. This is useful for argument parsing code that is
|
||||||
|
shared between program startup (when exiting is desired) and runtime
|
||||||
|
option parsing (when typically an error code is returned instead). The
|
||||||
|
difference between this function and argp_error is that the latter is for
|
||||||
|
*parsing errors*, and the former is for other problems that occur during
|
||||||
|
parsing but don't reflect a (syntactic) problem with the input. */
|
||||||
|
extern void argp_failure (const struct argp_state *__restrict __state,
|
||||||
|
int __status, int __errnum,
|
||||||
|
const char *__restrict __fmt, ...)
|
||||||
|
__attribute__ ((__format__ (__printf__, 4, 5)));
|
||||||
|
extern void __argp_failure (const struct argp_state *__restrict __state,
|
||||||
|
int __status, int __errnum,
|
||||||
|
const char *__restrict __fmt, ...)
|
||||||
|
__attribute__ ((__format__ (__printf__, 4, 5)));
|
||||||
|
|
||||||
|
#if _LIBC || !defined __USE_EXTERN_INLINES
|
||||||
|
/* Returns true if the option OPT is a valid short option. */
|
||||||
|
extern int _option_is_short (const struct argp_option *__opt) __THROW;
|
||||||
|
extern int __option_is_short (const struct argp_option *__opt) __THROW;
|
||||||
|
|
||||||
|
/* Returns true if the option OPT is in fact the last (unused) entry in an
|
||||||
|
options array. */
|
||||||
|
extern int _option_is_end (const struct argp_option *__opt) __THROW;
|
||||||
|
extern int __option_is_end (const struct argp_option *__opt) __THROW;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Return the input field for ARGP in the parser corresponding to STATE; used
|
||||||
|
by the help routines. */
|
||||||
|
extern void *_argp_input (const struct argp *__restrict __argp,
|
||||||
|
const struct argp_state *__restrict __state)
|
||||||
|
__THROW;
|
||||||
|
extern void *__argp_input (const struct argp *__restrict __argp,
|
||||||
|
const struct argp_state *__restrict __state)
|
||||||
|
__THROW;
|
||||||
|
|
||||||
|
#ifdef __USE_EXTERN_INLINES
|
||||||
|
|
||||||
|
# if !_LIBC
|
||||||
|
# define __argp_usage argp_usage
|
||||||
|
# define __argp_state_help argp_state_help
|
||||||
|
# define __option_is_short _option_is_short
|
||||||
|
# define __option_is_end _option_is_end
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef ARGP_EI
|
||||||
|
# ifdef __GNUC__
|
||||||
|
/* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
|
||||||
|
inline semantics, unless -fgnu89-inline is used. It defines a macro
|
||||||
|
__GNUC_STDC_INLINE__ to indicate this situation or a macro
|
||||||
|
__GNUC_GNU_INLINE__ to indicate the opposite situation.
|
||||||
|
GCC 4.2 with -std=c99 or -std=gnu99 implements the GNU C inline
|
||||||
|
semantics but warns, unless -fgnu89-inline is used:
|
||||||
|
warning: C99 inline functions are not supported; using GNU89
|
||||||
|
warning: to disable this warning use -fgnu89-inline or the gnu_inline function attribute
|
||||||
|
It defines a macro __GNUC_GNU_INLINE__ to indicate this situation. */
|
||||||
|
# if defined __GNUC_STDC_INLINE__
|
||||||
|
# define ARGP_EI __inline__
|
||||||
|
# elif defined __GNUC_GNU_INLINE__
|
||||||
|
# define ARGP_EI extern __inline__ __attribute__ ((__gnu_inline__))
|
||||||
|
# else
|
||||||
|
# define ARGP_EI extern __inline__
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
/* With other compilers, assume the ISO C99 meaning of 'inline', if
|
||||||
|
the compiler supports 'inline' at all. */
|
||||||
|
# define ARGP_EI inline
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
|
ARGP_EI void
|
||||||
|
__argp_usage (const struct argp_state *__state)
|
||||||
|
{
|
||||||
|
__argp_state_help (__state, stderr, ARGP_HELP_STD_USAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
ARGP_EI int
|
||||||
|
__NTH (__option_is_short (const struct argp_option *__opt))
|
||||||
|
{
|
||||||
|
if (__opt->flags & OPTION_DOC)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int __key = __opt->key;
|
||||||
|
return __key > 0 && __key <= UCHAR_MAX && isprint (__key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ARGP_EI int
|
||||||
|
__NTH (__option_is_end (const struct argp_option *__opt))
|
||||||
|
{
|
||||||
|
return !__opt->key && !__opt->name && !__opt->doc && !__opt->group;
|
||||||
|
}
|
||||||
|
|
||||||
|
# if !_LIBC
|
||||||
|
# undef __argp_usage
|
||||||
|
# undef __argp_state_help
|
||||||
|
# undef __option_is_short
|
||||||
|
# undef __option_is_end
|
||||||
|
# endif
|
||||||
|
#endif /* Use extern inlines. */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* argp.h */
|
152
gnulib/error.c
152
gnulib/error.c
|
@ -1,5 +1,5 @@
|
||||||
/* Error handler for noninteractive utilities
|
/* Error handler for noninteractive utilities
|
||||||
Copyright (C) 1990-1998, 2000-2007, 2009 Free Software Foundation, Inc.
|
Copyright (C) 1990-1998, 2000-2007, 2009-2010 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -70,8 +70,8 @@ unsigned int error_message_count;
|
||||||
extern void __error (int status, int errnum, const char *message, ...)
|
extern void __error (int status, int errnum, const char *message, ...)
|
||||||
__attribute__ ((__format__ (__printf__, 3, 4)));
|
__attribute__ ((__format__ (__printf__, 3, 4)));
|
||||||
extern void __error_at_line (int status, int errnum, const char *file_name,
|
extern void __error_at_line (int status, int errnum, const char *file_name,
|
||||||
unsigned int line_number, const char *message,
|
unsigned int line_number, const char *message,
|
||||||
...)
|
...)
|
||||||
__attribute__ ((__format__ (__printf__, 5, 6)));;
|
__attribute__ ((__format__ (__printf__, 5, 6)));;
|
||||||
# define error __error
|
# define error __error
|
||||||
# define error_at_line __error_at_line
|
# define error_at_line __error_at_line
|
||||||
|
@ -86,6 +86,7 @@ extern void __error_at_line (int status, int errnum, const char *file_name,
|
||||||
#else /* not _LIBC */
|
#else /* not _LIBC */
|
||||||
|
|
||||||
# include <fcntl.h>
|
# include <fcntl.h>
|
||||||
|
# include <unistd.h>
|
||||||
|
|
||||||
# if !HAVE_DECL_STRERROR_R && STRERROR_R_CHAR_P
|
# if !HAVE_DECL_STRERROR_R && STRERROR_R_CHAR_P
|
||||||
# ifndef HAVE_DECL_STRERROR_R
|
# ifndef HAVE_DECL_STRERROR_R
|
||||||
|
@ -100,8 +101,33 @@ extern char *program_name;
|
||||||
|
|
||||||
# if HAVE_STRERROR_R || defined strerror_r
|
# if HAVE_STRERROR_R || defined strerror_r
|
||||||
# define __strerror_r strerror_r
|
# define __strerror_r strerror_r
|
||||||
# endif /* HAVE_STRERROR_R || defined strerror_r */
|
# endif /* HAVE_STRERROR_R || defined strerror_r */
|
||||||
#endif /* not _LIBC */
|
#endif /* not _LIBC */
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
flush_stdout (void)
|
||||||
|
{
|
||||||
|
#if !_LIBC && defined F_GETFL
|
||||||
|
int stdout_fd;
|
||||||
|
|
||||||
|
# if GNULIB_FREOPEN_SAFER
|
||||||
|
/* Use of gnulib's freopen-safer module normally ensures that
|
||||||
|
fileno (stdout) == 1
|
||||||
|
whenever stdout is open. */
|
||||||
|
stdout_fd = STDOUT_FILENO;
|
||||||
|
# else
|
||||||
|
/* POSIX states that fileno (stdout) after fclose is unspecified. But in
|
||||||
|
practice it is not a problem, because stdout is statically allocated and
|
||||||
|
the fd of a FILE stream is stored as a field in its allocated memory. */
|
||||||
|
stdout_fd = fileno (stdout);
|
||||||
|
# endif
|
||||||
|
/* POSIX states that fflush (stdout) after fclose is unspecified; it
|
||||||
|
is safe in glibc, but not on all other platforms. fflush (NULL)
|
||||||
|
is always defined, but too draconian. */
|
||||||
|
if (0 <= stdout_fd && 0 <= fcntl (stdout_fd, F_GETFL))
|
||||||
|
#endif
|
||||||
|
fflush (stdout);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_errno_message (int errnum)
|
print_errno_message (int errnum)
|
||||||
|
@ -149,58 +175,58 @@ error_tail (int status, int errnum, const char *message, va_list args)
|
||||||
bool use_malloc = false;
|
bool use_malloc = false;
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
if (__libc_use_alloca (len * sizeof (wchar_t)))
|
if (__libc_use_alloca (len * sizeof (wchar_t)))
|
||||||
wmessage = (wchar_t *) alloca (len * sizeof (wchar_t));
|
wmessage = (wchar_t *) alloca (len * sizeof (wchar_t));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!use_malloc)
|
if (!use_malloc)
|
||||||
wmessage = NULL;
|
wmessage = NULL;
|
||||||
|
|
||||||
wchar_t *p = (wchar_t *) realloc (wmessage,
|
wchar_t *p = (wchar_t *) realloc (wmessage,
|
||||||
len * sizeof (wchar_t));
|
len * sizeof (wchar_t));
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
{
|
{
|
||||||
free (wmessage);
|
free (wmessage);
|
||||||
fputws_unlocked (L"out of memory\n", stderr);
|
fputws_unlocked (L"out of memory\n", stderr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wmessage = p;
|
wmessage = p;
|
||||||
use_malloc = true;
|
use_malloc = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset (&st, '\0', sizeof (st));
|
memset (&st, '\0', sizeof (st));
|
||||||
tmp = message;
|
tmp = message;
|
||||||
|
|
||||||
res = mbsrtowcs (wmessage, &tmp, len, &st);
|
res = mbsrtowcs (wmessage, &tmp, len, &st);
|
||||||
if (res != len)
|
if (res != len)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (__builtin_expect (len >= SIZE_MAX / 2, 0))
|
if (__builtin_expect (len >= SIZE_MAX / 2, 0))
|
||||||
{
|
{
|
||||||
/* This really should not happen if everything is fine. */
|
/* This really should not happen if everything is fine. */
|
||||||
res = (size_t) -1;
|
res = (size_t) -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
len *= 2;
|
len *= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res == (size_t) -1)
|
if (res == (size_t) -1)
|
||||||
{
|
{
|
||||||
/* The string cannot be converted. */
|
/* The string cannot be converted. */
|
||||||
if (use_malloc)
|
if (use_malloc)
|
||||||
{
|
{
|
||||||
free (wmessage);
|
free (wmessage);
|
||||||
use_malloc = false;
|
use_malloc = false;
|
||||||
}
|
}
|
||||||
wmessage = (wchar_t *) L"???";
|
wmessage = (wchar_t *) L"???";
|
||||||
}
|
}
|
||||||
|
|
||||||
__vfwprintf (stderr, wmessage, args);
|
__vfwprintf (stderr, wmessage, args);
|
||||||
|
|
||||||
if (use_malloc)
|
if (use_malloc)
|
||||||
free (wmessage);
|
free (wmessage);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
@ -235,16 +261,10 @@ error (int status, int errnum, const char *message, ...)
|
||||||
cancellation. Therefore disable cancellation for now. */
|
cancellation. Therefore disable cancellation for now. */
|
||||||
int state = PTHREAD_CANCEL_ENABLE;
|
int state = PTHREAD_CANCEL_ENABLE;
|
||||||
__libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state),
|
__libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state),
|
||||||
0);
|
0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !_LIBC && defined F_GETFL
|
flush_stdout ();
|
||||||
/* POSIX states that fflush (stdout) after fclose is unspecified; it
|
|
||||||
is safe in glibc, but not on all other platforms. fflush (NULL)
|
|
||||||
is always defined, but too draconian. */
|
|
||||||
if (0 <= fcntl (1, F_GETFL))
|
|
||||||
#endif
|
|
||||||
fflush (stdout);
|
|
||||||
#ifdef _LIBC
|
#ifdef _LIBC
|
||||||
_IO_flockfile (stderr);
|
_IO_flockfile (stderr);
|
||||||
#endif
|
#endif
|
||||||
|
@ -276,7 +296,7 @@ int error_one_per_line;
|
||||||
|
|
||||||
void
|
void
|
||||||
error_at_line (int status, int errnum, const char *file_name,
|
error_at_line (int status, int errnum, const char *file_name,
|
||||||
unsigned int line_number, const char *message, ...)
|
unsigned int line_number, const char *message, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
|
@ -286,10 +306,10 @@ error_at_line (int status, int errnum, const char *file_name,
|
||||||
static unsigned int old_line_number;
|
static unsigned int old_line_number;
|
||||||
|
|
||||||
if (old_line_number == line_number
|
if (old_line_number == line_number
|
||||||
&& (file_name == old_file_name
|
&& (file_name == old_file_name
|
||||||
|| strcmp (old_file_name, file_name) == 0))
|
|| strcmp (old_file_name, file_name) == 0))
|
||||||
/* Simply return and print nothing. */
|
/* Simply return and print nothing. */
|
||||||
return;
|
return;
|
||||||
|
|
||||||
old_file_name = file_name;
|
old_file_name = file_name;
|
||||||
old_line_number = line_number;
|
old_line_number = line_number;
|
||||||
|
@ -300,16 +320,10 @@ error_at_line (int status, int errnum, const char *file_name,
|
||||||
cancellation. Therefore disable cancellation for now. */
|
cancellation. Therefore disable cancellation for now. */
|
||||||
int state = PTHREAD_CANCEL_ENABLE;
|
int state = PTHREAD_CANCEL_ENABLE;
|
||||||
__libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state),
|
__libc_ptf_call (pthread_setcancelstate, (PTHREAD_CANCEL_DISABLE, &state),
|
||||||
0);
|
0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !_LIBC && defined F_GETFL
|
flush_stdout ();
|
||||||
/* POSIX states that fflush (stdout) after fclose is unspecified; it
|
|
||||||
is safe in glibc, but not on all other platforms. fflush (NULL)
|
|
||||||
is always defined, but too draconian. */
|
|
||||||
if (0 <= fcntl (1, F_GETFL))
|
|
||||||
#endif
|
|
||||||
fflush (stdout);
|
|
||||||
#ifdef _LIBC
|
#ifdef _LIBC
|
||||||
_IO_flockfile (stderr);
|
_IO_flockfile (stderr);
|
||||||
#endif
|
#endif
|
||||||
|
@ -326,10 +340,10 @@ error_at_line (int status, int errnum, const char *file_name,
|
||||||
|
|
||||||
#if _LIBC
|
#if _LIBC
|
||||||
__fxprintf (NULL, file_name != NULL ? "%s:%d: " : " ",
|
__fxprintf (NULL, file_name != NULL ? "%s:%d: " : " ",
|
||||||
file_name, line_number);
|
file_name, line_number);
|
||||||
#else
|
#else
|
||||||
fprintf (stderr, file_name != NULL ? "%s:%d: " : " ",
|
fprintf (stderr, file_name != NULL ? "%s:%d: " : " ",
|
||||||
file_name, line_number);
|
file_name, line_number);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
va_start (args, message);
|
va_start (args, message);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/* Declaration for error-reporting function
|
/* Declaration for error-reporting function
|
||||||
Copyright (C) 1995, 1996, 1997, 2003, 2006, 2008 Free Software Foundation, Inc.
|
Copyright (C) 1995, 1996, 1997, 2003, 2006, 2008, 2009, 2010 Free Software
|
||||||
|
Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -19,19 +20,18 @@
|
||||||
#define _ERROR_H 1
|
#define _ERROR_H 1
|
||||||
|
|
||||||
#ifndef __attribute__
|
#ifndef __attribute__
|
||||||
/* This feature is available in gcc versions 2.5 and later. */
|
/* The __attribute__ feature is available in gcc versions 2.5 and later.
|
||||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
|
The __-protected variants of the attributes 'format' and 'printf' are
|
||||||
# define __attribute__(Spec) /* empty */
|
accepted by gcc versions 2.6.4 (effectively 2.7) and later.
|
||||||
# endif
|
We enable __attribute__ only if these are supported too, because
|
||||||
/* The __-protected variants of `format' and `printf' attributes
|
gnulib and libintl do '#define printf __printf__' when they override
|
||||||
are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
|
the 'printf' function. */
|
||||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
|
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
|
||||||
# define __format__ format
|
# define __attribute__(Spec) /* empty */
|
||||||
# define __printf__ printf
|
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ extern void error (int __status, int __errnum, const char *__format, ...)
|
||||||
__attribute__ ((__format__ (__printf__, 3, 4)));
|
__attribute__ ((__format__ (__printf__, 3, 4)));
|
||||||
|
|
||||||
extern void error_at_line (int __status, int __errnum, const char *__fname,
|
extern void error_at_line (int __status, int __errnum, const char *__fname,
|
||||||
unsigned int __lineno, const char *__format, ...)
|
unsigned int __lineno, const char *__format, ...)
|
||||||
__attribute__ ((__format__ (__printf__, 5, 6)));
|
__attribute__ ((__format__ (__printf__, 5, 6)));
|
||||||
|
|
||||||
/* If NULL, error will flush stdout, then print on stderr the program
|
/* If NULL, error will flush stdout, then print on stderr the program
|
||||||
|
@ -58,7 +58,7 @@ extern unsigned int error_message_count;
|
||||||
variable controls whether this mode is selected or not. */
|
variable controls whether this mode is selected or not. */
|
||||||
extern int error_one_per_line;
|
extern int error_one_per_line;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
198
gnulib/fnmatch.c
198
gnulib/fnmatch.c
|
@ -1,5 +1,5 @@
|
||||||
/* Copyright (C) 1991,1992,1993,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007
|
/* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||||
Free Software Foundation, Inc.
|
2003, 2004, 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
/* Enable GNU extensions in fnmatch.h. */
|
/* Enable GNU extensions in fnmatch.h. */
|
||||||
#ifndef _GNU_SOURCE
|
#ifndef _GNU_SOURCE
|
||||||
# define _GNU_SOURCE 1
|
# define _GNU_SOURCE 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ! defined __builtin_expect && __GNUC__ < 3
|
#if ! defined __builtin_expect && __GNUC__ < 3
|
||||||
|
@ -89,7 +89,7 @@ extern int fnmatch (const char *pattern, const char *string, int flags);
|
||||||
# define isblank(c) ((c) == ' ' || (c) == '\t')
|
# define isblank(c) ((c) == ' ' || (c) == '\t')
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# define STREQ(s1, s2) ((strcmp (s1, s2) == 0))
|
# define STREQ(s1, s2) (strcmp (s1, s2) == 0)
|
||||||
|
|
||||||
# if defined _LIBC || WIDE_CHAR_SUPPORT
|
# if defined _LIBC || WIDE_CHAR_SUPPORT
|
||||||
/* The GNU C library provides support for user-defined character classes
|
/* The GNU C library provides support for user-defined character classes
|
||||||
|
@ -109,25 +109,25 @@ extern int fnmatch (const char *pattern, const char *string, int flags);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef _LIBC
|
# ifdef _LIBC
|
||||||
# define ISWCTYPE(WC, WT) __iswctype (WC, WT)
|
# define ISWCTYPE(WC, WT) __iswctype (WC, WT)
|
||||||
# else
|
# else
|
||||||
# define ISWCTYPE(WC, WT) iswctype (WC, WT)
|
# define ISWCTYPE(WC, WT) iswctype (WC, WT)
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# if (HAVE_MBSTATE_T && HAVE_MBSRTOWCS) || _LIBC
|
# if (HAVE_MBSTATE_T && HAVE_MBSRTOWCS) || _LIBC
|
||||||
/* In this case we are implementing the multibyte character handling. */
|
/* In this case we are implementing the multibyte character handling. */
|
||||||
# define HANDLE_MULTIBYTE 1
|
# define HANDLE_MULTIBYTE 1
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# else
|
# else
|
||||||
# define CHAR_CLASS_MAX_LENGTH 6 /* Namely, `xdigit'. */
|
# define CHAR_CLASS_MAX_LENGTH 6 /* Namely, `xdigit'. */
|
||||||
|
|
||||||
# define IS_CHAR_CLASS(string) \
|
# define IS_CHAR_CLASS(string) \
|
||||||
(STREQ (string, "alpha") || STREQ (string, "upper") \
|
(STREQ (string, "alpha") || STREQ (string, "upper") \
|
||||||
|| STREQ (string, "lower") || STREQ (string, "digit") \
|
|| STREQ (string, "lower") || STREQ (string, "digit") \
|
||||||
|| STREQ (string, "alnum") || STREQ (string, "xdigit") \
|
|| STREQ (string, "alnum") || STREQ (string, "xdigit") \
|
||||||
|| STREQ (string, "space") || STREQ (string, "print") \
|
|| STREQ (string, "space") || STREQ (string, "print") \
|
||||||
|| STREQ (string, "punct") || STREQ (string, "graph") \
|
|| STREQ (string, "punct") || STREQ (string, "graph") \
|
||||||
|| STREQ (string, "cntrl") || STREQ (string, "blank"))
|
|| STREQ (string, "cntrl") || STREQ (string, "blank"))
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
@ -145,17 +145,17 @@ static int posixly_correct;
|
||||||
|
|
||||||
/* Note that this evaluates C many times. */
|
/* Note that this evaluates C many times. */
|
||||||
# define FOLD(c) ((flags & FNM_CASEFOLD) ? tolower (c) : (c))
|
# define FOLD(c) ((flags & FNM_CASEFOLD) ? tolower (c) : (c))
|
||||||
# define CHAR char
|
# define CHAR char
|
||||||
# define UCHAR unsigned char
|
# define UCHAR unsigned char
|
||||||
# define INT int
|
# define INT int
|
||||||
# define FCT internal_fnmatch
|
# define FCT internal_fnmatch
|
||||||
# define EXT ext_match
|
# define EXT ext_match
|
||||||
# define END end_pattern
|
# define END end_pattern
|
||||||
# define L_(CS) CS
|
# define L_(CS) CS
|
||||||
# ifdef _LIBC
|
# ifdef _LIBC
|
||||||
# define BTOWC(C) __btowc (C)
|
# define BTOWC(C) __btowc (C)
|
||||||
# else
|
# else
|
||||||
# define BTOWC(C) btowc (C)
|
# define BTOWC(C) btowc (C)
|
||||||
# endif
|
# endif
|
||||||
# define STRLEN(S) strlen (S)
|
# define STRLEN(S) strlen (S)
|
||||||
# define STRCAT(D, S) strcat (D, S)
|
# define STRCAT(D, S) strcat (D, S)
|
||||||
|
@ -175,14 +175,14 @@ static int posixly_correct;
|
||||||
|
|
||||||
# if HANDLE_MULTIBYTE
|
# if HANDLE_MULTIBYTE
|
||||||
# define FOLD(c) ((flags & FNM_CASEFOLD) ? towlower (c) : (c))
|
# define FOLD(c) ((flags & FNM_CASEFOLD) ? towlower (c) : (c))
|
||||||
# define CHAR wchar_t
|
# define CHAR wchar_t
|
||||||
# define UCHAR wint_t
|
# define UCHAR wint_t
|
||||||
# define INT wint_t
|
# define INT wint_t
|
||||||
# define FCT internal_fnwmatch
|
# define FCT internal_fnwmatch
|
||||||
# define EXT ext_wmatch
|
# define EXT ext_wmatch
|
||||||
# define END end_wpattern
|
# define END end_wpattern
|
||||||
# define L_(CS) L##CS
|
# define L_(CS) L##CS
|
||||||
# define BTOWC(C) (C)
|
# define BTOWC(C) (C)
|
||||||
# ifdef _LIBC
|
# ifdef _LIBC
|
||||||
# define STRLEN(S) __wcslen (S)
|
# define STRLEN(S) __wcslen (S)
|
||||||
# define STRCAT(D, S) __wcscat (D, S)
|
# define STRCAT(D, S) __wcscat (D, S)
|
||||||
|
@ -218,40 +218,40 @@ is_char_class (const wchar_t *wcs)
|
||||||
/* Test for a printable character from the portable character set. */
|
/* Test for a printable character from the portable character set. */
|
||||||
# ifdef _LIBC
|
# ifdef _LIBC
|
||||||
if (*wcs < 0x20 || *wcs > 0x7e
|
if (*wcs < 0x20 || *wcs > 0x7e
|
||||||
|| *wcs == 0x24 || *wcs == 0x40 || *wcs == 0x60)
|
|| *wcs == 0x24 || *wcs == 0x40 || *wcs == 0x60)
|
||||||
return (wctype_t) 0;
|
return (wctype_t) 0;
|
||||||
# else
|
# else
|
||||||
switch (*wcs)
|
switch (*wcs)
|
||||||
{
|
{
|
||||||
case L' ': case L'!': case L'"': case L'#': case L'%':
|
case L' ': case L'!': case L'"': case L'#': case L'%':
|
||||||
case L'&': case L'\'': case L'(': case L')': case L'*':
|
case L'&': case L'\'': case L'(': case L')': case L'*':
|
||||||
case L'+': case L',': case L'-': case L'.': case L'/':
|
case L'+': case L',': case L'-': case L'.': case L'/':
|
||||||
case L'0': case L'1': case L'2': case L'3': case L'4':
|
case L'0': case L'1': case L'2': case L'3': case L'4':
|
||||||
case L'5': case L'6': case L'7': case L'8': case L'9':
|
case L'5': case L'6': case L'7': case L'8': case L'9':
|
||||||
case L':': case L';': case L'<': case L'=': case L'>':
|
case L':': case L';': case L'<': case L'=': case L'>':
|
||||||
case L'?':
|
case L'?':
|
||||||
case L'A': case L'B': case L'C': case L'D': case L'E':
|
case L'A': case L'B': case L'C': case L'D': case L'E':
|
||||||
case L'F': case L'G': case L'H': case L'I': case L'J':
|
case L'F': case L'G': case L'H': case L'I': case L'J':
|
||||||
case L'K': case L'L': case L'M': case L'N': case L'O':
|
case L'K': case L'L': case L'M': case L'N': case L'O':
|
||||||
case L'P': case L'Q': case L'R': case L'S': case L'T':
|
case L'P': case L'Q': case L'R': case L'S': case L'T':
|
||||||
case L'U': case L'V': case L'W': case L'X': case L'Y':
|
case L'U': case L'V': case L'W': case L'X': case L'Y':
|
||||||
case L'Z':
|
case L'Z':
|
||||||
case L'[': case L'\\': case L']': case L'^': case L'_':
|
case L'[': case L'\\': case L']': case L'^': case L'_':
|
||||||
case L'a': case L'b': case L'c': case L'd': case L'e':
|
case L'a': case L'b': case L'c': case L'd': case L'e':
|
||||||
case L'f': case L'g': case L'h': case L'i': case L'j':
|
case L'f': case L'g': case L'h': case L'i': case L'j':
|
||||||
case L'k': case L'l': case L'm': case L'n': case L'o':
|
case L'k': case L'l': case L'm': case L'n': case L'o':
|
||||||
case L'p': case L'q': case L'r': case L's': case L't':
|
case L'p': case L'q': case L'r': case L's': case L't':
|
||||||
case L'u': case L'v': case L'w': case L'x': case L'y':
|
case L'u': case L'v': case L'w': case L'x': case L'y':
|
||||||
case L'z': case L'{': case L'|': case L'}': case L'~':
|
case L'z': case L'{': case L'|': case L'}': case L'~':
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return (wctype_t) 0;
|
return (wctype_t) 0;
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
/* Avoid overrunning the buffer. */
|
/* Avoid overrunning the buffer. */
|
||||||
if (cp == s + CHAR_CLASS_MAX_LENGTH)
|
if (cp == s + CHAR_CLASS_MAX_LENGTH)
|
||||||
return (wctype_t) 0;
|
return (wctype_t) 0;
|
||||||
|
|
||||||
*cp++ = (char) *wcs++;
|
*cp++ = (char) *wcs++;
|
||||||
}
|
}
|
||||||
|
@ -287,58 +287,58 @@ fnmatch (const char *pattern, const char *string, int flags)
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
/* Calculate the size needed to convert the strings to
|
/* Calculate the size needed to convert the strings to
|
||||||
wide characters. */
|
wide characters. */
|
||||||
memset (&ps, '\0', sizeof (ps));
|
memset (&ps, '\0', sizeof (ps));
|
||||||
patsize = mbsrtowcs (NULL, &pattern, 0, &ps) + 1;
|
patsize = mbsrtowcs (NULL, &pattern, 0, &ps) + 1;
|
||||||
if (__builtin_expect (patsize != 0, 1))
|
if (__builtin_expect (patsize != 0, 1))
|
||||||
{
|
{
|
||||||
assert (mbsinit (&ps));
|
assert (mbsinit (&ps));
|
||||||
strsize = mbsrtowcs (NULL, &string, 0, &ps) + 1;
|
strsize = mbsrtowcs (NULL, &string, 0, &ps) + 1;
|
||||||
if (__builtin_expect (strsize != 0, 1))
|
if (__builtin_expect (strsize != 0, 1))
|
||||||
{
|
{
|
||||||
assert (mbsinit (&ps));
|
assert (mbsinit (&ps));
|
||||||
totsize = patsize + strsize;
|
totsize = patsize + strsize;
|
||||||
if (__builtin_expect (! (patsize <= totsize
|
if (__builtin_expect (! (patsize <= totsize
|
||||||
&& totsize <= SIZE_MAX / sizeof (wchar_t)),
|
&& totsize <= SIZE_MAX / sizeof (wchar_t)),
|
||||||
0))
|
0))
|
||||||
{
|
{
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate room for the wide characters. */
|
/* Allocate room for the wide characters. */
|
||||||
if (__builtin_expect (totsize < ALLOCA_LIMIT, 1))
|
if (__builtin_expect (totsize < ALLOCA_LIMIT, 1))
|
||||||
wpattern = (wchar_t *) alloca (totsize * sizeof (wchar_t));
|
wpattern = (wchar_t *) alloca (totsize * sizeof (wchar_t));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wpattern = malloc (totsize * sizeof (wchar_t));
|
wpattern = malloc (totsize * sizeof (wchar_t));
|
||||||
if (__builtin_expect (! wpattern, 0))
|
if (__builtin_expect (! wpattern, 0))
|
||||||
{
|
{
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wstring = wpattern + patsize;
|
wstring = wpattern + patsize;
|
||||||
|
|
||||||
/* Convert the strings into wide characters. */
|
/* Convert the strings into wide characters. */
|
||||||
mbsrtowcs (wpattern, &pattern, patsize, &ps);
|
mbsrtowcs (wpattern, &pattern, patsize, &ps);
|
||||||
assert (mbsinit (&ps));
|
assert (mbsinit (&ps));
|
||||||
mbsrtowcs (wstring, &string, strsize, &ps);
|
mbsrtowcs (wstring, &string, strsize, &ps);
|
||||||
|
|
||||||
res = internal_fnwmatch (wpattern, wstring, wstring + strsize - 1,
|
res = internal_fnwmatch (wpattern, wstring, wstring + strsize - 1,
|
||||||
flags & FNM_PERIOD, flags);
|
flags & FNM_PERIOD, flags);
|
||||||
|
|
||||||
if (__builtin_expect (! (totsize < ALLOCA_LIMIT), 0))
|
if (__builtin_expect (! (totsize < ALLOCA_LIMIT), 0))
|
||||||
free (wpattern);
|
free (wpattern);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# endif /* HANDLE_MULTIBYTE */
|
# endif /* HANDLE_MULTIBYTE */
|
||||||
|
|
||||||
return internal_fnmatch (pattern, string, string + strlen (string),
|
return internal_fnmatch (pattern, string, string + strlen (string),
|
||||||
flags & FNM_PERIOD, flags);
|
flags & FNM_PERIOD, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
# ifdef _LIBC
|
# ifdef _LIBC
|
||||||
|
@ -351,4 +351,4 @@ compat_symbol (libc, __fnmatch_old, fnmatch, GLIBC_2_0);
|
||||||
libc_hidden_ver (__fnmatch, fnmatch)
|
libc_hidden_ver (__fnmatch, fnmatch)
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
#endif /* _LIBC or not __GNU_LIBRARY__. */
|
#endif /* _LIBC or not __GNU_LIBRARY__. */
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,6 @@
|
||||||
/* getdelim.c --- Implementation of replacement getdelim function.
|
/* getdelim.c --- Implementation of replacement getdelim function.
|
||||||
Copyright (C) 1994, 1996, 1997, 1998, 2001, 2003, 2005, 2006, 2007,
|
Copyright (C) 1994, 1996, 1997, 1998, 2001, 2003, 2005, 2006, 2007, 2008,
|
||||||
2008, 2009 Free Software Foundation, Inc.
|
2009, 2010 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
This program is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License as
|
modify it under the terms of the GNU General Public License as
|
||||||
|
@ -21,13 +21,16 @@
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
|
/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
|
||||||
|
optimizes away the lineptr == NULL || n == NULL || fp == NULL tests below. */
|
||||||
|
#define _GL_ARG_NONNULL(params)
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#ifndef SSIZE_MAX
|
#ifndef SSIZE_MAX
|
||||||
# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
|
# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
|
||||||
|
@ -35,15 +38,15 @@
|
||||||
|
|
||||||
#if USE_UNLOCKED_IO
|
#if USE_UNLOCKED_IO
|
||||||
# include "unlocked-io.h"
|
# include "unlocked-io.h"
|
||||||
# define getc_maybe_unlocked(fp) getc(fp)
|
# define getc_maybe_unlocked(fp) getc(fp)
|
||||||
#elif !HAVE_FLOCKFILE || !HAVE_FUNLOCKFILE || !HAVE_DECL_GETC_UNLOCKED
|
#elif !HAVE_FLOCKFILE || !HAVE_FUNLOCKFILE || !HAVE_DECL_GETC_UNLOCKED
|
||||||
# undef flockfile
|
# undef flockfile
|
||||||
# undef funlockfile
|
# undef funlockfile
|
||||||
# define flockfile(x) ((void) 0)
|
# define flockfile(x) ((void) 0)
|
||||||
# define funlockfile(x) ((void) 0)
|
# define funlockfile(x) ((void) 0)
|
||||||
# define getc_maybe_unlocked(fp) getc(fp)
|
# define getc_maybe_unlocked(fp) getc(fp)
|
||||||
#else
|
#else
|
||||||
# define getc_maybe_unlocked(fp) getc_unlocked(fp)
|
# define getc_maybe_unlocked(fp) getc_unlocked(fp)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Read up to (and including) a DELIMITER from FP into *LINEPTR (and
|
/* Read up to (and including) a DELIMITER from FP into *LINEPTR (and
|
||||||
|
@ -72,10 +75,10 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
|
||||||
*n = 120;
|
*n = 120;
|
||||||
new_lineptr = (char *) realloc (*lineptr, *n);
|
new_lineptr = (char *) realloc (*lineptr, *n);
|
||||||
if (new_lineptr == NULL)
|
if (new_lineptr == NULL)
|
||||||
{
|
{
|
||||||
result = -1;
|
result = -1;
|
||||||
goto unlock_return;
|
goto unlock_return;
|
||||||
}
|
}
|
||||||
*lineptr = new_lineptr;
|
*lineptr = new_lineptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,44 +88,44 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
|
||||||
|
|
||||||
i = getc_maybe_unlocked (fp);
|
i = getc_maybe_unlocked (fp);
|
||||||
if (i == EOF)
|
if (i == EOF)
|
||||||
{
|
{
|
||||||
result = -1;
|
result = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make enough space for len+1 (for final NUL) bytes. */
|
/* Make enough space for len+1 (for final NUL) bytes. */
|
||||||
if (cur_len + 1 >= *n)
|
if (cur_len + 1 >= *n)
|
||||||
{
|
{
|
||||||
size_t needed_max =
|
size_t needed_max =
|
||||||
SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX;
|
SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX;
|
||||||
size_t needed = 2 * *n + 1; /* Be generous. */
|
size_t needed = 2 * *n + 1; /* Be generous. */
|
||||||
char *new_lineptr;
|
char *new_lineptr;
|
||||||
|
|
||||||
if (needed_max < needed)
|
if (needed_max < needed)
|
||||||
needed = needed_max;
|
needed = needed_max;
|
||||||
if (cur_len + 1 >= needed)
|
if (cur_len + 1 >= needed)
|
||||||
{
|
{
|
||||||
result = -1;
|
result = -1;
|
||||||
errno = EOVERFLOW;
|
errno = EOVERFLOW;
|
||||||
goto unlock_return;
|
goto unlock_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
new_lineptr = (char *) realloc (*lineptr, needed);
|
new_lineptr = (char *) realloc (*lineptr, needed);
|
||||||
if (new_lineptr == NULL)
|
if (new_lineptr == NULL)
|
||||||
{
|
{
|
||||||
result = -1;
|
result = -1;
|
||||||
goto unlock_return;
|
goto unlock_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
*lineptr = new_lineptr;
|
*lineptr = new_lineptr;
|
||||||
*n = needed;
|
*n = needed;
|
||||||
}
|
}
|
||||||
|
|
||||||
(*lineptr)[cur_len] = i;
|
(*lineptr)[cur_len] = i;
|
||||||
cur_len++;
|
cur_len++;
|
||||||
|
|
||||||
if (i == delimiter)
|
if (i == delimiter)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
(*lineptr)[cur_len] = '\0';
|
(*lineptr)[cur_len] = '\0';
|
||||||
result = cur_len ? cur_len : result;
|
result = cur_len ? cur_len : result;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* getline.c --- Implementation of replacement getline function.
|
/* getline.c --- Implementation of replacement getline function.
|
||||||
Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
|
Copyright (C) 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
This program is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License as
|
modify it under the terms of the GNU General Public License as
|
||||||
|
|
1247
gnulib/getopt.c
1247
gnulib/getopt.c
File diff suppressed because it is too large
Load diff
128
gnulib/getopt1.c
128
gnulib/getopt1.c
|
@ -1,6 +1,6 @@
|
||||||
/* getopt_long and getopt_long_only entry points for GNU getopt.
|
/* getopt_long and getopt_long_only entry points for GNU getopt.
|
||||||
Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98,2004,2006
|
Copyright (C) 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997,
|
||||||
Free Software Foundation, Inc.
|
1998, 2004, 2006, 2009, 2010 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -32,25 +32,25 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NULL
|
#ifndef NULL
|
||||||
#define NULL 0
|
#define NULL 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int
|
int
|
||||||
getopt_long (int argc, char *__getopt_argv_const *argv, const char *options,
|
getopt_long (int argc, char *__getopt_argv_const *argv, const char *options,
|
||||||
const struct option *long_options, int *opt_index)
|
const struct option *long_options, int *opt_index)
|
||||||
{
|
{
|
||||||
return _getopt_internal (argc, (char **) argv, options, long_options,
|
return _getopt_internal (argc, (char **) argv, options, long_options,
|
||||||
opt_index, 0, 0);
|
opt_index, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
_getopt_long_r (int argc, char **argv, const char *options,
|
_getopt_long_r (int argc, char **argv, const char *options,
|
||||||
const struct option *long_options, int *opt_index,
|
const struct option *long_options, int *opt_index,
|
||||||
struct _getopt_data *d)
|
struct _getopt_data *d)
|
||||||
{
|
{
|
||||||
return _getopt_internal_r (argc, argv, options, long_options, opt_index,
|
return _getopt_internal_r (argc, argv, options, long_options, opt_index,
|
||||||
0, 0, d);
|
0, d, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Like getopt_long, but '-' as well as '--' can indicate a long option.
|
/* Like getopt_long, but '-' as well as '--' can indicate a long option.
|
||||||
|
@ -60,20 +60,20 @@ _getopt_long_r (int argc, char **argv, const char *options,
|
||||||
|
|
||||||
int
|
int
|
||||||
getopt_long_only (int argc, char *__getopt_argv_const *argv,
|
getopt_long_only (int argc, char *__getopt_argv_const *argv,
|
||||||
const char *options,
|
const char *options,
|
||||||
const struct option *long_options, int *opt_index)
|
const struct option *long_options, int *opt_index)
|
||||||
{
|
{
|
||||||
return _getopt_internal (argc, (char **) argv, options, long_options,
|
return _getopt_internal (argc, (char **) argv, options, long_options,
|
||||||
opt_index, 1, 0);
|
opt_index, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
_getopt_long_only_r (int argc, char **argv, const char *options,
|
_getopt_long_only_r (int argc, char **argv, const char *options,
|
||||||
const struct option *long_options, int *opt_index,
|
const struct option *long_options, int *opt_index,
|
||||||
struct _getopt_data *d)
|
struct _getopt_data *d)
|
||||||
{
|
{
|
||||||
return _getopt_internal_r (argc, argv, options, long_options, opt_index,
|
return _getopt_internal_r (argc, argv, options, long_options, opt_index,
|
||||||
1, 0, d);
|
1, d, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,76 +91,76 @@ main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
int this_option_optind = optind ? optind : 1;
|
int this_option_optind = optind ? optind : 1;
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
static struct option long_options[] =
|
static const struct option long_options[] =
|
||||||
{
|
{
|
||||||
{"add", 1, 0, 0},
|
{"add", 1, 0, 0},
|
||||||
{"append", 0, 0, 0},
|
{"append", 0, 0, 0},
|
||||||
{"delete", 1, 0, 0},
|
{"delete", 1, 0, 0},
|
||||||
{"verbose", 0, 0, 0},
|
{"verbose", 0, 0, 0},
|
||||||
{"create", 0, 0, 0},
|
{"create", 0, 0, 0},
|
||||||
{"file", 1, 0, 0},
|
{"file", 1, 0, 0},
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
c = getopt_long (argc, argv, "abc:d:0123456789",
|
c = getopt_long (argc, argv, "abc:d:0123456789",
|
||||||
long_options, &option_index);
|
long_options, &option_index);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
printf ("option %s", long_options[option_index].name);
|
printf ("option %s", long_options[option_index].name);
|
||||||
if (optarg)
|
if (optarg)
|
||||||
printf (" with arg %s", optarg);
|
printf (" with arg %s", optarg);
|
||||||
printf ("\n");
|
printf ("\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '0':
|
case '0':
|
||||||
case '1':
|
case '1':
|
||||||
case '2':
|
case '2':
|
||||||
case '3':
|
case '3':
|
||||||
case '4':
|
case '4':
|
||||||
case '5':
|
case '5':
|
||||||
case '6':
|
case '6':
|
||||||
case '7':
|
case '7':
|
||||||
case '8':
|
case '8':
|
||||||
case '9':
|
case '9':
|
||||||
if (digit_optind != 0 && digit_optind != this_option_optind)
|
if (digit_optind != 0 && digit_optind != this_option_optind)
|
||||||
printf ("digits occur in two different argv-elements.\n");
|
printf ("digits occur in two different argv-elements.\n");
|
||||||
digit_optind = this_option_optind;
|
digit_optind = this_option_optind;
|
||||||
printf ("option %c\n", c);
|
printf ("option %c\n", c);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'a':
|
case 'a':
|
||||||
printf ("option a\n");
|
printf ("option a\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'b':
|
case 'b':
|
||||||
printf ("option b\n");
|
printf ("option b\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'c':
|
case 'c':
|
||||||
printf ("option c with value `%s'\n", optarg);
|
printf ("option c with value `%s'\n", optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'd':
|
case 'd':
|
||||||
printf ("option d with value `%s'\n", optarg);
|
printf ("option d with value `%s'\n", optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '?':
|
case '?':
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
printf ("?? getopt returned character code 0%o ??\n", c);
|
printf ("?? getopt returned character code 0%o ??\n", c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (optind < argc)
|
if (optind < argc)
|
||||||
{
|
{
|
||||||
printf ("non-option ARGV-elements: ");
|
printf ("non-option ARGV-elements: ");
|
||||||
while (optind < argc)
|
while (optind < argc)
|
||||||
printf ("%s ", argv[optind++]);
|
printf ("%s ", argv[optind++]);
|
||||||
printf ("\n");
|
printf ("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* Internal declarations for getopt.
|
/* Internal declarations for getopt.
|
||||||
Copyright (C) 1989-1994,1996-1999,2001,2003,2004
|
Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2004, 2009-2010 Free Software
|
||||||
Free Software Foundation, Inc.
|
Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -17,12 +17,14 @@
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
#ifndef _GETOPT_INT_H
|
#ifndef _GETOPT_INT_H
|
||||||
#define _GETOPT_INT_H 1
|
#define _GETOPT_INT_H 1
|
||||||
|
|
||||||
|
#include <getopt.h>
|
||||||
|
|
||||||
extern int _getopt_internal (int ___argc, char **___argv,
|
extern int _getopt_internal (int ___argc, char **___argv,
|
||||||
const char *__shortopts,
|
const char *__shortopts,
|
||||||
const struct option *__longopts, int *__longind,
|
const struct option *__longopts, int *__longind,
|
||||||
int __long_only, int __posixly_correct);
|
int __long_only, int __posixly_correct);
|
||||||
|
|
||||||
|
|
||||||
/* Reentrant versions which can handle parsing multiple argument
|
/* Reentrant versions which can handle parsing multiple argument
|
||||||
|
@ -108,23 +110,23 @@ struct _getopt_data
|
||||||
|
|
||||||
/* The initializer is necessary to set OPTIND and OPTERR to their
|
/* The initializer is necessary to set OPTIND and OPTERR to their
|
||||||
default values and to clear the initialization flag. */
|
default values and to clear the initialization flag. */
|
||||||
#define _GETOPT_DATA_INITIALIZER { 1, 1 }
|
#define _GETOPT_DATA_INITIALIZER { 1, 1 }
|
||||||
|
|
||||||
extern int _getopt_internal_r (int ___argc, char **___argv,
|
extern int _getopt_internal_r (int ___argc, char **___argv,
|
||||||
const char *__shortopts,
|
const char *__shortopts,
|
||||||
const struct option *__longopts, int *__longind,
|
const struct option *__longopts, int *__longind,
|
||||||
int __long_only, int __posixly_correct,
|
int __long_only, struct _getopt_data *__data,
|
||||||
struct _getopt_data *__data);
|
int __posixly_correct);
|
||||||
|
|
||||||
extern int _getopt_long_r (int ___argc, char **___argv,
|
extern int _getopt_long_r (int ___argc, char **___argv,
|
||||||
const char *__shortopts,
|
const char *__shortopts,
|
||||||
const struct option *__longopts, int *__longind,
|
const struct option *__longopts, int *__longind,
|
||||||
struct _getopt_data *__data);
|
struct _getopt_data *__data);
|
||||||
|
|
||||||
extern int _getopt_long_only_r (int ___argc, char **___argv,
|
extern int _getopt_long_only_r (int ___argc, char **___argv,
|
||||||
const char *__shortopts,
|
const char *__shortopts,
|
||||||
const struct option *__longopts,
|
const struct option *__longopts,
|
||||||
int *__longind,
|
int *__longind,
|
||||||
struct _getopt_data *__data);
|
struct _getopt_data *__data);
|
||||||
|
|
||||||
#endif /* getopt_int.h */
|
#endif /* getopt_int.h */
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/* Convenience header for conditional use of GNU <libintl.h>.
|
/* Convenience header for conditional use of GNU <libintl.h>.
|
||||||
Copyright (C) 1995-1998, 2000-2002, 2004-2006 Free Software Foundation, Inc.
|
Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2010 Free Software
|
||||||
|
Foundation, Inc.
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -63,21 +64,30 @@
|
||||||
for invalid uses of the value returned from these functions.
|
for invalid uses of the value returned from these functions.
|
||||||
On pre-ANSI systems without 'const', the config.h file is supposed to
|
On pre-ANSI systems without 'const', the config.h file is supposed to
|
||||||
contain "#define const". */
|
contain "#define const". */
|
||||||
|
# undef gettext
|
||||||
# define gettext(Msgid) ((const char *) (Msgid))
|
# define gettext(Msgid) ((const char *) (Msgid))
|
||||||
|
# undef dgettext
|
||||||
# define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid))
|
# define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid))
|
||||||
|
# undef dcgettext
|
||||||
# define dcgettext(Domainname, Msgid, Category) \
|
# define dcgettext(Domainname, Msgid, Category) \
|
||||||
((void) (Category), dgettext (Domainname, Msgid))
|
((void) (Category), dgettext (Domainname, Msgid))
|
||||||
|
# undef ngettext
|
||||||
# define ngettext(Msgid1, Msgid2, N) \
|
# define ngettext(Msgid1, Msgid2, N) \
|
||||||
((N) == 1 \
|
((N) == 1 \
|
||||||
? ((void) (Msgid2), (const char *) (Msgid1)) \
|
? ((void) (Msgid2), (const char *) (Msgid1)) \
|
||||||
: ((void) (Msgid1), (const char *) (Msgid2)))
|
: ((void) (Msgid1), (const char *) (Msgid2)))
|
||||||
|
# undef dngettext
|
||||||
# define dngettext(Domainname, Msgid1, Msgid2, N) \
|
# define dngettext(Domainname, Msgid1, Msgid2, N) \
|
||||||
((void) (Domainname), ngettext (Msgid1, Msgid2, N))
|
((void) (Domainname), ngettext (Msgid1, Msgid2, N))
|
||||||
|
# undef dcngettext
|
||||||
# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
|
# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
|
||||||
((void) (Category), dngettext(Domainname, Msgid1, Msgid2, N))
|
((void) (Category), dngettext (Domainname, Msgid1, Msgid2, N))
|
||||||
|
# undef textdomain
|
||||||
# define textdomain(Domainname) ((const char *) (Domainname))
|
# define textdomain(Domainname) ((const char *) (Domainname))
|
||||||
|
# undef bindtextdomain
|
||||||
# define bindtextdomain(Domainname, Dirname) \
|
# define bindtextdomain(Domainname, Dirname) \
|
||||||
((void) (Domainname), (const char *) (Dirname))
|
((void) (Domainname), (const char *) (Dirname))
|
||||||
|
# undef bind_textdomain_codeset
|
||||||
# define bind_textdomain_codeset(Domainname, Codeset) \
|
# define bind_textdomain_codeset(Domainname, Codeset) \
|
||||||
((void) (Domainname), (const char *) (Codeset))
|
((void) (Domainname), (const char *) (Codeset))
|
||||||
|
|
||||||
|
@ -131,8 +141,8 @@ inline
|
||||||
#endif
|
#endif
|
||||||
static const char *
|
static const char *
|
||||||
pgettext_aux (const char *domain,
|
pgettext_aux (const char *domain,
|
||||||
const char *msg_ctxt_id, const char *msgid,
|
const char *msg_ctxt_id, const char *msgid,
|
||||||
int category)
|
int category)
|
||||||
{
|
{
|
||||||
const char *translation = dcgettext (domain, msg_ctxt_id, category);
|
const char *translation = dcgettext (domain, msg_ctxt_id, category);
|
||||||
if (translation == msg_ctxt_id)
|
if (translation == msg_ctxt_id)
|
||||||
|
@ -150,9 +160,9 @@ inline
|
||||||
#endif
|
#endif
|
||||||
static const char *
|
static const char *
|
||||||
npgettext_aux (const char *domain,
|
npgettext_aux (const char *domain,
|
||||||
const char *msg_ctxt_id, const char *msgid,
|
const char *msg_ctxt_id, const char *msgid,
|
||||||
const char *msgid_plural, unsigned long int n,
|
const char *msgid_plural, unsigned long int n,
|
||||||
int category)
|
int category)
|
||||||
{
|
{
|
||||||
const char *translation =
|
const char *translation =
|
||||||
dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
|
dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
|
||||||
|
@ -190,8 +200,8 @@ inline
|
||||||
#endif
|
#endif
|
||||||
static const char *
|
static const char *
|
||||||
dcpgettext_expr (const char *domain,
|
dcpgettext_expr (const char *domain,
|
||||||
const char *msgctxt, const char *msgid,
|
const char *msgctxt, const char *msgid,
|
||||||
int category)
|
int category)
|
||||||
{
|
{
|
||||||
size_t msgctxt_len = strlen (msgctxt) + 1;
|
size_t msgctxt_len = strlen (msgctxt) + 1;
|
||||||
size_t msgid_len = strlen (msgid) + 1;
|
size_t msgid_len = strlen (msgid) + 1;
|
||||||
|
@ -213,10 +223,10 @@ dcpgettext_expr (const char *domain,
|
||||||
translation = dcgettext (domain, msg_ctxt_id, category);
|
translation = dcgettext (domain, msg_ctxt_id, category);
|
||||||
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
|
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
|
||||||
if (msg_ctxt_id != buf)
|
if (msg_ctxt_id != buf)
|
||||||
free (msg_ctxt_id);
|
free (msg_ctxt_id);
|
||||||
#endif
|
#endif
|
||||||
if (translation != msg_ctxt_id)
|
if (translation != msg_ctxt_id)
|
||||||
return translation;
|
return translation;
|
||||||
}
|
}
|
||||||
return msgid;
|
return msgid;
|
||||||
}
|
}
|
||||||
|
@ -235,9 +245,9 @@ inline
|
||||||
#endif
|
#endif
|
||||||
static const char *
|
static const char *
|
||||||
dcnpgettext_expr (const char *domain,
|
dcnpgettext_expr (const char *domain,
|
||||||
const char *msgctxt, const char *msgid,
|
const char *msgctxt, const char *msgid,
|
||||||
const char *msgid_plural, unsigned long int n,
|
const char *msgid_plural, unsigned long int n,
|
||||||
int category)
|
int category)
|
||||||
{
|
{
|
||||||
size_t msgctxt_len = strlen (msgctxt) + 1;
|
size_t msgctxt_len = strlen (msgctxt) + 1;
|
||||||
size_t msgid_len = strlen (msgid) + 1;
|
size_t msgid_len = strlen (msgid) + 1;
|
||||||
|
@ -259,10 +269,10 @@ dcnpgettext_expr (const char *domain,
|
||||||
translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
|
translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
|
||||||
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
|
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
|
||||||
if (msg_ctxt_id != buf)
|
if (msg_ctxt_id != buf)
|
||||||
free (msg_ctxt_id);
|
free (msg_ctxt_id);
|
||||||
#endif
|
#endif
|
||||||
if (!(translation == msg_ctxt_id || translation == msgid_plural))
|
if (!(translation == msg_ctxt_id || translation == msgid_plural))
|
||||||
return translation;
|
return translation;
|
||||||
}
|
}
|
||||||
return (n == 1 ? msgid : msgid_plural);
|
return (n == 1 ? msgid : msgid_plural);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* Program name management.
|
/* Program name management.
|
||||||
Copyright (C) 2001-2003, 2005-2009 Free Software Foundation, Inc.
|
Copyright (C) 2001-2003, 2005-2010 Free Software Foundation, Inc.
|
||||||
Written by Bruno Haible <haible@clisp.cons.org>, 2001.
|
Written by Bruno Haible <bruno@clisp.org>, 2001.
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -23,6 +23,8 @@
|
||||||
#include "progname.h"
|
#include "progname.h"
|
||||||
|
|
||||||
#include <errno.h> /* get program_invocation_name declaration */
|
#include <errno.h> /* get program_invocation_name declaration */
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,7 +32,9 @@
|
||||||
To be initialized by main(). */
|
To be initialized by main(). */
|
||||||
const char *program_name = NULL;
|
const char *program_name = NULL;
|
||||||
|
|
||||||
/* Set program_name, based on argv[0]. */
|
/* Set program_name, based on argv[0].
|
||||||
|
argv0 must be a string allocated with indefinite extent, and must not be
|
||||||
|
modified after this call. */
|
||||||
void
|
void
|
||||||
set_program_name (const char *argv0)
|
set_program_name (const char *argv0)
|
||||||
{
|
{
|
||||||
|
@ -42,20 +46,30 @@ set_program_name (const char *argv0)
|
||||||
const char *slash;
|
const char *slash;
|
||||||
const char *base;
|
const char *base;
|
||||||
|
|
||||||
|
/* Sanity check. POSIX requires the invoking process to pass a non-NULL
|
||||||
|
argv[0]. */
|
||||||
|
if (argv0 == NULL)
|
||||||
|
{
|
||||||
|
/* It's a bug in the invoking program. Help diagnosing it. */
|
||||||
|
fputs ("A NULL argv[0] was passed through an exec system call.\n",
|
||||||
|
stderr);
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
|
||||||
slash = strrchr (argv0, '/');
|
slash = strrchr (argv0, '/');
|
||||||
base = (slash != NULL ? slash + 1 : argv0);
|
base = (slash != NULL ? slash + 1 : argv0);
|
||||||
if (base - argv0 >= 7 && strncmp (base - 7, "/.libs/", 7) == 0)
|
if (base - argv0 >= 7 && strncmp (base - 7, "/.libs/", 7) == 0)
|
||||||
{
|
{
|
||||||
argv0 = base;
|
argv0 = base;
|
||||||
if (strncmp (base, "lt-", 3) == 0)
|
if (strncmp (base, "lt-", 3) == 0)
|
||||||
{
|
{
|
||||||
argv0 = base + 3;
|
argv0 = base + 3;
|
||||||
/* On glibc systems, remove the "lt-" prefix from the variable
|
/* On glibc systems, remove the "lt-" prefix from the variable
|
||||||
program_invocation_short_name. */
|
program_invocation_short_name. */
|
||||||
#if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
|
#if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
|
||||||
program_invocation_short_name = (char *) argv0;
|
program_invocation_short_name = (char *) argv0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* But don't strip off a leading <dirname>/ in general, because when the user
|
/* But don't strip off a leading <dirname>/ in general, because when the user
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* Program name management.
|
/* Program name management.
|
||||||
Copyright (C) 2001-2004, 2006 Free Software Foundation, Inc.
|
Copyright (C) 2001-2004, 2006, 2009-2010 Free Software Foundation, Inc.
|
||||||
Written by Bruno Haible <haible@clisp.cons.org>, 2001.
|
Written by Bruno Haible <bruno@clisp.org>, 2001.
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -31,7 +31,9 @@ extern "C" {
|
||||||
/* String containing name the program is called with. */
|
/* String containing name the program is called with. */
|
||||||
extern const char *program_name;
|
extern const char *program_name;
|
||||||
|
|
||||||
/* Set program_name, based on argv[0]. */
|
/* Set program_name, based on argv[0].
|
||||||
|
argv0 must be a string allocated with indefinite extent, and must not be
|
||||||
|
modified after this call. */
|
||||||
extern void set_program_name (const char *argv0);
|
extern void set_program_name (const char *argv0);
|
||||||
|
|
||||||
#if ENABLE_RELOCATABLE
|
#if ENABLE_RELOCATABLE
|
||||||
|
@ -39,8 +41,8 @@ extern void set_program_name (const char *argv0);
|
||||||
/* Set program_name, based on argv[0], and original installation prefix and
|
/* Set program_name, based on argv[0], and original installation prefix and
|
||||||
directory, for relocatability. */
|
directory, for relocatability. */
|
||||||
extern void set_program_name_and_installdir (const char *argv0,
|
extern void set_program_name_and_installdir (const char *argv0,
|
||||||
const char *orig_installprefix,
|
const char *orig_installprefix,
|
||||||
const char *orig_installdir);
|
const char *orig_installdir);
|
||||||
#undef set_program_name
|
#undef set_program_name
|
||||||
#define set_program_name(ARG0) \
|
#define set_program_name(ARG0) \
|
||||||
set_program_name_and_installdir (ARG0, INSTALLPREFIX, INSTALLDIR)
|
set_program_name_and_installdir (ARG0, INSTALLPREFIX, INSTALLDIR)
|
||||||
|
|
|
@ -84,7 +84,7 @@ grub_read_hook_datetime (struct grub_env_var *var,
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
GRUB_MOD_INIT(datetime)
|
GRUB_MOD_INIT(datehook)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ GRUB_MOD_INIT(datetime)
|
||||||
grub_read_hook_datetime, 0);
|
grub_read_hook_datetime, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
GRUB_MOD_FINI(datetime)
|
GRUB_MOD_FINI(datehook)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|
|
@ -102,6 +102,7 @@ union grub_aout_header
|
||||||
#define AOUT_MID_I386 134 /* i386 BSD binary */
|
#define AOUT_MID_I386 134 /* i386 BSD binary */
|
||||||
#define AOUT_MID_SPARC 138 /* sparc */
|
#define AOUT_MID_SPARC 138 /* sparc */
|
||||||
#define AOUT_MID_HP200 200 /* hp200 (68010) BSD binary */
|
#define AOUT_MID_HP200 200 /* hp200 (68010) BSD binary */
|
||||||
|
#define AOUT_MID_SUN 0x103
|
||||||
#define AOUT_MID_HP300 300 /* hp300 (68020+68881) BSD binary */
|
#define AOUT_MID_HP300 300 /* hp300 (68020+68881) BSD binary */
|
||||||
#define AOUT_MID_HPUX 0x20C /* hp200/300 HP-UX binary */
|
#define AOUT_MID_HPUX 0x20C /* hp200/300 HP-UX binary */
|
||||||
#define AOUT_MID_HPUX800 0x20B /* hp800 HP-UX binary */
|
#define AOUT_MID_HPUX800 0x20B /* hp800 HP-UX binary */
|
||||||
|
@ -114,10 +115,14 @@ union grub_aout_header
|
||||||
#define AOUT_GETMID(header) ((header).a_midmag >> 16) & 0x03ff)
|
#define AOUT_GETMID(header) ((header).a_midmag >> 16) & 0x03ff)
|
||||||
#define AOUT_GETFLAG(header) ((header).a_midmag >> 26) & 0x3f)
|
#define AOUT_GETFLAG(header) ((header).a_midmag >> 26) & 0x3f)
|
||||||
|
|
||||||
|
#ifndef GRUB_UTIL
|
||||||
|
|
||||||
int EXPORT_FUNC(grub_aout_get_type) (union grub_aout_header *header);
|
int EXPORT_FUNC(grub_aout_get_type) (union grub_aout_header *header);
|
||||||
|
|
||||||
grub_err_t EXPORT_FUNC(grub_aout_load) (grub_file_t file, int offset,
|
grub_err_t EXPORT_FUNC(grub_aout_load) (grub_file_t file, int offset,
|
||||||
grub_addr_t load_addr, int load_size,
|
grub_addr_t load_addr, int load_size,
|
||||||
grub_addr_t bss_end_addr);
|
grub_addr_t bss_end_addr);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* ! GRUB_AOUT_HEADER */
|
#endif /* ! GRUB_AOUT_HEADER */
|
||||||
|
|
89
include/grub/bsdlabel.h
Normal file
89
include/grub/bsdlabel.h
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
/*
|
||||||
|
* GRUB -- GRand Unified Bootloader
|
||||||
|
* Copyright (C) 1999,2000,2001,2002,2004,2007 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GRUB_BSDLABEL_PARTITION_HEADER
|
||||||
|
#define GRUB_BSDLABEL_PARTITION_HEADER 1
|
||||||
|
|
||||||
|
/* Constants for BSD disk label. */
|
||||||
|
#define GRUB_PC_PARTITION_BSD_LABEL_SECTOR 1
|
||||||
|
#define GRUB_PC_PARTITION_BSD_LABEL_MAGIC 0x82564557
|
||||||
|
|
||||||
|
/* BSD partition types. */
|
||||||
|
#define GRUB_PC_PARTITION_BSD_TYPE_UNUSED 0
|
||||||
|
#define GRUB_PC_PARTITION_BSD_TYPE_SWAP 1
|
||||||
|
#define GRUB_PC_PARTITION_BSD_TYPE_V6 2
|
||||||
|
#define GRUB_PC_PARTITION_BSD_TYPE_V7 3
|
||||||
|
#define GRUB_PC_PARTITION_BSD_TYPE_SYSV 4
|
||||||
|
#define GRUB_PC_PARTITION_BSD_TYPE_V71K 5
|
||||||
|
#define GRUB_PC_PARTITION_BSD_TYPE_V8 6
|
||||||
|
#define GRUB_PC_PARTITION_BSD_TYPE_BSDFFS 7
|
||||||
|
#define GRUB_PC_PARTITION_BSD_TYPE_MSDOS 8
|
||||||
|
#define GRUB_PC_PARTITION_BSD_TYPE_BSDLFS 9
|
||||||
|
#define GRUB_PC_PARTITION_BSD_TYPE_OTHER 10
|
||||||
|
#define GRUB_PC_PARTITION_BSD_TYPE_HPFS 11
|
||||||
|
#define GRUB_PC_PARTITION_BSD_TYPE_ISO9660 12
|
||||||
|
#define GRUB_PC_PARTITION_BSD_TYPE_BOOT 13
|
||||||
|
|
||||||
|
/* FreeBSD-specific types. */
|
||||||
|
#define GRUB_PC_PARTITION_FREEBSD_TYPE_VINUM 14
|
||||||
|
#define GRUB_PC_PARTITION_FREEBSD_TYPE_RAID 15
|
||||||
|
#define GRUB_PC_PARTITION_FREEBSD_TYPE_JFS2 21
|
||||||
|
|
||||||
|
/* NetBSD-specific types. */
|
||||||
|
#define GRUB_PC_PARTITION_NETBSD_TYPE_ADOS 14
|
||||||
|
#define GRUB_PC_PARTITION_NETBSD_TYPE_HFS 15
|
||||||
|
#define GRUB_PC_PARTITION_NETBSD_TYPE_FILECORE 16
|
||||||
|
#define GRUB_PC_PARTITION_NETBSD_TYPE_EXT2FS 17
|
||||||
|
#define GRUB_PC_PARTITION_NETBSD_TYPE_NTFS 18
|
||||||
|
#define GRUB_PC_PARTITION_NETBSD_TYPE_RAID 19
|
||||||
|
#define GRUB_PC_PARTITION_NETBSD_TYPE_CCD 20
|
||||||
|
#define GRUB_PC_PARTITION_NETBSD_TYPE_JFS2 21
|
||||||
|
#define GRUB_PC_PARTITION_NETBSD_TYPE_APPLEUFS 22
|
||||||
|
|
||||||
|
/* OpenBSD-specific types. */
|
||||||
|
#define GRUB_PC_PARTITION_OPENBSD_TYPE_ADOS 14
|
||||||
|
#define GRUB_PC_PARTITION_OPENBSD_TYPE_HFS 15
|
||||||
|
#define GRUB_PC_PARTITION_OPENBSD_TYPE_FILECORE 16
|
||||||
|
#define GRUB_PC_PARTITION_OPENBSD_TYPE_EXT2FS 17
|
||||||
|
#define GRUB_PC_PARTITION_OPENBSD_TYPE_NTFS 18
|
||||||
|
#define GRUB_PC_PARTITION_OPENBSD_TYPE_RAID 19
|
||||||
|
|
||||||
|
/* The BSD partition entry. */
|
||||||
|
struct grub_partition_bsd_entry
|
||||||
|
{
|
||||||
|
grub_uint32_t size;
|
||||||
|
grub_uint32_t offset;
|
||||||
|
grub_uint32_t fragment_size;
|
||||||
|
grub_uint8_t fs_type;
|
||||||
|
grub_uint8_t fs_fragments;
|
||||||
|
grub_uint16_t fs_cylinders;
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
/* The BSD disk label. Only define members useful for GRUB. */
|
||||||
|
struct grub_partition_bsd_disk_label
|
||||||
|
{
|
||||||
|
grub_uint32_t magic;
|
||||||
|
grub_uint8_t padding[128];
|
||||||
|
grub_uint32_t magic2;
|
||||||
|
grub_uint16_t checksum;
|
||||||
|
grub_uint16_t num_partitions;
|
||||||
|
grub_uint32_t boot_size;
|
||||||
|
grub_uint32_t superblock_size;
|
||||||
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
#endif /* ! GRUB_PC_PARTITION_HEADER */
|
|
@ -33,10 +33,17 @@ struct grub_datetime
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Return date and time. */
|
/* Return date and time. */
|
||||||
|
#ifdef GRUB_MACHINE_EMU
|
||||||
|
grub_err_t EXPORT_FUNC(grub_get_datetime) (struct grub_datetime *datetime);
|
||||||
|
|
||||||
|
/* Set date and time. */
|
||||||
|
grub_err_t EXPORT_FUNC(grub_set_datetime) (struct grub_datetime *datetime);
|
||||||
|
#else
|
||||||
grub_err_t grub_get_datetime (struct grub_datetime *datetime);
|
grub_err_t grub_get_datetime (struct grub_datetime *datetime);
|
||||||
|
|
||||||
/* Set date and time. */
|
/* Set date and time. */
|
||||||
grub_err_t grub_set_datetime (struct grub_datetime *datetime);
|
grub_err_t grub_set_datetime (struct grub_datetime *datetime);
|
||||||
|
#endif
|
||||||
|
|
||||||
int grub_get_weekday (struct grub_datetime *datetime);
|
int grub_get_weekday (struct grub_datetime *datetime);
|
||||||
char *grub_get_weekday_name (struct grub_datetime *datetime);
|
char *grub_get_weekday_name (struct grub_datetime *datetime);
|
||||||
|
|
|
@ -91,7 +91,12 @@ grub_dl_t grub_dl_load_core (void *addr, grub_size_t size);
|
||||||
int EXPORT_FUNC(grub_dl_unload) (grub_dl_t mod);
|
int EXPORT_FUNC(grub_dl_unload) (grub_dl_t mod);
|
||||||
void grub_dl_unload_unneeded (void);
|
void grub_dl_unload_unneeded (void);
|
||||||
void grub_dl_unload_all (void);
|
void grub_dl_unload_all (void);
|
||||||
#ifdef GRUB_UTIL
|
#if defined (GRUB_MACHINE_EMU) || defined (GRUB_UTIL)
|
||||||
|
#define GRUB_NO_MODULES 1
|
||||||
|
#else
|
||||||
|
#define GRUB_NO_MODULES 0
|
||||||
|
#endif
|
||||||
|
#if GRUB_NO_MODULES
|
||||||
static inline int
|
static inline int
|
||||||
grub_dl_ref (grub_dl_t mod)
|
grub_dl_ref (grub_dl_t mod)
|
||||||
{
|
{
|
||||||
|
@ -116,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_check_header (void *ehdr);
|
||||||
grub_err_t grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr);
|
grub_err_t grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr);
|
||||||
|
|
||||||
#if defined (_mips) && ! defined (GRUB_UTIL)
|
#if defined (_mips) && ! defined (GRUB_UTIL) && !defined (GRUB_MACHINE_EMU)
|
||||||
#define GRUB_LINKER_HAVE_INIT 1
|
#define GRUB_LINKER_HAVE_INIT 1
|
||||||
void grub_arch_dl_init_linker (void);
|
void grub_arch_dl_init_linker (void);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
extern const char *(*EXPORT_VAR(grub_gettext)) (const char *s);
|
extern const char *(*EXPORT_VAR(grub_gettext)) (const char *s);
|
||||||
|
|
||||||
/* NLS can be disabled through the configure --disable-nls option. */
|
/* NLS can be disabled through the configure --disable-nls option. */
|
||||||
#if ENABLE_NLS
|
#if (defined(ENABLE_NLS) && ENABLE_NLS)
|
||||||
|
|
||||||
# ifdef GRUB_UTIL
|
# ifdef GRUB_UTIL
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ extern const char *(*EXPORT_VAR(grub_gettext)) (const char *s);
|
||||||
|
|
||||||
# endif /* GRUB_UTIL */
|
# endif /* GRUB_UTIL */
|
||||||
|
|
||||||
#else /* ! ENABLE_NLS */
|
#else /* ! (defined(ENABLE_NLS) && ENABLE_NLS) */
|
||||||
|
|
||||||
/* Disabled NLS.
|
/* Disabled NLS.
|
||||||
The casts to 'const char *' serve the purpose of producing warnings
|
The casts to 'const char *' serve the purpose of producing warnings
|
||||||
|
@ -47,7 +47,7 @@ extern const char *(*EXPORT_VAR(grub_gettext)) (const char *s);
|
||||||
# define grub_gettext(str) ((const char *) (str))
|
# define grub_gettext(str) ((const char *) (str))
|
||||||
# endif /* GRUB_UTIL */
|
# endif /* GRUB_UTIL */
|
||||||
|
|
||||||
#endif /* ENABLE_NLS */
|
#endif /* (defined(ENABLE_NLS) && ENABLE_NLS) */
|
||||||
|
|
||||||
#ifdef GRUB_UTIL
|
#ifdef GRUB_UTIL
|
||||||
# define _(str) gettext(str)
|
# define _(str) gettext(str)
|
||||||
|
|
1
include/grub/i386/efi/serial.h
Normal file
1
include/grub/i386/efi/serial.h
Normal file
|
@ -0,0 +1 @@
|
||||||
|
#include <grub/i386/coreboot/serial.h>
|
|
@ -19,17 +19,23 @@
|
||||||
#ifndef GRUB_MULTIBOOT_CPU_HEADER
|
#ifndef GRUB_MULTIBOOT_CPU_HEADER
|
||||||
#define GRUB_MULTIBOOT_CPU_HEADER 1
|
#define GRUB_MULTIBOOT_CPU_HEADER 1
|
||||||
|
|
||||||
/* The asm part of the multiboot loader. */
|
|
||||||
void grub_multiboot_real_boot (grub_addr_t entry,
|
|
||||||
struct multiboot_info *mbi)
|
|
||||||
__attribute__ ((noreturn));
|
|
||||||
void grub_multiboot2_real_boot (grub_addr_t entry,
|
|
||||||
struct multiboot_info *mbi)
|
|
||||||
__attribute__ ((noreturn));
|
|
||||||
|
|
||||||
extern grub_uint32_t grub_multiboot_payload_eip;
|
extern grub_uint32_t grub_multiboot_payload_eip;
|
||||||
extern char *grub_multiboot_payload_orig;
|
extern char *grub_multiboot_payload_orig;
|
||||||
extern grub_addr_t grub_multiboot_payload_dest;
|
extern grub_addr_t grub_multiboot_payload_dest;
|
||||||
extern grub_size_t grub_multiboot_payload_size;
|
extern grub_size_t grub_multiboot_payload_size;
|
||||||
|
|
||||||
|
#define MULTIBOOT_INITIAL_STATE { .eax = MULTIBOOT_BOOTLOADER_MAGIC, \
|
||||||
|
.ecx = 0, \
|
||||||
|
.edx = 0, \
|
||||||
|
/* Set esp to some random location in low memory to avoid breaking */ \
|
||||||
|
/* non-compliant kernels. */ \
|
||||||
|
.esp = 0x7ff00 \
|
||||||
|
}
|
||||||
|
#define MULTIBOOT_ENTRY_REGISTER eip
|
||||||
|
#define MULTIBOOT_MBI_REGISTER ebx
|
||||||
|
#define MULTIBOOT_ARCHITECTURE_CURRENT MULTIBOOT_ARCHITECTURE_I386
|
||||||
|
|
||||||
|
#define MULTIBOOT_ELF32_MACHINE EM_386
|
||||||
|
#define MULTIBOOT_ELF64_MACHINE EM_X86_64
|
||||||
|
|
||||||
#endif /* ! GRUB_MULTIBOOT_CPU_HEADER */
|
#endif /* ! GRUB_MULTIBOOT_CPU_HEADER */
|
||||||
|
|
|
@ -33,7 +33,7 @@ grub_uint32_t grub_get_eisa_mmap (void);
|
||||||
|
|
||||||
/* Get a memory map entry. Return next continuation value. Zero means
|
/* Get a memory map entry. Return next continuation value. Zero means
|
||||||
the end. */
|
the end. */
|
||||||
grub_uint32_t EXPORT_FUNC(grub_get_mmap_entry) (struct grub_machine_mmap_entry *entry,
|
grub_uint32_t grub_get_mmap_entry (struct grub_machine_mmap_entry *entry,
|
||||||
grub_uint32_t cont);
|
grub_uint32_t cont);
|
||||||
|
|
||||||
/* Turn on/off Gate A20. */
|
/* Turn on/off Gate A20. */
|
||||||
|
|
|
@ -28,7 +28,4 @@
|
||||||
/* Set the video mode to MODE and return the previous mode. */
|
/* Set the video mode to MODE and return the previous mode. */
|
||||||
unsigned char EXPORT_FUNC(grub_vga_set_mode) (unsigned char mode);
|
unsigned char EXPORT_FUNC(grub_vga_set_mode) (unsigned char mode);
|
||||||
|
|
||||||
/* Return a pointer to the ROM font table. */
|
|
||||||
unsigned char *EXPORT_FUNC(grub_vga_get_font) (void);
|
|
||||||
|
|
||||||
#endif /* ! GRUB_VGA_MACHINE_HEADER */
|
#endif /* ! GRUB_VGA_MACHINE_HEADER */
|
||||||
|
|
|
@ -180,4 +180,8 @@ EXPORT_FUNC(grub_ieee1275_map) (grub_addr_t phys, grub_addr_t virt,
|
||||||
char *EXPORT_FUNC(grub_ieee1275_encode_devname) (const char *path);
|
char *EXPORT_FUNC(grub_ieee1275_encode_devname) (const char *path);
|
||||||
char *EXPORT_FUNC(grub_ieee1275_get_filename) (const char *path);
|
char *EXPORT_FUNC(grub_ieee1275_get_filename) (const char *path);
|
||||||
|
|
||||||
|
int EXPORT_FUNC(grub_ieee1275_devices_iterate) (int (*hook)
|
||||||
|
(struct grub_ieee1275_devalias *
|
||||||
|
alias));
|
||||||
|
|
||||||
#endif /* ! GRUB_IEEE1275_HEADER */
|
#endif /* ! GRUB_IEEE1275_HEADER */
|
||||||
|
|
|
@ -59,6 +59,8 @@ extern grub_addr_t grub_arch_modules_addr (void);
|
||||||
|
|
||||||
extern void EXPORT_FUNC(grub_module_iterate) (int (*hook) (struct grub_module_header *));
|
extern void EXPORT_FUNC(grub_module_iterate) (int (*hook) (struct grub_module_header *));
|
||||||
|
|
||||||
|
grub_addr_t grub_modules_get_end (void);
|
||||||
|
|
||||||
/* The start point of the C code. */
|
/* The start point of the C code. */
|
||||||
void grub_main (void);
|
void grub_main (void);
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ grub_bad_type_cast_real (int line, const char *file)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define grub_bad_type_cast() grub_bad_type_cast_real(__LINE__, __FILE__)
|
#define grub_bad_type_cast() grub_bad_type_cast_real(__LINE__, GRUB_FILE)
|
||||||
|
|
||||||
#define GRUB_FIELD_MATCH(ptr, type, field) \
|
#define GRUB_FIELD_MATCH(ptr, type, field) \
|
||||||
((char *) &(ptr)->field == (char *) &((type) (ptr))->field)
|
((char *) &(ptr)->field == (char *) &((type) (ptr))->field)
|
||||||
|
|
36
include/grub/mips/multiboot.h
Normal file
36
include/grub/mips/multiboot.h
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* GRUB -- GRand Unified Bootloader
|
||||||
|
* Copyright (C) 2002,2003,2004,2007,2008,2009 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GRUB_MULTIBOOT_CPU_HEADER
|
||||||
|
#define GRUB_MULTIBOOT_CPU_HEADER 1
|
||||||
|
|
||||||
|
extern grub_uint32_t grub_multiboot_payload_eip;
|
||||||
|
extern char *grub_multiboot_payload_orig;
|
||||||
|
extern grub_addr_t grub_multiboot_payload_dest;
|
||||||
|
extern grub_size_t grub_multiboot_payload_size;
|
||||||
|
|
||||||
|
#define MULTIBOOT_INITIAL_STATE { .gpr[4] = MULTIBOOT_BOOTLOADER_MAGIC, \
|
||||||
|
.jumpreg = 1 }
|
||||||
|
#define MULTIBOOT_ENTRY_REGISTER gpr[1]
|
||||||
|
#define MULTIBOOT_MBI_REGISTER gpr[5]
|
||||||
|
#define MULTIBOOT_ARCHITECTURE_CURRENT MULTIBOOT_ARCHITECTURE_MIPS32
|
||||||
|
|
||||||
|
#define MULTIBOOT_ELF32_MACHINE EM_MIPS
|
||||||
|
#define MULTIBOOT_ELF64_MACHINE EM_MIPS
|
||||||
|
|
||||||
|
#endif /* ! GRUB_MULTIBOOT_CPU_HEADER */
|
|
@ -46,7 +46,7 @@
|
||||||
#define ARRAY_SIZE(array) (sizeof (array) / sizeof (array[0]))
|
#define ARRAY_SIZE(array) (sizeof (array) / sizeof (array[0]))
|
||||||
#define COMPILE_TIME_ASSERT(cond) switch (0) { case 1: case !(cond): ; }
|
#define COMPILE_TIME_ASSERT(cond) switch (0) { case 1: case !(cond): ; }
|
||||||
|
|
||||||
#define grub_dprintf(condition, fmt, args...) grub_real_dprintf(__FILE__, __LINE__, condition, fmt, ## args)
|
#define grub_dprintf(condition, fmt, args...) grub_real_dprintf(GRUB_FILE, __LINE__, condition, fmt, ## args)
|
||||||
/* XXX: If grub_memmove is too slow, we must implement grub_memcpy. */
|
/* XXX: If grub_memmove is too slow, we must implement grub_memcpy. */
|
||||||
#define grub_memcpy(d,s,n) grub_memmove ((d), (s), (n))
|
#define grub_memcpy(d,s,n) grub_memmove ((d), (s), (n))
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ grub_size_t EXPORT_FUNC(grub_utf8_to_ucs4) (grub_uint32_t *dest,
|
||||||
grub_uint64_t EXPORT_FUNC(grub_divmod64) (grub_uint64_t n,
|
grub_uint64_t EXPORT_FUNC(grub_divmod64) (grub_uint64_t n,
|
||||||
grub_uint32_t d, grub_uint32_t *r);
|
grub_uint32_t d, grub_uint32_t *r);
|
||||||
|
|
||||||
#ifdef NEED_ENABLE_EXECUTE_STACK
|
#if defined(NEED_ENABLE_EXECUTE_STACK) && !defined(GRUB_UTIL)
|
||||||
void EXPORT_FUNC(__enable_execute_stack) (void *addr);
|
void EXPORT_FUNC(__enable_execute_stack) (void *addr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ void *EXPORT_FUNC(grub_realloc) (void *ptr, grub_size_t size);
|
||||||
void *EXPORT_FUNC(grub_memalign) (grub_size_t align, grub_size_t size);
|
void *EXPORT_FUNC(grub_memalign) (grub_size_t align, grub_size_t size);
|
||||||
|
|
||||||
/* For debugging. */
|
/* For debugging. */
|
||||||
#if defined(MM_DEBUG) && !defined(GRUB_UTIL)
|
#if defined(MM_DEBUG) && !defined(GRUB_UTIL) && !defined (GRUB_MACHINE_EMU)
|
||||||
/* Set this variable to 1 when you want to trace all memory function calls. */
|
/* Set this variable to 1 when you want to trace all memory function calls. */
|
||||||
extern int EXPORT_VAR(grub_mm_debug);
|
extern int EXPORT_VAR(grub_mm_debug);
|
||||||
|
|
||||||
|
@ -44,19 +44,19 @@ void grub_mm_dump_free (void);
|
||||||
void grub_mm_dump (unsigned lineno);
|
void grub_mm_dump (unsigned lineno);
|
||||||
|
|
||||||
#define grub_malloc(size) \
|
#define grub_malloc(size) \
|
||||||
grub_debug_malloc (__FILE__, __LINE__, size)
|
grub_debug_malloc (GRUB_FILE, __LINE__, size)
|
||||||
|
|
||||||
#define grub_zalloc(size) \
|
#define grub_zalloc(size) \
|
||||||
grub_debug_zalloc (__FILE__, __LINE__, size)
|
grub_debug_zalloc (GRUB_FILE, __LINE__, size)
|
||||||
|
|
||||||
#define grub_realloc(ptr,size) \
|
#define grub_realloc(ptr,size) \
|
||||||
grub_debug_realloc (__FILE__, __LINE__, ptr, size)
|
grub_debug_realloc (GRUB_FILE, __LINE__, ptr, size)
|
||||||
|
|
||||||
#define grub_memalign(align,size) \
|
#define grub_memalign(align,size) \
|
||||||
grub_debug_memalign (__FILE__, __LINE__, align, size)
|
grub_debug_memalign (GRUB_FILE, __LINE__, align, size)
|
||||||
|
|
||||||
#define grub_free(ptr) \
|
#define grub_free(ptr) \
|
||||||
grub_debug_free (__FILE__, __LINE__, ptr)
|
grub_debug_free (GRUB_FILE, __LINE__, ptr)
|
||||||
|
|
||||||
void *EXPORT_FUNC(grub_debug_malloc) (const char *file, int line,
|
void *EXPORT_FUNC(grub_debug_malloc) (const char *file, int line,
|
||||||
grub_size_t size);
|
grub_size_t size);
|
||||||
|
|
|
@ -53,75 +53,6 @@
|
||||||
#define GRUB_PC_PARTITION_TYPE_GPT_DISK 0xee
|
#define GRUB_PC_PARTITION_TYPE_GPT_DISK 0xee
|
||||||
#define GRUB_PC_PARTITION_TYPE_LINUX_RAID 0xfd
|
#define GRUB_PC_PARTITION_TYPE_LINUX_RAID 0xfd
|
||||||
|
|
||||||
/* Constants for BSD disk label. */
|
|
||||||
#define GRUB_PC_PARTITION_BSD_LABEL_SECTOR 1
|
|
||||||
#define GRUB_PC_PARTITION_BSD_LABEL_MAGIC 0x82564557
|
|
||||||
#define GRUB_PC_PARTITION_BSD_MAX_ENTRIES 8
|
|
||||||
|
|
||||||
/* BSD partition types. */
|
|
||||||
#define GRUB_PC_PARTITION_BSD_TYPE_UNUSED 0
|
|
||||||
#define GRUB_PC_PARTITION_BSD_TYPE_SWAP 1
|
|
||||||
#define GRUB_PC_PARTITION_BSD_TYPE_V6 2
|
|
||||||
#define GRUB_PC_PARTITION_BSD_TYPE_V7 3
|
|
||||||
#define GRUB_PC_PARTITION_BSD_TYPE_SYSV 4
|
|
||||||
#define GRUB_PC_PARTITION_BSD_TYPE_V71K 5
|
|
||||||
#define GRUB_PC_PARTITION_BSD_TYPE_V8 6
|
|
||||||
#define GRUB_PC_PARTITION_BSD_TYPE_BSDFFS 7
|
|
||||||
#define GRUB_PC_PARTITION_BSD_TYPE_MSDOS 8
|
|
||||||
#define GRUB_PC_PARTITION_BSD_TYPE_BSDLFS 9
|
|
||||||
#define GRUB_PC_PARTITION_BSD_TYPE_OTHER 10
|
|
||||||
#define GRUB_PC_PARTITION_BSD_TYPE_HPFS 11
|
|
||||||
#define GRUB_PC_PARTITION_BSD_TYPE_ISO9660 12
|
|
||||||
#define GRUB_PC_PARTITION_BSD_TYPE_BOOT 13
|
|
||||||
|
|
||||||
/* FreeBSD-specific types. */
|
|
||||||
#define GRUB_PC_PARTITION_FREEBSD_TYPE_VINUM 14
|
|
||||||
#define GRUB_PC_PARTITION_FREEBSD_TYPE_RAID 15
|
|
||||||
#define GRUB_PC_PARTITION_FREEBSD_TYPE_JFS2 21
|
|
||||||
|
|
||||||
/* NetBSD-specific types. */
|
|
||||||
#define GRUB_PC_PARTITION_NETBSD_TYPE_ADOS 14
|
|
||||||
#define GRUB_PC_PARTITION_NETBSD_TYPE_HFS 15
|
|
||||||
#define GRUB_PC_PARTITION_NETBSD_TYPE_FILECORE 16
|
|
||||||
#define GRUB_PC_PARTITION_NETBSD_TYPE_EXT2FS 17
|
|
||||||
#define GRUB_PC_PARTITION_NETBSD_TYPE_NTFS 18
|
|
||||||
#define GRUB_PC_PARTITION_NETBSD_TYPE_RAID 19
|
|
||||||
#define GRUB_PC_PARTITION_NETBSD_TYPE_CCD 20
|
|
||||||
#define GRUB_PC_PARTITION_NETBSD_TYPE_JFS2 21
|
|
||||||
#define GRUB_PC_PARTITION_NETBSD_TYPE_APPLEUFS 22
|
|
||||||
|
|
||||||
/* OpenBSD-specific types. */
|
|
||||||
#define GRUB_PC_PARTITION_OPENBSD_TYPE_ADOS 14
|
|
||||||
#define GRUB_PC_PARTITION_OPENBSD_TYPE_HFS 15
|
|
||||||
#define GRUB_PC_PARTITION_OPENBSD_TYPE_FILECORE 16
|
|
||||||
#define GRUB_PC_PARTITION_OPENBSD_TYPE_EXT2FS 17
|
|
||||||
#define GRUB_PC_PARTITION_OPENBSD_TYPE_NTFS 18
|
|
||||||
#define GRUB_PC_PARTITION_OPENBSD_TYPE_RAID 19
|
|
||||||
|
|
||||||
/* The BSD partition entry. */
|
|
||||||
struct grub_msdos_partition_bsd_entry
|
|
||||||
{
|
|
||||||
grub_uint32_t size;
|
|
||||||
grub_uint32_t offset;
|
|
||||||
grub_uint32_t fragment_size;
|
|
||||||
grub_uint8_t fs_type;
|
|
||||||
grub_uint8_t fs_fragments;
|
|
||||||
grub_uint16_t fs_cylinders;
|
|
||||||
} __attribute__ ((packed));
|
|
||||||
|
|
||||||
/* The BSD disk label. Only define members useful for GRUB. */
|
|
||||||
struct grub_msdos_partition_disk_label
|
|
||||||
{
|
|
||||||
grub_uint32_t magic;
|
|
||||||
grub_uint8_t padding[128];
|
|
||||||
grub_uint32_t magic2;
|
|
||||||
grub_uint16_t checksum;
|
|
||||||
grub_uint16_t num_partitions;
|
|
||||||
grub_uint32_t boot_size;
|
|
||||||
grub_uint32_t superblock_size;
|
|
||||||
struct grub_msdos_partition_bsd_entry entries[GRUB_PC_PARTITION_BSD_MAX_ENTRIES];
|
|
||||||
} __attribute__ ((packed));
|
|
||||||
|
|
||||||
/* The partition entry. */
|
/* The partition entry. */
|
||||||
struct grub_msdos_partition_entry
|
struct grub_msdos_partition_entry
|
||||||
{
|
{
|
||||||
|
@ -168,23 +99,6 @@ struct grub_msdos_partition_mbr
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
|
||||||
struct grub_msdos_partition
|
|
||||||
{
|
|
||||||
/* The DOS partition number. */
|
|
||||||
int dos_part;
|
|
||||||
|
|
||||||
/* The BSD partition number (a == 0). */
|
|
||||||
int bsd_part;
|
|
||||||
|
|
||||||
/* The DOS partition type. */
|
|
||||||
int dos_type;
|
|
||||||
|
|
||||||
/* The BSD partition type. */
|
|
||||||
int bsd_type;
|
|
||||||
|
|
||||||
/* The offset of the extended partition. */
|
|
||||||
unsigned long ext_offset;
|
|
||||||
};
|
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
grub_msdos_partition_is_empty (int type)
|
grub_msdos_partition_is_empty (int type)
|
||||||
|
@ -200,12 +114,4 @@ grub_msdos_partition_is_extended (int type)
|
||||||
|| type == GRUB_PC_PARTITION_TYPE_LINUX_EXTENDED);
|
|| type == GRUB_PC_PARTITION_TYPE_LINUX_EXTENDED);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int
|
|
||||||
grub_msdos_partition_is_bsd (int type)
|
|
||||||
{
|
|
||||||
return (type == GRUB_PC_PARTITION_TYPE_FREEBSD
|
|
||||||
|| type == GRUB_PC_PARTITION_TYPE_OPENBSD
|
|
||||||
|| type == GRUB_PC_PARTITION_TYPE_NETBSD);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* ! GRUB_PC_PARTITION_HEADER */
|
#endif /* ! GRUB_PC_PARTITION_HEADER */
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
#ifndef GRUB_MULTIBOOT_HEADER
|
#ifndef GRUB_MULTIBOOT_HEADER
|
||||||
#define GRUB_MULTIBOOT_HEADER 1
|
#define GRUB_MULTIBOOT_HEADER 1
|
||||||
|
|
||||||
|
#include <grub/file.h>
|
||||||
|
|
||||||
#ifdef GRUB_USE_MULTIBOOT2
|
#ifdef GRUB_USE_MULTIBOOT2
|
||||||
#include <multiboot2.h>
|
#include <multiboot2.h>
|
||||||
/* Same thing as far as our loader is concerned. */
|
/* Same thing as far as our loader is concerned. */
|
||||||
|
@ -35,8 +37,6 @@
|
||||||
void grub_multiboot (int argc, char *argv[]);
|
void grub_multiboot (int argc, char *argv[]);
|
||||||
void grub_module (int argc, char *argv[]);
|
void grub_module (int argc, char *argv[]);
|
||||||
|
|
||||||
void grub_multiboot_set_accepts_video (int val);
|
|
||||||
|
|
||||||
grub_size_t grub_multiboot_get_mbi_size (void);
|
grub_size_t grub_multiboot_get_mbi_size (void);
|
||||||
grub_err_t grub_multiboot_make_mbi (void *orig, grub_uint32_t dest,
|
grub_err_t grub_multiboot_make_mbi (void *orig, grub_uint32_t dest,
|
||||||
grub_off_t buf_off, grub_size_t bufsize);
|
grub_off_t buf_off, grub_size_t bufsize);
|
||||||
|
@ -46,5 +46,29 @@ grub_err_t grub_multiboot_add_module (grub_addr_t start, grub_size_t size,
|
||||||
int argc, char *argv[]);
|
int argc, char *argv[]);
|
||||||
void grub_multiboot_set_bootdev (void);
|
void grub_multiboot_set_bootdev (void);
|
||||||
|
|
||||||
|
grub_uint32_t grub_get_multiboot_mmap_count (void);
|
||||||
|
grub_err_t grub_multiboot_set_video_mode (void);
|
||||||
|
|
||||||
|
#if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_QEMU)
|
||||||
|
#include <grub/i386/pc/vbe.h>
|
||||||
|
#define GRUB_MACHINE_HAS_VGA_TEXT 1
|
||||||
|
#else
|
||||||
|
#define GRUB_MACHINE_HAS_VGA_TEXT 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define GRUB_MULTIBOOT_CONSOLE_EGA_TEXT 1
|
||||||
|
#define GRUB_MULTIBOOT_CONSOLE_FRAMEBUFFER 2
|
||||||
|
|
||||||
|
grub_err_t
|
||||||
|
grub_multiboot_set_console (int console_type, int accepted_consoles,
|
||||||
|
int width, int height, int depth,
|
||||||
|
int console_required);
|
||||||
|
grub_err_t
|
||||||
|
grub_multiboot_load (grub_file_t file);
|
||||||
|
/* Load ELF32 or ELF64. */
|
||||||
|
grub_err_t
|
||||||
|
grub_multiboot_load_elf (grub_file_t file, void *buffer);
|
||||||
|
extern grub_size_t grub_multiboot_pure_size;
|
||||||
|
extern grub_size_t grub_multiboot_alloc_mbi;
|
||||||
|
|
||||||
#endif /* ! GRUB_MULTIBOOT_HEADER */
|
#endif /* ! GRUB_MULTIBOOT_HEADER */
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#define GRUB_PART_HEADER 1
|
#define GRUB_PART_HEADER 1
|
||||||
|
|
||||||
#include <grub/dl.h>
|
#include <grub/dl.h>
|
||||||
|
#include <grub/list.h>
|
||||||
|
|
||||||
struct grub_disk;
|
struct grub_disk;
|
||||||
|
|
||||||
|
@ -28,6 +29,9 @@ typedef struct grub_partition *grub_partition_t;
|
||||||
/* Partition map type. */
|
/* Partition map type. */
|
||||||
struct grub_partition_map
|
struct grub_partition_map
|
||||||
{
|
{
|
||||||
|
/* The next partition map type. */
|
||||||
|
struct grub_partition_map *next;
|
||||||
|
|
||||||
/* The name of the partition map type. */
|
/* The name of the partition map type. */
|
||||||
const char *name;
|
const char *name;
|
||||||
|
|
||||||
|
@ -35,22 +39,15 @@ struct grub_partition_map
|
||||||
grub_err_t (*iterate) (struct grub_disk *disk,
|
grub_err_t (*iterate) (struct grub_disk *disk,
|
||||||
int (*hook) (struct grub_disk *disk,
|
int (*hook) (struct grub_disk *disk,
|
||||||
const grub_partition_t partition));
|
const grub_partition_t partition));
|
||||||
|
|
||||||
/* Return the partition named STR on the disk DISK. */
|
|
||||||
grub_partition_t (*probe) (struct grub_disk *disk,
|
|
||||||
const char *str);
|
|
||||||
|
|
||||||
/* Return the name of the partition PARTITION. */
|
|
||||||
char *(*get_name) (const grub_partition_t partition);
|
|
||||||
|
|
||||||
/* The next partition map type. */
|
|
||||||
struct grub_partition_map *next;
|
|
||||||
};
|
};
|
||||||
typedef struct grub_partition_map *grub_partition_map_t;
|
typedef struct grub_partition_map *grub_partition_map_t;
|
||||||
|
|
||||||
/* Partition description. */
|
/* Partition description. */
|
||||||
struct grub_partition
|
struct grub_partition
|
||||||
{
|
{
|
||||||
|
/* The partition number. */
|
||||||
|
int number;
|
||||||
|
|
||||||
/* The start sector. */
|
/* The start sector. */
|
||||||
grub_disk_addr_t start;
|
grub_disk_addr_t start;
|
||||||
|
|
||||||
|
@ -63,8 +60,8 @@ struct grub_partition
|
||||||
/* The index of this partition in the partition table. */
|
/* The index of this partition in the partition table. */
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
/* Partition map type specific data. */
|
/* Parent partition map. */
|
||||||
void *data;
|
struct grub_partition *parent;
|
||||||
|
|
||||||
/* The type partition map. */
|
/* The type partition map. */
|
||||||
grub_partition_map_t partmap;
|
grub_partition_map_t partmap;
|
||||||
|
@ -77,17 +74,36 @@ int EXPORT_FUNC(grub_partition_iterate) (struct grub_disk *disk,
|
||||||
const grub_partition_t partition));
|
const grub_partition_t partition));
|
||||||
char *EXPORT_FUNC(grub_partition_get_name) (const grub_partition_t partition);
|
char *EXPORT_FUNC(grub_partition_get_name) (const grub_partition_t partition);
|
||||||
|
|
||||||
int EXPORT_FUNC(grub_partition_map_iterate) (int (*hook) (const grub_partition_map_t partmap));
|
|
||||||
|
|
||||||
void EXPORT_FUNC(grub_partition_map_register) (grub_partition_map_t partmap);
|
extern grub_partition_map_t EXPORT_VAR(grub_partition_map_list);
|
||||||
|
|
||||||
void EXPORT_FUNC(grub_partition_map_unregister) (grub_partition_map_t partmap);
|
static inline void
|
||||||
|
grub_partition_map_register (grub_partition_map_t partmap)
|
||||||
|
{
|
||||||
|
grub_list_push (GRUB_AS_LIST_P (&grub_partition_map_list),
|
||||||
|
GRUB_AS_LIST (partmap));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
grub_partition_map_unregister (grub_partition_map_t partmap)
|
||||||
|
{
|
||||||
|
grub_list_remove (GRUB_AS_LIST_P (&grub_partition_map_list),
|
||||||
|
GRUB_AS_LIST (partmap));
|
||||||
|
}
|
||||||
|
|
||||||
|
#define FOR_PARTITION_MAPS(var) for (var = grub_partition_map_list; var; var = var->next)
|
||||||
|
|
||||||
|
|
||||||
static inline grub_disk_addr_t
|
static inline grub_disk_addr_t
|
||||||
grub_partition_get_start (const grub_partition_t p)
|
grub_partition_get_start (const grub_partition_t p)
|
||||||
{
|
{
|
||||||
return p->start;
|
grub_partition_t part;
|
||||||
|
grub_uint64_t part_start = 0;
|
||||||
|
|
||||||
|
for (part = p; part; part = part->parent)
|
||||||
|
part_start += part->start;
|
||||||
|
|
||||||
|
return part_start;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline grub_uint64_t
|
static inline grub_uint64_t
|
||||||
|
|
|
@ -71,7 +71,7 @@
|
||||||
#ifndef ASM_FILE
|
#ifndef ASM_FILE
|
||||||
typedef grub_uint32_t grub_pci_id_t;
|
typedef grub_uint32_t grub_pci_id_t;
|
||||||
|
|
||||||
#ifdef GRUB_UTIL
|
#ifdef GRUB_MACHINE_EMU
|
||||||
#include <grub/pciutils.h>
|
#include <grub/pciutils.h>
|
||||||
#else
|
#else
|
||||||
typedef grub_uint32_t grub_pci_address_t;
|
typedef grub_uint32_t grub_pci_address_t;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* normal_parser.h */
|
/* normal_parser.h */
|
||||||
/*
|
/*
|
||||||
* GRUB -- GRand Unified Bootloader
|
* GRUB -- GRand Unified Bootloader
|
||||||
* Copyright (C) 2005,2007,2009 Free Software Foundation, Inc.
|
* Copyright (C) 2005,2007,2009,2010 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* GRUB is free software: you can redistribute it and/or modify
|
* GRUB is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -45,8 +45,11 @@ struct grub_script
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
GRUB_SCRIPT_ARG_TYPE_STR,
|
GRUB_SCRIPT_ARG_TYPE_VAR,
|
||||||
GRUB_SCRIPT_ARG_TYPE_VAR
|
GRUB_SCRIPT_ARG_TYPE_TEXT,
|
||||||
|
GRUB_SCRIPT_ARG_TYPE_DQVAR,
|
||||||
|
GRUB_SCRIPT_ARG_TYPE_DQSTR,
|
||||||
|
GRUB_SCRIPT_ARG_TYPE_SQSTR
|
||||||
} grub_script_arg_type_t;
|
} grub_script_arg_type_t;
|
||||||
|
|
||||||
/* A part of an argument. */
|
/* A part of an argument. */
|
||||||
|
@ -103,6 +106,21 @@ struct grub_script_cmdif
|
||||||
struct grub_script_cmd *exec_on_false;
|
struct grub_script_cmd *exec_on_false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* A for statement. */
|
||||||
|
struct grub_script_cmdfor
|
||||||
|
{
|
||||||
|
struct grub_script_cmd cmd;
|
||||||
|
|
||||||
|
/* The name used as looping variable. */
|
||||||
|
struct grub_script_arg *name;
|
||||||
|
|
||||||
|
/* The words loop iterates over. */
|
||||||
|
struct grub_script_arglist *words;
|
||||||
|
|
||||||
|
/* The command list executed in each loop. */
|
||||||
|
struct grub_script_cmd *list;
|
||||||
|
};
|
||||||
|
|
||||||
/* A menu entry generate statement. */
|
/* A menu entry generate statement. */
|
||||||
struct grub_script_cmd_menuentry
|
struct grub_script_cmd_menuentry
|
||||||
{
|
{
|
||||||
|
@ -121,12 +139,6 @@ struct grub_script_cmd_menuentry
|
||||||
/* State of the lexer as passed to the lexer. */
|
/* State of the lexer as passed to the lexer. */
|
||||||
struct grub_lexer_param
|
struct grub_lexer_param
|
||||||
{
|
{
|
||||||
/* Set to 0 when the lexer is done. */
|
|
||||||
int done;
|
|
||||||
|
|
||||||
/* State of the state machine. */
|
|
||||||
grub_parser_state_t state;
|
|
||||||
|
|
||||||
/* Function used by the lexer to get a new line when more input is
|
/* Function used by the lexer to get a new line when more input is
|
||||||
expected, but not available. */
|
expected, but not available. */
|
||||||
grub_reader_getline_t getline;
|
grub_reader_getline_t getline;
|
||||||
|
@ -137,10 +149,6 @@ struct grub_lexer_param
|
||||||
depleted. */
|
depleted. */
|
||||||
int refs;
|
int refs;
|
||||||
|
|
||||||
/* The character stream that has to be parsed. */
|
|
||||||
char *script;
|
|
||||||
char *newscript; /* XXX */
|
|
||||||
|
|
||||||
/* While walking through the databuffer, `record' the characters to
|
/* While walking through the databuffer, `record' the characters to
|
||||||
this other buffer. It can be used to edit the menu entry at a
|
this other buffer. It can be used to edit the menu entry at a
|
||||||
later moment. */
|
later moment. */
|
||||||
|
@ -157,13 +165,31 @@ struct grub_lexer_param
|
||||||
/* Size of RECORDING. */
|
/* Size of RECORDING. */
|
||||||
int recordlen;
|
int recordlen;
|
||||||
|
|
||||||
/* The token that is already parsed but not yet returned. */
|
/* End of file reached. */
|
||||||
int tokenonhold;
|
int eof;
|
||||||
|
|
||||||
/* Was the last token a newline? */
|
/* Merge multiple word tokens. */
|
||||||
int was_newline;
|
int merge_start;
|
||||||
|
int merge_end;
|
||||||
|
|
||||||
|
/* Part of a multi-part token. */
|
||||||
|
char *text;
|
||||||
|
unsigned used;
|
||||||
|
unsigned size;
|
||||||
|
|
||||||
|
/* Type of text. */
|
||||||
|
grub_script_arg_type_t type;
|
||||||
|
|
||||||
|
/* Flex scanner. */
|
||||||
|
void *yyscanner;
|
||||||
|
|
||||||
|
/* Flex scanner buffer. */
|
||||||
|
void *buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define GRUB_LEXER_INITIAL_TEXT_SIZE 32
|
||||||
|
#define GRUB_LEXER_INITIAL_RECORD_SIZE 256
|
||||||
|
|
||||||
/* State of the parser as passes to the parser. */
|
/* State of the parser as passes to the parser. */
|
||||||
struct grub_parser_param
|
struct grub_parser_param
|
||||||
{
|
{
|
||||||
|
@ -202,6 +228,12 @@ grub_script_create_cmdif (struct grub_parser_param *state,
|
||||||
struct grub_script_cmd *exec_on_true,
|
struct grub_script_cmd *exec_on_true,
|
||||||
struct grub_script_cmd *exec_on_false);
|
struct grub_script_cmd *exec_on_false);
|
||||||
|
|
||||||
|
struct grub_script_cmd *
|
||||||
|
grub_script_create_cmdfor (struct grub_parser_param *state,
|
||||||
|
struct grub_script_arg *name,
|
||||||
|
struct grub_script_arglist *words,
|
||||||
|
struct grub_script_cmd *list);
|
||||||
|
|
||||||
struct grub_script_cmd *
|
struct grub_script_cmd *
|
||||||
grub_script_create_cmdmenu (struct grub_parser_param *state,
|
grub_script_create_cmdmenu (struct grub_parser_param *state,
|
||||||
struct grub_script_arglist *arglist,
|
struct grub_script_arglist *arglist,
|
||||||
|
@ -223,12 +255,16 @@ void grub_script_free (struct grub_script *script);
|
||||||
struct grub_script *grub_script_create (struct grub_script_cmd *cmd,
|
struct grub_script *grub_script_create (struct grub_script_cmd *cmd,
|
||||||
struct grub_script_mem *mem);
|
struct grub_script_mem *mem);
|
||||||
|
|
||||||
struct grub_lexer_param *grub_script_lexer_init (char *s,
|
struct grub_lexer_param *grub_script_lexer_init (struct grub_parser_param *parser,
|
||||||
|
char *script,
|
||||||
grub_reader_getline_t getline);
|
grub_reader_getline_t getline);
|
||||||
|
void grub_script_lexer_fini (struct grub_lexer_param *);
|
||||||
void grub_script_lexer_ref (struct grub_lexer_param *);
|
void grub_script_lexer_ref (struct grub_lexer_param *);
|
||||||
void grub_script_lexer_deref (struct grub_lexer_param *);
|
void grub_script_lexer_deref (struct grub_lexer_param *);
|
||||||
void grub_script_lexer_record_start (struct grub_lexer_param *);
|
void grub_script_lexer_record_start (struct grub_parser_param *);
|
||||||
char *grub_script_lexer_record_stop (struct grub_lexer_param *);
|
char *grub_script_lexer_record_stop (struct grub_parser_param *);
|
||||||
|
int grub_script_lexer_yywrap (struct grub_parser_param *);
|
||||||
|
void grub_script_lexer_record (struct grub_parser_param *, char *);
|
||||||
|
|
||||||
/* Functions to track allocated memory. */
|
/* Functions to track allocated memory. */
|
||||||
struct grub_script_mem *grub_script_mem_record (struct grub_parser_param *state);
|
struct grub_script_mem *grub_script_mem_record (struct grub_parser_param *state);
|
||||||
|
@ -246,6 +282,7 @@ void grub_script_yyerror (struct grub_parser_param *, char const *);
|
||||||
grub_err_t grub_script_execute_cmdline (struct grub_script_cmd *cmd);
|
grub_err_t grub_script_execute_cmdline (struct grub_script_cmd *cmd);
|
||||||
grub_err_t grub_script_execute_cmdblock (struct grub_script_cmd *cmd);
|
grub_err_t grub_script_execute_cmdblock (struct grub_script_cmd *cmd);
|
||||||
grub_err_t grub_script_execute_cmdif (struct grub_script_cmd *cmd);
|
grub_err_t grub_script_execute_cmdif (struct grub_script_cmd *cmd);
|
||||||
|
grub_err_t grub_script_execute_cmdfor (struct grub_script_cmd *cmd);
|
||||||
grub_err_t grub_script_execute_menuentry (struct grub_script_cmd *cmd);
|
grub_err_t grub_script_execute_menuentry (struct grub_script_cmd *cmd);
|
||||||
|
|
||||||
/* Execute any GRUB pre-parsed command or script. */
|
/* Execute any GRUB pre-parsed command or script. */
|
||||||
|
@ -284,7 +321,7 @@ int grub_script_function_iterate (int (*iterate) (grub_script_function_t));
|
||||||
int grub_script_function_call (grub_script_function_t func,
|
int grub_script_function_call (grub_script_function_t func,
|
||||||
int argc, char **args);
|
int argc, char **args);
|
||||||
|
|
||||||
char *
|
char **
|
||||||
grub_script_execute_argument_to_string (struct grub_script_arg *arg);
|
grub_script_execute_arglist_to_argv (struct grub_script_arglist *arglist, int *count);
|
||||||
|
|
||||||
#endif /* ! GRUB_NORMAL_PARSER_HEADER */
|
#endif /* ! GRUB_NORMAL_PARSER_HEADER */
|
||||||
|
|
|
@ -25,7 +25,8 @@
|
||||||
#define BOOTDEV_REG %l6
|
#define BOOTDEV_REG %l6
|
||||||
#define PIC_REG %l7
|
#define PIC_REG %l7
|
||||||
|
|
||||||
#define SCRATCH_PAD 0x10000
|
#define SCRATCH_PAD_BOOT 0x5000
|
||||||
|
#define SCRATCH_PAD_DISKBOOT 0x4000
|
||||||
|
|
||||||
#define GET_ABS(symbol, reg) \
|
#define GET_ABS(symbol, reg) \
|
||||||
add PIC_REG, (symbol - pic_base), reg
|
add PIC_REG, (symbol - pic_base), reg
|
||||||
|
@ -51,7 +52,7 @@
|
||||||
|
|
||||||
#define GRUB_BOOT_MACHINE_LIST_SIZE 12
|
#define GRUB_BOOT_MACHINE_LIST_SIZE 12
|
||||||
|
|
||||||
#define GRUB_BOOT_MACHINE_IMAGE_ADDRESS 0x200000
|
#define GRUB_BOOT_MACHINE_IMAGE_ADDRESS 0x4400
|
||||||
|
|
||||||
#define GRUB_BOOT_MACHINE_KERNEL_ADDR 0x4200
|
#define GRUB_BOOT_MACHINE_KERNEL_ADDR 0x4200
|
||||||
|
|
||||||
|
|
|
@ -43,4 +43,6 @@ extern int EXPORT_FUNC(grub_ieee1275_alloc_physmem) (grub_addr_t *paddr,
|
||||||
grub_size_t size,
|
grub_size_t size,
|
||||||
grub_uint32_t align);
|
grub_uint32_t align);
|
||||||
|
|
||||||
|
extern grub_addr_t EXPORT_VAR (grub_ieee1275_original_stack);
|
||||||
|
|
||||||
#endif /* ! GRUB_IEEE1275_MACHINE_HEADER */
|
#endif /* ! GRUB_IEEE1275_MACHINE_HEADER */
|
||||||
|
|
|
@ -39,8 +39,24 @@
|
||||||
/* End of the data section. */
|
/* End of the data section. */
|
||||||
#define GRUB_KERNEL_MACHINE_DATA_END 0x114
|
#define GRUB_KERNEL_MACHINE_DATA_END 0x114
|
||||||
|
|
||||||
|
#define GRUB_KERNEL_MACHINE_RAW_SIZE 0
|
||||||
|
#define GRUB_KERNEL_MACHINE_STACK_SIZE 0x40000
|
||||||
|
|
||||||
|
#define GRUB_PLATFORM_IMAGE_FORMATS "raw, aout"
|
||||||
|
#define GRUB_PLATFORM_IMAGE_DEFAULT_FORMAT "raw"
|
||||||
|
|
||||||
|
#define GRUB_PLATFORM_IMAGE_DEFAULT GRUB_PLATFORM_IMAGE_RAW
|
||||||
|
|
||||||
#ifndef ASM_FILE
|
#ifndef ASM_FILE
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
GRUB_PLATFORM_IMAGE_RAW,
|
||||||
|
GRUB_PLATFORM_IMAGE_AOUT
|
||||||
|
}
|
||||||
|
grub_platform_image_format_t;
|
||||||
|
#define GRUB_PLATFORM_IMAGE_RAW GRUB_PLATFORM_IMAGE_RAW
|
||||||
|
#define GRUB_PLATFORM_IMAGE_AOUT GRUB_PLATFORM_IMAGE_AOUT
|
||||||
|
|
||||||
#include <grub/symbol.h>
|
#include <grub/symbol.h>
|
||||||
#include <grub/types.h>
|
#include <grub/types.h>
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ void grub_test_nonzero (int cond, const char *file,
|
||||||
|
|
||||||
/* Macro to fill in location details and an optional error message. */
|
/* Macro to fill in location details and an optional error message. */
|
||||||
#define grub_test_assert(cond, ...) \
|
#define grub_test_assert(cond, ...) \
|
||||||
grub_test_nonzero(cond, __FILE__, __FUNCTION__, __LINE__, \
|
grub_test_nonzero(cond, GRUB_FILE, __FUNCTION__, __LINE__, \
|
||||||
## __VA_ARGS__, \
|
## __VA_ARGS__, \
|
||||||
"assert failed: %s", #cond)
|
"assert failed: %s", #cond)
|
||||||
|
|
||||||
|
|
|
@ -180,7 +180,8 @@ typedef enum grub_video_driver_id
|
||||||
GRUB_VIDEO_DRIVER_NONE,
|
GRUB_VIDEO_DRIVER_NONE,
|
||||||
GRUB_VIDEO_DRIVER_VBE,
|
GRUB_VIDEO_DRIVER_VBE,
|
||||||
GRUB_VIDEO_DRIVER_EFI_UGA,
|
GRUB_VIDEO_DRIVER_EFI_UGA,
|
||||||
GRUB_VIDEO_DRIVER_EFI_GOP
|
GRUB_VIDEO_DRIVER_EFI_GOP,
|
||||||
|
GRUB_VIDEO_DRIVER_SM712
|
||||||
} grub_video_driver_id_t;
|
} grub_video_driver_id_t;
|
||||||
|
|
||||||
struct grub_video_adapter
|
struct grub_video_adapter
|
||||||
|
@ -272,7 +273,7 @@ grub_err_t EXPORT_FUNC (grub_video_get_info) (struct grub_video_mode_info *mode_
|
||||||
sure that framebuffer address doesn't change. To ensure this abstraction
|
sure that framebuffer address doesn't change. To ensure this abstraction
|
||||||
grub_video_get_info_and_fini is the only function supplying framebuffer
|
grub_video_get_info_and_fini is the only function supplying framebuffer
|
||||||
address. */
|
address. */
|
||||||
grub_err_t grub_video_get_info_and_fini (struct grub_video_mode_info *mode_info,
|
grub_err_t EXPORT_FUNC (grub_video_get_info_and_fini) (struct grub_video_mode_info *mode_info,
|
||||||
void **framebuffer);
|
void **framebuffer);
|
||||||
|
|
||||||
enum grub_video_blit_format grub_video_get_blit_format (struct grub_video_mode_info *mode_info);
|
enum grub_video_blit_format grub_video_get_blit_format (struct grub_video_mode_info *mode_info);
|
||||||
|
@ -280,8 +281,9 @@ enum grub_video_blit_format grub_video_get_blit_format (struct grub_video_mode_i
|
||||||
grub_err_t grub_video_set_palette (unsigned int start, unsigned int count,
|
grub_err_t grub_video_set_palette (unsigned int start, unsigned int count,
|
||||||
struct grub_video_palette_data *palette_data);
|
struct grub_video_palette_data *palette_data);
|
||||||
|
|
||||||
grub_err_t grub_video_get_palette (unsigned int start, unsigned int count,
|
grub_err_t EXPORT_FUNC (grub_video_get_palette) (unsigned int start,
|
||||||
struct grub_video_palette_data *palette_data);
|
unsigned int count,
|
||||||
|
struct grub_video_palette_data *palette_data);
|
||||||
|
|
||||||
grub_err_t EXPORT_FUNC (grub_video_set_viewport) (unsigned int x,
|
grub_err_t EXPORT_FUNC (grub_video_set_viewport) (unsigned int x,
|
||||||
unsigned int y,
|
unsigned int y,
|
||||||
|
@ -356,7 +358,6 @@ grub_video_check_mode_flag (unsigned int flags, unsigned int mask,
|
||||||
return (flag & mask) ? !! (flags & flag) : def;
|
return (flag & mask) ? !! (flags & flag) : def;
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_video_driver_id_t
|
grub_video_driver_id_t EXPORT_FUNC (grub_video_get_driver_id) (void);
|
||||||
grub_video_get_driver_id (void);
|
|
||||||
|
|
||||||
#endif /* ! GRUB_VIDEO_HEADER */
|
#endif /* ! GRUB_VIDEO_HEADER */
|
||||||
|
|
1
include/grub/x86_64/efi/serial.h
Normal file
1
include/grub/x86_64/efi/serial.h
Normal file
|
@ -0,0 +1 @@
|
||||||
|
#include <grub/i386/coreboot/serial.h>
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
/* How many bytes from the start of the file we search for the header. */
|
/* How many bytes from the start of the file we search for the header. */
|
||||||
#define MULTIBOOT_SEARCH 8192
|
#define MULTIBOOT_SEARCH 8192
|
||||||
|
#define MULTIBOOT_HEADER_ALIGN 4
|
||||||
|
|
||||||
/* The magic field should contain this. */
|
/* The magic field should contain this. */
|
||||||
#define MULTIBOOT_HEADER_MAGIC 0x1BADB002
|
#define MULTIBOOT_HEADER_MAGIC 0x1BADB002
|
||||||
|
|
|
@ -23,7 +23,8 @@
|
||||||
#define MULTIBOOT_HEADER 1
|
#define MULTIBOOT_HEADER 1
|
||||||
|
|
||||||
/* How many bytes from the start of the file we search for the header. */
|
/* How many bytes from the start of the file we search for the header. */
|
||||||
#define MULTIBOOT_SEARCH 8192
|
#define MULTIBOOT_SEARCH 32768
|
||||||
|
#define MULTIBOOT_HEADER_ALIGN 8
|
||||||
|
|
||||||
/* The magic field should contain this. */
|
/* The magic field should contain this. */
|
||||||
#define MULTIBOOT2_HEADER_MAGIC 0xe85250d6
|
#define MULTIBOOT2_HEADER_MAGIC 0xe85250d6
|
||||||
|
@ -35,58 +36,37 @@
|
||||||
#define MULTIBOOT_MOD_ALIGN 0x00001000
|
#define MULTIBOOT_MOD_ALIGN 0x00001000
|
||||||
|
|
||||||
/* Alignment of the multiboot info structure. */
|
/* Alignment of the multiboot info structure. */
|
||||||
#define MULTIBOOT_INFO_ALIGN 0x00000004
|
#define MULTIBOOT_INFO_ALIGN 0x00000008
|
||||||
|
|
||||||
/* Flags set in the 'flags' member of the multiboot header. */
|
/* Flags set in the 'flags' member of the multiboot header. */
|
||||||
|
|
||||||
/* Align all boot modules on i386 page (4KB) boundaries. */
|
#define MULTIBOOT_TAG_ALIGN 8
|
||||||
#define MULTIBOOT_PAGE_ALIGN 0x00000001
|
#define MULTIBOOT_TAG_TYPE_END 0
|
||||||
|
#define MULTIBOOT_TAG_TYPE_CMDLINE 1
|
||||||
|
#define MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME 2
|
||||||
|
#define MULTIBOOT_TAG_TYPE_MODULE 3
|
||||||
|
#define MULTIBOOT_TAG_TYPE_BASIC_MEMINFO 4
|
||||||
|
#define MULTIBOOT_TAG_TYPE_BOOTDEV 5
|
||||||
|
#define MULTIBOOT_TAG_TYPE_MMAP 6
|
||||||
|
#define MULTIBOOT_TAG_TYPE_VBE 7
|
||||||
|
#define MULTIBOOT_TAG_TYPE_FRAMEBUFFER 8
|
||||||
|
#define MULTIBOOT_TAG_TYPE_ELF_SECTIONS 9
|
||||||
|
#define MULTIBOOT_TAG_TYPE_APM 10
|
||||||
|
|
||||||
/* Must pass memory information to OS. */
|
#define MULTIBOOT_HEADER_TAG_END 0
|
||||||
#define MULTIBOOT_MEMORY_INFO 0x00000002
|
#define MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST 1
|
||||||
|
#define MULTIBOOT_HEADER_TAG_ADDRESS 2
|
||||||
|
#define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS 3
|
||||||
|
#define MULTIBOOT_HEADER_TAG_CONSOLE_FLAGS 4
|
||||||
|
#define MULTIBOOT_HEADER_TAG_FRAMEBUFFER 5
|
||||||
|
#define MULTIBOOT_HEADER_TAG_MODULE_ALIGN 6
|
||||||
|
|
||||||
/* Must pass video information to OS. */
|
#define MULTIBOOT_ARCHITECTURE_I386 0
|
||||||
#define MULTIBOOT_VIDEO_MODE 0x00000004
|
#define MULTIBOOT_ARCHITECTURE_MIPS32 4
|
||||||
|
#define MULTIBOOT_HEADER_TAG_OPTIONAL 1
|
||||||
|
|
||||||
/* This flag indicates the use of the address fields in the header. */
|
#define MULTIBOOT_CONSOLE_FLAGS_CONSOLE_REQUIRED 1
|
||||||
#define MULTIBOOT_AOUT_KLUDGE 0x00010000
|
#define MULTIBOOT_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED 2
|
||||||
|
|
||||||
/* Flags to be set in the 'flags' member of the multiboot info structure. */
|
|
||||||
|
|
||||||
/* is there basic lower/upper memory information? */
|
|
||||||
#define MULTIBOOT_INFO_MEMORY 0x00000001
|
|
||||||
/* is there a boot device set? */
|
|
||||||
#define MULTIBOOT_INFO_BOOTDEV 0x00000002
|
|
||||||
/* is the command-line defined? */
|
|
||||||
#define MULTIBOOT_INFO_CMDLINE 0x00000004
|
|
||||||
/* are there modules to do something with? */
|
|
||||||
#define MULTIBOOT_INFO_MODS 0x00000008
|
|
||||||
|
|
||||||
/* These next two are mutually exclusive */
|
|
||||||
|
|
||||||
/* is there a symbol table loaded? */
|
|
||||||
#define MULTIBOOT_INFO_AOUT_SYMS 0x00000010
|
|
||||||
/* is there an ELF section header table? */
|
|
||||||
#define MULTIBOOT_INFO_ELF_SHDR 0X00000020
|
|
||||||
|
|
||||||
/* is there a full memory map? */
|
|
||||||
#define MULTIBOOT_INFO_MEM_MAP 0x00000040
|
|
||||||
|
|
||||||
/* Is there drive info? */
|
|
||||||
#define MULTIBOOT_INFO_DRIVE_INFO 0x00000080
|
|
||||||
|
|
||||||
/* Is there a config table? */
|
|
||||||
#define MULTIBOOT_INFO_CONFIG_TABLE 0x00000100
|
|
||||||
|
|
||||||
/* Is there a boot loader name? */
|
|
||||||
#define MULTIBOOT_INFO_BOOT_LOADER_NAME 0x00000200
|
|
||||||
|
|
||||||
/* Is there a APM table? */
|
|
||||||
#define MULTIBOOT_INFO_APM_TABLE 0x00000400
|
|
||||||
|
|
||||||
/* Is there video information? */
|
|
||||||
#define MULTIBOOT_INFO_VBE_INFO 0x00000800
|
|
||||||
#define MULTIBOOT_INFO_FRAMEBUFFER_INFO 0x00001000
|
|
||||||
|
|
||||||
#ifndef ASM_FILE
|
#ifndef ASM_FILE
|
||||||
|
|
||||||
|
@ -100,96 +80,175 @@ struct multiboot_header
|
||||||
/* Must be MULTIBOOT_MAGIC - see above. */
|
/* Must be MULTIBOOT_MAGIC - see above. */
|
||||||
multiboot_uint32_t magic;
|
multiboot_uint32_t magic;
|
||||||
|
|
||||||
/* Feature flags. */
|
/* ISA */
|
||||||
multiboot_uint32_t flags;
|
multiboot_uint32_t architecture;
|
||||||
|
|
||||||
|
/* Total header length. */
|
||||||
|
multiboot_uint32_t header_length;
|
||||||
|
|
||||||
/* The above fields plus this one must equal 0 mod 2^32. */
|
/* The above fields plus this one must equal 0 mod 2^32. */
|
||||||
multiboot_uint32_t checksum;
|
multiboot_uint32_t checksum;
|
||||||
|
};
|
||||||
|
|
||||||
/* These are only valid if MULTIBOOT_AOUT_KLUDGE is set. */
|
struct multiboot_header_tag
|
||||||
|
{
|
||||||
|
multiboot_uint16_t type;
|
||||||
|
multiboot_uint16_t flags;
|
||||||
|
multiboot_uint32_t size;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct multiboot_header_tag_information_request
|
||||||
|
{
|
||||||
|
multiboot_uint16_t type;
|
||||||
|
multiboot_uint16_t flags;
|
||||||
|
multiboot_uint32_t size;
|
||||||
|
multiboot_uint32_t requests[0];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct multiboot_header_tag_address
|
||||||
|
{
|
||||||
|
multiboot_uint16_t type;
|
||||||
|
multiboot_uint16_t flags;
|
||||||
|
multiboot_uint32_t size;
|
||||||
multiboot_uint32_t header_addr;
|
multiboot_uint32_t header_addr;
|
||||||
multiboot_uint32_t load_addr;
|
multiboot_uint32_t load_addr;
|
||||||
multiboot_uint32_t load_end_addr;
|
multiboot_uint32_t load_end_addr;
|
||||||
multiboot_uint32_t bss_end_addr;
|
multiboot_uint32_t bss_end_addr;
|
||||||
multiboot_uint32_t entry_addr;
|
};
|
||||||
|
|
||||||
/* These are only valid if MULTIBOOT_VIDEO_MODE is set. */
|
struct multiboot_header_tag_entry_address
|
||||||
multiboot_uint32_t mode_type;
|
{
|
||||||
|
multiboot_uint16_t type;
|
||||||
|
multiboot_uint16_t flags;
|
||||||
|
multiboot_uint32_t size;
|
||||||
|
multiboot_uint32_t entry_addr;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct multiboot_header_tag_console_flags
|
||||||
|
{
|
||||||
|
multiboot_uint16_t type;
|
||||||
|
multiboot_uint16_t flags;
|
||||||
|
multiboot_uint32_t size;
|
||||||
|
multiboot_uint32_t console_flags;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct multiboot_header_tag_framebuffer
|
||||||
|
{
|
||||||
|
multiboot_uint16_t type;
|
||||||
|
multiboot_uint16_t flags;
|
||||||
|
multiboot_uint32_t size;
|
||||||
multiboot_uint32_t width;
|
multiboot_uint32_t width;
|
||||||
multiboot_uint32_t height;
|
multiboot_uint32_t height;
|
||||||
multiboot_uint32_t depth;
|
multiboot_uint32_t depth;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* The symbol table for a.out. */
|
struct multiboot_header_tag_module_align
|
||||||
struct multiboot_aout_symbol_table
|
|
||||||
{
|
{
|
||||||
multiboot_uint32_t tabsize;
|
multiboot_uint16_t type;
|
||||||
multiboot_uint32_t strsize;
|
multiboot_uint16_t flags;
|
||||||
multiboot_uint32_t addr;
|
|
||||||
multiboot_uint32_t reserved;
|
|
||||||
};
|
|
||||||
typedef struct multiboot_aout_symbol_table multiboot_aout_symbol_table_t;
|
|
||||||
|
|
||||||
/* The section header table for ELF. */
|
|
||||||
struct multiboot_elf_section_header_table
|
|
||||||
{
|
|
||||||
multiboot_uint32_t num;
|
|
||||||
multiboot_uint32_t size;
|
multiboot_uint32_t size;
|
||||||
multiboot_uint32_t addr;
|
multiboot_uint32_t width;
|
||||||
multiboot_uint32_t shndx;
|
multiboot_uint32_t height;
|
||||||
|
multiboot_uint32_t depth;
|
||||||
};
|
};
|
||||||
typedef struct multiboot_elf_section_header_table multiboot_elf_section_header_table_t;
|
|
||||||
|
|
||||||
struct multiboot_info
|
struct multiboot_color
|
||||||
{
|
{
|
||||||
/* Multiboot info version number */
|
multiboot_uint8_t red;
|
||||||
multiboot_uint32_t flags;
|
multiboot_uint8_t green;
|
||||||
|
multiboot_uint8_t blue;
|
||||||
|
};
|
||||||
|
|
||||||
/* Available memory from BIOS */
|
struct multiboot_mmap_entry
|
||||||
|
{
|
||||||
|
multiboot_uint64_t addr;
|
||||||
|
multiboot_uint64_t len;
|
||||||
|
#define MULTIBOOT_MEMORY_AVAILABLE 1
|
||||||
|
#define MULTIBOOT_MEMORY_RESERVED 2
|
||||||
|
#define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE 3
|
||||||
|
#define MULTIBOOT_MEMORY_NVS 4
|
||||||
|
multiboot_uint32_t type;
|
||||||
|
multiboot_uint32_t zero;
|
||||||
|
} __attribute__((packed));
|
||||||
|
typedef struct multiboot_mmap_entry multiboot_memory_map_t;
|
||||||
|
|
||||||
|
struct multiboot_tag
|
||||||
|
{
|
||||||
|
multiboot_uint32_t type;
|
||||||
|
multiboot_uint32_t size;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct multiboot_tag_string
|
||||||
|
{
|
||||||
|
multiboot_uint32_t type;
|
||||||
|
multiboot_uint32_t size;
|
||||||
|
char string[0];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct multiboot_tag_module
|
||||||
|
{
|
||||||
|
multiboot_uint32_t type;
|
||||||
|
multiboot_uint32_t size;
|
||||||
|
multiboot_uint32_t mod_start;
|
||||||
|
multiboot_uint32_t mod_end;
|
||||||
|
char cmdline[0];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct multiboot_tag_basic_meminfo
|
||||||
|
{
|
||||||
|
multiboot_uint32_t type;
|
||||||
|
multiboot_uint32_t size;
|
||||||
multiboot_uint32_t mem_lower;
|
multiboot_uint32_t mem_lower;
|
||||||
multiboot_uint32_t mem_upper;
|
multiboot_uint32_t mem_upper;
|
||||||
|
};
|
||||||
|
|
||||||
/* "root" partition */
|
struct multiboot_tag_bootdev
|
||||||
multiboot_uint32_t boot_device;
|
{
|
||||||
|
multiboot_uint32_t type;
|
||||||
|
multiboot_uint32_t size;
|
||||||
|
multiboot_uint32_t biosdev;
|
||||||
|
multiboot_uint32_t slice;
|
||||||
|
multiboot_uint32_t part;
|
||||||
|
};
|
||||||
|
|
||||||
/* Kernel command line */
|
struct multiboot_tag_mmap
|
||||||
multiboot_uint32_t cmdline;
|
{
|
||||||
|
multiboot_uint32_t type;
|
||||||
|
multiboot_uint32_t size;
|
||||||
|
multiboot_uint32_t entry_size;
|
||||||
|
multiboot_uint32_t entry_version;
|
||||||
|
struct multiboot_mmap_entry entries[0];
|
||||||
|
};
|
||||||
|
|
||||||
/* Boot-Module list */
|
struct multiboot_vbe_info_block
|
||||||
multiboot_uint32_t mods_count;
|
{
|
||||||
multiboot_uint32_t mods_addr;
|
multiboot_uint8_t external_specification[512];
|
||||||
|
};
|
||||||
|
|
||||||
union
|
struct multiboot_vbe_mode_info_block
|
||||||
{
|
{
|
||||||
multiboot_aout_symbol_table_t aout_sym;
|
multiboot_uint8_t external_specification[256];
|
||||||
multiboot_elf_section_header_table_t elf_sec;
|
};
|
||||||
} u;
|
|
||||||
|
|
||||||
/* Memory Mapping buffer */
|
struct multiboot_tag_vbe
|
||||||
multiboot_uint32_t mmap_length;
|
{
|
||||||
multiboot_uint32_t mmap_addr;
|
multiboot_uint32_t type;
|
||||||
|
multiboot_uint32_t size;
|
||||||
|
|
||||||
/* Drive Info buffer */
|
|
||||||
multiboot_uint32_t drives_length;
|
|
||||||
multiboot_uint32_t drives_addr;
|
|
||||||
|
|
||||||
/* ROM configuration table */
|
|
||||||
multiboot_uint32_t config_table;
|
|
||||||
|
|
||||||
/* Boot Loader Name */
|
|
||||||
multiboot_uint32_t boot_loader_name;
|
|
||||||
|
|
||||||
/* APM table */
|
|
||||||
multiboot_uint32_t apm_table;
|
|
||||||
|
|
||||||
/* Video */
|
|
||||||
multiboot_uint32_t vbe_control_info;
|
|
||||||
multiboot_uint32_t vbe_mode_info;
|
|
||||||
multiboot_uint16_t vbe_mode;
|
multiboot_uint16_t vbe_mode;
|
||||||
multiboot_uint16_t vbe_interface_seg;
|
multiboot_uint16_t vbe_interface_seg;
|
||||||
multiboot_uint16_t vbe_interface_off;
|
multiboot_uint16_t vbe_interface_off;
|
||||||
multiboot_uint16_t vbe_interface_len;
|
multiboot_uint16_t vbe_interface_len;
|
||||||
|
|
||||||
|
struct multiboot_vbe_info_block vbe_control_info;
|
||||||
|
struct multiboot_vbe_mode_info_block vbe_mode_info;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct multiboot_tag_framebuffer_common
|
||||||
|
{
|
||||||
|
multiboot_uint32_t type;
|
||||||
|
multiboot_uint32_t size;
|
||||||
|
|
||||||
multiboot_uint64_t framebuffer_addr;
|
multiboot_uint64_t framebuffer_addr;
|
||||||
multiboot_uint32_t framebuffer_pitch;
|
multiboot_uint32_t framebuffer_pitch;
|
||||||
multiboot_uint32_t framebuffer_width;
|
multiboot_uint32_t framebuffer_width;
|
||||||
|
@ -199,12 +258,19 @@ struct multiboot_info
|
||||||
#define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1
|
#define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1
|
||||||
#define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2
|
#define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2
|
||||||
multiboot_uint8_t framebuffer_type;
|
multiboot_uint8_t framebuffer_type;
|
||||||
|
multiboot_uint16_t reserved;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct multiboot_tag_framebuffer
|
||||||
|
{
|
||||||
|
struct multiboot_tag_framebuffer_common common;
|
||||||
|
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
multiboot_uint32_t framebuffer_palette_addr;
|
|
||||||
multiboot_uint16_t framebuffer_palette_num_colors;
|
multiboot_uint16_t framebuffer_palette_num_colors;
|
||||||
|
struct multiboot_color framebuffer_palette[0];
|
||||||
};
|
};
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
|
@ -217,41 +283,31 @@ struct multiboot_info
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
typedef struct multiboot_info multiboot_info_t;
|
|
||||||
|
|
||||||
struct multiboot_color
|
struct multiboot_tag_elf_sections
|
||||||
{
|
{
|
||||||
multiboot_uint8_t red;
|
|
||||||
multiboot_uint8_t green;
|
|
||||||
multiboot_uint8_t blue;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct multiboot_mmap_entry
|
|
||||||
{
|
|
||||||
multiboot_uint32_t size;
|
|
||||||
multiboot_uint64_t addr;
|
|
||||||
multiboot_uint64_t len;
|
|
||||||
#define MULTIBOOT_MEMORY_AVAILABLE 1
|
|
||||||
#define MULTIBOOT_MEMORY_RESERVED 2
|
|
||||||
#define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE 3
|
|
||||||
#define MULTIBOOT_MEMORY_NVS 4
|
|
||||||
multiboot_uint32_t type;
|
multiboot_uint32_t type;
|
||||||
} __attribute__((packed));
|
multiboot_uint32_t size;
|
||||||
typedef struct multiboot_mmap_entry multiboot_memory_map_t;
|
multiboot_uint32_t num;
|
||||||
|
multiboot_uint32_t entsize;
|
||||||
struct multiboot_mod_list
|
multiboot_uint32_t shndx;
|
||||||
{
|
char sections[0];
|
||||||
/* the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */
|
};
|
||||||
multiboot_uint32_t mod_start;
|
|
||||||
multiboot_uint32_t mod_end;
|
struct multiboot_tag_apm
|
||||||
|
{
|
||||||
/* Module command line */
|
multiboot_uint32_t type;
|
||||||
multiboot_uint32_t cmdline;
|
multiboot_uint32_t size;
|
||||||
|
multiboot_uint16_t version;
|
||||||
/* padding to take it to 16 bytes (must be zero) */
|
multiboot_uint16_t cseg;
|
||||||
multiboot_uint32_t pad;
|
multiboot_uint32_t offset;
|
||||||
|
multiboot_uint16_t cseg_16;
|
||||||
|
multiboot_uint16_t dseg;
|
||||||
|
multiboot_uint16_t flags;
|
||||||
|
multiboot_uint16_t cseg_len;
|
||||||
|
multiboot_uint16_t cseg_16_len;
|
||||||
|
multiboot_uint16_t dseg_len;
|
||||||
};
|
};
|
||||||
typedef struct multiboot_mod_list multiboot_module_t;
|
|
||||||
|
|
||||||
#endif /* ! ASM_FILE */
|
#endif /* ! ASM_FILE */
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,10 @@ grub_device_iterate (int (*hook) (const char *name))
|
||||||
|
|
||||||
dev = grub_device_open (disk_name);
|
dev = grub_device_open (disk_name);
|
||||||
if (! dev)
|
if (! dev)
|
||||||
return 0;
|
{
|
||||||
|
grub_errno = GRUB_ERR_NONE;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (dev->disk && dev->disk->has_partitions)
|
if (dev->disk && dev->disk->has_partitions)
|
||||||
{
|
{
|
||||||
|
|
17
kern/disk.c
17
kern/disk.c
|
@ -330,6 +330,7 @@ grub_disk_open (const char *name)
|
||||||
void
|
void
|
||||||
grub_disk_close (grub_disk_t disk)
|
grub_disk_close (grub_disk_t disk)
|
||||||
{
|
{
|
||||||
|
grub_partition_t part;
|
||||||
grub_dprintf ("disk", "Closing `%s'.\n", disk->name);
|
grub_dprintf ("disk", "Closing `%s'.\n", disk->name);
|
||||||
|
|
||||||
if (disk->dev && disk->dev->close)
|
if (disk->dev && disk->dev->close)
|
||||||
|
@ -338,7 +339,12 @@ grub_disk_close (grub_disk_t disk)
|
||||||
/* Reset the timer. */
|
/* Reset the timer. */
|
||||||
grub_last_time = grub_get_time_ms ();
|
grub_last_time = grub_get_time_ms ();
|
||||||
|
|
||||||
grub_free (disk->partition);
|
while (disk->partition)
|
||||||
|
{
|
||||||
|
part = disk->partition->parent;
|
||||||
|
grub_free (disk->partition);
|
||||||
|
disk->partition = part;
|
||||||
|
}
|
||||||
grub_free ((void *) disk->name);
|
grub_free ((void *) disk->name);
|
||||||
grub_free (disk);
|
grub_free (disk);
|
||||||
}
|
}
|
||||||
|
@ -349,18 +355,19 @@ grub_disk_close (grub_disk_t disk)
|
||||||
- Verify that the range is inside the partition. */
|
- Verify that the range is inside the partition. */
|
||||||
static grub_err_t
|
static grub_err_t
|
||||||
grub_disk_adjust_range (grub_disk_t disk, grub_disk_addr_t *sector,
|
grub_disk_adjust_range (grub_disk_t disk, grub_disk_addr_t *sector,
|
||||||
grub_off_t *offset, grub_size_t size)
|
grub_off_t *offset, grub_size_t size)
|
||||||
{
|
{
|
||||||
|
grub_partition_t part;
|
||||||
*sector += *offset >> GRUB_DISK_SECTOR_BITS;
|
*sector += *offset >> GRUB_DISK_SECTOR_BITS;
|
||||||
*offset &= GRUB_DISK_SECTOR_SIZE - 1;
|
*offset &= GRUB_DISK_SECTOR_SIZE - 1;
|
||||||
|
|
||||||
if (disk->partition)
|
for (part = disk->partition; part; part = part->parent)
|
||||||
{
|
{
|
||||||
grub_disk_addr_t start;
|
grub_disk_addr_t start;
|
||||||
grub_uint64_t len;
|
grub_uint64_t len;
|
||||||
|
|
||||||
start = grub_partition_get_start (disk->partition);
|
start = part->start;
|
||||||
len = grub_partition_get_len (disk->partition);
|
len = part->len;
|
||||||
|
|
||||||
if (*sector >= len
|
if (*sector >= len
|
||||||
|| len - *sector < ((*offset + size + GRUB_DISK_SECTOR_SIZE - 1)
|
|| len - *sector < ((*offset + size + GRUB_DISK_SECTOR_SIZE - 1)
|
||||||
|
|
|
@ -348,7 +348,7 @@ grub_dl_resolve_symbols (grub_dl_t mod, Elf_Ehdr *e)
|
||||||
sym->st_value = (Elf_Addr) grub_dl_resolve_symbol (name);
|
sym->st_value = (Elf_Addr) grub_dl_resolve_symbol (name);
|
||||||
if (! sym->st_value)
|
if (! sym->st_value)
|
||||||
return grub_error (GRUB_ERR_BAD_MODULE,
|
return grub_error (GRUB_ERR_BAD_MODULE,
|
||||||
"the symbol `%s' not found", name);
|
"symbol not found: `%s'", name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -469,7 +469,7 @@ grub_dl_resolve_dependencies (grub_dl_t mod, Elf_Ehdr *e)
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef GRUB_UTIL
|
#if !GRUB_NO_MODULES
|
||||||
int
|
int
|
||||||
grub_dl_ref (grub_dl_t mod)
|
grub_dl_ref (grub_dl_t mod)
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
#include <multiboot.h>
|
#include <multiboot.h>
|
||||||
#include <multiboot2.h>
|
#include <multiboot2.h>
|
||||||
|
|
||||||
#define ABS(x) ((x) - _start + GRUB_BOOT_MACHINE_KERNEL_ADDR + 0x200)
|
#define ABS(x) ((x) - LOCAL (base) + GRUB_BOOT_MACHINE_KERNEL_ADDR + 0x200)
|
||||||
|
|
||||||
.file "startup.S"
|
.file "startup.S"
|
||||||
|
|
||||||
|
@ -66,16 +66,15 @@
|
||||||
.globl start, _start
|
.globl start, _start
|
||||||
start:
|
start:
|
||||||
_start:
|
_start:
|
||||||
|
LOCAL (base):
|
||||||
/*
|
/*
|
||||||
* Guarantee that "main" is loaded at 0x0:0x8200.
|
* Guarantee that "main" is loaded at 0x0:0x8200.
|
||||||
*/
|
*/
|
||||||
#ifdef APPLE_CC
|
#ifdef __APPLE__
|
||||||
codestart_abs = ABS(codestart) - 0x10000
|
ljmp $0, $(ABS(LOCAL (codestart)) - 0x10000)
|
||||||
ljmp $0, $(codestart_abs)
|
|
||||||
#else
|
#else
|
||||||
ljmp $0, $ABS(codestart)
|
ljmp $0, $ABS(LOCAL (codestart))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Compatibility version number
|
* Compatibility version number
|
||||||
*
|
*
|
||||||
|
@ -183,7 +182,7 @@ multiboot_trampoline:
|
||||||
.code16
|
.code16
|
||||||
|
|
||||||
/* the real mode code continues... */
|
/* the real mode code continues... */
|
||||||
codestart:
|
LOCAL (codestart):
|
||||||
cli /* we're not safe here! */
|
cli /* we're not safe here! */
|
||||||
|
|
||||||
/* set up %ds, %ss, and %es */
|
/* set up %ds, %ss, and %es */
|
||||||
|
@ -1156,7 +1155,7 @@ FUNCTION(grub_console_real_putchar)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* this table is used in translate_keycode below */
|
/* this table is used in translate_keycode below */
|
||||||
translation_table:
|
LOCAL (translation_table):
|
||||||
.word GRUB_CONSOLE_KEY_LEFT, GRUB_TERM_LEFT
|
.word GRUB_CONSOLE_KEY_LEFT, GRUB_TERM_LEFT
|
||||||
.word GRUB_CONSOLE_KEY_RIGHT, GRUB_TERM_RIGHT
|
.word GRUB_CONSOLE_KEY_RIGHT, GRUB_TERM_RIGHT
|
||||||
.word GRUB_CONSOLE_KEY_UP, GRUB_TERM_UP
|
.word GRUB_CONSOLE_KEY_UP, GRUB_TERM_UP
|
||||||
|
@ -1178,11 +1177,10 @@ translate_keycode:
|
||||||
pushw %bx
|
pushw %bx
|
||||||
pushw %si
|
pushw %si
|
||||||
|
|
||||||
#ifdef APPLE_CC
|
#ifdef __APPLE__
|
||||||
translation_table_abs = ABS (translation_table) - 0x10000
|
movw $(ABS(LOCAL (translation_table)) - 0x10000), %si
|
||||||
movw $(translation_table_abs), %si
|
|
||||||
#else
|
#else
|
||||||
movw $ABS(translation_table), %si
|
movw $ABS(LOCAL (translation_table)), %si
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
1: lodsw
|
1: lodsw
|
||||||
|
@ -1446,47 +1444,6 @@ FUNCTION(grub_console_setcursor)
|
||||||
popl %ebp
|
popl %ebp
|
||||||
ret
|
ret
|
||||||
|
|
||||||
/*
|
|
||||||
* grub_getrtsecs()
|
|
||||||
* if a seconds value can be read, read it and return it (BCD),
|
|
||||||
* otherwise return 0xFF
|
|
||||||
* BIOS call "INT 1AH Function 02H" to check whether a character is pending
|
|
||||||
* Call with %ah = 0x2
|
|
||||||
* Return:
|
|
||||||
* If RT Clock can give correct values
|
|
||||||
* %ch = hour (BCD)
|
|
||||||
* %cl = minutes (BCD)
|
|
||||||
* %dh = seconds (BCD)
|
|
||||||
* %dl = daylight savings time (00h std, 01h daylight)
|
|
||||||
* Carry flag = clear
|
|
||||||
* else
|
|
||||||
* Carry flag = set
|
|
||||||
* (this indicates that the clock is updating, or
|
|
||||||
* that it isn't running)
|
|
||||||
*/
|
|
||||||
FUNCTION(grub_getrtsecs)
|
|
||||||
pushl %ebp
|
|
||||||
|
|
||||||
call prot_to_real /* enter real mode */
|
|
||||||
.code16
|
|
||||||
|
|
||||||
clc
|
|
||||||
movb $0x2, %ah
|
|
||||||
int $0x1a
|
|
||||||
|
|
||||||
DATA32 jnc gottime
|
|
||||||
movb $0xff, %dh
|
|
||||||
|
|
||||||
gottime:
|
|
||||||
DATA32 call real_to_prot
|
|
||||||
.code32
|
|
||||||
|
|
||||||
movb %dh, %al
|
|
||||||
|
|
||||||
popl %ebp
|
|
||||||
ret
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* grub_get_rtc()
|
* grub_get_rtc()
|
||||||
* return the real time in ticks, of which there are about
|
* return the real time in ticks, of which there are about
|
||||||
|
@ -1541,33 +1498,6 @@ FUNCTION(grub_vga_set_mode)
|
||||||
popl %ebp
|
popl %ebp
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* unsigned char *grub_vga_get_font (void)
|
|
||||||
*/
|
|
||||||
FUNCTION(grub_vga_get_font)
|
|
||||||
pushl %ebp
|
|
||||||
pushl %ebx
|
|
||||||
|
|
||||||
call prot_to_real
|
|
||||||
.code16
|
|
||||||
movw $0x1130, %ax
|
|
||||||
movb $0x06, %bh
|
|
||||||
int $0x10
|
|
||||||
movw %es, %bx
|
|
||||||
movw %bp, %dx
|
|
||||||
DATA32 call real_to_prot
|
|
||||||
.code32
|
|
||||||
|
|
||||||
movzwl %bx, %ecx
|
|
||||||
shll $4, %ecx
|
|
||||||
movw %dx, %ax
|
|
||||||
addl %ecx, %eax
|
|
||||||
|
|
||||||
popl %ebx
|
|
||||||
popl %ebp
|
|
||||||
ret
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* grub_vbe_bios_status_t grub_vbe_get_controller_info (struct grub_vbe_info_block *controller_info)
|
* grub_vbe_bios_status_t grub_vbe_get_controller_info (struct grub_vbe_info_block *controller_info)
|
||||||
*
|
*
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue