From d9743fd28e64cddb74c734350431f33e60cc74d7 Mon Sep 17 00:00:00 2001 From: Antoine Leca Date: Fri, 19 Aug 2016 18:58:32 +0200 Subject: [PATCH 1/3] Kyua framework does not build up with /usr/obj Reported to NetBSD as PR/51389, fix by dholland http://gnats.netbsd.org/51389 Change-Id: Ib31662000255a62261fb461fcab2d931faa47f70 --- .../kyua-testers/libexec/kyua-atf-tester/Makefile | 13 +++++++------ .../kyua-testers/libexec/kyua-plain-tester/Makefile | 8 ++++---- .../bsd/kyua-testers/tests/kyua-testers/Makefile | 13 +++++++------ 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/external/bsd/kyua-testers/libexec/kyua-atf-tester/Makefile b/external/bsd/kyua-testers/libexec/kyua-atf-tester/Makefile index 04c4be2dc..dd5150747 100644 --- a/external/bsd/kyua-testers/libexec/kyua-atf-tester/Makefile +++ b/external/bsd/kyua-testers/libexec/kyua-atf-tester/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.1 2013/02/19 06:04:43 jmmv Exp $ +# $NetBSD: Makefile,v 1.3 2016/08/26 23:55:04 dholland Exp $ .include @@ -11,11 +11,12 @@ SRCS= atf_main.c MAN= kyua-atf-tester.1 MAN+= kyua-atf-interface.7 -PRIVATELIBDIR!= cd ${.CURDIR}/../../lib; ${PRINTOBJDIR} -LDADD+= ${PRIVATELIBDIR}/libatf_tester/libatf_tester.a -DPADD+= ${PRIVATELIBDIR}/libatf_tester/libatf_tester.a -LDADD+= ${PRIVATELIBDIR}/libtester/libtester.a -DPADD+= ${PRIVATELIBDIR}/libtester/libtester.a +ATFTESTER_LIBDIR!= cd ${.CURDIR}/../../lib/libatf_tester; ${PRINTOBJDIR} +TESTER_LIBDIR!= cd ${.CURDIR}/../../lib/libtester; ${PRINTOBJDIR} +LDADD+= ${ATFTESTER_LIBDIR}/libatf_tester.a +DPADD+= ${ATFTESTER_LIBDIR}/libatf_tester.a +LDADD+= ${TESTER_LIBDIR}/libtester.a +DPADD+= ${TESTER_LIBDIR}/libtester.a CPPFLAGS+= -DHAVE_CONFIG_H CPPFLAGS+= -I${.CURDIR}/../../lib/libtester diff --git a/external/bsd/kyua-testers/libexec/kyua-plain-tester/Makefile b/external/bsd/kyua-testers/libexec/kyua-plain-tester/Makefile index ac13ea6fe..d723de397 100644 --- a/external/bsd/kyua-testers/libexec/kyua-plain-tester/Makefile +++ b/external/bsd/kyua-testers/libexec/kyua-plain-tester/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.1 2013/02/19 06:04:43 jmmv Exp $ +# $NetBSD: Makefile,v 1.3 2016/08/26 23:55:04 dholland Exp $ .include @@ -11,9 +11,9 @@ SRCS= plain_main.c MAN= kyua-plain-tester.1 MAN+= kyua-plain-interface.7 -PRIVATELIBDIR!= cd ${.CURDIR}/../../lib; ${PRINTOBJDIR} -LDADD+= ${PRIVATELIBDIR}/libtester/libtester.a -DPADD+= ${PRIVATELIBDIR}/libtester/libtester.a +TESTER_LIBDIR!= cd ${.CURDIR}/../../lib/libtester; ${PRINTOBJDIR} +LDADD+= ${TESTER_LIBDIR}/libtester.a +DPADD+= ${TESTER_LIBDIR}/libtester.a CPPFLAGS+= -DHAVE_CONFIG_H CPPFLAGS+= -I${.CURDIR}/../../lib/libtester diff --git a/external/bsd/kyua-testers/tests/kyua-testers/Makefile b/external/bsd/kyua-testers/tests/kyua-testers/Makefile index 981ff2152..7f7bb2b44 100644 --- a/external/bsd/kyua-testers/tests/kyua-testers/Makefile +++ b/external/bsd/kyua-testers/tests/kyua-testers/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.1 2013/02/19 06:04:44 jmmv Exp $ +# $NetBSD: Makefile,v 1.3 2016/08/26 23:55:04 dholland Exp $ .include @@ -12,11 +12,12 @@ CPPFLAGS+= -DTESTERSDIR=\"/usr/libexec\" CPPFLAGS+= -I${.CURDIR}/../../lib/libtester CPPFLAGS+= -I${SRCDIR} -PRIVATELIBDIR!= cd ${.CURDIR}/../../lib; ${PRINTOBJDIR} -.for lib in atf_tester tester -LDADD+= ${PRIVATELIBDIR}/lib${lib}/lib${lib}.a -DPADD+= ${PRIVATELIBDIR}/lib${lib}/lib${lib}.a -.endfor +ATFTESTER_LIBDIR!= cd ${.CURDIR}/../../lib/libatf_tester; ${PRINTOBJDIR} +TESTER_LIBDIR!= cd ${.CURDIR}/../../lib/libtester; ${PRINTOBJDIR} +LDADD+= ${ATFTESTER_LIBDIR}/libatf_tester.a +DPADD+= ${ATFTESTER_LIBDIR}/libatf_tester.a +LDADD+= ${TESTER_LIBDIR}/libtester.a +DPADD+= ${TESTER_LIBDIR}/libtester.a TESTS_C= atf_list_test TESTS_C+= atf_result_test From 89afdb5848033571b0ef7e083104ad1640e0d82a Mon Sep 17 00:00:00 2001 From: Antoine Leca Date: Mon, 29 Aug 2016 14:12:06 +0200 Subject: [PATCH 2/3] Obey HAVE_GOLD=no to no intent to build gold This is useful when the host C++ compiler is broken or not compliant. Change-Id: I09933e81ae07e95e5696b177cd4670cab33ce6c1 --- tools/binutils/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/binutils/Makefile b/tools/binutils/Makefile index 79fa6a822..1878deca8 100644 --- a/tools/binutils/Makefile +++ b/tools/binutils/Makefile @@ -37,7 +37,7 @@ ALL_TARGET+= all-gprof INSTALL_TARGET+=install-gprof .endif -.if defined(__MINIX) +.if defined(__MINIX) && ${HAVE_GOLD:Uyes} != "no" ALL_TARGET+= all-gold INSTALL_TARGET+=install-gold From 19e0754978c594d11a2c093cdf6737e67c686936 Mon Sep 17 00:00:00 2001 From: Antoine Leca Date: Mon, 29 Aug 2016 13:48:31 +0200 Subject: [PATCH 3/3] 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 --- external/gpl3/binutils/lib/libbfd/Makefile | 11 +++ external/gpl3/binutils/lib/libiberty/Makefile | 11 +++ .../gpl3/binutils/lib/libopcodes/Makefile | 11 +++ gnu/Makefile | 4 -- gnu/dist/Makefile | 18 ----- gnu/usr.bin/texinfo/makedoc/Makefile | 12 ++++ minix/Makefile.fetchgnu | 71 +++++++++++++++++++ tools/Makefile.gnuhost | 24 +------ tools/binutils/Makefile | 13 ++-- 9 files changed, 126 insertions(+), 49 deletions(-) delete mode 100644 gnu/dist/Makefile create mode 100644 minix/Makefile.fetchgnu diff --git a/external/gpl3/binutils/lib/libbfd/Makefile b/external/gpl3/binutils/lib/libbfd/Makefile index 195fb93fd..e08e3c82c 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 + 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 diff --git a/external/gpl3/binutils/lib/libiberty/Makefile b/external/gpl3/binutils/lib/libiberty/Makefile index 41a05d87b..c621f0de8 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 + 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 diff --git a/external/gpl3/binutils/lib/libopcodes/Makefile b/external/gpl3/binutils/lib/libopcodes/Makefile index 515ee8490..a41ca2001 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 + 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 + .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..e54604c07 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 diff --git a/minix/Makefile.fetchgnu b/minix/Makefile.fetchgnu new file mode 100644 index 000000000..540036dd0 --- /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_) \ No newline at end of file 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}