| @@ -1,156 +1,158 @@ | | | @@ -1,156 +1,158 @@ |
1 | # $NetBSD: cwrappers.mk,v 1.23 2015/04/27 19:59:07 jperkin Exp $ | | 1 | # $NetBSD: cwrappers.mk,v 1.24 2015/04/28 21:08:34 jperkin Exp $ |
2 | # | | 2 | # |
3 | # This Makefile fragment implements integration of pkgtools/cwrappers. | | 3 | # This Makefile fragment implements integration of pkgtools/cwrappers. |
4 | | | 4 | |
5 | .include "../../mk/buildlink3/bsd.buildlink3.mk" | | 5 | .include "../../mk/buildlink3/bsd.buildlink3.mk" |
6 | | | 6 | |
7 | BUILD_DEPENDS+= cwrappers>=20150314:../../pkgtools/cwrappers | | 7 | BUILD_DEPENDS+= cwrappers>=20150314:../../pkgtools/cwrappers |
8 | | | 8 | |
9 | # Public variables used by pkgsrc infrastructure and packages. | | 9 | # Public variables used by pkgsrc infrastructure and packages. |
10 | WRAPPER_DIR= ${WRKDIR}/.cwrapper | | 10 | WRAPPER_DIR= ${WRKDIR}/.cwrapper |
11 | WRAPPER_BINDIR= ${WRAPPER_DIR}/bin | | 11 | WRAPPER_BINDIR= ${WRAPPER_DIR}/bin |
12 | | | 12 | |
13 | # XXX This should be PREFIX, but USE_CROSSBASE overrides it. | | 13 | # XXX This should be PREFIX, but USE_CROSSBASE overrides it. |
14 | CWRAPPERS_SRC_DIR= ${LOCALBASE}/libexec/cwrappers | | 14 | CWRAPPERS_SRC_DIR= ${LOCALBASE}/libexec/cwrappers |
15 | CWRAPPERS_CONFIG_DIR= ${WRKDIR}/.cwrapper/config | | 15 | CWRAPPERS_CONFIG_DIR= ${WRKDIR}/.cwrapper/config |
16 | CONFIGURE_ENV+= CWRAPPERS_CONFIG_DIR=${CWRAPPERS_CONFIG_DIR} | | 16 | CONFIGURE_ENV+= CWRAPPERS_CONFIG_DIR=${CWRAPPERS_CONFIG_DIR} |
17 | MAKE_ENV+= CWRAPPERS_CONFIG_DIR=${CWRAPPERS_CONFIG_DIR} | | 17 | MAKE_ENV+= CWRAPPERS_CONFIG_DIR=${CWRAPPERS_CONFIG_DIR} |
18 | ALL_ENV+= CWRAPPERS_CONFIG_DIR=${CWRAPPERS_CONFIG_DIR} | | 18 | ALL_ENV+= CWRAPPERS_CONFIG_DIR=${CWRAPPERS_CONFIG_DIR} |
19 | | | 19 | |
20 | # TODO: Fix direct calls to CC and LIBTOOL to provide correct environment. | | 20 | # TODO: Fix direct calls to CC and LIBTOOL to provide correct environment. |
21 | .export CWRAPPERS_CONFIG_DIR | | 21 | .export CWRAPPERS_CONFIG_DIR |
22 | | | 22 | |
23 | CWRAPPERS_CONFIG.as= as | | 23 | CWRAPPERS_CONFIG.as= as |
24 | CWRAPPERS_CONFIG.cc= cc | | 24 | CWRAPPERS_CONFIG.cc= cc |
25 | CWRAPPERS_CONFIG.cxx= c++ | | 25 | CWRAPPERS_CONFIG.cxx= c++ |
26 | CWRAPPERS_CONFIG.cpp= cpp | | 26 | CWRAPPERS_CONFIG.cpp= cpp |
27 | CWRAPPERS_CONFIG.f77= f77 | | 27 | CWRAPPERS_CONFIG.f77= f77 |
28 | CWRAPPERS_CONFIG.imake= imake | | 28 | CWRAPPERS_CONFIG.imake= imake |
29 | CWRAPPERS_CONFIG.ld= ld | | 29 | CWRAPPERS_CONFIG.ld= ld |
30 | CWRAPPERS_CONFIG.libtool= libtool | | 30 | CWRAPPERS_CONFIG.libtool= libtool |
31 | CWRAPPERS_CONFIG.shlibtool= shlibtool | | 31 | CWRAPPERS_CONFIG.shlibtool= shlibtool |
32 | | | 32 | |
33 | CWRAPPERS_ALIASES.as= as | | 33 | CWRAPPERS_ALIASES.as= as |
34 | CWRAPPERS_ALIASES.cc= cc gcc clang | | 34 | CWRAPPERS_ALIASES.cc= cc gcc clang |
35 | CWRAPPERS_ALIASES.cxx= c++ g++ cxx clang++ | | 35 | CWRAPPERS_ALIASES.cxx= c++ g++ cxx clang++ |
36 | CWRAPPERS_ALIASES.cpp= cpp clang-cpp | | 36 | CWRAPPERS_ALIASES.cpp= cpp clang-cpp |
37 | CWRAPPERS_ALIASES.f77= f77 g77 gfortran | | 37 | CWRAPPERS_ALIASES.f77= f77 g77 gfortran |
38 | CWRAPPERS_ALIASES.imake= imake | | 38 | CWRAPPERS_ALIASES.imake= imake |
39 | CWRAPPERS_ALIASES.ld= ld | | 39 | CWRAPPERS_ALIASES.ld= ld |
40 | CWRAPPERS_ALIASES.libtool= libtool | | 40 | CWRAPPERS_ALIASES.libtool= libtool |
41 | CWRAPPERS_ALIASES.shlibtool= shlibtool | | 41 | CWRAPPERS_ALIASES.shlibtool= shlibtool |
42 | | | 42 | |
43 | CWRAPPERS_WRAPPEE.as= ${AS:Ufalse} | | 43 | CWRAPPERS_WRAPPEE.as= ${AS:Ufalse} |
44 | CWRAPPERS_WRAPPEE.cxx= ${PKG_CXX:Ufalse} | | 44 | CWRAPPERS_WRAPPEE.cxx= ${PKG_CXX:Ufalse} |
45 | CWRAPPERS_WRAPPEE.cc= ${PKG_CC:Ufalse} | | 45 | CWRAPPERS_WRAPPEE.cc= ${PKG_CC:Ufalse} |
46 | CWRAPPERS_WRAPPEE.cpp= ${PKG_CPP:Ufalse} | | 46 | CWRAPPERS_WRAPPEE.cpp= ${PKG_CPP:Ufalse} |
47 | CWRAPPERS_WRAPPEE.f77= ${PKG_FC:Ufalse} | | 47 | CWRAPPERS_WRAPPEE.f77= ${PKG_FC:Ufalse} |
48 | CWRAPPERS_WRAPPEE.imake= ${TOOLS_PATH.imake:Ufalse} | | 48 | CWRAPPERS_WRAPPEE.imake= ${TOOLS_PATH.imake:Ufalse} |
49 | CWRAPPERS_WRAPPEE.ld= ${LD:Ufalse} | | 49 | CWRAPPERS_WRAPPEE.ld= ${LD:Ufalse} |
50 | CWRAPPERS_WRAPPEE.libtool= ${PKG_LIBTOOL:Ufalse} | | 50 | CWRAPPERS_WRAPPEE.libtool= ${PKG_LIBTOOL:Ufalse} |
51 | CWRAPPERS_WRAPPEE.shlibtool= ${PKG_SHLIBTOOL:Ufalse} | | 51 | CWRAPPERS_WRAPPEE.shlibtool= ${PKG_SHLIBTOOL:Ufalse} |
52 | | | 52 | |
53 | # TODO: Find and fix packages depending on the implicit include path. | | 53 | # TODO: Find and fix packages depending on the implicit include path. |
54 | CWRAPPERS_APPEND.cc+= -I${PREFIX}/include | | 54 | CWRAPPERS_APPEND.cc+= -I${PREFIX}/include |
55 | CWRAPPERS_APPEND.cxx+= -I${PREFIX}/include | | 55 | CWRAPPERS_APPEND.cxx+= -I${PREFIX}/include |
56 | CWRAPPERS_APPEND.cpp+= -I${PREFIX}/include | | 56 | CWRAPPERS_APPEND.cpp+= -I${PREFIX}/include |
57 | | | 57 | |
58 | .if defined(USE_IMAKE) || !empty(USE_TOOLS:Mimake) | | 58 | .if defined(USE_IMAKE) || !empty(USE_TOOLS:Mimake) |
59 | CWRAPPERS_TRANSFORM.imake+= I:${PREFIX}/lib/X11/config:${PREFIX}/lib/X11/config | | 59 | CWRAPPERS_TRANSFORM.imake+= I:${PREFIX}/lib/X11/config:${PREFIX}/lib/X11/config |
60 | CWRAPPERS_APPEND.imake+= ${IMAKEOPTS} | | 60 | CWRAPPERS_APPEND.imake+= ${IMAKEOPTS} |
61 | .endif | | 61 | .endif |
62 | | | 62 | |
63 | .PHONY: generate-cwrappers | | 63 | .PHONY: generate-cwrappers |
64 | | | 64 | |
65 | .for _target_ in ${WRAPPER_TARGETS} | | 65 | .for _target_ in ${WRAPPER_TARGETS} |
66 | generate-cwrappers: ${_target_} | | 66 | generate-cwrappers: ${_target_} |
67 | .endfor | | 67 | .endfor |
68 | | | 68 | |
69 | generate-cwrappers: | | 69 | generate-cwrappers: |
70 | ${RUN}${MKDIR} ${CWRAPPERS_CONFIG_DIR} ${WRAPPER_BINDIR} | | | |
71 | .for wrappee in as cxx cc cpp f77 imake ld libtool shlibtool | | 70 | .for wrappee in as cxx cc cpp f77 imake ld libtool shlibtool |
72 | ${RUN}echo worklog=${WRKLOG:Q} > ${CWRAPPERS_CONFIG_DIR}/${CWRAPPERS_CONFIG.${wrappee}} | | 71 | ${RUN}echo worklog=${WRKLOG:Q} > ${CWRAPPERS_CONFIG_DIR}/${CWRAPPERS_CONFIG.${wrappee}} |
73 | ${RUN}echo wrksrc=${WRKSRC:Q} >> ${CWRAPPERS_CONFIG_DIR}/${CWRAPPERS_CONFIG.${wrappee}} | | 72 | ${RUN}echo wrksrc=${WRKSRC:Q} >> ${CWRAPPERS_CONFIG_DIR}/${CWRAPPERS_CONFIG.${wrappee}} |
74 | ${RUN}case ${wrappee} in *libtool) ;; *) echo path=${_PATH_ORIG:Q} >> ${CWRAPPERS_CONFIG_DIR}/${CWRAPPERS_CONFIG.${wrappee}};; esac | | 73 | ${RUN}case ${wrappee} in *libtool) ;; *) echo path=${_PATH_ORIG:Q} >> ${CWRAPPERS_CONFIG_DIR}/${CWRAPPERS_CONFIG.${wrappee}};; esac |
75 | ${RUN}echo exec_path=${WRAPPER_BINDIR}/${CWRAPPERS_ALIASES.${wrappee}:[1]} >> ${CWRAPPERS_CONFIG_DIR}/${CWRAPPERS_CONFIG.${wrappee}} | | 74 | ${RUN}echo exec_path=${WRAPPER_BINDIR}/${CWRAPPERS_ALIASES.${wrappee}:[1]} >> ${CWRAPPERS_CONFIG_DIR}/${CWRAPPERS_CONFIG.${wrappee}} |
76 | ${RUN}echo exec=${CWRAPPERS_WRAPPEE.${wrappee}:Q} >> ${CWRAPPERS_CONFIG_DIR}/${CWRAPPERS_CONFIG.${wrappee}} | | 75 | ${RUN}echo exec=${CWRAPPERS_WRAPPEE.${wrappee}:Q} >> ${CWRAPPERS_CONFIG_DIR}/${CWRAPPERS_CONFIG.${wrappee}} |
77 | . for cmd in ${WRAPPER_REORDER_CMDS} | | 76 | . for cmd in ${WRAPPER_REORDER_CMDS} |
78 | ${RUN}echo reorder=${cmd:S/^reorder://:Q} >> ${CWRAPPERS_CONFIG_DIR}/${CWRAPPERS_CONFIG.${wrappee}} | | 77 | ${RUN}echo reorder=${cmd:S/^reorder://:Q} >> ${CWRAPPERS_CONFIG_DIR}/${CWRAPPERS_CONFIG.${wrappee}} |
79 | . endfor | | 78 | . endfor |
80 | . for cmd in ${CWRAPPERS_TRANSFORM.${wrappee}} ${_CWRAPPERS_TRANSFORM} | | 79 | . for cmd in ${CWRAPPERS_TRANSFORM.${wrappee}} ${_CWRAPPERS_TRANSFORM} |
81 | ${RUN}echo transform=${cmd:u:Q} >> ${CWRAPPERS_CONFIG_DIR}/${CWRAPPERS_CONFIG.${wrappee}} | | 80 | ${RUN}echo transform=${cmd:u:Q} >> ${CWRAPPERS_CONFIG_DIR}/${CWRAPPERS_CONFIG.${wrappee}} |
82 | . endfor | | 81 | . endfor |
83 | . for cmd in ${CWRAPPERS_APPEND.${wrappee}:U} | | 82 | . for cmd in ${CWRAPPERS_APPEND.${wrappee}:U} |
84 | ${RUN}echo append=${cmd:Q} >> ${CWRAPPERS_CONFIG_DIR}/${CWRAPPERS_CONFIG.${wrappee}} | | 83 | ${RUN}echo append=${cmd:Q} >> ${CWRAPPERS_CONFIG_DIR}/${CWRAPPERS_CONFIG.${wrappee}} |
85 | . endfor | | 84 | . endfor |
86 | . for cmd in ${_CWRAPPERS_UNWRAP} | | 85 | . for cmd in ${_CWRAPPERS_UNWRAP} |
87 | ${RUN}echo unwrap=${cmd:Q} >> ${CWRAPPERS_CONFIG_DIR}/${CWRAPPERS_CONFIG.${wrappee}} | | 86 | ${RUN}echo unwrap=${cmd:Q} >> ${CWRAPPERS_CONFIG_DIR}/${CWRAPPERS_CONFIG.${wrappee}} |
88 | . endfor | | 87 | . endfor |
89 | . for alias in ${CWRAPPERS_ALIASES.${wrappee}} | | 88 | . for alias in ${CWRAPPERS_ALIASES.${wrappee}} |
90 | ${RUN}ln -s ${CWRAPPERS_SRC_DIR}/${CWRAPPERS_CONFIG.${wrappee}}-wrapper ${WRAPPER_BINDIR}/${alias} | | 89 | ${RUN}ln -s ${CWRAPPERS_SRC_DIR}/${CWRAPPERS_CONFIG.${wrappee}}-wrapper ${WRAPPER_BINDIR}/${alias} |
91 | . endfor | | 90 | . endfor |
92 | .endfor | | 91 | .endfor |
93 | | | 92 | |
94 | .if defined(USE_LIBTOOL) | | 93 | .if defined(USE_LIBTOOL) |
95 | _LIBTOOL= ${WRAPPER_BINDIR}/libtool | | 94 | _LIBTOOL= ${WRAPPER_BINDIR}/libtool |
96 | _SHLIBTOOL= ${WRAPPER_BINDIR}/shlibtool | | 95 | _SHLIBTOOL= ${WRAPPER_BINDIR}/shlibtool |
97 | .endif | | 96 | .endif |
98 | PREPEND_PATH+= ${WRAPPER_BINDIR} | | 97 | PREPEND_PATH+= ${WRAPPER_BINDIR} |
99 | | | 98 | |
100 | _COOKIE.wrapper= ${WRKDIR}/.wrapper_done | | 99 | _COOKIE.wrapper= ${WRKDIR}/.wrapper_done |
101 | | | 100 | |
102 | .PHONY: wrapper | | 101 | .PHONY: wrapper |
103 | .if !target(wrapper) | | 102 | .if !target(wrapper) |
104 | . if exists(${_COOKIE.wrapper}) | | 103 | . if exists(${_COOKIE.wrapper}) |
105 | wrapper: | | 104 | wrapper: |
106 | @${DO_NADA} | | 105 | @${DO_NADA} |
107 | . elif defined(_PKGSRC_BARRIER) | | 106 | . elif defined(_PKGSRC_BARRIER) |
108 | wrapper: check-vulnerable patch acquire-wrapper-lock ${_COOKIE.wrapper} release-wrapper-lock | | 107 | wrapper: check-vulnerable patch acquire-wrapper-lock ${_COOKIE.wrapper} release-wrapper-lock |
109 | . else | | 108 | . else |
110 | wrapper: barrier | | 109 | wrapper: barrier |
111 | . endif | | 110 | . endif |
112 | .endif | | 111 | .endif |
113 | | | 112 | |
114 | .PHONY: acquire-wrapper-lock release-wrapper-lock | | 113 | .PHONY: acquire-wrapper-lock release-wrapper-lock |
115 | acquire-wrapper-lock: acquire-lock | | 114 | acquire-wrapper-lock: acquire-lock |
116 | release-wrapper-lock: release-lock | | 115 | release-wrapper-lock: release-lock |
117 | | | 116 | |
118 | .if exists(${_COOKIE.wrapper}) | | 117 | .if exists(${_COOKIE.wrapper}) |
119 | ${_COOKIE.wrapper}: | | 118 | ${_COOKIE.wrapper}: |
120 | @${DO_NADA} | | 119 | @${DO_NADA} |
121 | .else | | 120 | .else |
122 | ${_COOKIE.wrapper}: real-wrapper | | 121 | ${_COOKIE.wrapper}: real-wrapper |
123 | .endif | | 122 | .endif |
124 | | | 123 | |
125 | .PHONY: real-wrapper | | 124 | .PHONY: real-wrapper |
126 | real-wrapper: wrapper-message wrapper-vars pre-wrapper do-wrapper post-wrapper wrapper-cookie error-check | | 125 | real-wrapper: wrapper-message wrapper-dirs wrapper-vars pre-wrapper do-wrapper post-wrapper wrapper-cookie error-check |
127 | | | 126 | |
128 | .PHONY: wrapper-message | | 127 | .PHONY: wrapper-message |
129 | | | | |
130 | wrapper-message: | | 128 | wrapper-message: |
131 | @${PHASE_MSG} "Creating toolchain wrappers for ${PKGNAME}" | | 129 | @${PHASE_MSG} "Creating toolchain wrappers for ${PKGNAME}" |
132 | | | 130 | |
| | | 131 | .PHONY: wrapper-dirs |
| | | 132 | wrapper-dirs: |
| | | 133 | ${RUN}${MKDIR} ${CWRAPPERS_CONFIG_DIR} ${WRAPPER_BINDIR} |
| | | 134 | |
133 | .PHONY: pre-wrapper do-wrapper post-wrapper | | 135 | .PHONY: pre-wrapper do-wrapper post-wrapper |
134 | | | 136 | |
135 | do-wrapper: generate-cwrappers | | 137 | do-wrapper: generate-cwrappers |
136 | | | 138 | |
137 | .if !target(do-wrapper) | | 139 | .if !target(do-wrapper) |
138 | do-wrapper: | | 140 | do-wrapper: |
139 | @${DO_NADA} | | 141 | @${DO_NADA} |
140 | .endif | | 142 | .endif |
141 | | | 143 | |
142 | .if !target(pre-wrapper) | | 144 | .if !target(pre-wrapper) |
143 | pre-wrapper: | | 145 | pre-wrapper: |
144 | @${DO_NADA} | | 146 | @${DO_NADA} |
145 | .endif | | 147 | .endif |
146 | | | 148 | |
147 | .if !target(post-wrapper) | | 149 | .if !target(post-wrapper) |
148 | post-wrapper: | | 150 | post-wrapper: |
149 | @${DO_NADA} | | 151 | @${DO_NADA} |
150 | .endif | | 152 | .endif |
151 | | | 153 | |
152 | .PHONY: wrapper-cookie | | 154 | .PHONY: wrapper-cookie |
153 | wrapper-cookie: | | 155 | wrapper-cookie: |
154 | ${RUN} [ ! -f ${_COOKIE.wrapper} ] | | 156 | ${RUN} [ ! -f ${_COOKIE.wrapper} ] |
155 | ${RUN} ${MKDIR} ${_COOKIE.wrapper:H} | | 157 | ${RUN} ${MKDIR} ${_COOKIE.wrapper:H} |
156 | ${RUN} ${ECHO} ${PKGNAME} > ${_COOKIE.wrapper} | | 158 | ${RUN} ${ECHO} ${PKGNAME} > ${_COOKIE.wrapper} |