All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johan Rydberg <jrydberg@night.trouble.net>
To: Marco Gerards <metgerards@student.han.nl>
Cc: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Re: multiboot
Date: Wed, 08 Dec 2004 14:24:37 +0100	[thread overview]
Message-ID: <87brd4q5wq.fsf@night.trouble.net> (raw)
In-Reply-To: <87d5xlhtcb.fsf@marco.marco-g.com> (Marco Gerards's message of "Wed, 08 Dec 2004 12:23:16 +0000")

[-- Attachment #1: Type: text/plain, Size: 1619 bytes --]

Marco Gerards <metgerards@student.han.nl> writes:

>> I didn't manage to do so.  I'll research it a bit and probably send in
>> a patch.
>
> Nice.

The initial problem was that AC_CHECK_SIZEOF doesn't work if you're
cross-compiling.  I fixed this by using AC_COMPILE_CHECK_SIZEOF [1]
instead.

But the major problem is that parts of GRUB2 requires a C library to
be installed, at least headers such as alloca.h and stdint.h.  Is this
really a valid demand?  

Another issue regarding BUILD_CC.  The normal convention is that if
you want to build something that should run on the build machine, you
use something similar to BUILD_CC.  That's why I think the following
patch is self-explaining.

--- configure.ac        4 Apr 2004 13:45:59 -0000       1.9
+++ configure.ac        8 Dec 2004 12:57:07 -0000
@@ -109,7 +109,7 @@
 AC_PATH_PROG(RUBY, ruby)
 
 # For cross-compiling.
-if test "x$build" = "x$host"; then
+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
@@ -127,8 +127,8 @@

That brings us the next issue; BUILD_CC is used to build _everything_,
including the host-specific object files, and since BUILD_CC is set to
/usr/bin/gcc in my cross-compiler environment it will try to compile
PPC assembler sources with a i386 compiler.  Not good.

My suggestion is to create a new class for programs that should be
host-specific, and let Utilities be compiled on the build machine.
See the patch.  

~j

 [1] http://ac-archive.sourceforge.net/Miscellaneous/ac_compile_check_sizeof.html


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: grub-build-cc.patch --]
[-- Type: text/x-patch, Size: 2747 bytes --]

Index: genmk.rb
===================================================================
RCS file: /cvsroot/grub/grub2/genmk.rb,v
retrieving revision 1.8
diff -u -r1.8 genmk.rb
--- genmk.rb	4 Apr 2004 13:45:59 -0000	1.8
+++ genmk.rb	8 Dec 2004 13:11:19 -0000
@@ -205,9 +205,55 @@
   end
 end
 
+class Program
+  def initialize(dir, name)
+    @dir = dir
+    @name = name
+  end
+  attr_reader :dir, :name
+
+  def rule(sources)
+    prefix = @name.to_var
+    objs = sources.collect do |src|
+      raise "unknown source file `#{src}'" if /\.[cS]$/ !~ src
+      prefix + '-' + src.to_obj
+    end
+    objs_str = objs.join(' ');
+    deps = objs.collect {|obj| obj.suffix('d')}
+    deps_str = deps.join(' ');
+
+    "CLEANFILES += #{@name} #{objs_str}
+MOSTLYCLEANFILES += #{deps_str}
+
+#{@name}: #{objs_str}
+	$(BUILD_CC) -o $@ $^ $(BUILD_LDFLAGS) $(#{prefix}_LDFLAGS)
+
+" + objs.collect_with_index do |obj, i|
+      src = sources[i]
+      fake_obj = File.basename(src).suffix('o')
+      dep = deps[i]
+      dir = File.dirname(src)
+
+      "#{obj}: #{src}
+	$(CC) -I#{dir} -I$(srcdir)/#{dir} $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(#{prefix}_CFLAGS) -c -o $@ $<
+
+#{dep}: #{src}
+	set -e; \
+	  $(CC) -I#{dir} -I$(srcdir)/#{dir} $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(#{prefix}_CFLAGS) -M $< \
+	  | sed 's,#{Regexp.quote(fake_obj)}[ :]*,#{obj} $@ : ,g' > $@; \
+	  [ -s $@ ] || rm -f $@
+
+-include #{dep}
+
+"
+    end.join('')
+  end
+end
+
 images = []
 utils = []
 pmodules = []
+programs = []
 
 cont = false
 s = nil
@@ -245,6 +291,11 @@
 	    Utility.new(prefix, util)
 	  end
 
+	when 'PROGRAMS'
+	  programs += args.split(/\s+/).collect do |util|
+	    Program.new(prefix, util)
+	  end
+
 	when 'SOURCES'
 	  if img = images.detect() {|i| i.name.to_var == prefix}
 	    print img.rule(args.split(/\s+/))
@@ -252,6 +303,8 @@
 	    print pmod.rule(args.split(/\s+/))
 	  elsif util = utils.detect() {|u| u.name.to_var == prefix}
 	    print util.rule(args.split(/\s+/))
+	  elsif program = programs.detect() {|u| u.name.to_var == prefix}
+	    print program.rule(args.split(/\s+/))
 	  end
 	end
       end
Index: conf/powerpc-ieee1275.rmk
===================================================================
RCS file: /cvsroot/grub/grub2/conf/powerpc-ieee1275.rmk,v
retrieving revision 1.15
diff -u -r1.15 powerpc-ieee1275.rmk
--- conf/powerpc-ieee1275.rmk	4 Dec 2004 18:45:45 -0000	1.15
+++ conf/powerpc-ieee1275.rmk	8 Dec 2004 13:11:19 -0000
@@ -15,8 +15,10 @@
 kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) genkernsyms.sh
 	sh $(srcdir)/genkernsyms.sh $(filter %h,$^) > $@
 
+# Programs.
+sbin_PROGRAMS = grubof
+
 # Utilities.
-sbin_UTILITIES = grubof
 bin_UTILITIES = grub-emu
 noinst_UTILITIES = genmoddep
 

  reply	other threads:[~2004-12-08 13:23 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-07 11:09 multiboot Johan Rydberg
2004-12-07 14:51 ` multiboot Marco Gerards
2004-12-08 10:44   ` multiboot Johan Rydberg
2004-12-08 11:59     ` multiboot Marco Gerards
2004-12-08 12:27       ` multiboot Johan Rydberg
2004-12-08 12:23         ` multiboot Marco Gerards
2004-12-08 13:24           ` Johan Rydberg [this message]
2004-12-08 13:34             ` multiboot Johan Rydberg
2004-12-08 14:57             ` multiboot Marco Gerards
2004-12-08 15:32               ` multiboot Johan Rydberg
2004-12-08 19:10                 ` multiboot Marco Gerards
2004-12-09  2:16             ` multiboot Yoshinori K. Okuji
2004-12-09 11:42               ` multiboot Johan Rydberg
2004-12-09 13:51                 ` multiboot Marco Gerards

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87brd4q5wq.fsf@night.trouble.net \
    --to=jrydberg@night.trouble.net \
    --cc=grub-devel@gnu.org \
    --cc=metgerards@student.han.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.