Hello, OKUJI!

The attached patch implements --disable-{ext2fs,fat,ffs} options
for the configure script.

Some comments:

1) AM_CONDITIONAL is not scalable. If 10 filesystems will be supported,
Automake will need to handle all 1024 combinations separately.
That's why I'm using AC_SUBST

2) All filesystems are enabled by default. This may change when support
for more complicated and less used filesystems is added.

3) The line in stage2/Makefile.am
stage2_exec_DEPENDENCIES = $(stage2_exec_LDADD)
is actually a workaround. Some day Automake will not need this line.

4) The new flags affect only stage2. However, FSYS_* variables don't
hardcode stage2, so it can easily be changed.

5) Since one can disable all filesystems for stage2 (and still be able
to load a lot of OS'es), the filesystems are forcedly enabled for
GRUB_UTIL only.

6) Since fsys_*.c can now be compiled without flags for stage2 (because
of the item 4), make sure that they always have the needed prototypes.

Pavel Roskin

diff -urN grub/configure.in grub.new/configure.in
--- grub/configure.in   Thu Aug  5 18:01:41 1999
+++ grub.new/configure.in       Tue Aug 10 03:14:05 1999
@@ -117,5 +117,40 @@
 # Check for headers.
 AC_CHECK_HEADERS(string.h strings.h)
 
+FSYS_EXT2FS="fsys_ext2fs.$ac_objext"
+AC_ARG_ENABLE(ext2fs,
+  [  --disable-ext2fs        Disable EXT2FS support in stage2],
+  [if test x"$enable_ext2fs" = xno; then
+     FSYS_EXT2FS=
+   fi])
+AC_SUBST(FSYS_EXT2FS)
+if test x"$FSYS_EXT2FS" != x; then
+  FSYS_CFLAGS="$FSYS_CFLAGS -DFSYS_EXT2FS=1"
+fi
+
+FSYS_FAT="fsys_fat.$ac_objext"
+AC_ARG_ENABLE(fat,
+  [  --disable-fat           Disable FAT support in stage2],
+  [if test x"$enable_fat" = xno; then
+     FSYS_FAT=
+   fi])
+AC_SUBST(FSYS_FAT)
+if test x"$FSYS_FAT" != x; then
+  FSYS_CFLAGS="$FSYS_CFLAGS -DFSYS_FAT=1"
+fi
+
+FSYS_FFS="fsys_ffs.$ac_objext"
+AC_ARG_ENABLE(ffs,
+  [  --disable-ffs           Disable FFS support in stage2],
+  [if test x"$enable_ffs" = xno; then
+     FSYS_FFS=
+   fi])
+AC_SUBST(FSYS_FFS)
+if test x"$FSYS_FFS" != x; then
+  FSYS_CFLAGS="$FSYS_CFLAGS -DFSYS_FFS=1"
+fi
+
+AC_SUBST(FSYS_CFLAGS)
+
 AC_OUTPUT([Makefile stage1/Makefile stage2/Makefile docs/Makefile \
        debian/Makefile grub/Makefile])
diff -urN grub/stage2/Makefile.am grub.new/stage2/Makefile.am
--- grub/stage2/Makefile.am     Fri Jul 16 09:51:59 1999
+++ grub.new/stage2/Makefile.am Tue Aug 10 02:56:49 1999
@@ -35,10 +35,12 @@
 # asm.S absolutely needs to come first!
 # For stage2 target.
 stage2_exec_SOURCES = asm.S boot.c common.c char_io.c cmdline.c \
-       disk_io.c gunzip.c fsys_ffs.c fsys_ext2fs.c fsys_fat.c stage2.c \
-       bios.c smp-imps.c
-stage2_exec_CFLAGS = $(STAGE2_COMPILE)
+       disk_io.c gunzip.c stage2.c bios.c smp-imps.c
+EXTRA_stage2_exec_SOURCES = fsys_ffs.c fsys_ext2fs.c fsys_fat.c
+stage2_exec_CFLAGS = $(STAGE2_COMPILE) @FSYS_CFLAGS@
 stage2_exec_LDFLAGS = $(STAGE2_LINK)
+stage2_exec_LDADD = @FSYS_EXT2FS@ @FSYS_FAT@ @FSYS_FFS@
+stage2_exec_DEPENDENCIES = $(stage2_exec_LDADD)
 
 # For e2fs_stage1_5 target.
 e2fs_stage1_5_exec_SOURCES = asm.S common.c char_io.c disk_io.c \
diff -urN grub/stage2/filesys.h grub.new/stage2/filesys.h
--- grub/stage2/filesys.h       Thu Jun 24 04:03:18 1999
+++ grub.new/stage2/filesys.h   Tue Aug 10 03:33:44 1999
@@ -22,10 +22,10 @@
 #include "pc_slice.h"
 
 /*
- *  Default to all functioning filesystems enabled
+ *  Enable all functioning filesystems for /sbin/grub
  */
 
-#if !( defined(FSYS_FFS) || defined(FSYS_FAT) || defined(FSYS_EXT2FS) )
+#ifdef GRUB_UTIL
 #define FSYS_FFS
 #define FSYS_FAT
 #define FSYS_EXT2FS
diff -urN grub/stage2/fsys_ext2fs.c grub.new/stage2/fsys_ext2fs.c
--- grub/stage2/fsys_ext2fs.c   Mon Aug  9 21:22:01 1999
+++ grub.new/stage2/fsys_ext2fs.c       Tue Aug 10 03:23:03 1999
@@ -20,6 +20,11 @@
 
 
 #include "shared.h"
+
+#ifndef FSYS_EXT2FS
+#define FSYS_EXT2FS
+#endif
+
 #include "filesys.h"
 
 static int mapblock1, mapblock2;
diff -urN grub/stage2/fsys_fat.c grub.new/stage2/fsys_fat.c
--- grub/stage2/fsys_fat.c      Mon Aug  9 21:22:01 1999
+++ grub.new/stage2/fsys_fat.c  Tue Aug 10 03:23:48 1999
@@ -20,6 +20,10 @@
 
 #include "shared.h"
 
+#ifndef FSYS_FAT
+#define FSYS_FAT
+#endif
+
 #include "filesys.h"
 
 #include "fat.h"
diff -urN grub/stage2/fsys_ffs.c grub.new/stage2/fsys_ffs.c
--- grub/stage2/fsys_ffs.c      Mon Aug  9 21:22:01 1999
+++ grub.new/stage2/fsys_ffs.c  Tue Aug 10 03:24:13 1999
@@ -57,6 +57,10 @@
 
 #include "shared.h"
 
+#ifndef FSYS_FFS
+#define FSYS_FFS
+#endif
+
 #include "filesys.h"
 
 #include "defs.h"

Reply via email to