Skip to content

Commit a150b26

Browse files
antoineLsambuc
authored andcommitted
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
1 parent 76c7f3d commit a150b26

File tree

9 files changed

+126
-49
lines changed

9 files changed

+126
-49
lines changed

external/gpl3/binutils/lib/libbfd/Makefile

+11
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ DEFS_MK=${.CURDIR}/arch/${BFD_MACHINE_ARCH}/defs.mk
2727

2828
DIST= ${NETBSDSRCDIR}/external/gpl3/binutils/dist
2929

30+
.if defined(__MINIX)
31+
# MINIX: make sure sources are fetched, even when tools not built earlier
32+
GNUHOSTDIST= ${DIST}
33+
.include "${.CURDIR}/../../../../../minix/Makefile.fetchgnu"
34+
.endif # defined(__MINIX)
35+
3036
SHLIB_MAJOR= 13
3137
SHLIB_MINOR= 0
3238

@@ -105,3 +111,8 @@ pepigen.c: peXXigen.c
105111
pex64igen.c: peXXigen.c
106112
${_MKTARGET_CREATE}
107113
${TOOL_SED} -e s/XX/pex64/g < $> > $@
114+
115+
.if defined(__MINIX) && ${USETOOLS} != "yes"
116+
# Trigger the fetch phase, even when not building tools
117+
${SRCS} realdepend realall realinstall: ${fetch_done}
118+
.endif # defined(__MINIX)

external/gpl3/binutils/lib/libiberty/Makefile

+11
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ COPTS.regex.c = -Wno-stack-protector
2121

2222
DIST= ${NETBSDSRCDIR}/external/gpl3/binutils/dist
2323

24+
.if defined(__MINIX)
25+
# MINIX: make sure sources are fetched, even when tools not built earlier
26+
GNUHOSTDIST= ${DIST}
27+
.include "${.CURDIR}/../../../../../minix/Makefile.fetchgnu"
28+
.endif # defined(__MINIX)
29+
2430
SRCS= ${G_REQUIRED_OFILES:.o=.c} ${G_EXTRA_OFILES:.o=.c} \
2531
${G_LIBOBJS:.o=.c} ${G_ALLOCA:.o=.c}
2632

@@ -30,3 +36,8 @@ CPPFLAGS+= -DHAVE_CONFIG_H -I${.CURDIR}/arch/${BINUTILS_MACHINE_ARCH} \
3036
.PATH: ${DIST}/libiberty
3137

3238
.include <bsd.lib.mk>
39+
40+
.if defined(__MINIX) && ${USETOOLS} != "yes"
41+
# Trigger the fetch phase, even when not building tools
42+
${SRCS} realdepend realall realinstall: ${fetch_done}
43+
.endif # defined(__MINIX)

external/gpl3/binutils/lib/libopcodes/Makefile

+11
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ BFD_MACHINE_ARCH?= ${MACHINE_ARCH:C/armv[4-7]/arm/}
1717

1818
DIST= ${NETBSDSRCDIR}/external/gpl3/binutils/dist
1919

20+
.if defined(__MINIX)
21+
# MINIX: make sure sources are fetched, even when tools not built earlier
22+
GNUHOSTDIST= ${DIST}
23+
.include "${.CURDIR}/../../../../../minix/Makefile.fetchgnu"
24+
.endif # defined(__MINIX)
25+
2026
SHLIB_MAJOR= 6
2127
SHLIB_MINOR= 0
2228

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

3541
.include <bsd.lib.mk>
3642

43+
.if defined(__MINIX) #&& ${USETOOLS} != "yes"
44+
# Trigger the fetch phase, even when not building tools
45+
${SRCS} realdepend realall realinstall: ${fetch_done}
46+
.endif # defined(__MINIX)
47+
3748
.else
3849
.include <bsd.prog.mk> # do nothing
3950
.endif

gnu/Makefile

-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
# $NetBSD: Makefile,v 1.17 2010/12/03 21:38:47 plunky Exp $
22

3-
.if defined(__MINIX)
4-
#LSC: Trigger fetch.sh script
5-
SUBDIR+= dist .WAIT
6-
.endif # defined(__MINIX)
73
SUBDIR+= usr.bin
84

95
# Speedup stubs for some subtrees that don't need to run these rules

gnu/dist/Makefile

-18
This file was deleted.

gnu/usr.bin/texinfo/makedoc/Makefile

+12
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ MAKEDOC=
55

66
.include "../Makefile.inc"
77

8+
.if defined(__MINIX)
9+
#LSC: First program within texinfo: trigger fetch.sh script
10+
MODULE= texinfo
11+
GNUHOSTDIST= ${DIST}/${MODULE}
12+
.include "${.CURDIR}/../../../../minix/Makefile.fetchgnu"
13+
.endif # defined(__MINIX)
14+
815
HOSTPROG= makedoc
916
SRCS= makedoc.c xexit.c xmalloc.c xstrdup.c
1017

@@ -13,3 +20,8 @@ HOST_CPPFLAGS+= -I${IDIST}/info -I${IDIST}/lib -I${.CURDIR}/../common
1320
HOST_CPPFLAGS+= -DHOSTTOOL
1421

1522
.include <bsd.hostprog.mk>
23+
24+
.if defined(__MINIX) && ${USETOOLS} != "yes"
25+
# MINIX: make sure sources are fetched, even when tools not built earlier
26+
${SRCS} realdepend realall realinstall: ${fetch_done}
27+
.endif # defined(__MINIX)

minix/Makefile.fetchgnu

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# NOT NetBSD
2+
#
3+
# Rules used to fetch a GNU package. Expects GNUHOSTDIST to be set
4+
# and <bsd.own.mk> to be previously .include'd.
5+
#
6+
# New interface:
7+
#
8+
# * When using the `cleandir' target, defining CLEANFETCHED=yes will
9+
# additionally remove all the fetched files.
10+
# This is particularly useful when a GNU package is updated.
11+
#
12+
# The rest should be operations hidden to the normal programmers.
13+
#
14+
# How to use: (maintainers manual)
15+
#
16+
# * put a fetch.sh script one directory below the GNUHOSTDIST;
17+
#
18+
# * .include "path/to/minix/Makefile.fetchgnu", after having
19+
# defined GNUHOSTDIST and before any use of the variable below;
20+
#
21+
# * insert ${fetch_done} as source before performing any operation
22+
# on the files under GPL license which are usually found
23+
# within NetBSD src/ tree;
24+
#
25+
# * rinse and repeat for every target which assumes the presence of
26+
# these files, and for every Makefile operating upon them.
27+
#
28+
#
29+
# TODO: does not handle correctly the cases where there are more than
30+
# one package downloaded by fetch.sh (e.g.gnu/dist with texinfo+gmake):
31+
# .gitignore only "protects" the first package which triggers.
32+
33+
.if !defined(__MINIX) || !defined(GNUHOSTDIST)
34+
.error Bad logic in Makefiles.
35+
.endif
36+
37+
.if !defined(_MINIX_FETCHGNU_MK_)
38+
_MINIX_FETCHGNU_MK_=1
39+
40+
# MINIX /usr/src does not have the sources for the GNU utilities
41+
# in-tree, for licensing reasons. So to successfully use them while
42+
# cross-compiling, we have to fetch them. The success of that operation
43+
# is indicated by the presence of a .gitignore file in the corresponding
44+
# source parent directory, which also conveniently hides from git.
45+
.if exists(${GNUHOSTDIST:H}/fetch.sh)
46+
${GNUHOSTDIST:H}/.gitignore: ${GNUHOSTDIST:H}/fetch.sh
47+
SED=${TOOL_SED} ${HOST_SH} ${GNUHOSTDIST:H}/fetch.sh
48+
@test -e ${GNUHOSTDIST}/configure
49+
@echo "${MODULE:U${.CURDIR:T}:C,gcc[0-9]*,gcc,:C,gmake*,make,}-*.tar.*z*" >> $@
50+
@echo ${GNUHOSTDIST:T} >> $@
51+
52+
# Do the fetching as an extra step, to force serialization
53+
.fetch_done: ${GNUHOSTDIST:H}/.gitignore
54+
@touch $@
55+
fetch_done=.fetch_done
56+
57+
# Special target for MINIX, reset the source tree as pristine
58+
# Note it does NOT remove the downloaded tarball
59+
.if ${CLEANFETCHED:Uno} == "yes"
60+
cleandir: clean_gnu_src
61+
clean_gnu_src:
62+
-rm -r -f ${GNUHOSTDIST} ${GNUHOSTDIST:H}/.gitignore
63+
.endif # CLEANFETCHED == yes
64+
65+
clean: clean.fetchgnu
66+
clean.fetchgnu:
67+
-@rm -f .fetch_done
68+
69+
.endif # exists(GNUHOSTDIST:H/fetch.sh) on MINIX
70+
71+
.endif # !defined(_MINIX_FETCHGNU_MK_)

tools/Makefile.gnuhost

+2-22
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,7 @@ MAKE_PROGRAM?= ${MAKE}
2727
GNUHOSTDIST?= ${.CURDIR}/../../gnu/dist/${MODULE}
2828

2929
.if defined(__MINIX)
30-
# AL - MINIX /usr/src does not have the sources for the GNU utilities
31-
# in-tree (they are much bigger than Minix itself!) So to successfully
32-
# use them while cross-compiling, we have to fetch them. The success of
33-
# that operation is indicated by the presence of a .gitignore file in
34-
# the corresponding ${.CURDIR}, which also conveniently hides from git.
35-
.if exists(${GNUHOSTDIST:H}/fetch.sh)
36-
${GNUHOSTDIST:H}/.gitignore: ${GNUHOSTDIST:H}/fetch.sh
37-
SED=${TOOL_SED} ${HOST_SH} ${GNUHOSTDIST:H}/fetch.sh
38-
@test -e ${GNUHOSTDIST}/configure
39-
@echo "${MODULE:U${.CURDIR:T}:C,gcc[0-9]*,gcc,:C,gmake*,make,}-*.tar.*z*" >> $@
40-
@echo ${GNUHOSTDIST:T} >> $@
41-
_gnu_get_src=${GNUHOSTDIST:H}/.gitignore
42-
.endif # exists(GNUHOSTDIST:H/fetch.sh) on MINIX
43-
44-
# AL - Special target for MINIX, reset the source tree as pristine
45-
.if ${CLEANFETCHED:Uno} == "yes" && exists(${GNUHOSTDIST:H}/fetch.sh)
46-
cleandir: clean_gnu_src
47-
clean_gnu_src:
48-
-rm -r -f ${GNUHOSTDIST} ${GNUHOSTDIST:H}/.gitignore
49-
# XXX CHECKME: could have used the content of .gitignore as well?
50-
.endif # CLEANFETCHED == yes
30+
.include "../minix/Makefile.fetchgnu"
5131
.endif # defined(__MINIX)
5232

5333
FIND_ARGS+= \! \( -type d \( \
@@ -134,7 +114,7 @@ configure_cleanup=configure_cleanup
134114
.endif
135115

136116
# AL For MINIX, fetch the source if not there
137-
.configure_done: ${_gnu_get_src} .WAIT ${_GNU_CFGSRC} ${.CURDIR}/Makefile ${configure_cleanup}
117+
.configure_done: ${fetch_done} ${_GNU_CFGSRC} ${.CURDIR}/Makefile ${configure_cleanup}
138118
@mkdir build 2>/dev/null || true
139119
@(cd build && ${CONFIGURE_ENV} ${HOST_SH} ${GNUHOSTDIST}/configure ${CONFIGURE_ARGS})
140120
@echo ${BUILD_PLATFORM} > $@

tools/binutils/Makefile

+8-5
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@ CONFIGURE_ARGS= --target=${MACHINE_GNU_PLATFORM} --disable-nls \
1616
--disable-werror \
1717
${BRANDING}
1818

19-
.if !defined(__MINIX)
20-
build/gas/m68k-parse.c: ${GNUHOSTDIST}/gas/m68k-parse.c
21-
.else
19+
.if defined(__MINIX) && ! exists(${GNUHOSTDIST}/gas/m68k-parse.c)
2220
# MINIX: LSC: Make sure we trigger the fetch rule
23-
build/gas/m68k-parse.c: ${GNUHOSTDIST:H}/.gitignore .WAIT ${GNUHOSTDIST}/gas/m68k-parse.c
24-
.endif # !defined(__MINIX)
21+
.include "${.CURDIR}/../../minix/Makefile.fetchgnu"
22+
23+
${GNUHOSTDIST}/gas/m68k-parse.c: ${fetch_done}
24+
@true
25+
.endif # defined(__MINIX)
26+
27+
build/gas/m68k-parse.c: ${GNUHOSTDIST}/gas/m68k-parse.c
2528
@mkdir build 2>/dev/null || true
2629
@mkdir build/gas 2>/dev/null || true
2730
cat ${GNUHOSTDIST}/gas/m68k-parse.c > ${.TARGET}

0 commit comments

Comments
 (0)