From owner-freebsd-current Thu Jul 31 04:34:55 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id EAA00676 for current-outgoing; Thu, 31 Jul 1997 04:34:55 -0700 (PDT) Received: from silvia.HIP.Berkeley.EDU (silvia.HIP.Berkeley.EDU [136.152.64.181]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id EAA00630; Thu, 31 Jul 1997 04:34:42 -0700 (PDT) Received: (from asami@localhost) by silvia.HIP.Berkeley.EDU (8.8.6/8.6.9) id EAA16307; Thu, 31 Jul 1997 04:34:38 -0700 (PDT) Date: Thu, 31 Jul 1997 04:34:38 -0700 (PDT) Message-Id: <199707311134.EAA16307@silvia.HIP.Berkeley.EDU> To: committers@freebsd.org CC: current@freebsd.org, stable@freebsd.org Reply-to: committers@freebsd.org Subject: A whole new world From: asami@cs.berkeley.edu (Satoshi Asami) Sender: owner-freebsd-current@freebsd.org X-Loop: FreeBSD.org Precedence: bulk Here is a patch for 2.2-stable. As I said elsewhere, I don't have a 3.0-machine anymore, so that has to wait until thud comes back online. I believe -current people will have a reasonably good success by checking out a 2.2 /usr/src/Makefile, applying the patch, and just using that Makefile (IIRC, the previous patch made -current and -stable src/Makefile's look almost the same) in conjunction with the following patches to src/share/mk: %%%%%%%%%%%%%%%%%%% Index: share/mk/bsd.lib.mk =================================================================== RCS file: /usr/cvs/src/share/mk/bsd.lib.mk,v retrieving revision 1.59 diff -u -r1.59 bsd.lib.mk --- bsd.lib.mk 1997/06/21 15:40:32 1.59 +++ bsd.lib.mk 1997/07/01 21:15:03 @@ -186,10 +186,12 @@ > $$TMP; \ mv $$TMP ${DEPENDFILE} .endif +.if !defined(NOEXTRADEPEND) _EXTRADEPEND:: echo lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}: \ `${LDDESTDIRENV} ${CC} -shared -Wl,-f ${LDDESTDIR} ${LDADD}` \ >> ${DEPENDFILE} +.endif .if !target(install) .if !target(beforeinstall) Index: share/mk/bsd.prog.mk =================================================================== RCS file: /usr/cvs/src/share/mk/bsd.prog.mk,v retrieving revision 1.52 diff -u -r1.52 bsd.prog.mk --- bsd.prog.mk 1997/06/28 08:14:10 1.52 +++ bsd.prog.mk 1997/07/01 21:15:03 @@ -68,7 +68,7 @@ .endif .endif -.if defined(PROG) +.if defined(PROG) && !defined(NOEXTRADEPEND) _EXTRADEPEND: echo ${PROG}: `${CC} -Wl,-f ${CFLAGS} ${LDFLAGS} ${LDDESTDIR} \ ${LDADD:S/^/-Wl,/}` >> ${DEPENDFILE} %%%%%%%%%%%%%%%%%%% This isn't really necessary unless you are building -current on a very old system. If your source tree is -stable, you don't need the above patch (it won't apply anyway ;). Now, here is a patch to Makefile. %%%%%%%%%%%%%%%%%%% Index: Makefile =================================================================== RCS file: /usr/cvs/src/Makefile,v retrieving revision 1.109.2.8 diff -u -r1.109.2.8 Makefile --- Makefile 1997/07/31 08:32:42 1.109.2.8 +++ Makefile 1997/07/31 08:41:42 @@ -31,6 +31,9 @@ # /usr/share/mk. These include: # obj depend all install clean cleandepend cleanobj +.if (!make(world)) && (!make(buildworld)) && (!make(installworld)) +.MAKEFLAGS:= ${.MAKEFLAGS} -m ${.CURDIR}/share/mk +.endif # Put initial settings here. SUBDIR= @@ -113,8 +116,8 @@ .endif .endif -SUP?= sup -SUPFLAGS?= -v +SUP?= sup +SUPFLAGS?= -v # # While building tools for bootstrapping, we dont need to waste time on @@ -135,98 +138,151 @@ @echo "make world started on `LC_TIME=C date`" @echo "--------------------------------------------------------------" .if target(pre-world) + @echo @echo "--------------------------------------------------------------" @echo " Making 'pre-world' target" @echo "--------------------------------------------------------------" cd ${.CURDIR} && ${MAKE} pre-world - @echo .endif - @echo "--------------------------------------------------------------" - @echo " Making hierarchy" - @echo "--------------------------------------------------------------" - cd ${.CURDIR} && ${MAKE} hierarchy + cd ${.CURDIR} && ${MAKE} buildworld + cd ${.CURDIR} && ${MAKE} installworld +.if target(post-world) @echo @echo "--------------------------------------------------------------" - @echo " Rebuilding /usr/share/mk" + @echo " Making 'post-world' target" @echo "--------------------------------------------------------------" - cd ${.CURDIR} && ${MAKE} mk + cd ${.CURDIR} && ${MAKE} post-world +.endif @echo @echo "--------------------------------------------------------------" - @echo " Cleaning up the source tree" + @echo "make world completed on `LC_TIME=C date`" @echo "--------------------------------------------------------------" -.if defined(NOCLEAN) - @echo "Not cleaning anything! I sure hope you know what you are doing!" + +.if defined(MAKEOBJDIRPREFIX) +WORLDTMP= ${MAKEOBJDIRPREFIX}${.CURDIR}/tmp .else - cd ${.CURDIR} && ${MAKE} ${CLEANDIR} +WORLDTMP= /usr/obj${.CURDIR}/tmp .endif +STRICTTMPPATH= ${WORLDTMP}/sbin:${WORLDTMP}/usr/sbin:${WORLDTMP}/bin:${WORLDTMP}/usr/bin +TMPPATH= ${STRICTTMPPATH}:${PATH} + +# XXX COMPILER_PATH is needed for finding cc1, ld and as +# XXX GCC_EXEC_PREFIX is for *crt.o. It is probably unnecssary now +# tbat LIBRARY_PATH is set. We still can't use -nostdlib, since gcc +# wouldn't link *crt.o or libgcc if it were used. +# XXX LD_LIBRARY_PATH is for ld.so. It is also used by ld, although we don't +# want that - all compile-time library paths should be resolved by gcc. +# It fails for set[ug]id executables (are any used?). +COMPILER_ENV= BISON_SIMPLE=${WORLDTMP}/usr/share/misc/bison.simple \ + COMPILER_PATH=${WORLDTMP}/usr/libexec:${WORLDTMP}/usr/bin \ + GCC_EXEC_PREFIX=${WORLDTMP}/usr/lib/ \ + LD_LIBRARY_PATH=${WORLDTMP}${SHLIBDIR} \ + LIBRARY_PATH=${WORLDTMP}${SHLIBDIR}:${WORLDTMP}/usr/lib + +BMAKEENV= PATH=${TMPPATH} ${COMPILER_ENV} NOEXTRADEPEND=t +XMAKEENV= PATH=${STRICTTMPPATH} ${COMPILER_ENV} \ + CC='cc -nostdinc' # XXX -nostdlib + +# used to compile and install 'make' in temporary build tree +IBMAKE= ${BMAKEENV} ${MAKE} DESTDIR=${WORLDTMP} +# bootstrap make +BMAKE= ${BMAKEENV} ${WORLDTMP}/usr/bin/${MAKE} DESTDIR=${WORLDTMP} +# cross make used for compilation +XMAKE= ${XMAKEENV} ${WORLDTMP}/usr/bin/${MAKE} DESTDIR=${WORLDTMP} +# cross make used for final installation +IXMAKE= ${XMAKEENV} ${WORLDTMP}/usr/bin/${MAKE} + +# +# buildworld +# +# Attempt to rebuild the entire system, with reasonable chance of +# success, regardless of how old your existing system is. +# +buildworld: +.if !defined(NOCLEAN) @echo -.if !defined(NOOBJDIR) @echo "--------------------------------------------------------------" - @echo " Rebuilding the obj tree" + @echo " Cleaning up the temporary build tree" @echo "--------------------------------------------------------------" - cd ${.CURDIR} && ${MAKE} obj - @echo + mkdir -p ${WORLDTMP} + chflags -R noschg ${WORLDTMP}/ + rm -rf ${WORLDTMP} .endif + @echo @echo "--------------------------------------------------------------" - @echo " Rebuilding bootstrap tools" + @echo " Making make" @echo "--------------------------------------------------------------" - cd ${.CURDIR} && ${MAKE} bootstrap + mkdir -p ${WORLDTMP}/usr/bin + cd ${.CURDIR}/usr.bin/make && \ + ${IBMAKE} -I${.CURDIR}/share/mk ${OBJDIR} clean cleandepend depend && \ + ${IBMAKE} -I${.CURDIR}/share/mk ${MK_FLAGS} all install clean cleandepend @echo @echo "--------------------------------------------------------------" - @echo " Rebuilding tools necessary to build the include files" + @echo " Making hierarchy" @echo "--------------------------------------------------------------" - cd ${.CURDIR} && ${MAKE} include-tools + cd ${.CURDIR} && ${BMAKE} hierarchy +.if !defined(NOCLEAN) @echo @echo "--------------------------------------------------------------" - @echo " Rebuilding /usr/include" + @echo " Cleaning up the obj tree" @echo "--------------------------------------------------------------" - cd ${.CURDIR} && ${MAKE} includes + cd ${.CURDIR} && ${BMAKE} ${CLEANDIR} +.endif +.if !defined(NOOBJDIR) @echo @echo "--------------------------------------------------------------" - @echo " Rebuilding tools needed to build the libraries" + @echo " Rebuilding the obj tree" @echo "--------------------------------------------------------------" - cd ${.CURDIR} && ${MAKE} lib-tools + cd ${.CURDIR} && ${BMAKE} obj +.endif @echo @echo "--------------------------------------------------------------" - @echo " Rebuilding /usr/lib" + @echo " Rebuilding bootstrap tools" @echo "--------------------------------------------------------------" - cd ${.CURDIR} && ${MAKE} libraries + cd ${.CURDIR} && ${BMAKE} bootstrap @echo @echo "--------------------------------------------------------------" - @echo " Rebuilding symorder, groff and zic(8)" + @echo " Rebuilding tools necessary to build the include files" @echo "--------------------------------------------------------------" - cd ${.CURDIR} && ${MAKE} build-tools + cd ${.CURDIR} && ${BMAKE} include-tools @echo @echo "--------------------------------------------------------------" - @echo " Rebuilding dependencies" + @echo " Rebuilding /usr/include" @echo "--------------------------------------------------------------" - cd ${.CURDIR} && ${MAKE} depend + cd ${.CURDIR} && ${BMAKE} includes @echo @echo "--------------------------------------------------------------" - @echo " Building everything.." + @echo " Rebuilding tools needed to build the libraries" @echo "--------------------------------------------------------------" - cd ${.CURDIR} && ${MAKE} all + cd ${.CURDIR} && ${BMAKE} lib-tools @echo @echo "--------------------------------------------------------------" - @echo " Installing everything.." + @echo " Rebuilding /usr/lib" @echo "--------------------------------------------------------------" - cd ${.CURDIR} && ${MAKE} install + cd ${.CURDIR} && ${BMAKE} libraries @echo @echo "--------------------------------------------------------------" - @echo " Rebuilding man page indexes" + @echo " Rebuilding all other tools needed to build the world" @echo "--------------------------------------------------------------" - cd ${.CURDIR}/share/man && ${MAKE} makedb -.if target(post-world) + cd ${.CURDIR} && ${BMAKE} build-tools @echo @echo "--------------------------------------------------------------" - @echo " Making 'post-world' target" + @echo " Rebuilding dependencies" @echo "--------------------------------------------------------------" - cd ${.CURDIR} && ${MAKE} post-world -.endif + cd ${.CURDIR} && ${XMAKE} depend @echo @echo "--------------------------------------------------------------" - @echo "make world completed on `LC_TIME=C date`" + @echo " Building everything.." @echo "--------------------------------------------------------------" + cd ${.CURDIR} && ${XMAKE} all + +# +# installworld +# +# Installs everything compiled by a 'buildworld'. +# +installworld: + cd ${.CURDIR} && ${IXMAKE} reinstall # # reinstall @@ -242,11 +298,6 @@ cd ${.CURDIR} && ${MAKE} hierarchy @echo @echo "--------------------------------------------------------------" - @echo " Rebuilding /usr/share/mk" - @echo "--------------------------------------------------------------" - cd ${.CURDIR} && ${MAKE} mk - @echo - @echo "--------------------------------------------------------------" @echo " Installing everything.." @echo "--------------------------------------------------------------" cd ${.CURDIR} && ${MAKE} install @@ -256,7 +307,6 @@ @echo "--------------------------------------------------------------" cd ${.CURDIR}/share/man && ${MAKE} makedb - # # update # @@ -283,7 +333,6 @@ cd ${.CURDIR} && cvs -q update -P -d .endif - # # most # @@ -351,17 +400,17 @@ cd ${.CURDIR}/etc && ${MAKE} distrib-dirs # -# mk - update the /usr/share/mk makefiles. -# -mk: - cd ${.CURDIR}/share/mk && ${MAKE} install - -# # bootstrap - [re]build tools needed to run the actual build, this includes # tools needed by 'make depend', as some tools are needed to generate source # for the dependency information to be gathered from. # bootstrap: +.if defined(DESTDIR) + rm -f ${DESTDIR}/usr/src/sys + ln -s ${.CURDIR}/sys ${DESTDIR}/usr/src + cd ${.CURDIR}/include && find -dx . | cpio -dump ${DESTDIR}/usr/include + cd ${.CURDIR}/include && make symlinks +.endif cd ${.CURDIR}/usr.bin/make && ${MAKE} depend && \ ${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR} cd ${.CURDIR}/usr.bin/xinstall && ${MAKE} depend && \ @@ -373,11 +422,13 @@ # include-tools - generally the same as 'bootstrap', except that it's for # things that are specifically needed to generate include files. # -# XXX should be merged with bootstrap, it's not worth keeeping them seperate +# XXX should be merged with bootstrap, it's not worth keeeping them separate. +# Well, maybe it is now. We force 'cleandepend' here to avoid dependencies +# on cleaned away headers in ${WORLDTMP}. # include-tools: - cd ${.CURDIR}/usr.bin/rpcgen && ${MAKE} depend && \ - ${MAKE} ${MK_FLAGS} depend all install ${CLEANDIR} ${OBJDIR} + cd ${.CURDIR}/usr.bin/rpcgen && ${MAKE} cleandepend depend && \ + ${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR} # # includes - possibly generate and install the include files. @@ -388,8 +439,7 @@ mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \ -p ${DESTDIR}/usr/include .endif - cd ${.CURDIR}/include/rpcsvc && ${MAKE} all - cd ${.CURDIR}/include && ${MAKE} install + cd ${.CURDIR}/include && ${MAKE} all install cd ${.CURDIR}/gnu/include && ${MAKE} install cd ${.CURDIR}/gnu/lib/libreadline && ${MAKE} beforeinstall cd ${.CURDIR}/gnu/lib/libregex && ${MAKE} beforeinstall @@ -422,36 +472,31 @@ cd ${.CURDIR}/lib/libss && ${MAKE} beforeinstall cd ${.CURDIR}/lib/libscsi && ${MAKE} beforeinstall cd ${.CURDIR}/lib/libutil && ${MAKE} beforeinstall + cd ${.CURDIR}/lib/libz && ${MAKE} beforeinstall # # lib-tools - build tools to compile and install the libraries. # +# XXX gperf is required for cc +# XXX a new ld and tsort is required for cc lib-tools: - cd ${.CURDIR}/usr.bin/tsort && ${MAKE} depend && \ - ${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR} - cd ${.CURDIR}/gnu/usr.bin/ld && ${MAKE} depend && \ - ${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR} - cd ${.CURDIR}/gnu/usr.bin/as && ${MAKE} depend && \ - ${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR} - cd ${.CURDIR}/usr.bin/ar && ${MAKE} depend && \ - ${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR} - cd ${.CURDIR}/usr.bin/ranlib && ${MAKE} depend && \ - ${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR} - cd ${.CURDIR}/usr.bin/nm && ${MAKE} depend && \ - ${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR} - cd ${.CURDIR}/usr.bin/lex/lib && ${MAKE} depend && \ - ${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR} - cd ${.CURDIR}/usr.bin/compile_et && ${MAKE} depend && \ - ${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR} && \ - rm -f /usr/sbin/compile_et - cd ${.CURDIR}/usr.bin/mk_cmds && ${MAKE} depend && \ - ${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR} - cd ${.CURDIR}/gnu/usr.bin/bison && ${MAKE} depend && \ - ${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR} - cd ${.CURDIR}/gnu/usr.bin/gperf && ${MAKE} depend && \ - ${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR} - cd ${.CURDIR}/gnu/usr.bin/cc && ${MAKE} depend && \ +.for d in \ + gnu/usr.bin/gperf \ + gnu/usr.bin/ld \ + usr.bin/tsort \ + gnu/usr.bin/as \ + gnu/usr.bin/bison \ + gnu/usr.bin/cc \ + usr.bin/ar \ + usr.bin/compile_et \ + usr.bin/lex/lib \ + usr.bin/mk_cmds \ + usr.bin/nm \ + usr.bin/ranlib \ + usr.bin/uudecode + cd ${.CURDIR}/$d && ${MAKE} depend && \ ${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR} +.endfor # # libraries - build and install the libraries @@ -501,15 +546,70 @@ # # build-tools - build and install any other tools needed to complete the # compile and install. +# ifdef stale +# bc and cpp are required to build groff. Otherwise, the order here is +# mostly historical, i.e., bogus. +# chmod is used to build gcc's tmpmultilib[2] at obscure times. +# endif stale +# XXX uname is a bug - the target should not depend on the host. # build-tools: .for d in \ + bin/cat \ + bin/chmod \ + bin/cp \ + bin/date \ + bin/dd \ + bin/echo \ + bin/expr \ + bin/hostname \ + bin/ln \ + bin/ls \ + bin/mkdir \ + bin/mv \ + bin/rm \ + bin/sh \ + bin/test \ + gnu/usr.bin/awk \ + gnu/usr.bin/bc \ + gnu/usr.bin/grep \ + gnu/usr.bin/groff \ + gnu/usr.bin/gzip \ + gnu/usr.bin/man/makewhatis \ + gnu/usr.bin/sort \ + gnu/usr.bin/texinfo \ share/info \ - gnu/usr.bin/texinfo \ + usr.bin/basename \ + usr.bin/cap_mkdb \ + usr.bin/chflags \ + usr.bin/cmp \ + usr.bin/col \ + usr.bin/cpp \ + usr.bin/expand \ + usr.bin/file2c \ + usr.bin/find \ + usr.bin/gencat \ + usr.bin/lorder \ + usr.bin/m4 \ + usr.bin/mkdep \ + usr.bin/paste \ + usr.bin/sed \ + usr.bin/size \ + usr.bin/soelim \ + usr.bin/strip \ usr.bin/symorder \ - usr.sbin/zic \ - gnu/usr.bin/awk \ - gnu/usr.bin/groff + usr.bin/touch \ + usr.bin/tr \ + usr.bin/true \ + usr.bin/uname \ + usr.bin/uuencode \ + usr.bin/vgrind \ + usr.bin/vi \ + usr.bin/wc \ + usr.bin/yacc \ + usr.sbin/chown \ + usr.sbin/mtree \ + usr.sbin/zic cd ${.CURDIR}/$d && ${MAKE} depend && \ ${MAKE} ${MK_FLAGS} all install ${CLEANDIR} ${OBJDIR} .endfor %%%%%%%%%%%%%%%%%%% Basically what it does is to split "world" into two parts, "buildworld" and "installworld", which can be run together or separately (or even on different machines). The "buildworld" target does not install anything outside /usr/obj; you still need to be root to run it (the default install rules want to set the ownership, etc.), but it's now possible to upgrade a bunch of -stable machines by running "make buildworld" on a 2.1.5 NFS server and then running "make installworld" on each of the clients, while not compromising the stability of the server at all. (Trust me, I've done exactly that last week. :) One thing this patch does not address (i.e., I tried, but gave up) is that your source tree still has to be called "/usr/src" -- there are far too many brokenness in the tree for me to fix by myself (and those can be hunted down/fixed independently of this project anyway). If that can be fixed, the above NFS server in the example above can even build binaries for -current and -stable machines simultaneously. If someone can take a stab at this, it is great. I would like people, especially those with very old systems, to try to upgrade your machine by using this Makefile. Everything (except for upgrading /etc) should be done with a single "make world", followed by a kernel rebuild and reboot; if it doesn't, then there is something wrong, and I want to know about it. Thanks! Satoshi