Grub2 on Mac OS X
Hello,
I'm trying to compile Grub2 on Mac OS X and I get somme truble. To be more precise I try to compile from powerpc-apple-darwinX.Y.Z to powerpc-elf. The gcc provided with XCode cannot link at arbitrary address so I had to rebuild a complete compilation environment (binutils/gcc) with --target=powerpc-elf. So far so good, I was able to build the L4 kernel and libs for Pistachio L4 for powerpc. Now I try to get Grub2 to boot it.
So I manage to compile Grub with --host=powerpc-elf. I fond manny errors I corrected : configure fails at detecting both gcc (from the system) and powerpc-elf-gcc (for xcompil). The were somme problems with the differences between linux and Mac OS like malloc.h located in malloc/malloc.h for Mac. There were truble also with the argp functions provided by glibc. This is not present in Mac OS X so I replaced it by getopt like for grub-mkimage. There were somme other problems with the mix-up of i386 code used by the ppc part. Somme of the types defined in include/gruc/i386/pc/init.h were not present il powerpc/ieee1275/init.h.
Grub2 still fails at compiling (somewere in the linux module) now but I'll try to find a way to make it work. Most problem I get it from the use of somme linux specific types that are not present on Mac OS.
Here is a patch with the modifications I made. Please tell me if some of them are wrong. I hope I would help.
Thank's
bye
--
--
____
/ \ / [email protected]
| o o | - http://antoine.terrienne.free.fr | o | \ #153026466 \ V V /
\_/\_/
diff -cNr ../grub2/Makefile.in grub2/Makefile.in
*** ../grub2/Makefile.in Mon Mar 21 17:42:55 2005
--- grub2/Makefile.in Mon Mar 21 18:07:51 2005
***************
*** 60,66 ****
BUILD_CC = @BUILD_CC@
BUILD_CFLAGS = -g -O2
BUILD_CPPFLAGS = -I. -Iinclude -I$(srcdir)/include -Wall -W \
! -DGRUB_DATADIR=\"$(pkgdatadir)\"
OBJCOPY = @OBJCOPY@
STRIP = @STRIP@
NM = @NM@
--- 60,66 ----
BUILD_CC = @BUILD_CC@
BUILD_CFLAGS = -g -O2
BUILD_CPPFLAGS = -I. -Iinclude -I$(srcdir)/include -Wall -W \
! -DGRUB_DATADIR=\"$(pkgdatadir)\" @BUILD_CPPFLAGS@
OBJCOPY = @OBJCOPY@
STRIP = @STRIP@
NM = @NM@
diff -cNr ../grub2/aclocal.m4 grub2/aclocal.m4
*** ../grub2/aclocal.m4 Sun Apr 4 15:45:59 2004
--- grub2/aclocal.m4 Mon Mar 21 17:55:39 2005
***************
*** 329,331 ****
--- 329,338 ----
AC_DEFINE([NESTED_FUNC_ATTR], [], [Catch gcc bug])
fi
])
+
+ AC_DEFINE([HAVE_MEMALIGN], 1, [Define to 1 if you vare the memalign function])
+ AH_VERBATIM([HAVE_MEMALIGN], [#ifndef HAVE_MEMALIGN
+ #define memalign(a, b) malloc(b)
+ #endif])
+
+ AC_DEFINE([HAVE_INTPTR_T], 1, [Define to 1 if you vare the memalign function]) diff -cNr ../grub2/autom4te.cache/output.0 grub2/autom4te.cache/output.0
*** ../grub2/autom4te.cache/output.0 Tue Mar 1 15:23:38 2005
--- grub2/autom4te.cache/output.0 Mon Mar 21 17:55:51 2005
***************
*** 310,316 ****
# include <unistd.h> #endif"
! ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA SET_MAKE OBJCOPY ac_ct_OBJCOPY STRIP ac_ct_STRIP NM ac_ct_NM LD ac_ct_LD RUBY BUILD_CC CPP EGREP LIB@&t@OBJS LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
--- 310,316 ----
# include <unistd.h> #endif"
! ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA SET_MAKE OBJCOPY ac_ct_OBJCOPY STRIP ac_ct_STRIP NM ac_ct_NM LD ac_ct_LD RUBY BUILD_CC CPP EGREP BUILD_CPPFLAGS LIB@&t@OBJS LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
***************
*** 3881,3886 ****
--- 3881,3889 ----
# For cross-compiling.
if test "x$build" = "x$host"; then
+ BUILD_CC="$CC"
+
+ else
for ac_prog in gcc egcs cc
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
***************
*** 3924,3932 ****
echo "$as_me: error: none of gcc, egcs and cc is found. set BUILD_CC manually." >&2;}
{ (exit 1); exit 1; }; }"- else
- BUILD_CC="$CC"
-
fi
# Test the C compiler for the build environment.
--- 3927,3932 ----
***************
*** 5337,5342 ****
--- 5337,5462 ----
_ACEOF
+ echo "$as_me:$LINENO: checking for memalign in -lc" >&5
+ echo $ECHO_N "checking for memalign in -lc... $ECHO_C" >&6
+ if test "${ac_cv_lib_c_memalign+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+ ac_check_lib_save_LIBS=$LIBS
+ LIBS="-lc $LIBS"
+ cat >conftest.$ac_ext <<_ACEOF
+ #line $LINENO "configure"
+ /* confdefs.h. */
+ _ACEOF
+ cat confdefs.h >>conftest.$ac_ext
+ cat >>conftest.$ac_ext <<_ACEOF
+ /* end confdefs.h. */
+
+ /* Override any gcc2 internal prototype to avoid an error. */
+ #ifdef __cplusplus
+ extern "C"
+ #endif
+ /* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+ char memalign ();
+ int
+ main ()
+ {
+ memalign ();
+ ;
+ return 0;
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext conftest$ac_exeext
+ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_c_memalign=yes+ else
+ echo "$as_me: failed program was:" >&5
+ sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_lib_c_memalign=no
+ fi
+ rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+ LIBS=$ac_check_lib_save_LIBS
+ fi
+ echo "$as_me:$LINENO: result: $ac_cv_lib_c_memalign" >&5
+ echo "${ECHO_T}$ac_cv_lib_c_memalign" >&6
+ if test $ac_cv_lib_c_memalign = yes; then
+ cat >>confdefs.h <<\_ACEOF
+ @%:@define HAVE_MEMALIGN 1
+ _ACEOF
+
+ fi
+
+ echo "$as_me:$LINENO: checking for intptr_t" >&5
+ echo $ECHO_N "checking for intptr_t... $ECHO_C" >&6
+ if test "${ac_cv_type_intptr_t+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+ cat >conftest.$ac_ext <<_ACEOF
+ #line $LINENO "configure"
+ /* confdefs.h. */
+ _ACEOF
+ cat confdefs.h >>conftest.$ac_ext
+ cat >>conftest.$ac_ext <<_ACEOF
+ /* end confdefs.h. */
+ $ac_includes_default
+ int
+ main ()
+ {
+ if ((intptr_t *) 0)
+ return 0;
+ if (sizeof (intptr_t))
+ return 0; + ; + return 0;
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_type_intptr_t=yes+ else
+ echo "$as_me: failed program was:" >&5
+ sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_type_intptr_t=no
+ fi
+ rm -f conftest.$ac_objext conftest.$ac_ext
+ fi
+ echo "$as_me:$LINENO: result: $ac_cv_type_intptr_t" >&5
+ echo "${ECHO_T}$ac_cv_type_intptr_t" >&6
+ if test $ac_cv_type_intptr_t = yes; then
+
+ cat >>confdefs.h <<_ACEOF
+ @%:@define HAVE_INTPTR_T 1
+ _ACEOF
+
+ cat >>confdefs.h <<\_ACEOF
+ @%:@define HAVE_INTPTR_T 1
+ _ACEOF
+
+ fi
+
# Check LZO when compiling for the i386.
if test "x$host_cpu" = xi386; then
***************
*** 5494,5499 ****
--- 5614,5624 ----
CFLAGS="$tmp_CFLAGS"
CPPFLAGS="$tmp_CPPFLAGS"
+ case "$build_vendor"-"$build_os" in
+ apple-darwin*) BUILD_CPPFLAGS="$BUILD_CPPFLAGS -D_MACOSX_" ;;
+ esac
+
+
# Output files.
ac_config_links="$ac_config_links include/grub/cpu:include/grub/$host_cpu include/grub/machine:include/grub/$host_cpu/$host_vendor"
***************
*** 6149,6154 ****
--- 6274,6280 ----
s,@BUILD_CC@,$BUILD_CC,;t t
s,@CPP@,$CPP,;t t
s,@EGREP@,$EGREP,;t t
+ s,@BUILD_CPPFLAGS@,$BUILD_CPPFLAGS,;t t s,@LIB@&t@OBJS@,$LIB@&t@OBJS,;t t s,@LTLIBOBJS@,$LTLIBOBJS,;t t
CEOF
diff -cNr ../grub2/autom4te.cache/requests grub2/autom4te.cache/requests
*** ../grub2/autom4te.cache/requests Tue Mar 1 15:26:30 2005
--- grub2/autom4te.cache/requests Mon Mar 21 18:05:52 2005
***************
*** 15,110 ****
'configure.ac'
],
{
- 'AC_HEADER_DIRENT' => 1,
- 'm4_pattern_forbid' => 1,
- 'AC_CHECK_MEMBERS' => 1,
- 'AC_PROG_CXX' => 1,
- 'AC_TYPE_UID_T' => 1,
- 'AC_CANONICAL_HOST' => 1,
- 'AC_FUNC_LSTAT' => 1,
- 'AC_FUNC_FORK' => 1,
- 'AC_FUNC_FSEEKO' => 1,
- 'AC_FUNC_MKTIME' => 1,
- 'AC_SUBST' => 1,
- 'm4_include' => 1,
- 'AC_FUNC_ALLOCA' => 1,
- 'AH_OUTPUT' => 1,
'AC_CHECK_LIB' => 1,
! 'AC_FUNC_STRTOD' => 1,
! 'AC_DEFINE_TRACE_LITERAL' => 1,
! 'AC_FUNC_ERROR_AT_LINE' => 1,
! 'AC_PROG_LIBTOOL' => 1,
! 'AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK' => 1,
! 'AC_STRUCT_ST_BLOCKS' => 1,
! 'AC_FUNC_SETPGRP' => 1,
! 'AC_FUNC_UTIME_NULL' => 1,
'AM_PROG_CC_C_O' => 1,
! 'AC_FUNC_STRNLEN' => 1,
! 'AC_PATH_X' => 1,
! 'include' => 1,
'AC_FUNC_MEMCMP' => 1,
'AC_C_VOLATILE' => 1,
! 'AC_FUNC_REALLOC' => 1,
! 'AC_PROG_RANLIB' => 1,
! 'AC_FUNC_GETPGRP' => 1,
! 'AC_FUNC_GETLOADAVG' => 1,
! 'AM_AUTOMAKE_VERSION' => 1,
! 'AC_STRUCT_TM' => 1,
! 'AC_CHECK_FUNCS' => 1,
! 'AC_REPLACE_FNMATCH' => 1,
! 'AC_FUNC_MALLOC' => 1,
'AC_FUNC_OBSTACK' => 1,
! 'AC_PROG_YACC' => 1,
! 'AC_TYPE_MODE_T' => 1,
! 'AC_FUNC_STAT' => 1,
'AC_TYPE_SIZE_T' => 1,
'AC_FUNC_STRERROR_R' => 1,
'AC_STRUCT_TIMEZONE' => 1,
'AM_INIT_AUTOMAKE' => 1,
! 'AC_FUNC_MBRTOWC' => 1,
! 'AC_FUNC_STRCOLL' => 1,
! 'AC_HEADER_TIME' => 1,
! 'AC_CHECK_HEADERS' => 1,
! 'AC_INIT' => 1,
! 'AC_FUNC_CHOWN' => 1,
'AC_FUNC_VPRINTF' => 1,
! 'AC_FUNC_STRFTIME' => 1,
'AC_CONFIG_HEADERS' => 1,
! 'AC_PROG_MAKE_SET' => 1,
'AC_FUNC_CLOSEDIR_VOID' => 1,
! 'AC_LIBSOURCE' => 1,
! 'AC_DECL_SYS_SIGLIST' => 1,
'AC_PROG_GCC_TRADITIONAL' => 1,
! 'AC_PROG_AWK' => 1,
! 'AC_TYPE_OFF_T' => 1,
! 'AC_HEADER_MAJOR' => 1,
! 'AC_PROG_CC' => 1,
! 'AC_FUNC_GETMNTENT' => 1,
! 'AC_PROG_INSTALL' => 1,
! 'AC_CHECK_TYPES' => 1,
! 'AM_GNU_GETTEXT' => 1,
! 'm4_pattern_allow' => 1,
! 'AC_FUNC_WAIT3' => 1,
! 'AC_CANONICAL_SYSTEM' => 1,
! 'AC_HEADER_STDC' => 1,
'AC_PROG_CPP' => 1,
! 'AC_TYPE_SIGNAL' => 1,
! 'AC_FUNC_MMAP' => 1,
! 'AC_C_CONST' => 1,
'AC_PROG_LN_S' => 1,
! 'AC_HEADER_STAT' => 1,
! 'AC_HEADER_SYS_WAIT' => 1,
! 'AC_CONFIG_SUBDIRS' => 1,
! 'AC_TYPE_PID_T' => 1,
! 'AC_CONFIG_AUX_DIR' => 1,
! 'AC_FUNC_SELECT_ARGTYPES' => 1,
! 'AM_CONDITIONAL' => 1,
! 'AC_FUNC_SETVBUF_REVERSED' => 1,
! 'AC_PROG_LEX' => 1,
! 'AC_CONFIG_FILES' => 1,
! 'AC_C_INLINE' => 1,
! 'AM_MAINTAINER_MODE' => 1,
! 'AC_FUNC_GETGROUPS' => 1
}
], 'Request' )
);
--- 15,110 ----
'configure.ac'
],
{
'AC_CHECK_LIB' => 1,
! 'AC_FUNC_GETLOADAVG' => 1,
! 'AC_FUNC_STRFTIME' => 1,
! 'AC_PROG_CC' => 1,
! 'AC_FUNC_STAT' => 1,
'AM_PROG_CC_C_O' => 1,
! 'AC_C_CONST' => 1,
! 'AC_FUNC_STRCOLL' => 1,
'AC_FUNC_MEMCMP' => 1,
+ 'AC_SUBST' => 1,
+ 'AC_FUNC_STRTOD' => 1,
+ 'AC_FUNC_STRNLEN' => 1,
+ 'AM_CONDITIONAL' => 1,
'AC_C_VOLATILE' => 1,
! 'AC_PROG_MAKE_SET' => 1,
! 'AC_DECL_SYS_SIGLIST' => 1,
'AC_FUNC_OBSTACK' => 1,
! 'AC_PROG_LEX' => 1,
! 'AC_PROG_RANLIB' => 1,
! 'AC_FUNC_SELECT_ARGTYPES' => 1,
! 'AC_FUNC_FSEEKO' => 1,
! 'AC_PROG_LIBTOOL' => 1,
! 'AC_PROG_AWK' => 1,
! 'AC_FUNC_SETVBUF_REVERSED' => 1,
'AC_TYPE_SIZE_T' => 1,
+ 'AC_FUNC_MMAP' => 1,
+ 'AC_PROG_CXX' => 1,
+ 'AC_HEADER_STDC' => 1,
+ 'AH_OUTPUT' => 1,
+ 'include' => 1,
+ 'AC_TYPE_PID_T' => 1,
+ 'AC_FUNC_MALLOC' => 1,
+ 'AM_GNU_GETTEXT' => 1,
'AC_FUNC_STRERROR_R' => 1,
+ 'AC_FUNC_SETPGRP' => 1,
'AC_STRUCT_TIMEZONE' => 1,
+ 'AC_CONFIG_SUBDIRS' => 1,
+ 'AC_PROG_INSTALL' => 1,
+ 'AC_FUNC_REALLOC' => 1,
+ 'AC_LIBSOURCE' => 1,
+ 'AC_REPLACE_FNMATCH' => 1,
+ 'AC_PATH_X' => 1,
+ 'AC_CHECK_FUNCS' => 1,
+ 'AC_CONFIG_FILES' => 1,
+ 'AC_CONFIG_AUX_DIR' => 1,
+ 'AC_FUNC_ALLOCA' => 1,
+ 'AC_CANONICAL_HOST' => 1,
+ 'AC_CANONICAL_SYSTEM' => 1,
'AM_INIT_AUTOMAKE' => 1,
! 'AC_TYPE_UID_T' => 1,
! 'AC_FUNC_ERROR_AT_LINE' => 1,
! 'AC_FUNC_GETPGRP' => 1,
! 'AC_DEFINE_TRACE_LITERAL' => 1,
! 'AM_MAINTAINER_MODE' => 1,
'AC_FUNC_VPRINTF' => 1,
! 'AC_C_INLINE' => 1,
! 'AM_AUTOMAKE_VERSION' => 1,
! 'AC_FUNC_GETGROUPS' => 1,
! 'm4_pattern_allow' => 1,
! 'AC_HEADER_MAJOR' => 1,
! 'AC_HEADER_SYS_WAIT' => 1,
! 'AC_FUNC_CHOWN' => 1,
! 'AC_FUNC_WAIT3' => 1,
! 'AC_STRUCT_TM' => 1,
! 'AC_TYPE_MODE_T' => 1,
! 'AC_FUNC_MBRTOWC' => 1,
! 'AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK' => 1,
! 'AC_STRUCT_ST_BLOCKS' => 1,
! 'AC_FUNC_FORK' => 1,
! 'm4_include' => 1,
'AC_CONFIG_HEADERS' => 1,
! 'AC_CHECK_MEMBERS' => 1,
'AC_FUNC_CLOSEDIR_VOID' => 1,
! 'AC_CHECK_HEADERS' => 1,
'AC_PROG_GCC_TRADITIONAL' => 1,
! 'AC_FUNC_LSTAT' => 1,
'AC_PROG_CPP' => 1,
! 'AC_CHECK_TYPES' => 1,
! 'AC_FUNC_GETMNTENT' => 1,
! 'AC_PROG_YACC' => 1,
! 'AC_FUNC_UTIME_NULL' => 1,
! 'AC_INIT' => 1,
! 'm4_pattern_forbid' => 1,
'AC_PROG_LN_S' => 1,
! 'AC_FUNC_MKTIME' => 1,
! 'AC_TYPE_SIGNAL' => 1,
! 'AC_HEADER_DIRENT' => 1,
! 'AC_TYPE_OFF_T' => 1,
! 'AC_HEADER_TIME' => 1,
! 'AC_HEADER_STAT' => 1
}
], 'Request' )
);diff -cNr ../grub2/autom4te.cache/traces.0 grub2/autom4te.cache/traces.0
*** ../grub2/autom4te.cache/traces.0 Tue Mar 1 15:23:38 2005
--- grub2/autom4te.cache/traces.0 Mon Mar 21 17:55:51 2005
***************
*** 1,3 ****
--- 1,12 ----
+ m4trace:aclocal.m4:333: -1- AC_DEFINE_TRACE_LITERAL([HAVE_MEMALIGN])
+ m4trace:aclocal.m4:333: -1- AH_OUTPUT([HAVE_MEMALIGN], [/* Define to 1 if you vare the memalign function */
+ #undef HAVE_MEMALIGN])
+ m4trace:aclocal.m4:336: -1- AH_OUTPUT([HAVE_MEMALIGN], [#ifndef HAVE_MEMALIGN
+ #define memalign(a, b) malloc(b)
+ #endif])
+ m4trace:aclocal.m4:338: -1- AC_DEFINE_TRACE_LITERAL([HAVE_INTPTR_T])
+ m4trace:aclocal.m4:338: -1- AH_OUTPUT([HAVE_INTPTR_T], [/* Define to 1 if you vare the memalign function */
+ #undef HAVE_INTPTR_T])
m4trace:configure.ac:14: -1- AC_INIT([GRUB], [1.90], [[email protected]])
m4trace:configure.ac:14: -1- m4_pattern_forbid([^_?A[CHUM]_])
m4trace:configure.ac:14: -1- m4_pattern_forbid([_AC_])
***************
*** 175,187 ****
m4trace:configure.ac:131: -1- AC_DEFINE_TRACE_LITERAL([SIZEOF_LONG])
m4trace:configure.ac:131: -1- AH_OUTPUT([SIZEOF_LONG], [/* The size of a `long\', as computed by sizeof. */
#undef SIZEOF_LONG])
! m4trace:configure.ac:136: -1- AC_CHECK_LIB([lzo], [__lzo_init2], [], [{ { echo "$as_me:$LINENO: error: LZO library version 1.02 or later is required" >&5
echo "$as_me: error: LZO library version 1.02 or later is required" >&2;}
{ (exit 1); exit 1; }; }])! m4trace:configure.ac:136: -1- AH_OUTPUT([HAVE_LIBLZO], [/* Define to 1 if you have the `lzo\' library (-llzo). */
#undef HAVE_LIBLZO])
! m4trace:configure.ac:136: -1- AC_DEFINE_TRACE_LITERAL([HAVE_LIBLZO])
! m4trace:configure.ac:148: -1- AC_CONFIG_FILES([Makefile])
! m4trace:configure.ac:149: -1- AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
! m4trace:configure.ac:150: -1- AC_SUBST([LIB@&t@OBJS], [$ac_libobjs])
! m4trace:configure.ac:150: -1- AC_SUBST([LTLIBOBJS], [$ac_ltlibobjs])
--- 184,210 ----
m4trace:configure.ac:131: -1- AC_DEFINE_TRACE_LITERAL([SIZEOF_LONG])
m4trace:configure.ac:131: -1- AH_OUTPUT([SIZEOF_LONG], [/* The size of a `long\', as computed by sizeof. */
#undef SIZEOF_LONG])
! m4trace:configure.ac:132: -2- AC_DEFINE_TRACE_LITERAL([HAVE_MEMALIGN])
! m4trace:configure.ac:132: -1- AC_CHECK_LIB([c], [memalign], [cat >>confdefs.h <<\_ACEOF
! @%:@define HAVE_MEMALIGN 1
! _ACEOF
! ])
! m4trace:configure.ac:133: -2- AC_DEFINE_TRACE_LITERAL([HAVE_INTPTR_T])
! m4trace:configure.ac:133: -1- AC_CHECK_TYPES([intptr_t], [cat >>confdefs.h <<\_ACEOF
! @%:@define HAVE_INTPTR_T 1
! _ACEOF
! ])
! m4trace:configure.ac:133: -1- AC_DEFINE_TRACE_LITERAL([HAVE_INTPTR_T])
! m4trace:configure.ac:133: -1- AH_OUTPUT([HAVE_INTPTR_T], [/* Define to 1 if the system has the type `intptr_t\'. */
! #undef HAVE_INTPTR_T])
! m4trace:configure.ac:138: -1- AC_CHECK_LIB([lzo], [__lzo_init2], [], [{ { echo "$as_me:$LINENO: error: LZO library version 1.02 or later is required" >&5
echo "$as_me: error: LZO library version 1.02 or later is required" >&2;}
{ (exit 1); exit 1; }; }])! m4trace:configure.ac:138: -1- AH_OUTPUT([HAVE_LIBLZO], [/* Define to 1 if you have the `lzo\' library (-llzo). */
#undef HAVE_LIBLZO])
! m4trace:configure.ac:138: -1- AC_DEFINE_TRACE_LITERAL([HAVE_LIBLZO])
! m4trace:configure.ac:150: -1- AC_SUBST([BUILD_CPPFLAGS])
! m4trace:configure.ac:155: -1- AC_CONFIG_FILES([Makefile])
! m4trace:configure.ac:156: -1- AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
! m4trace:configure.ac:157: -1- AC_SUBST([LIB@&t@OBJS], [$ac_libobjs])
! m4trace:configure.ac:157: -1- AC_SUBST([LTLIBOBJS], [$ac_ltlibobjs])
diff -cNr ../grub2/config.h.in grub2/config.h.in
*** ../grub2/config.h.in Wed Dec 3 20:17:24 2003
--- grub2/config.h.in Mon Mar 21 17:55:52 2005
***************
*** 19,29 ****
--- 19,36 ----
/* Define if C symbols get an underscore after compilation */
#undef HAVE_ASM_USCORE
+ /* Define to 1 if the system has the type `intptr_t'. */
+ #undef HAVE_INTPTR_T
+
/* Define to 1 if you have the <inttypes.h> header file. */ #undef HAVE_INTTYPES_H
/* Define to 1 if you have the `lzo' library (-llzo). */ #undef HAVE_LIBLZO
+
+ #ifndef HAVE_MEMALIGN
+ #define memalign(a, b) malloc(b)
+ #endif
/* Define to 1 if you have the <memory.h> header file. */ #undef HAVE_MEMORY_H
diff -cNr ../grub2/configure grub2/configure
*** ../grub2/configure Tue Mar 1 15:23:39 2005
--- grub2/configure Mon Mar 21 17:55:55 2005
***************
*** 310,316 ****
# include <unistd.h> #endif"
! ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA SET_MAKE OBJCOPY ac_ct_OBJCOPY STRIP ac_ct_STRIP NM ac_ct_NM LD ac_ct_LD RUBY BUILD_CC CPP EGREP LIBOBJS LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
--- 310,316 ----
# include <unistd.h> #endif"
! ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA SET_MAKE OBJCOPY ac_ct_OBJCOPY STRIP ac_ct_STRIP NM ac_ct_NM LD ac_ct_LD RUBY BUILD_CC CPP EGREP BUILD_CPPFLAGS LIBOBJS LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
***************
*** 3881,3886 ****
--- 3881,3889 ----
# For cross-compiling.
if test "x$build" = "x$host"; then
+ BUILD_CC="$CC"
+
+ else
for ac_prog in gcc egcs cc
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
***************
*** 3924,3932 ****
echo "$as_me: error: none of gcc, egcs and cc is found. set BUILD_CC manually." >&2;}
{ (exit 1); exit 1; }; }"- else
- BUILD_CC="$CC"
-
fi
# Test the C compiler for the build environment.
--- 3927,3932 ----
***************
*** 5337,5342 ****
--- 5337,5462 ----
_ACEOF
+ echo "$as_me:$LINENO: checking for memalign in -lc" >&5
+ echo $ECHO_N "checking for memalign in -lc... $ECHO_C" >&6
+ if test "${ac_cv_lib_c_memalign+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+ ac_check_lib_save_LIBS=$LIBS
+ LIBS="-lc $LIBS"
+ cat >conftest.$ac_ext <<_ACEOF
+ #line $LINENO "configure"
+ /* confdefs.h. */
+ _ACEOF
+ cat confdefs.h >>conftest.$ac_ext
+ cat >>conftest.$ac_ext <<_ACEOF
+ /* end confdefs.h. */
+
+ /* Override any gcc2 internal prototype to avoid an error. */
+ #ifdef __cplusplus
+ extern "C"
+ #endif
+ /* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+ char memalign ();
+ int
+ main ()
+ {
+ memalign ();
+ ;
+ return 0;
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext conftest$ac_exeext
+ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_c_memalign=yes+ else
+ echo "$as_me: failed program was:" >&5
+ sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_lib_c_memalign=no
+ fi
+ rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+ LIBS=$ac_check_lib_save_LIBS
+ fi
+ echo "$as_me:$LINENO: result: $ac_cv_lib_c_memalign" >&5
+ echo "${ECHO_T}$ac_cv_lib_c_memalign" >&6
+ if test $ac_cv_lib_c_memalign = yes; then
+ cat >>confdefs.h <<\_ACEOF
+ #define HAVE_MEMALIGN 1
+ _ACEOF
+
+ fi
+
+ echo "$as_me:$LINENO: checking for intptr_t" >&5
+ echo $ECHO_N "checking for intptr_t... $ECHO_C" >&6
+ if test "${ac_cv_type_intptr_t+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+ cat >conftest.$ac_ext <<_ACEOF
+ #line $LINENO "configure"
+ /* confdefs.h. */
+ _ACEOF
+ cat confdefs.h >>conftest.$ac_ext
+ cat >>conftest.$ac_ext <<_ACEOF
+ /* end confdefs.h. */
+ $ac_includes_default
+ int
+ main ()
+ {
+ if ((intptr_t *) 0)
+ return 0;
+ if (sizeof (intptr_t))
+ return 0; + ; + return 0;
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_type_intptr_t=yes+ else
+ echo "$as_me: failed program was:" >&5
+ sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_type_intptr_t=no
+ fi
+ rm -f conftest.$ac_objext conftest.$ac_ext
+ fi
+ echo "$as_me:$LINENO: result: $ac_cv_type_intptr_t" >&5
+ echo "${ECHO_T}$ac_cv_type_intptr_t" >&6
+ if test $ac_cv_type_intptr_t = yes; then
+
+ cat >>confdefs.h <<_ACEOF
+ #define HAVE_INTPTR_T 1
+ _ACEOF
+
+ cat >>confdefs.h <<\_ACEOF
+ #define HAVE_INTPTR_T 1
+ _ACEOF
+
+ fi
+
# Check LZO when compiling for the i386.
if test "x$host_cpu" = xi386; then
***************
*** 5494,5499 ****
--- 5614,5624 ----
CFLAGS="$tmp_CFLAGS"
CPPFLAGS="$tmp_CPPFLAGS"
+ case "$build_vendor"-"$build_os" in
+ apple-darwin*) BUILD_CPPFLAGS="$BUILD_CPPFLAGS -D_MACOSX_" ;;
+ esac
+
+
# Output files.
ac_config_links="$ac_config_links include/grub/cpu:include/grub/$host_cpu include/grub/machine:include/grub/$host_cpu/$host_vendor"
***************
*** 6149,6154 ****
--- 6274,6280 ----
s,@BUILD_CC@,$BUILD_CC,;t t s,@CPP@,$CPP,;t t
s,@EGREP@,$EGREP,;t t
+ s,@BUILD_CPPFLAGS@,$BUILD_CPPFLAGS,;t t s,@LIBOBJS@,$LIBOBJS,;t t s,@LTLIBOBJS@,$LTLIBOBJS,;t t
CEOF
diff -cNr ../grub2/configure.ac grub2/configure.ac
*** ../grub2/configure.ac Sun Apr 4 15:45:59 2004
--- grub2/configure.ac Mon Mar 21 17:51:42 2005
***************
*** 110,120 ****
# For cross-compiling.
if test "x$build" = "x$host"; then
- AC_CHECK_PROGS(BUILD_CC, [gcc egcs cc],
- [AC_MSG_ERROR([none of gcc, egcs and cc is found. set BUILD_CC manually.])])
- else
BUILD_CC="$CC"
AC_SUBST(BUILD_CC)fi
# Test the C compiler for the build environment.
--- 110,120 ----
# For cross-compiling.
if test "x$build" = "x$host"; then
BUILD_CC="$CC"
AC_SUBST(BUILD_CC)+ else
+ AC_CHECK_PROGS(BUILD_CC, [gcc egcs cc],
+ [AC_MSG_ERROR([none of gcc, egcs and cc is found. set BUILD_CC manually.])])
fi
# Test the C compiler for the build environment.
***************
*** 129,134 ****
--- 129,136 ----
AC_C_BIGENDIAN
AC_CHECK_SIZEOF(void *) AC_CHECK_SIZEOF(long)
+ AC_CHECK_LIB(c,memalign, AC_DEFINE(HAVE_MEMALIGN))
+ AC_CHECK_TYPES(intptr_t, AC_DEFINE(HAVE_INTPTR_T))
# Check LZO when compiling for the i386.
if test "x$host_cpu" = xi386; then
***************
*** 141,146 ****
--- 143,153 ----
CC="$tmp_CC"
CFLAGS="$tmp_CFLAGS"
CPPFLAGS="$tmp_CPPFLAGS"
+
+ case "$build_vendor"-"$build_os" in
+ apple-darwin*) BUILD_CPPFLAGS="$BUILD_CPPFLAGS -D_MACOSX_" ;;
+ esac
+ AC_SUBST(BUILD_CPPFLAGS)
# Output files.
AC_CONFIG_LINKS([include/grub/cpu:include/grub/$host_cpu
diff -cNr ../grub2/include/grub/powerpc/ieee1275/init.h grub2/include/grub/powerpc/ieee1275/init.h
*** ../grub2/include/grub/powerpc/ieee1275/init.h Mon Dec 27 14:46:20 2004
--- grub2/include/grub/powerpc/ieee1275/init.h Mon Mar 21 18:00:35 2005
***************
*** 21,28 ****
#ifndef GRUB_INIT_MACHINE_HEADER
#define GRUB_INIT_MACHINE_HEADER 1
! void cmain (uint32_t r3, uint32_t r4 __attribute__((unused)), uint32_t r5);
void grub_ofdisk_init (void);
void grub_console_init (void);
#endif /* ! GRUB_INIT_MACHINE_HEADER */
--- 21,35 ----
#ifndef GRUB_INIT_MACHINE_HEADER
#define GRUB_INIT_MACHINE_HEADER 1
! #include <grub/types.h>
! #include <grub/symbol.h>
!
! void cmain (grub_uint32_t r3, grub_uint32_t r4 __attribute__((unused)), grub_uint32_t r5);
void grub_ofdisk_init (void);
void grub_console_init (void);
+
+ /* Halt the system, using APM if possible. If NO_APM is true, don't
+ * use APM even if it is available. (from grub/i386/pc/init.h)*/
+ void EXPORT_FUNC (grub_halt) (int no_apm);
#endif /* ! GRUB_INIT_MACHINE_HEADER */
diff -cNr ../grub2/util/grub-emu.c grub2/util/grub-emu.c
*** ../grub2/util/grub-emu.c Thu Mar 10 17:47:05 2005
--- grub2/util/grub-emu.c Mon Mar 21 18:03:49 2005
***************
*** 18,28 ****
*/
#include <stdlib.h>
#include <malloc.h>
#include <sys/stat.h>
- #include <argp.h>
#include <string.h>
#include <signal.h>
#include <grub/mm.h>
#include <grub/setjmp.h>
--- 18,32 ----
*/
#include <stdlib.h>
+ #ifdef _MACOSX_
+ #include <malloc/malloc.h>
+ #else
#include <malloc.h>
+ #endif
#include <sys/stat.h>
#include <string.h>
#include <signal.h>
+ #include <getopt.h>
#include <grub/mm.h>
#include <grub/setjmp.h>
***************
*** 86,103 ****
}
- const char *argp_program_version = PACKAGE_STRING;
- const char *argp_program_bug_address = PACKAGE_BUGREPORT;
- static char doc[] = "GRUB emulator";
-
- static struct argp_option options[] = {
- {"root-device", 'r', "DEV", 0, "use DEV as the root device [default=guessed]", 0},
- {"device-map", 'm', "FILE", 0, "use FILE as the device map", 0},
- {"directory", 'd', "DIR", 0, "use GRUB files in the directory DIR", 0},
- {"verbose", 'v', 0 , 0, "print verbose messages", 0},
- { 0, 0, 0, 0, 0, 0 }
- };
-
struct arguments
{
char *root_dev;
--- 90,95 ----
***************
*** 105,138 ****
char *dir;};
! static error_t
! parse_opt (int key, char *arg, struct argp_state *state)
{
! struct arguments *args = state->input;
! switch (key)
{! case 'r':
! args->root_dev = arg;
! break;
! case 'd':
! args->dir = arg;
! break;
! case 'm':
! args->dev_map = arg;
! break;
! case 'v':
! verbosity++;
! break;
! case ARGP_KEY_END:
! break;
! default:
! return ARGP_ERR_UNKNOWN;
}- return 0;
}
-
- static struct argp argp = {options, parse_opt, 0, doc, 0, 0, 0};
int
--- 97,169 ----
char *dir;
};
! static struct option options[] =
! {
! {"root-device", required_argument, 0, 'r'},
! {"device-map", required_argument, 0, 'm'},
! {"directory", required_argument, 0, 'd'},
! {"help", no_argument, 0, 'h'},
! {"version", no_argument, 0, 'V'},
! {"verbose", no_argument, 0, 'v'},
! { 0, 0, 0, 0 },! };
!
! static void
! usage (int status)
! {
! if (status)
! fprintf (stderr, "Try ``grub-emu --help'' for more information.\n");
! else
! printf ("\
! Usage: grub-emu ???\n\
! \n\
! Make something of GRUB... I guess...\n\
! \n\
! -r, --root-device=DEV use DEV as the root device [default=guessed]\n\ ! -m, --device-map=FILE use FILE as the device map\n\ ! -d, --directory=DIR use GRUB files in the directory DIR\n\ ! -h, --help display this message and exit\n\ ! -n, --note add NOTE segment for CHRP Open Firmware\n\ ! -V, --version print version information and exit\n\ ! -v, --verbose print verbose messages\n\
! \n\
! Report bugs to " PACKAGE_BUGREPORT ".\n");
!
! exit (status);
! }
!
! void parse_args(struct arguments *args, int argc, char **argv)
{
! char c;
! while ((c = getopt_long (argc, argv, "r:m:d:hVv", options, 0)) != -1)
{! switch (c)
! {
! case 'r':
! args->root_dev = optarg;
! break;
! case 'm':
! args->dev_map = optarg;
! break;
! case 'd':
! args->dir = optarg;
! break;
! case 'h':
! usage(0);
! break;
! case 'V':
! printf ("grub-emu (" PACKAGE_NAME ") " PACKAGE_VERSION "\n");
! break;
! case 'v':
! verbosity++;
! break;
! default:
! usage(1);
! break;
! }
}
}
int
***************
*** 148,155 ****
progname = "grub-emu";
! argp_parse (&argp, argc, argv, 0, 0, &args);
!
/* Make sure that there is a root device. */
if (! args.root_dev)
{--- 179,186 ----
progname = "grub-emu";
! parse_args(&args, argc, argv);
!
/* Make sure that there is a root device. */
if (! args.root_dev)
{diff -cNr ../grub2/util/misc.c grub2/util/misc.c
*** ../grub2/util/misc.c Tue Mar 1 15:19:42 2005
--- grub2/util/misc.c Mon Mar 21 18:10:56 2005
***************
*** 24,30 ****
--- 24,34 ----
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
+ #ifdef _MACOSX_
+ #include <malloc/malloc.h>
+ #else
#include <malloc.h>
+ #endif
#include <unistd.h>
#include <grub/util/misc.h>
Quoted 2 lines · Antoine Terrienne
Here is a patch with the modifications I made. Please tell me if some of them are wrong. I hope I would help.
Could you make a patch with -u? The standard diff format is too difficult for me.
I describe what I think are not appropriate in your patch:
- memalign should not be just a macro. memalign is not the same as malloc.
- The macro _MACOSX_ should not be defined. OS-specific code should be enabled in a more generic way. Take a look at the autoconf manual and the autobook
<http://sources.redhat.com/autobook/>.
- Rather than replacing argp with getopt, please include the standalone version of argp <http://gd.tuwien.ac.at/utils/shells/lsh/>.
- ChangeLog, please.
Okuji
Quoted 9 lines
Quoted 2 lines
Here is a patch with the modifications I made. Please tell me if some of them are wrong. I hope I would help.
Could you make a patch with -u? The standard diff format is too difficult for me.
I describe what I think are not appropriate in your patch:
- memalign should not be just a macro. memalign is not the same as malloc.
Antoine's post inspired me to investigate building grub2 on my OpenDarwin system.
I have two comments so far:
1) The memalign issue can be avoided by not building grub-emu (and possibly doing something about grub-mkimage and grub-setup, which use util/misc.c but probably not memalign) On darwin-ppc, these programs will not be missed much (by the type of geek currently using grub2), since it's relatively easy to arrange to call grubof from OpenFirmware, and do the setup from there. On darwin-x86, the lack of these programs still leaves people with the option of using a grub floppy.
2) Perhaps you should switch from memalign to posix_memalign. There's better odds of convincing Apple to add posix_memalign to future releases of Darwin than with memalign. It appears that memalign is glibc-specific. Does {Free|Net|Open}BSD have memalign? Is anyone building grub2 on any of the BSDs?
Quoted 5 lines · Brian Sammon
2) Perhaps you should switch from memalign to
posix_memalign. There's better odds of convincing Apple to addposix_memalignto future releases of Darwin than with memalign. It appears that memalign is glibc-specific. Does {Free|Net|Open}BSD have memalign? Is anyone building grub2 on any of the BSDs?
memalign is used only because the utilities do not use GRUB's own memory management but operating system's. I think it would be better to change them to use GRUB's.
Okuji
Quoted 10 lines · Yoshinori K. Okuji
Quoted 5 lines · Brian Sammon
2) Perhaps you should switch from memalign to
posix_memalign. There's better odds of convincing Apple to addposix_memalignto future releases of Darwin than with memalign. It appears that memalign is glibc-specific. Does {Free|Net|Open}BSD have memalign? Is anyone building grub2 on any of the BSDs?memalign is used only because the utilities do not use GRUB's own memory management but operating system's. I think it would be better to change them to use GRUB's.
I have some code for that which I used to test and debug module loading. It can be integrated into GRUB easily.
--
Marco