diff --git a/ChangeLog b/ChangeLog index fdf61bbda..f26936e8b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2009-06-04 Vladimir Serbinenko + + Use objconv when compiling with Apple's CC + + * conf/i386-pc.rmk (efiemu32.o): use OBJCONV if defined + (efiemu64.o): likewise + (efiemu64_c.o): omit -mcmodel=large and add -DAPPLE_CC=1 + when compiling with Apple's CC + (efiemu64_s.o): likewise + * configure.ac: check for objconv when compiling with Apple's CC + * genmk.rb: use objconv for modules when compiled with Apple's CC + 2009-06-04 Vladimir Serbinenko Define segment as well as section when compiling with diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk index 83857672f..066b50625 100644 --- a/conf/i386-pc.rmk +++ b/conf/i386-pc.rmk @@ -397,16 +397,44 @@ hdparm_mod_LDFLAGS = $(COMMON_LDFLAGS) ifeq ($(enable_efiemu), yes) -efiemu32.o: efiemu/runtime/efiemu.c - $(CC) -c -m32 -DELF32 -o $@ -Wall -Werror $< -nostdlib -O2 -I$(srcdir)/efiemu/runtime -I$(srcdir)/include -Iinclude +efiemu32.o: efiemu/runtime/efiemu.c $(TARGET_OBJ2ELF) + -rm -f $@ +ifeq ($(TARGET_APPLE_CC), 1) + -rm -f $@.bin + $(TARGET_CC) -c -m32 -DELF32 -DAPPLE_CC -o $@.bin -Wall -Werror $< -nostdlib -O2 -I$(srcdir)/efiemu/runtime -I$(srcdir)/include -Iinclude + $(OBJCONV) -felf32 -nu -nd $@.bin $@ + -rm -f $@.bin +else + $(TARGET_CC) -c -m32 -DELF32 -o $@ -Wall -Werror $< -nostdlib -O2 -I$(srcdir)/efiemu/runtime -I$(srcdir)/include -Iinclude + if test ! -z $(TARGET_OBJ2ELF); then ./$(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi +endif + efiemu64_c.o: efiemu/runtime/efiemu.c - $(CC) -c -m64 -DELF64 -o $@ -Wall -Werror $< -nostdlib -mcmodel=large -mno-red-zone -O2 -I$(srcdir)/efiemu/runtime -I$(srcdir)/include -Iinclude +ifeq ($(TARGET_APPLE_CC), 1) + $(TARGET_CC) -c -m64 -DAPPLE_CC=1 -DELF64 -o $@ -Wall -Werror $< -nostdlib -mno-red-zone -O2 -I$(srcdir)/efiemu/runtime -I$(srcdir)/include -Iinclude +else + $(TARGET_CC) -c -m64 -DELF64 -o $@ -Wall -Werror $< -nostdlib -mcmodel=large -mno-red-zone -O2 -I$(srcdir)/efiemu/runtime -I$(srcdir)/include -Iinclude +endif efiemu64_s.o: efiemu/runtime/efiemu.S - $(CC) -c -m64 -DELF64 -o $@ -Wall -Werror $< -nostdlib -mcmodel=large -mno-red-zone -O2 -I$(srcdir)/efiemu/runtime -I$(srcdir)/include -Iinclude + -rm -f $@ +ifeq ($(TARGET_APPLE_CC), 1) + $(TARGET_CC) -c -m64 -DAPPLE_CC=1 -DELF64 -o $@ -Wall -Werror $< -nostdlib -mno-red-zone -O2 -I$(srcdir)/efiemu/runtime -I$(srcdir)/include -Iinclude +else + $(TARGET_CC) -c -m64 -DELF64 -o $@ -Wall -Werror $< -nostdlib -mcmodel=large -mno-red-zone -O2 -I$(srcdir)/efiemu/runtime -I$(srcdir)/include -Iinclude +endif -efiemu64.o: efiemu64_c.o efiemu64_s.o - ld -melf_x86_64 -o $@ -r $^ -nostdlib +efiemu64.o: efiemu64_c.o efiemu64_s.o $(TARGET_OBJ2ELF) + -rm -f $@ +ifeq ($(TARGET_APPLE_CC), 1) + -rm -f $@.bin + $(TARGET_CC) -m64 -o $@.bin -Wl,-r $^ -nostdlib + $(OBJCONV) -felf64 -nu -nd $@.bin $@ + -rm -f $@.bin +else + $(TARGET_CC) -m64 -o $@ -Wl,-r $^ -nostdlib + if test ! -z $(TARGET_OBJ2ELF); then ./$(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi +endif CLEANFILES += efiemu32.o efiemu64.o efiemu64_c.o efiemu64_s.o pkglib_DATA += efiemu32.o efiemu64.o diff --git a/configure.ac b/configure.ac index bd89e4ecb..e448c2fd1 100644 --- a/configure.ac +++ b/configure.ac @@ -287,6 +287,13 @@ if test x$grub_cv_apple_target_cc == xyes ; then CFLAGS="$CFLAGS -DAPPLE_CC=1 -fnested-functions" TARGET_ASFLAGS="$TARGET_ASFLAGS -DAPPLE_CC=1" TARGET_APPLE_CC=1 + AC_CHECK_PROG([OBJCONV], [objconv], [objconv], []) + if test "x$OBJCONV" = x ; then + AC_CHECK_PROG([OBJCONV], [objconv], [./objconv], [], [.]) + fi + if test "x$OBJCONV" = x ; then + AC_MSG_ERROR([objconv not found which is required when building with apple compiler]) + fi TARGET_IMG_LDSCRIPT= TARGET_IMG_CFLAGS="-static" TARGET_IMG_LDFLAGS='-nostdlib -static -Wl,-preload -Wl,-segalign,20 -Wl,-image_base,' @@ -390,6 +397,7 @@ fi AC_SUBST(TARGET_CFLAGS) AC_SUBST(TARGET_MODULE_FORMAT) +AC_SUBST(OBJCONV) AC_SUBST(TARGET_APPLE_CC) AC_SUBST(TARGET_ASFLAGS) AC_SUBST(TARGET_CPPFLAGS) diff --git a/genmk.rb b/genmk.rb index cfe120ad0..249dcb5f7 100644 --- a/genmk.rb +++ b/genmk.rb @@ -112,11 +112,20 @@ endif MOSTLYCLEANFILES += #{deps_str} UNDSYMFILES += #{undsym} +ifneq ($(TARGET_APPLE_CC),1) #{@name}: #{pre_obj} #{mod_obj} $(TARGET_OBJ2ELF) -rm -f $@ $(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 $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -K _grub_mod_init -K _grub_mod_fini -R .note -R .comment $@ +else +#{@name}: #{pre_obj} #{mod_obj} $(TARGET_OBJ2ELF) + -rm -f $@ + -rm -f $@.bin + $(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 $@ + -rm -f $@.bin +endif #{pre_obj}: $(#{prefix}_DEPENDENCIES) #{objs_str} -rm -f $@