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