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
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)
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}
.PATH: ${DIST}/libiberty
.include <bsd.lib.mk>
+
+.if defined(__MINIX) && ${USETOOLS} != "yes"
+# Trigger the fetch phase, even when not building tools
+${SRCS} realdepend realall realinstall: ${fetch_done}
+.endif # defined(__MINIX)
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
.include <bsd.lib.mk>
+.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 <bsd.prog.mk> # do nothing
.endif
# $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
+++ /dev/null
-# LSC FIXME: Hackish way to trigger the fetch phase from here
-# in the same way as from tools.
-
-.include <bsd.own.mk>
-
-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
-
.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
HOST_CPPFLAGS+= -DHOSTTOOL
.include <bsd.hostprog.mk>
+
+.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)
--- /dev/null
+# NOT NetBSD
+#
+# Rules used to fetch a GNU package. Expects GNUHOSTDIST to be set
+# and <bsd.own.mk> 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_)
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 \( \
.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} > $@
--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}