Skip to contentSkip to conversation

Conditionally building `grub-emu'

PATCH Thomas Schwinge 4 participants 9 messages Oct 22, 2006 – Dec 15, 2006 Kbuild

lore
Share & tools
lore
#0 lore raw

Hello!

On request / suggestion / whatever ;-) of Marco I created the following patch. Its origin: I was trying to build GRUB2 on a system where no (n)curses header files were installed (which configure even detected correctly, but didn't complain about it) and then the build stopped with an error when building grub-emu''s object files. As grub-emu' is considered to ``only'' be a debugging tool, the patch disables it for a default build (and thusly also avoids the (n)curses dependency for a default build).

The only remaining problem --- which only happens if building without having `grub-emu' enabled --- is the following one:

#v+
[...]
cc -Iloader/i386/pc -I../loader/i386/pc -I. -Iinclude -I../include -Wall -W -Wall -W -Wshadow -Wpointer-arith -Wmissing-prototypes -Wundef -Wstrict-prototypes -g -Os -falign-jumps=1 -falign-loops=1 -falign-functions=1 -fno-builtin -mrtd -mregparm=3 -m32 -MD -c -o chain_mod-loader_i386_pc_chainloader_normal.o ../loader/i386/pc/chainloader_normal.c
In file included from ../include/grub/normal.h:28,

                 from ../loader/i386/pc/chainloader_normal.c:23:
../include/grub/script.h:27:29: error: grub_script.tab.h: No such file or directory
In file included from ../include/grub/normal.h:28,
                 from ../loader/i386/pc/chainloader_normal.c:23:

../include/grub/script.h:242: error: expected ')' before '*' token
make: *** [chain_mod-loader_i386_pc_chainloader_normal.o] Error 1 #v-

Running make grub_script.tab.h' and then again make' makes the build succeed. So my guess is that there is a missing dependency somewhere and it wasn't a problem so far because the file was built earlier (for `grub-emu'?). Someone who knows the dependencies between the source files should be able to quickly spot the missing one.

2006-10-22 Thomas Schwinge <[email protected]>

* Makefile.in (enable_grub_emu): New variable.
* configure.ac (--enable-grub-emu): New option.
Do the checks for (n)curses only if `--enable-grub-emu' is requested.
* conf/i386-efi.rmk (sbin_UTILITIES): Add `grub-emu' only if requested.
* conf/i386-pc.rmk: Likewise.
* conf/powerpc-ieee1275.rmk: Likewise.
* conf/sparc64-ieee1275.rmk (bin_UTILITIES): Likewise.

Index: Makefile.in
===================================================================
RCS file: /cvsroot/grub/grub2/Makefile.in,v
retrieving revision 1.22

Makefile.in +3 -0
diff -u -p -r1.22 Makefile.in
@@ -73,6 +73,9 @@ LIBCURSES = @LIBCURSES@
 LIBLZO = @LIBLZO@
 YACC = @YACC@
 
+# Options.
+enable_grub_emu = @enable_grub_emu@
+
 ### General variables.
 
 RMKFILES = $(addprefix conf/,common.rmk i386-pc.rmk powerpc-ieee1275.rmk \

Index: configure.ac
===================================================================
RCS file: /cvsroot/grub/grub2/configure.ac,v
retrieving revision 1.34

configure.ac +22 -8
diff -u -p -r1.34 configure.ac
@@ -145,14 +145,6 @@ if test "$target_cpu"-"$platform" = i386
   AC_CHECK_HEADERS(lzo/lzo1x.h lzo1x.h)
 fi
 
-# Check for curses.
-AC_CHECK_LIB(ncurses, wgetch, [LIBCURSES="-lncurses"],
-  [AC_CHECK_LIB(curses, wgetch, [LIBCURSES="-lcurses"])])
-AC_SUBST(LIBCURSES)
-
-# Check for headers.
-AC_CHECK_HEADERS(ncurses/curses.h ncurses.h curses.h)
-
 # Check for functions.
 AC_CHECK_FUNCS(posix_memalign memalign)
 
@@ -265,13 +257,35 @@ CPPFLAGS="$tmp_CPPFLAGS"
 LDFLAGS="$tmp_LDFLAGS"
 LIBS="$tmp_LIBS"
 
+#
 # Check for options.
+#
+
+# Memory manager debugging.
 AC_ARG_ENABLE([mm-debug], 
 	      AS_HELP_STRING([--enable-mm-debug],
                              [include memory manager debugging]),
               [AC_DEFINE([MM_DEBUG], [1],
                          [Define to 1 if you enable memory manager debugging.])])
 
+AC_ARG_ENABLE([grub-emu],
+	      [AS_HELP_STRING([--enable-grub-emu],
+                             [build and install the `grub-emu' debugging utility])])
+[if [ x"$enable_grub_emu" = xyes ]; then
+  # Check for curses libraries.]
+  AC_CHECK_LIB([ncurses], [wgetch], [LIBCURSES="-lncurses"],
+    [AC_CHECK_LIB([curses], [wgetch], [LIBCURSES="-lcurses"],
+      [AC_MSG_ERROR([(n)curses libraries are required to build `grub-emu'])])])
+  AC_SUBST([LIBCURSES])
+
+  [# Check for headers.]
+  AC_CHECK_HEADERS([ncurses/curses.h], [],
+    [AC_CHECK_HEADERS([ncurses.h], [],
+      [AC_CHECK_HEADERS([curses.h], [],
+	[AC_MSG_ERROR([(n)curses header files are required to build `grub-emu'])])])])
+[fi]
+AC_SUBST([enable_grub_emu])
+
 # Output files.
 AC_CONFIG_LINKS([include/grub/cpu:include/grub/$target_cpu
 	include/grub/machine:include/grub/$target_cpu/$platform])

Index: conf/i386-efi.rmk
===================================================================
RCS file: /cvsroot/grub/grub2/conf/i386-efi.rmk,v
retrieving revision 1.11

i386-efi.rmk +4 -1
diff -u -p -r1.11 i386-efi.rmk
@@ -6,7 +6,10 @@ COMMON_LDFLAGS = -melf_i386 -nostdlib
 
 # Utilities.
 bin_UTILITIES = grub-mkimage
-#sbin_UTILITIES = grub-setup grub-emu grub-mkdevicemap grub-probe
+#sbin_UTILITIES = grub-setup grub-mkdevicemap grub-probe
+#ifeq ($(enable_grub_emu), yes)
+#sbin_UTILITIES += grub-emu
+#endif
 
 # For grub-mkimage.
 grub_mkimage_SOURCES = util/i386/efi/grub-mkimage.c util/misc.c \

Index: conf/i386-pc.rmk
===================================================================
RCS file: /cvsroot/grub/grub2/conf/i386-pc.rmk,v
retrieving revision 1.72

i386-pc.rmk +4 -1
diff -u -p -r1.72 i386-pc.rmk
@@ -51,7 +51,10 @@ kernel_syms.lst: $(addprefix include/gru
 
 # Utilities.
 bin_UTILITIES = grub-mkimage
-sbin_UTILITIES = grub-setup grub-emu grub-mkdevicemap grub-probe
+sbin_UTILITIES = grub-setup grub-mkdevicemap grub-probe
+ifeq ($(enable_grub_emu), yes)
+sbin_UTILITIES += grub-emu
+endif
 
 # For grub-mkimage.
 grub_mkimage_SOURCES = util/i386/pc/grub-mkimage.c util/misc.c \

Index: conf/powerpc-ieee1275.rmk
===================================================================
RCS file: /cvsroot/grub/grub2/conf/powerpc-ieee1275.rmk,v retrieving revision 1.60

powerpc-ieee1275.rmk +3 -1
diff -u -p -r1.60 powerpc-ieee1275.rmk
@@ -27,7 +27,9 @@ pkgdata_PROGRAMS = kernel.elf
 
 # Utilities.
 bin_UTILITIES = grub-mkimage
-sbin_UTILITIES = grub-emu 
+ifeq ($(enable_grub_emu), yes)
+sbin_UTILITIES = grub-emu
+endif
  
 # For grub-mkimage.
 grub_mkimage_SOURCES = util/powerpc/ieee1275/grub-mkimage.c util/misc.c \

Index: conf/sparc64-ieee1275.rmk
===================================================================
RCS file: /cvsroot/grub/grub2/conf/sparc64-ieee1275.rmk,v retrieving revision 1.14

sparc64-ieee1275.rmk +4 -1
diff -u -p -r1.14 sparc64-ieee1275.rmk
@@ -30,7 +30,10 @@ kernel_syms.lst: $(addprefix include/gru
 pkgdata_PROGRAMS = kernel.elf
 
 # Utilities.
-#bin_UTILITIES = grub-emu grub-mkimage
+#bin_UTILITIES = grub-mkimage
+#ifeq ($(enable_grub_emu), yes)
+#bin_UTILITIES += grub-emu
+#endif
 
 # For grub-mkimage.
 grub_mkimage_SOURCES = util/sparc64/ieee1275/grub-mkimage.c util/misc.c \

Regards,
Thomas

#1 lore raw

Hi Okuji, any comments on this patch? (I ask because I think you're the most familiar with the build system.)

-Hollis

Quoted 202 lines · Thomas Schwinge

Hello!

On request / suggestion / whatever ;-) of Marco I created the following patch. Its origin: I was trying to build GRUB2 on a system where no (n)curses header files were installed (which configure even detected correctly, but didn't complain about it) and then the build stopped with an error when building grub-emu''s object files. As grub-emu' is considered to ``only'' be a debugging tool, the patch disables it for a default build (and thusly also avoids the (n)curses dependency for a default build).

The only remaining problem --- which only happens if building without having `grub-emu' enabled --- is the following one:

#v+
[...]
cc -Iloader/i386/pc -I../loader/i386/pc -I. -Iinclude -I../include -Wall -W -Wall -W -Wshadow -Wpointer-arith -Wmissing-prototypes -Wundef -Wstrict-prototypes -g -Os -falign-jumps=1 -falign-loops=1 -falign-functions=1 -fno-builtin -mrtd -mregparm=3 -m32 -MD -c -o chain_mod-loader_i386_pc_chainloader_normal.o ../loader/i386/pc/chainloader_normal.c
In file included from ../include/grub/normal.h:28,

                 from ../loader/i386/pc/chainloader_normal.c:23:
../include/grub/script.h:27:29: error: grub_script.tab.h: No such file or directory
In file included from ../include/grub/normal.h:28,
                 from ../loader/i386/pc/chainloader_normal.c:23:

../include/grub/script.h:242: error: expected ')' before '*' token
make: *** [chain_mod-loader_i386_pc_chainloader_normal.o] Error 1 #v-

Running make grub_script.tab.h' and then again make' makes the build succeed. So my guess is that there is a missing dependency somewhere and it wasn't a problem so far because the file was built earlier (for `grub-emu'?). Someone who knows the dependencies between the source files should be able to quickly spot the missing one.

2006-10-22 Thomas Schwinge <[email protected]>

* Makefile.in (enable_grub_emu): New variable.
* configure.ac (--enable-grub-emu): New option.
Do the checks for (n)curses only if `--enable-grub-emu' is requested.
* conf/i386-efi.rmk (sbin_UTILITIES): Add `grub-emu' only if requested.
* conf/i386-pc.rmk: Likewise.
* conf/powerpc-ieee1275.rmk: Likewise.
* conf/sparc64-ieee1275.rmk (bin_UTILITIES): Likewise.

Index: Makefile.in
===================================================================
RCS file: /cvsroot/grub/grub2/Makefile.in,v
retrieving revision 1.22
diff -u -p -r1.22 Makefile.in

Makefile.in +3 -0
@@ -73,6 +73,9 @@ LIBCURSES = @LIBCURSES@
 LIBLZO = @LIBLZO@
 YACC = @YACC@
 
+# Options.
+enable_grub_emu = @enable_grub_emu@
+
 ### General variables.
 
 RMKFILES = $(addprefix conf/,common.rmk i386-pc.rmk powerpc-ieee1275.rmk \

Index: configure.ac
===================================================================
RCS file: /cvsroot/grub/grub2/configure.ac,v
retrieving revision 1.34
diff -u -p -r1.34 configure.ac

configure.ac +22 -8
@@ -145,14 +145,6 @@ if test "$target_cpu"-"$platform" = i386
   AC_CHECK_HEADERS(lzo/lzo1x.h lzo1x.h)
 fi
 
-# Check for curses.
-AC_CHECK_LIB(ncurses, wgetch, [LIBCURSES="-lncurses"],
-  [AC_CHECK_LIB(curses, wgetch, [LIBCURSES="-lcurses"])])
-AC_SUBST(LIBCURSES)
-
-# Check for headers.
-AC_CHECK_HEADERS(ncurses/curses.h ncurses.h curses.h)
-
 # Check for functions.
 AC_CHECK_FUNCS(posix_memalign memalign)
 
@@ -265,13 +257,35 @@ CPPFLAGS="$tmp_CPPFLAGS"
 LDFLAGS="$tmp_LDFLAGS"
 LIBS="$tmp_LIBS"
 
+#
 # Check for options.
+#
+
+# Memory manager debugging.
 AC_ARG_ENABLE([mm-debug], 
 	      AS_HELP_STRING([--enable-mm-debug],
                              [include memory manager debugging]),
               [AC_DEFINE([MM_DEBUG], [1],
                          [Define to 1 if you enable memory manager debugging.])])
 
+AC_ARG_ENABLE([grub-emu],
+	      [AS_HELP_STRING([--enable-grub-emu],
+                             [build and install the `grub-emu' debugging utility])])
+[if [ x"$enable_grub_emu" = xyes ]; then
+  # Check for curses libraries.]
+  AC_CHECK_LIB([ncurses], [wgetch], [LIBCURSES="-lncurses"],
+    [AC_CHECK_LIB([curses], [wgetch], [LIBCURSES="-lcurses"],
+      [AC_MSG_ERROR([(n)curses libraries are required to build `grub-emu'])])])
+  AC_SUBST([LIBCURSES])
+
+  [# Check for headers.]
+  AC_CHECK_HEADERS([ncurses/curses.h], [],
+    [AC_CHECK_HEADERS([ncurses.h], [],
+      [AC_CHECK_HEADERS([curses.h], [],
+	[AC_MSG_ERROR([(n)curses header files are required to build `grub-emu'])])])])
+[fi]
+AC_SUBST([enable_grub_emu])
+
 # Output files.
 AC_CONFIG_LINKS([include/grub/cpu:include/grub/$target_cpu
 	include/grub/machine:include/grub/$target_cpu/$platform])

Index: conf/i386-efi.rmk
===================================================================
RCS file: /cvsroot/grub/grub2/conf/i386-efi.rmk,v
retrieving revision 1.11
diff -u -p -r1.11 i386-efi.rmk

i386-efi.rmk +4 -1
@@ -6,7 +6,10 @@ COMMON_LDFLAGS = -melf_i386 -nostdlib
 
 # Utilities.
 bin_UTILITIES = grub-mkimage
-#sbin_UTILITIES = grub-setup grub-emu grub-mkdevicemap grub-probe
+#sbin_UTILITIES = grub-setup grub-mkdevicemap grub-probe
+#ifeq ($(enable_grub_emu), yes)
+#sbin_UTILITIES += grub-emu
+#endif
 
 # For grub-mkimage.
 grub_mkimage_SOURCES = util/i386/efi/grub-mkimage.c util/misc.c \

Index: conf/i386-pc.rmk
===================================================================
RCS file: /cvsroot/grub/grub2/conf/i386-pc.rmk,v
retrieving revision 1.72
diff -u -p -r1.72 i386-pc.rmk

i386-pc.rmk +4 -1
@@ -51,7 +51,10 @@ kernel_syms.lst: $(addprefix include/gru
 
 # Utilities.
 bin_UTILITIES = grub-mkimage
-sbin_UTILITIES = grub-setup grub-emu grub-mkdevicemap grub-probe
+sbin_UTILITIES = grub-setup grub-mkdevicemap grub-probe
+ifeq ($(enable_grub_emu), yes)
+sbin_UTILITIES += grub-emu
+endif
 
 # For grub-mkimage.
 grub_mkimage_SOURCES = util/i386/pc/grub-mkimage.c util/misc.c \

Index: conf/powerpc-ieee1275.rmk
===================================================================
RCS file: /cvsroot/grub/grub2/conf/powerpc-ieee1275.rmk,v retrieving revision 1.60
diff -u -p -r1.60 powerpc-ieee1275.rmk

powerpc-ieee1275.rmk +3 -1
@@ -27,7 +27,9 @@ pkgdata_PROGRAMS = kernel.elf
 
 # Utilities.
 bin_UTILITIES = grub-mkimage
-sbin_UTILITIES = grub-emu 
+ifeq ($(enable_grub_emu), yes)
+sbin_UTILITIES = grub-emu
+endif
 
 # For grub-mkimage.
 grub_mkimage_SOURCES = util/powerpc/ieee1275/grub-mkimage.c util/misc.c \

Index: conf/sparc64-ieee1275.rmk
===================================================================
RCS file: /cvsroot/grub/grub2/conf/sparc64-ieee1275.rmk,v retrieving revision 1.14
diff -u -p -r1.14 sparc64-ieee1275.rmk

sparc64-ieee1275.rmk +4 -1
@@ -30,7 +30,10 @@ kernel_syms.lst: $(addprefix include/gru
 pkgdata_PROGRAMS = kernel.elf
 
 # Utilities.
-#bin_UTILITIES = grub-emu grub-mkimage
+#bin_UTILITIES = grub-mkimage
+#ifeq ($(enable_grub_emu), yes)
+#bin_UTILITIES += grub-emu
+#endif
 
 # For grub-mkimage.
 grub_mkimage_SOURCES = util/sparc64/ieee1275/grub-mkimage.c util/misc.c \

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

#2 lore raw
In reply to Thomas Schwinge
Quoted 8 lines · Thomas Schwinge

On request / suggestion / whatever ;-) of Marco I created the following patch. Its origin: I was trying to build GRUB2 on a system where no (n)curses header files were installed (which configure even detected correctly, but didn't complain about it) and then the build stopped with an error when building grub-emu''s object files. As grub-emu' is considered to ``only'' be a debugging tool, the patch disables it for a default build (and thusly also avoids the (n)curses dependency for a default build).

This patch is good. But we need a copyright assignment to apply it. I will send another mail to you later.

Quoted 5 lines

Running make grub_script.tab.h' and then again make' makes the build succeed. So my guess is that there is a missing dependency somewhere and it wasn't a problem so far because the file was built earlier (for `grub-emu'?). Someone who knows the dependencies between the source files should be able to quickly spot the missing one.

For this problem, I think we should remove the inclusion of script.h in normal.h, and add a dependency explicitly to normal.mod. I'll try.

Thanks,
Okuji

#3 lore raw

Hello!

Quoted 7 lines · Yoshinori K. Okuji
Quoted 3 lines · Thomas Schwinge

As `grub-emu' is considered to ``only'' be a debugging tool, the patch disables it for a default build (and thusly also avoids the (n)curses dependency for a default build).

This patch is good. But we need a copyright assignment to apply it. I will send another mail to you later.

This is in process now.

Quoted 8 lines
Quoted 5 lines

Running make grub_script.tab.h' and then again make' makes the build succeed. So my guess is that there is a missing dependency somewhere and it wasn't a problem so far because the file was built earlier (for `grub-emu'?). Someone who knows the dependencies between the source files should be able to quickly spot the missing one.

For this problem, I think we should remove the inclusion of script.h in normal.h, and add a dependency explicitly to normal.mod. I'll try.

The patch you applied indeed does fix this problem. Thanks.

Regards,
Thomas

#4 lore raw
In reply to Yoshinori K. Okuji

Hello!

Quoted 10 lines · Yoshinori K. Okuji
Quoted 8 lines · Thomas Schwinge

On request / suggestion / whatever ;-) of Marco I created the following patch. Its origin: I was trying to build GRUB2 on a system where no (n)curses header files were installed (which configure even detected correctly, but didn't complain about it) and then the build stopped with an error when building grub-emu''s object files. As grub-emu' is considered to ``only'' be a debugging tool, the patch disables it for a default build (and thusly also avoids the (n)curses dependency for a default build).

Quoted 2 lines

This patch is good. But we need a copyright assignment to apply it. I will send another mail to you later.

This has been resolved some time ago, so you could now install that patch (or enable me to do it).

Regards,
Thomas

#5 lore raw
Quoted 9 lines · Thomas Schwinge
Quoted 9 lines
Quoted 8 lines

On request / suggestion / whatever ;-) of Marco I created the following patch. Its origin: I was trying to build GRUB2 on a system where no (n)curses header files were installed (which configure even detected correctly, but didn't complain about it) and then the build stopped with an error when building grub-emu''s object files. As grub-emu' is considered to ``only'' be a debugging tool, the patch disables it for a default build (and thusly also avoids the (n)curses dependency for a default build).

Quoted 5 lines
Quoted 2 lines

This patch is good. But we need a copyright assignment to apply it. I will send another mail to you later.

This has been resolved some time ago, so you could now install that patch (or enable me to do it).

Thanks. As I am quite lazy, I've added you to the members. Could you check it in yourself?

Okuji

#6 lore raw
Quoted 2 lines · Yoshinori K. Okuji

Thanks. As I am quite lazy, I've added you to the members. Could you check it in yourself?

Thanks!

I installed the following:

#v+
2006-12-13 Thomas Schwinge <[email protected]>

* Makefile.in (enable_grub_emu): New variable.
* configure.ac (--enable-grub-emu): New option.
Do the checks for (n)curses only if `--enable-grub-emu' is requested.
* conf/i386-efi.rmk (sbin_UTILITIES): Add `grub-emu' only if requested.
* conf/i386-pc.rmk: Likewise.
* conf/powerpc-ieee1275.rmk: Likewise.
* conf/sparc64-ieee1275.rmk (bin_UTILITIES): Likewise.
#v-

Afterwards I installed the regenerated files, without a ChangeLog entry, as adviced my Marco.

Regards,
Thomas

#7 lore raw
In reply to Thomas Schwinge

Thomas Schwinge <[email protected]> writes:

Hi Thomas,

Quoted 2 lines

On request / suggestion / whatever ;-) of Marco I created the following patch.

Thanks a lot for doing this!

[...]

Quoted 2 lines

The only remaining problem --- which only happens if building without having `grub-emu' enabled --- is the following one:

[...]

Is this fixed already by what Okuji proposed (and possibly committed)?

--
Marco

#8 lore raw

Hello!

Quoted 5 lines · Marco Gerards
Quoted 2 lines · Thomas Schwinge

On request / suggestion / whatever ;-) of Marco I created the following patch.

Thanks a lot for doing this!

Sure, sure.

Quoted 4 lines
Quoted 2 lines

The only remaining problem --- which only happens if building without having `grub-emu' enabled --- is the following one:

Is this fixed already by what Okuji proposed (and possibly committed)?

Yesh, I think I validated it at that time.

Regards,
Thomas