Skip to contentSkip to conversation

fix building bug with --enable-grub-emu-usb

PATCH In review Vladimir 'phcoder' Serbinenko 3 participants 6 messages Jun 17, 2009 – Jul 16, 2009 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix building bug with --enable-grub-emu-usb

Hello. This is a fix for problem in subject line. I believe this fix to be correct and legitimate but as I don't know ruby well could someone review it? If nobody knows ruby in depth I think we can commit this even without deep review

Signature · 2 lines
Regards
Vladimir 'phcoder' Serbinenko
ChangeLog +9 -0
index f3e631c..c7526d2 100644
@@ -1,3 +1,12 @@
+2009-06-17  Vladimir Serbinenko  <[email protected]>
+
+	Fix libusb
+
+	* Makefile.in (LIBUSB): new macro
+	* genmk.rb (Utility/print_tail): new method
+	(Utility/rule): use intermediary variable #{prefix}_OBJECTS
+	(top level): call util.print_tail at the end.
+
 2009-06-16  James Jarvis  <[email protected]>
 
 	* commands/help.c GRUB_MOD_INIT(echo): Fix the help output of
Makefile.in +1 -0
index f82566a..cfbdfb8 100644
@@ -95,6 +95,7 @@ endif
 AWK = @AWK@
 LIBCURSES = @LIBCURSES@
 LIBLZO = @LIBLZO@
+LIBUSB = @LIBUSB@
 YACC = @YACC@
 UNIFONT_BDF = @UNIFONT_BDF@
 
genmk.rb +9 -3
index 36f4020..3356c3e 100644
@@ -220,6 +220,13 @@ class Utility
     @dir = dir
     @name = name
   end
+  def print_tail()
+    prefix = @name.to_var
+    print "#{@name}: $(#{prefix}_DEPENDENCIES) $(#{prefix}_OBJECTS)
+	$(CC) -o $@ $(#{prefix}_OBJECTS) $(LDFLAGS) $(#{prefix}_LDFLAGS)
+
+"
+  end
   attr_reader :dir, :name
 
   def rule(sources)
@@ -234,9 +241,7 @@ class Utility
 
     "CLEANFILES += #{@name}$(EXEEXT) #{objs_str}
 MOSTLYCLEANFILES += #{deps_str}
-
-#{@name}: $(#{prefix}_DEPENDENCIES) #{objs_str}
-	$(CC) -o $@ #{objs_str} $(LDFLAGS) $(#{prefix}_LDFLAGS)
+#{prefix}_OBJECTS += #{objs_str}
 
 " + objs.collect_with_index do |obj, i|
       src = sources[i]
@@ -393,4 +398,5 @@ while l = gets
   end
 
 end
+utils.each {|util| util.print_tail()}
 
#1 lore raw
Quoted 4 lines · Vladimir 'phcoder' Serbinenko

Hello. This is a fix for problem in subject line. I believe this fix to be correct and legitimate but as I don't know ruby well could someone review it? If nobody knows ruby in depth I think we can commit this even without deep review

I would prefer that we take a different approach with grub-emu. I think the USB support should be enabled whenever libusb is enabled. If libusb is missing, then the USB related code should be omitted from the sources using preprocessor directives. The build system doesn't need to know anything about it.

Generally, please think how to reduce complexity, not how to add to it. Complex systems are harder to maintain.

Signature · 2 lines
Regards,
Pavel Roskin
#2 lore raw
Quoted 8 lines · Pavel Roskin
Quoted 4 lines · Vladimir 'phcoder' Serbinenko

Hello. This is a fix for problem in subject line. I believe this fix to be correct and legitimate but as I don't know ruby well could someone review it? If nobody knows ruby in depth I think we can commit this even without deep review

I would prefer that we take a different approach with grub-emu. I think the USB support should be enabled whenever libusb is enabled.

See my other patch for it

Quoted 4 lines

If libusb
is missing, then the USB related code should be omitted from the sources using preprocessor directives. The build system doesn't need to know anything about it.

This proposition would go to Marco Gerards - original author of this code. I personaly don't like putting a whole file in #ifdef but it's matter of taset (AFAIK there is no technical reason not to do so). Perhaps we can discuss it on IRC?

Quoted 5 lines

Generally, please think how to reduce complexity, not how to add to it. Complex systems are harder to maintain.

This patch wouldn't increase complexity. It just moves a bit of complexity from ruby to (g)make by defining a variable.

Quoted 11 lines

--
Regards,
Pavel Roskin

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 4 lines
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
#3 lore raw
In reply to Pavel Roskin
Quoted 3 lines · Pavel Roskin

Generally, please think how to reduce complexity, not how to add to it. Complex systems are harder to maintain.

In general, I completely agree with this.

However grub-emu has very special requirements that could make it desireable sometimes. Its purpose is to emulate GRUB as faithfully as possible to uncover bugs so in general we want to use interfaces as lower as possible _but_ it's sometimes useful to be able to isolate those bugs, which makes options to choose between higher or lower interfaces also desireable.

For example, should we use our USB drivers against libusb, or should we ditch libusb and use our *HCI controllers against libpci? Should we use our gfxterm against SDL, or should we use our own hardware drivers to access the hardware (sort of) directly like X does?

I think we need some balance here, and decide on a case by case basis.

Anyway, given that grub-emu is a debugging/development tool, I'm not sure it's that useful to export those flags to autoconf. We could just live with #ifdefs in the code IMHO. Distributors are going to ship whatever we choose as default for grub-emu anyway.

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."
#4 lore raw
Quoted 5 lines

Anyway, given that grub-emu is a debugging/development tool, I'm not sure it's that useful to export those flags to autoconf. We could just live with #ifdefs in the code IMHO. Distributors are going to ship whatever we choose as default for grub-emu anyway.

Actually the problem isn't grub-emu. It's building system. This was just a revealer. Build system needs improvements and reorganisation. And we should remove this bug too because it's one of the obstacles to e.g. declare all the filesystems as a variable in one place

Quoted 14 lines

--
Robert Millan

The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 4 lines
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
#5 lore raw

comitted

Quoted 35 lines · Vladimir 'phcoder' Serbinenko
Quoted 7 lines

Anyway, given that grub-emu is a debugging/development tool, I'm not sure it's that useful to export those flags to autoconf.  We could just live with #ifdefs in the code IMHO.  Distributors are going to ship whatever we choose as default for grub-emu anyway.

Actually the problem isn't grub-emu. It's building system. This was just a revealer. Build system needs improvements and reorganisation. And we should remove this bug too because it's one of the obstacles to e.g. declare all the  filesystems as a variable in one place

Quoted 10 lines

--
Robert Millan

 The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
 how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."

Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

--
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git

Signature · 4 lines
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git