summaryrefslogtreecommitdiff
path: root/mk/configure/install-sh-override.mk
blob: 1564aae0602b3ab46ce6c997ed609168fd145aad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# $NetBSD: install-sh-override.mk,v 1.2 2008/02/07 21:36:13 rillig Exp $

######################################################################
### install-sh-override (PRIVATE)
######################################################################
### install-sh-override replace any existing install-sh under
### ${WRKSRC} with the version from sysutils/install-sh, which works
### on all pkgsrc platforms, in particular Interix.
###
do-configure-pre-hook: install-sh-override

OVERRIDE_DIRDEPTH.install-sh?=	${OVERRIDE_DIRDEPTH}

_SCRIPT.install-sh-override=						\
	${RM} -f $$file;						\
	${SED} -e "s|@DEFAULT_INSTALL_MODE@|${PKGDIRMODE}|g"		\
		${PKGSRCDIR}/sysutils/install-sh/files/install-sh.in	\
		> $$file;						\
	${CHMOD} +x $$file

.PHONY: install-sh-override
install-sh-override:
	@${STEP_MSG} "Replacing install-sh with pkgsrc version"
.if defined(INSTALL_SH_OVERRIDE) && !empty(INSTALL_SH_OVERRIDE)
	${RUN} \
	cd ${WRKSRC};							\
	set -- dummy ${INSTALL_SH_OVERRIDE}; shift;			\
	while [ $$# -gt 0 ]; do						\
		file="$$1"; shift;					\
		[ -f "$$file" ] || [ -h "$$file" ] || continue;		\
		${_SCRIPT.${.TARGET}};					\
	done
.else
	${RUN} \
	cd ${WRKSRC};							\
	depth=0; pattern=install-sh;					\
	while [ $$depth -le ${OVERRIDE_DIRDEPTH.install-sh} ]; do	\
		for file in $$pattern; do				\
			[ -f "$$file" ] || [ -h "$$file" ] || continue;	\
			${_SCRIPT.${.TARGET}};				\
		done;							\
		depth=`${EXPR} $$depth + 1`; pattern="*/$$pattern";	\
	done
.endif