David!

As you have been warned, revisions 1.19 and 1.20 to file/Makefile
broke cross builds and upgrade path from 4.x to 5.0.  This is due
to the use of just built ./file binary to produce magic.mgc and
magic.mime.mgc files.  In the case of 4.x->5.0 upgrade, buildworld
bombs with

./file -C -m magic
/usr/libexec/ld-elf.so.1: Shared object "libc.so.5" not found
*** Error code 1

when trying to compile the "magic" file.  In the cross build case,
the "./file" binary is targetted for a different platform.

The attached patch adds `build-tools' target to usr.bin/file that
build "xfile" binary on the host platform, and that is used to
compile magic and magic.mime file.  (This is done similar to how
it's done in usr.bin/sysinstall, in case you wonder.)

Simply adding usr.bin/file to bootstrap-tools did not work because
the "all" target in file/Makefile depends on .mgc files, and this
requires -C flag to be available at "make all" in usr.bin/file when
running through `bootstrap-tools' stage of Makefile.inc1.  Actually,
we can still bootstrap the file(1), and use it later at `buildworld'
time, but this is somewhat tricky.  We would:

1)  Add usr.bin/file to bootstrap-tools
2)  Add -DBOOTSTRAPPING flag to ${BMAKE}
3)  Check this flag from within file/Makefile

If this flag is set, we could skip building/installing .mgc
files.

But by concept, this should be a build-tool anyway.  It just
appears to be the first precedence where a tool is also a
build tool.  (Compare with sysinstall.)


Cheers,
-- 
Ruslan Ermilov          Oracle Developer/DBA,
[EMAIL PROTECTED]           Sunbay Software AG,
[EMAIL PROTECTED]          FreeBSD committer,
+380.652.512.251        Simferopol, Ukraine

http://www.FreeBSD.org  The Power To Serve
http://www.oracle.com   Enabling The Information Age
Index: Makefile.inc1
===================================================================
RCS file: /home/ncvs/src/Makefile.inc1,v
retrieving revision 1.208
diff -u -r1.208 Makefile.inc1
--- Makefile.inc1       2001/08/04 18:25:38     1.208
+++ Makefile.inc1       2001/08/09 09:21:15
@@ -600,7 +600,8 @@
 
 build-tools:
 .for _tool in bin/csh bin/sh ${_games} gnu/usr.bin/cc/cc_tools ${_fortran} \
-    ${_libroken4} ${_libkrb5} lib/libncurses ${_share} usr.sbin/sysinstall
+    ${_libroken4} ${_libkrb5} lib/libncurses ${_share} usr.bin/file \
+    usr.sbin/sysinstall
        cd ${.CURDIR}/${_tool}; ${MAKE} build-tools
 .endfor
 
Index: usr.bin/file/Makefile
===================================================================
RCS file: /home/ncvs/src/usr.bin/file/Makefile,v
retrieving revision 1.21
diff -u -r1.21 Makefile
--- usr.bin/file/Makefile       2001/08/08 16:19:30     1.21
+++ usr.bin/file/Makefile       2001/08/09 09:21:15
@@ -34,23 +34,28 @@
 CFLAGS+= -DMAGIC='"${MAGICPATH}/magic"' -DBUILTIN_ELF -DELFCORE -DHAVE_CONFIG_H
 CFLAGS+= -I${.CURDIR} -I${SRCDIR}
 
-CLEANFILES+=   magic magic.mgc magic.mime.mgc magic.mime.PITA
+CLEANFILES+=   xfile magic magic.mgc magic.mime.mgc magic.mime.PITA
 
 MAGFILES=      ${SRCDIR}/Header\
                ${SRCDIR}/Localstuff\
                ${SRCDIR}/Magdir/[a-z]*
 
-all: file magic magic.mgc magic.mime.mgc
+all: ${PROG} magic magic.mgc magic.mime.mgc
 
+build-tools: xfile
+
+xfile: ${SRCS}
+       ${CC} ${CFLAGS} -o ${.TARGET} ${.ALLSRC}
+
 magic: ${MAGFILES}
        cat ${.ALLSRC} > ${.TARGET}
 
 magic.mgc: file magic
-       ./${PROG} -C -m magic
+       ./xfile -C -m magic
 
 magic.mime.mgc: file magic.mime
        ln -sf ${SRCDIR}/magic.mime magic.mime.PITA
-       ./${PROG} -C -m magic.mime.PITA
+       ./xfile -C -m magic.mime.PITA
        mv magic.mime.PITA.mgc magic.mime.mgc
 
 CLEANFILES+=   print-hacked.c

Reply via email to