strangeness involving e2fsprogs header files

Robert P. J. Day rpjday at mindspring.com
Mon Jul 3 04:53:00 PDT 2006


  in my travels through the source code, i wandered across the fact
that a number of header file inclusions under e2fsprogs use relative
pathnames:

  e2fsprogs/e2p/uuid.c:#include "../ext2fs/ext2_types.h"
  e2fsprogs/e2p/e2p.h:#include "../ext2fs/ext2_fs.h"
  e2fsprogs/blkid/read.c:#include "../uuid/uuid.h"
  e2fsprogs/ext2fs/mkjournal.c:#include "../e2p/e2p.h"
  e2fsprogs/ext2fs/mkjournal.c:#include "../e2fsck.h"

that sort of thing.  i've never been a fan of locking header file
names to locations like this since it will break immediately if the
directories are restructured.  it always seemed to be more reasonable
to add extra "-I" options to the compile command so that you might do
something like:

  #include "ext2fs/ext2_types.h"
  #include "ext2fs/ext2_fs.h"

now, as i read e2fsprogs/Makefile.in, it would seem that that's
exactly what *should* be happening:

...
# XXX: FIXME: change .c to include their stuff relative to $(E2FSPROGS_SRC)
E2FSPROGS_TMP_KLUDGE:=$(patsubst %,-I$(E2FSPROGS_SRC)/%,blkid e2fsck e2p ext2fs uuid)

APPLETS_DEFINE-y+=$(E2FSPROGS_CFLAGS) -I$(E2FSPROGS_SRC) $(E2FSPROGS_TMP_KLUDGE)
APPLETS_DEFINE-a+=$(E2FSPROGS_CFLAGS) -I$(E2FSPROGS_SRC) $(E2FSPROGS_TMP_KLUDGE)
...

but if i tweak those includes to take advantage of that, the build
breaks:

...
  CC e2fsprogs/ext2fs/mkjournal.o
/home/rpjday/bbx/busybox/e2fsprogs/ext2fs/mkjournal.c:38:20: error:
e2fsck.h: No such file or directory
make[1]: *** [/home/rpjday/bbx/busybox/e2fsprogs/ext2fs/mkjournal.o]
Error 1
make: *** [busybox] Error 2
...

if i build verbosely, here's what i get:

make -C /home/rpjday/bbx/busybox \
        top_srcdir=/home/rpjday/bbx/busybox \
        top_builddir=/home/rpjday/bbx/busybox \
        BUILD_SRC=/home/rpjday/bbx/busybox \
        -f /home/rpjday/bbx/busybox/Makefile busybox
gcc -I/home/rpjday/bbx/busybox/include
-I/home/rpjday/bbx/busybox/include -I/home/rpjday/bbx/busybox/libbb
-D_GNU_SOURCE -Wall -Wstrict-prototypes -Wshadow -funsigned-char
-fno-builtin-strlen -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
-D_FILE_OFFSET_BITS=64 -DNDEBUG -Os -march=i386
-mpreferred-stack-boundary=2 -falign-functions=1 -falign-jumps=1
-falign-loops=1 -fno-tree-loop-optimize -fno-tree-dominator-opts
-fno-strength-reduce -fno-branch-count-reg -fomit-frame-pointer
-ffunction-sections -fdata-sections -Wall -Wstrict-prototypes -Wshadow
-funsigned-char -fno-builtin-strlen -c -o
/home/rpjday/bbx/busybox/e2fsprogs/ext2fs/mkjournal.o
/home/rpjday/bbx/busybox/e2fsprogs/ext2fs/mkjournal.c/home/rpjday/bbx/busybox/e2fsprogs/ext2fs/mkjournal.c:38:20:
error: e2fsck.h: No such file or directory
make[1]: *** [/home/rpjday/bbx/busybox/e2fsprogs/ext2fs/mkjournal.o]
Error 1
make: *** [busybox] Error 2

the problem appears to be that the variable APPLETS_DEFINE is being
used in Rules.mak, but has no effect on the compile step, only the
link step:

 cmd_link           = $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) \
                        $(PROG_CFLAGS) $(PROG_LDFLAGS) $(CFLAGS_COMBINE) \
                        -o $@ $(LD_START_GROUP)  \
                        $(APPLETS_DEFINE) $(APPLET_SRC) \
                        $(BUSYBOX_DEFINE) $(BUSYBOX_SRC) $(libraries-y) \
                        $(LDBUSYBOX) $(LIBRARIES) \
                        $(LD_END_GROUP)

so adding those extra "-I" options to APPLETS_DEFINE doesn't do a
whole lot of good.

  thoughts?

rday


More information about the busybox mailing list