Add files from parent branch HEAD:
[pkgsrc.git] / mk / configure / install-sh-override.mk
1 # $NetBSD: install-sh-override.mk,v 1.1 2007/07/12 18:59:15 jlam Exp $
2
3 ######################################################################
4 ### install-sh-override (PRIVATE)
5 ######################################################################
6 ### install-sh-override replace any existing install-sh under
7 ### ${WRKSRC} with the version from sysutils/install-sh, which works
8 ### on all pkgsrc platforms, in particular Interix.
9 ###
10 do-configure-pre-hook: install-sh-override
11
12 OVERRIDE_DIRDEPTH.install-sh?=  ${OVERRIDE_DIRDEPTH}
13
14 _SCRIPT.install-sh-override=                                            \
15         ${RM} -f $$file;                                                \
16         ${SED} -e "s|@DEFAULT_INSTALL_MODE@|${PKGDIRMODE}|g"            \
17                 ${PKGSRCDIR}/sysutils/install-sh/files/install-sh.in    \
18                 > $$file;                                               \
19         ${CHMOD} +x $$file
20
21 .PHONY: install-sh-override
22 install-sh-override:
23         @${STEP_MSG} "Replacing install-sh with pkgsrc version"
24 .if defined(INSTALL_SH_OVERRIDE) && !empty(INSTALL_SH_OVERRIDE)
25         ${RUN} \
26         cd ${WRKSRC};                                                   \
27         set -- dummy ${INSTALL_SH_OVERRIDE}; shift;                     \
28         while [ $$# -gt 0 ]; do                                         \
29                 file="$$1"; shift;                                      \
30                 [ -f "$$file" ] || [ -h "$$file" ] || continue;         \
31                 ${_SCRIPT.${.TARGET}};                                  \
32         done
33 .else
34         ${RUN} \
35         cd ${WRKSRC};                                                   \
36         depth=0; pattern=install-sh;                                    \
37         while [ $$depth -le ${OVERRIDE_DIRDEPTH.install-sh} ]; do       \
38                 for file in $$pattern; do                               \
39                         [ -f "$$file" ] || [ -h "$$file" ] || continue; \
40                         ${_SCRIPT.${.TARGET}};                          \
41                 done;                                                   \
42                 depth=`${EXPR} $$depth + 1`; pattern="*/$$pattern";     \
43         done
44 .endif