Skip to content

Commit

Permalink
Improve the process for GNU tools
Browse files Browse the repository at this point in the history
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
  • Loading branch information
antoineL authored and sambuc committed Sep 1, 2016
1 parent 76c7f3d commit a150b26
Show file tree
Hide file tree
Showing 9 changed files with 126 additions and 49 deletions.
11 changes: 11 additions & 0 deletions external/gpl3/binutils/lib/libbfd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
11 changes: 11 additions & 0 deletions external/gpl3/binutils/lib/libiberty/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand All @@ -30,3 +36,8 @@ CPPFLAGS+= -DHAVE_CONFIG_H -I${.CURDIR}/arch/${BINUTILS_MACHINE_ARCH} \
.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)
11 changes: 11 additions & 0 deletions external/gpl3/binutils/lib/libopcodes/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -34,6 +40,11 @@ SRCS= ${GSRCS:.lo=.c} ${G_libopcodes_la_SOURCES}

.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
4 changes: 0 additions & 4 deletions gnu/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
18 changes: 0 additions & 18 deletions gnu/dist/Makefile

This file was deleted.

12 changes: 12 additions & 0 deletions gnu/usr.bin/texinfo/makedoc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -13,3 +20,8 @@ HOST_CPPFLAGS+= -I${IDIST}/info -I${IDIST}/lib -I${.CURDIR}/../common
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)
71 changes: 71 additions & 0 deletions minix/Makefile.fetchgnu
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# 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_)
24 changes: 2 additions & 22 deletions tools/Makefile.gnuhost
Original file line number Diff line number Diff line change
Expand Up @@ -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 \( \
Expand Down Expand Up @@ -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} > $@
Expand Down
13 changes: 8 additions & 5 deletions tools/binutils/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit a150b26

Please sign in to comment.