From: Antoine Leca Date: Mon, 29 Aug 2016 11:48:31 +0000 (+0200) Subject: Improve the process for GNU tools X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zpipe.c?a=commitdiff_plain;h=refs%2Fchanges%2F55%2F3355%2F3;p=minix.git Improve the process for GNU tools Split the process to fetch GNU tools (until now embedded within tools/Makefile.gnuhost) into a new Makefile.fetchgnu, MINIX-specific hence relocated, which is to be also used to fetch sources even when not building the tools. Use it for binutils too. Improve documentation. Also do not run configure on each run when MKUPDATE=yes The .WAIT serialization instruction between fetching and other configure sources was raising a new run of configure at each compilation. Avoid it by using two rules. Change-Id: Ie24950ccbb5c5067f3c1ea57b7bd8294e4c9445e --- diff --git a/external/gpl3/binutils/lib/libbfd/Makefile b/external/gpl3/binutils/lib/libbfd/Makefile index 195fb93fd..616122a3e 100644 --- a/external/gpl3/binutils/lib/libbfd/Makefile +++ b/external/gpl3/binutils/lib/libbfd/Makefile @@ -27,6 +27,12 @@ DEFS_MK=${.CURDIR}/arch/${BFD_MACHINE_ARCH}/defs.mk DIST= ${NETBSDSRCDIR}/external/gpl3/binutils/dist +.if defined(__MINIX) +# MINIX: make sure sources are fetched, even when tools not built earlier +GNUHOSTDIST= ${DIST} +.include "${.CURDIR}/../../../../../minix/Makefile.fetchgnu" +.endif # defined(__MINIX) + SHLIB_MAJOR= 13 SHLIB_MINOR= 0 @@ -105,3 +111,8 @@ pepigen.c: peXXigen.c pex64igen.c: peXXigen.c ${_MKTARGET_CREATE} ${TOOL_SED} -e s/XX/pex64/g < $> > $@ + +.if defined(__MINIX) && ${USETOOLS} != "yes" +# Trigger the fetch phase, even when not building tools +${SRCS} realdepend realall realinstall: ${fetch_done} +.endif # defined(__MINIX) diff --git a/external/gpl3/binutils/lib/libiberty/Makefile b/external/gpl3/binutils/lib/libiberty/Makefile index 41a05d87b..23fcf9f3e 100644 --- a/external/gpl3/binutils/lib/libiberty/Makefile +++ b/external/gpl3/binutils/lib/libiberty/Makefile @@ -21,6 +21,12 @@ COPTS.regex.c = -Wno-stack-protector DIST= ${NETBSDSRCDIR}/external/gpl3/binutils/dist +.if defined(__MINIX) +# MINIX: make sure sources are fetched, even when tools not built earlier +GNUHOSTDIST= ${DIST} +.include "${.CURDIR}/../../../../../minix/Makefile.fetchgnu" +.endif # defined(__MINIX) + SRCS= ${G_REQUIRED_OFILES:.o=.c} ${G_EXTRA_OFILES:.o=.c} \ ${G_LIBOBJS:.o=.c} ${G_ALLOCA:.o=.c} @@ -30,3 +36,8 @@ CPPFLAGS+= -DHAVE_CONFIG_H -I${.CURDIR}/arch/${BINUTILS_MACHINE_ARCH} \ .PATH: ${DIST}/libiberty .include + +.if defined(__MINIX) && ${USETOOLS} != "yes" +# Trigger the fetch phase, even when not building tools +${SRCS} realdepend realall realinstall: ${fetch_done} +.endif # defined(__MINIX) diff --git a/external/gpl3/binutils/lib/libopcodes/Makefile b/external/gpl3/binutils/lib/libopcodes/Makefile index 515ee8490..63c5e561b 100644 --- a/external/gpl3/binutils/lib/libopcodes/Makefile +++ b/external/gpl3/binutils/lib/libopcodes/Makefile @@ -17,6 +17,12 @@ BFD_MACHINE_ARCH?= ${MACHINE_ARCH:C/armv[4-7]/arm/} DIST= ${NETBSDSRCDIR}/external/gpl3/binutils/dist +.if defined(__MINIX) +# MINIX: make sure sources are fetched, even when tools not built earlier +GNUHOSTDIST= ${DIST} +.include "${.CURDIR}/../../../../../minix/Makefile.fetchgnu" +.endif # defined(__MINIX) + SHLIB_MAJOR= 6 SHLIB_MINOR= 0 @@ -34,6 +40,11 @@ SRCS= ${GSRCS:.lo=.c} ${G_libopcodes_la_SOURCES} .include +.if defined(__MINIX) #&& ${USETOOLS} != "yes" +# Trigger the fetch phase, even when not building tools +${SRCS} realdepend realall realinstall: ${fetch_done} +.endif # defined(__MINIX) + .else .include # do nothing .endif diff --git a/gnu/Makefile b/gnu/Makefile index 41038e359..0800e8544 100644 --- a/gnu/Makefile +++ b/gnu/Makefile @@ -1,9 +1,5 @@ # $NetBSD: Makefile,v 1.17 2010/12/03 21:38:47 plunky Exp $ -.if defined(__MINIX) -#LSC: Trigger fetch.sh script -SUBDIR+= dist .WAIT -.endif # defined(__MINIX) SUBDIR+= usr.bin # Speedup stubs for some subtrees that don't need to run these rules diff --git a/gnu/dist/Makefile b/gnu/dist/Makefile deleted file mode 100644 index 3646a1a4c..000000000 --- a/gnu/dist/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -# LSC FIXME: Hackish way to trigger the fetch phase from here -# in the same way as from tools. - -.include - -MODULE= texinfo - -.include "${.CURDIR}/../../tools/Makefile.gnuhost" - -# Force the mapping to standard targets even when not building tools -# We considere work to be done as soon as the fetch step is done, -# as everything else has to be triggered from /tools or ../usr.bin - -.if ${USETOOLS} != "yes" -realall realinstall: ${GNUHOSTDIST:H}/.gitignore - -.endif - diff --git a/gnu/usr.bin/texinfo/makedoc/Makefile b/gnu/usr.bin/texinfo/makedoc/Makefile index ea7e579a3..145d5db9f 100644 --- a/gnu/usr.bin/texinfo/makedoc/Makefile +++ b/gnu/usr.bin/texinfo/makedoc/Makefile @@ -5,6 +5,13 @@ MAKEDOC= .include "../Makefile.inc" +.if defined(__MINIX) +#LSC: First program within texinfo: trigger fetch.sh script +MODULE= texinfo +GNUHOSTDIST= ${DIST}/${MODULE} +.include "${.CURDIR}/../../../../minix/Makefile.fetchgnu" +.endif # defined(__MINIX) + HOSTPROG= makedoc SRCS= makedoc.c xexit.c xmalloc.c xstrdup.c @@ -13,3 +20,8 @@ HOST_CPPFLAGS+= -I${IDIST}/info -I${IDIST}/lib -I${.CURDIR}/../common HOST_CPPFLAGS+= -DHOSTTOOL .include + +.if defined(__MINIX) && ${USETOOLS} != "yes" +# MINIX: make sure sources are fetched, even when tools not built earlier +${SRCS} realdepend realall realinstall: ${fetch_done} +.endif # defined(__MINIX) diff --git a/minix/Makefile.fetchgnu b/minix/Makefile.fetchgnu new file mode 100644 index 000000000..6f0dddb38 --- /dev/null +++ b/minix/Makefile.fetchgnu @@ -0,0 +1,71 @@ +# NOT NetBSD +# +# Rules used to fetch a GNU package. Expects GNUHOSTDIST to be set +# and to be previously .include'd. +# +# New interface: +# +# * When using the `cleandir' target, defining CLEANFETCHED=yes will +# additionally remove all the fetched files. +# This is particularly useful when a GNU package is updated. +# +# The rest should be operations hidden to the normal programmers. +# +# How to use: (maintainers manual) +# +# * put a fetch.sh script one directory below the GNUHOSTDIST; +# +# * .include "path/to/minix/Makefile.fetchgnu", after having +# defined GNUHOSTDIST and before any use of the variable below; +# +# * insert ${fetch_done} as source before performing any operation +# on the files under GPL license which are usually found +# within NetBSD src/ tree; +# +# * rinse and repeat for every target which assumes the presence of +# these files, and for every Makefile operating upon them. +# +# +# TODO: does not handle correctly the cases where there are more than +# one package downloaded by fetch.sh (e.g.gnu/dist with texinfo+gmake): +# .gitignore only "protects" the first package which triggers. + +.if !defined(__MINIX) || !defined(GNUHOSTDIST) +.error Bad logic in Makefiles. +.endif + +.if !defined(_MINIX_FETCHGNU_MK_) +_MINIX_FETCHGNU_MK_=1 + +# MINIX /usr/src does not have the sources for the GNU utilities +# in-tree, for licensing reasons. So to successfully use them while +# cross-compiling, we have to fetch them. The success of that operation +# is indicated by the presence of a .gitignore file in the corresponding +# source parent directory, which also conveniently hides from git. +.if exists(${GNUHOSTDIST:H}/fetch.sh) +${GNUHOSTDIST:H}/.gitignore: ${GNUHOSTDIST:H}/fetch.sh + SED=${TOOL_SED} ${HOST_SH} ${GNUHOSTDIST:H}/fetch.sh + @test -e ${GNUHOSTDIST}/configure + @echo "${MODULE:U${.CURDIR:T}:C,gcc[0-9]*,gcc,:C,gmake*,make,}-*.tar.*z*" >> $@ + @echo ${GNUHOSTDIST:T} >> $@ + +# Do the fetching as an extra step, to force serialization +.fetch_done: ${GNUHOSTDIST:H}/.gitignore + @touch $@ +fetch_done=.fetch_done + +# Special target for MINIX, reset the source tree as pristine +# Note it does NOT remove the downloaded tarball +.if ${CLEANFETCHED:Uno} == "yes" +cleandir: clean_gnu_src +clean_gnu_src: + -rm -r -f ${GNUHOSTDIST} ${GNUHOSTDIST:H}/.gitignore +.endif # CLEANFETCHED == yes + +clean: clean.fetchgnu +clean.fetchgnu: + -@rm -f .fetch_done + +.endif # exists(GNUHOSTDIST:H/fetch.sh) on MINIX + +.endif # !defined(_MINIX_FETCHGNU_MK_) diff --git a/tools/Makefile.gnuhost b/tools/Makefile.gnuhost index fe2a0c17f..f1342fe48 100644 --- a/tools/Makefile.gnuhost +++ b/tools/Makefile.gnuhost @@ -27,27 +27,7 @@ MAKE_PROGRAM?= ${MAKE} GNUHOSTDIST?= ${.CURDIR}/../../gnu/dist/${MODULE} .if defined(__MINIX) -# AL - MINIX /usr/src does not have the sources for the GNU utilities -# in-tree (they are much bigger than Minix itself!) So to successfully -# use them while cross-compiling, we have to fetch them. The success of -# that operation is indicated by the presence of a .gitignore file in -# the corresponding ${.CURDIR}, which also conveniently hides from git. -.if exists(${GNUHOSTDIST:H}/fetch.sh) -${GNUHOSTDIST:H}/.gitignore: ${GNUHOSTDIST:H}/fetch.sh - SED=${TOOL_SED} ${HOST_SH} ${GNUHOSTDIST:H}/fetch.sh - @test -e ${GNUHOSTDIST}/configure - @echo "${MODULE:U${.CURDIR:T}:C,gcc[0-9]*,gcc,:C,gmake*,make,}-*.tar.*z*" >> $@ - @echo ${GNUHOSTDIST:T} >> $@ -_gnu_get_src=${GNUHOSTDIST:H}/.gitignore -.endif # exists(GNUHOSTDIST:H/fetch.sh) on MINIX - -# AL - Special target for MINIX, reset the source tree as pristine -.if ${CLEANFETCHED:Uno} == "yes" && exists(${GNUHOSTDIST:H}/fetch.sh) -cleandir: clean_gnu_src -clean_gnu_src: - -rm -r -f ${GNUHOSTDIST} ${GNUHOSTDIST:H}/.gitignore -# XXX CHECKME: could have used the content of .gitignore as well? -.endif # CLEANFETCHED == yes +.include "../minix/Makefile.fetchgnu" .endif # defined(__MINIX) FIND_ARGS+= \! \( -type d \( \ @@ -134,7 +114,7 @@ configure_cleanup=configure_cleanup .endif # AL For MINIX, fetch the source if not there -.configure_done: ${_gnu_get_src} .WAIT ${_GNU_CFGSRC} ${.CURDIR}/Makefile ${configure_cleanup} +.configure_done: ${fetch_done} ${_GNU_CFGSRC} ${.CURDIR}/Makefile ${configure_cleanup} @mkdir build 2>/dev/null || true @(cd build && ${CONFIGURE_ENV} ${HOST_SH} ${GNUHOSTDIST}/configure ${CONFIGURE_ARGS}) @echo ${BUILD_PLATFORM} > $@ diff --git a/tools/binutils/Makefile b/tools/binutils/Makefile index 1878deca8..c0b4fa77a 100644 --- a/tools/binutils/Makefile +++ b/tools/binutils/Makefile @@ -16,12 +16,15 @@ CONFIGURE_ARGS= --target=${MACHINE_GNU_PLATFORM} --disable-nls \ --disable-werror \ ${BRANDING} -.if !defined(__MINIX) -build/gas/m68k-parse.c: ${GNUHOSTDIST}/gas/m68k-parse.c -.else +.if defined(__MINIX) && ! exists(${GNUHOSTDIST}/gas/m68k-parse.c) # MINIX: LSC: Make sure we trigger the fetch rule -build/gas/m68k-parse.c: ${GNUHOSTDIST:H}/.gitignore .WAIT ${GNUHOSTDIST}/gas/m68k-parse.c -.endif # !defined(__MINIX) +.include "${.CURDIR}/../../minix/Makefile.fetchgnu" + +${GNUHOSTDIST}/gas/m68k-parse.c: ${fetch_done} + @true +.endif # defined(__MINIX) + +build/gas/m68k-parse.c: ${GNUHOSTDIST}/gas/m68k-parse.c @mkdir build 2>/dev/null || true @mkdir build/gas 2>/dev/null || true cat ${GNUHOSTDIST}/gas/m68k-parse.c > ${.TARGET}