Tue Jan 18 02:24:36 2022 UTC ()
Support PKGSRC_MKPIE


(pho)
diff -r1.36 -r1.37 pkgsrc/mk/haskell.mk

cvs diff -r1.36 -r1.37 pkgsrc/mk/haskell.mk (switch to unified diff)

--- pkgsrc/mk/haskell.mk 2021/09/27 14:30:47 1.36
+++ pkgsrc/mk/haskell.mk 2022/01/18 02:24:36 1.37
@@ -1,322 +1,325 @@ @@ -1,322 +1,325 @@
1# $NetBSD: haskell.mk,v 1.36 2021/09/27 14:30:47 nia Exp $ 1# $NetBSD: haskell.mk,v 1.37 2022/01/18 02:24:36 pho Exp $
2# 2#
3# This Makefile fragment handles Haskell Cabal packages. 3# This Makefile fragment handles Haskell Cabal packages.
4# Package configuration, building, installation, registration and 4# Package configuration, building, installation, registration and
5# unregistration are fully automated. 5# unregistration are fully automated.
6# See https://www.haskell.org/cabal/. 6# See https://www.haskell.org/cabal/.
7# 7#
8# Package-settable variables: 8# Package-settable variables:
9# 9#
10# PKGNAME 10# PKGNAME
11# Defaults to hs-${DISTNAME}. 11# Defaults to hs-${DISTNAME}.
12# 12#
13# HOMEPAGE 13# HOMEPAGE
14# MASTER_SITES 14# MASTER_SITES
15# Default to HackageDB URLs. 15# Default to HackageDB URLs.
16# 16#
17# HASKELL_OPTIMIZATION_LEVEL 17# HASKELL_OPTIMIZATION_LEVEL
18# Optimization level for compilation. 18# Optimization level for compilation.
19# 19#
20# Possible values: 0 1 2 20# Possible values: 0 1 2
21# Default value: 2 21# Default value: 2
22# 22#
23# User-settable variables: 23# User-settable variables:
24# 24#
25# HASKELL_ENABLE_SHARED_LIBRARY 25# HASKELL_ENABLE_SHARED_LIBRARY
26# Whether shared library should be built or not. 26# Whether shared library should be built or not.
27# 27#
28# Possible values: yes, no 28# Possible values: yes, no
29# Default value: yes 29# Default value: yes
30# 30#
31# HASKELL_ENABLE_LIBRARY_PROFILING 31# HASKELL_ENABLE_LIBRARY_PROFILING
32# Whether profiling library should be built or not. 32# Whether profiling library should be built or not.
33# 33#
34# Possible values: yes, no 34# Possible values: yes, no
35# Default value: yes 35# Default value: yes
36# 36#
37# HASKELL_ENABLE_HADDOCK_DOCUMENTATION 37# HASKELL_ENABLE_HADDOCK_DOCUMENTATION
38# Whether haddock documentation should be built or not. 38# Whether haddock documentation should be built or not.
39# 39#
40# Possible values: yes, no 40# Possible values: yes, no
41# Default value: yes 41# Default value: yes
42 42
43.if !defined(HASKELL_MK) 43.if !defined(HASKELL_MK)
44HASKELL_MK= # defined 44HASKELL_MK= # defined
45 45
46MKPIE_SUPPORTED= no 
47 
48.include "../../mk/bsd.fast.prefs.mk" 46.include "../../mk/bsd.fast.prefs.mk"
49 47
50HS_UPDATE_PLIST?= no 48HS_UPDATE_PLIST?= no
51 49
52BUILD_DEFS+= HASKELL_ENABLE_SHARED_LIBRARY 50BUILD_DEFS+= HASKELL_ENABLE_SHARED_LIBRARY
53BUILD_DEFS+= HASKELL_ENABLE_LIBRARY_PROFILING 51BUILD_DEFS+= HASKELL_ENABLE_LIBRARY_PROFILING
54BUILD_DEFS+= HASKELL_ENABLE_HADDOCK_DOCUMENTATION 52BUILD_DEFS+= HASKELL_ENABLE_HADDOCK_DOCUMENTATION
55 53
56# Declarations for ../../mk/misc/show.mk 54# Declarations for ../../mk/misc/show.mk
57_VARGROUPS+= haskell 55_VARGROUPS+= haskell
58_USER_VARS.haskell= \ 56_USER_VARS.haskell= \
59 HASKELL_ENABLE_SHARED_LIBRARY \ 57 HASKELL_ENABLE_SHARED_LIBRARY \
60 HASKELL_ENABLE_LIBRARY_PROFILING \ 58 HASKELL_ENABLE_LIBRARY_PROFILING \
61 HASKELL_ENABLE_HADDOCK_DOCUMENTATION \ 59 HASKELL_ENABLE_HADDOCK_DOCUMENTATION \
62 HS_UPDATE_PLIST 60 HS_UPDATE_PLIST
63_SYS_VARS.haskell= \ 61_SYS_VARS.haskell= \
64 PKGNAME DISTNAME MASTER_SITES MASTER_SITE_HASKELL_HACKAGE \ 62 PKGNAME DISTNAME MASTER_SITES MASTER_SITE_HASKELL_HACKAGE \
65 HOMEPAGE UNLIMIT_RESOURCES PREFIX 63 HOMEPAGE UNLIMIT_RESOURCES PREFIX
66_DEF_VARS.haskell= \ 64_DEF_VARS.haskell= \
67 HASKELL_OPTIMIZATION_LEVEL \ 65 HASKELL_OPTIMIZATION_LEVEL \
68 HASKELL_PKG_NAME \ 66 HASKELL_PKG_NAME \
69 USE_LANGUAGES \ 67 USE_LANGUAGES \
70 CONFIGURE_ARGS \ 68 CONFIGURE_ARGS \
71 PLIST_SUBST \ 69 PLIST_SUBST \
72 PRINT_PLIST_AWK \ 70 PRINT_PLIST_AWK \
73 GENERATE_PLIST \ 71 GENERATE_PLIST \
74 PLIST_SRC \ 72 PLIST_SRC \
75 FILES_SUBST \ 73 FILES_SUBST \
76 INSTALLATION_DIRS \ 74 INSTALLATION_DIRS \
77 INSTALL_TEMPLATES \ 75 INSTALL_TEMPLATES \
78 DEINSTALL_TEMPLATES \ 76 DEINSTALL_TEMPLATES \
79 _HASKELL_VERSION_CMD \ 77 _HASKELL_VERSION_CMD \
80 _HASKELL_BIN \ 78 _HASKELL_BIN \
81 _HASKELL_PKG_BIN \ 79 _HASKELL_PKG_BIN \
82 _HASKELL_PKG_DESCR_FILE \ 80 _HASKELL_PKG_DESCR_FILE \
83 _HASKELL_PKG_ID_FILE \ 81 _HASKELL_PKG_ID_FILE \
84 _HASKELL_VERSION 82 _HASKELL_VERSION
85_USE_VARS.haskell= \ 83_USE_VARS.haskell= \
86 PKG_VERBOSE \ 84 PKG_VERBOSE \
87 BUILDLINK_PREFIX.ghc \ 85 BUILDLINK_PREFIX.ghc \
88 PKGDIR DESTDIR \ 86 PKGDIR DESTDIR \
89 WRKSRC 87 WRKSRC
90_LISTED_VARS.haskell= \ 88_LISTED_VARS.haskell= \
91 CONFIGURE_ARGS \ 89 CONFIGURE_ARGS \
92 PLIST_SUBST \ 90 PLIST_SUBST \
93 PRINT_PLIST_AWK \ 91 PRINT_PLIST_AWK \
94 FILES_SUBST 92 FILES_SUBST
95_IGN_VARS.haskell= \ 93_IGN_VARS.haskell= \
96 USE_TOOLS CONFIGURE_ENV MAKE_ENV WARNINGS _* 94 USE_TOOLS CONFIGURE_ENV MAKE_ENV WARNINGS _*
97 95
98PKGNAME?= hs-${DISTNAME} 96PKGNAME?= hs-${DISTNAME}
99MASTER_SITES?= ${MASTER_SITE_HASKELL_HACKAGE:=${DISTNAME}/} 97MASTER_SITES?= ${MASTER_SITE_HASKELL_HACKAGE:=${DISTNAME}/}
100HOMEPAGE?= http://hackage.haskell.org/package/${DISTNAME:C/-[^-]*$//} 98HOMEPAGE?= http://hackage.haskell.org/package/${DISTNAME:C/-[^-]*$//}
101 99
102# Cabal packages may use pkg-config, but url2pkg can't detect 100# Cabal packages may use pkg-config, but url2pkg can't detect
103# that. (PHO: I think that should be handled by url2pkg (2009-05-20)) 101# that. (PHO: I think that should be handled by url2pkg (2009-05-20))
104USE_TOOLS+= pkg-config 102USE_TOOLS+= pkg-config
105 103
106# GHC can be a memory hog, so don't apply regular limits. 104# GHC can be a memory hog, so don't apply regular limits.
107UNLIMIT_RESOURCES+= datasize virtualsize 105UNLIMIT_RESOURCES+= datasize virtualsize
108 106
109HASKELL_OPTIMIZATION_LEVEL?= 2 107HASKELL_OPTIMIZATION_LEVEL?= 2
110HASKELL_ENABLE_SHARED_LIBRARY?= yes 108HASKELL_ENABLE_SHARED_LIBRARY?= yes
111HASKELL_ENABLE_LIBRARY_PROFILING?= yes 109HASKELL_ENABLE_LIBRARY_PROFILING?= yes
112HASKELL_ENABLE_HADDOCK_DOCUMENTATION?= yes 110HASKELL_ENABLE_HADDOCK_DOCUMENTATION?= yes
113 111
114.include "../../lang/ghc90/buildlink3.mk" 112.include "../../lang/ghc90/buildlink3.mk"
115 113
116# Some Cabal packages requires preprocessors to build, and we don't 114# Some Cabal packages requires preprocessors to build, and we don't
117# want them to implicitly depend on such tools. Place dummy scripts by 115# want them to implicitly depend on such tools. Place dummy scripts by
118# default. 116# default.
119.include "../../mk/haskell/tools/alex.mk" 117.include "../../mk/haskell/tools/alex.mk"
120.include "../../mk/haskell/tools/cpphs.mk" 118.include "../../mk/haskell/tools/cpphs.mk"
121.include "../../mk/haskell/tools/happy.mk" 119.include "../../mk/haskell/tools/happy.mk"
122 120
123# Tools 121# Tools
124_HASKELL_BIN= ${BUILDLINK_PREFIX.ghc:U${PREFIX}}/bin/ghc 122_HASKELL_BIN= ${BUILDLINK_PREFIX.ghc:U${PREFIX}}/bin/ghc
125_HASKELL_PKG_BIN= ${BUILDLINK_PREFIX.ghc:U${PREFIX}}/bin/ghc-pkg 123_HASKELL_PKG_BIN= ${BUILDLINK_PREFIX.ghc:U${PREFIX}}/bin/ghc-pkg
126 124
127_HASKELL_VERSION_CMD= ${_HASKELL_BIN} -V 2>/dev/null | ${CUT} -d ' ' -f 8 125_HASKELL_VERSION_CMD= ${_HASKELL_BIN} -V 2>/dev/null | ${CUT} -d ' ' -f 8
128_HASKELL_VERSION= ghc-${_HASKELL_VERSION_CMD:sh} 126_HASKELL_VERSION= ghc-${_HASKELL_VERSION_CMD:sh}
129 127
130# By default GHC uses a per-user default environment file if one is 128# By default GHC uses a per-user default environment file if one is
131# available. Cabal has to be visible in order to compile Setup.?hs, 129# available. Cabal has to be visible in order to compile Setup.?hs,
132# but per-user default environment files usually don't mark it as 130# but per-user default environment files usually don't mark it as
133# visible. Tell GHC not to read any environment files. 131# visible. Tell GHC not to read any environment files.
134_HASKELL_BUILD_SETUP_OPTS= -package-env - 132_HASKELL_BUILD_SETUP_OPTS= -package-env -
135 133
136# GHC requires C compiler. 134# GHC requires C compiler.
137USE_LANGUAGES+= c 135USE_LANGUAGES+= c
138 136
139# Declarations for ../../mk/configure/configure.mk 137# Declarations for ../../mk/configure/configure.mk
140CONFIGURE_ARGS+= --ghc 138CONFIGURE_ARGS+= --ghc
141CONFIGURE_ARGS+= --with-compiler=${_HASKELL_BIN:Q} 139CONFIGURE_ARGS+= --with-compiler=${_HASKELL_BIN:Q}
142CONFIGURE_ARGS+= --with-hc-pkg=${_HASKELL_PKG_BIN:Q} 140CONFIGURE_ARGS+= --with-hc-pkg=${_HASKELL_PKG_BIN:Q}
143CONFIGURE_ARGS+= --prefix=${PREFIX:Q} 141CONFIGURE_ARGS+= --prefix=${PREFIX:Q}
144 142
 143PKGSRC_OVERRIDE_MKPIE= yes
 144.if ${_PKGSRC_MKPIE} == "yes"
 145CONFIGURE_ARGS+= --ghc-option=-fPIC --ghc-option=-pie
 146.endif
 147
145.if ${HASKELL_ENABLE_SHARED_LIBRARY} == "yes" 148.if ${HASKELL_ENABLE_SHARED_LIBRARY} == "yes"
146CONFIGURE_ARGS+= --enable-shared --enable-executable-dynamic 149CONFIGURE_ARGS+= --enable-shared --enable-executable-dynamic
147.else 150.else
148CONFIGURE_ARGS+= --disable-shared --disable-executable-dynamic 151CONFIGURE_ARGS+= --disable-shared --disable-executable-dynamic
149.endif 152.endif
150 153
151.if ${HASKELL_ENABLE_LIBRARY_PROFILING} == "yes" 154.if ${HASKELL_ENABLE_LIBRARY_PROFILING} == "yes"
152CONFIGURE_ARGS+= --enable-library-profiling 155CONFIGURE_ARGS+= --enable-library-profiling
153.else 156.else
154CONFIGURE_ARGS+= --disable-library-profiling 157CONFIGURE_ARGS+= --disable-library-profiling
155.endif 158.endif
156 159
157.if ${HASKELL_ENABLE_HADDOCK_DOCUMENTATION} == "yes" 160.if ${HASKELL_ENABLE_HADDOCK_DOCUMENTATION} == "yes"
158CONFIGURE_ARGS+= --with-haddock=${BUILDLINK_PREFIX.ghc:Q}/bin/haddock 161CONFIGURE_ARGS+= --with-haddock=${BUILDLINK_PREFIX.ghc:Q}/bin/haddock
159.endif 162.endif
160 163
161CONFIGURE_ARGS+= -O${HASKELL_OPTIMIZATION_LEVEL} 164CONFIGURE_ARGS+= -O${HASKELL_OPTIMIZATION_LEVEL}
162 165
163# Support RELRO. When PKGSRC_USE_RELRO isn't set to "no", 166# Support RELRO. When PKGSRC_USE_RELRO isn't set to "no",
164# mk/compiler/{ghc,clang}.mk add "-Wl,-z,relro" and optionally 167# mk/compiler/{ghc,clang}.mk add "-Wl,-z,relro" and optionally
165# "-Wl,-z,now" to LDFLAGS. Since Cabal doesn't respect the environment 168# "-Wl,-z,now" to LDFLAGS. Since Cabal doesn't respect the environment
166# variable LDFLAGS, we need to be explicit about it. Note that -optl 169# variable LDFLAGS, we need to be explicit about it. Note that -optl
167# is a GHC option which specifies options to be passed to CC, not LD, 170# is a GHC option which specifies options to be passed to CC, not LD,
168# while linking executables and shared libraries. 171# while linking executables and shared libraries.
169CONFIGURE_ARGS+= ${LDFLAGS:S/^/--ghc-options=-optl\ /} 172CONFIGURE_ARGS+= ${LDFLAGS:S/^/--ghc-options=-optl\ /}
170# GHC heavily uses "ld -r" to combine multiple .o files but our ld 173# GHC heavily uses "ld -r" to combine multiple .o files but our ld
171# wrapper is going to inject the relro flags. In this case these flags 174# wrapper is going to inject the relro flags. In this case these flags
172# don't make sense so ld(1) emits warnings. Use the original, 175# don't make sense so ld(1) emits warnings. Use the original,
173# non-wrapped ld(1) for merging objects as a dirty workaround. 176# non-wrapped ld(1) for merging objects as a dirty workaround.
174_HS_ORIG_LD_CMD= ${SETENV} PATH=${_PATH_ORIG} which ld 177_HS_ORIG_LD_CMD= ${SETENV} PATH=${_PATH_ORIG} which ld
175CONFIGURE_ARGS+= --ghc-options=-pgmlm\ ${_HS_ORIG_LD_CMD:sh} 178CONFIGURE_ARGS+= --ghc-options=-pgmlm\ ${_HS_ORIG_LD_CMD:sh}
176CONFIGURE_ARGS+= --ghc-options=-optlm\ -r 179CONFIGURE_ARGS+= --ghc-options=-optlm\ -r
177 180
178.if !exists(${PKGDIR}/PLIST) 181.if !exists(${PKGDIR}/PLIST)
179_HS_PLIST_STATUS= missing 182_HS_PLIST_STATUS= missing
180.elif !${${GREP} "." ${PKGDIR}/PLIST || ${TRUE}:L:sh} 183.elif !${${GREP} "." ${PKGDIR}/PLIST || ${TRUE}:L:sh}
181_HS_PLIST_STATUS= missing 184_HS_PLIST_STATUS= missing
182.elif ${${GREP} HS_VERSION ${PKGDIR}/PLIST || ${TRUE}:L:sh} 185.elif ${${GREP} HS_VERSION ${PKGDIR}/PLIST || ${TRUE}:L:sh}
183_HS_PLIST_STATUS= ok 186_HS_PLIST_STATUS= ok
184.elif !${${GREP} "/package-description" ${PKGDIR}/PLIST || ${TRUE}:L:sh} 187.elif !${${GREP} "/package-description" ${PKGDIR}/PLIST || ${TRUE}:L:sh}
185_HS_PLIST_STATUS= ok 188_HS_PLIST_STATUS= ok
186.else 189.else
187_HS_PLIST_STATUS= outdated 190_HS_PLIST_STATUS= outdated
188.endif 191.endif
189 192
190# Starting from GHC 7.10 (or 7.8?), packages are installed in directories 193# Starting from GHC 7.10 (or 7.8?), packages are installed in directories
191# with a hashed name, which makes it a bit more complicated to generate 194# with a hashed name, which makes it a bit more complicated to generate
192# the PLIST. 195# the PLIST.
193# 196#
194 197
195# There is no easy way to obtain a platform string such as 198# There is no easy way to obtain a platform string such as
196# "x86_64-netbsd-ghc-9.0.1". If the package contains a library we 199# "x86_64-netbsd-ghc-9.0.1". If the package contains a library we
197# could extract it from the description file, but if it's 200# could extract it from the description file, but if it's
198# executable-only there's no such file. As a workaround we read the 201# executable-only there's no such file. As a workaround we read the
199# description of "base" (which always exists) and extract the platform 202# description of "base" (which always exists) and extract the platform
200# from it. 203# from it.
201_HS_PLIST.platform.cmd= ${_HASKELL_PKG_BIN} --simple-output field base data-dir 204_HS_PLIST.platform.cmd= ${_HASKELL_PKG_BIN} --simple-output field base data-dir
202_HS_PLIST.platform= ${_HS_PLIST.platform.cmd:sh:H:T} 205_HS_PLIST.platform= ${_HS_PLIST.platform.cmd:sh:H:T}
203# Package ID formatted as "{name}-{version}-{hash}": this only exists 206# Package ID formatted as "{name}-{version}-{hash}": this only exists
204# if the package contains a library. 207# if the package contains a library.
205_HS_PLIST.lib.pkg-id.cmd= ${CAT} ${DESTDIR}${_HASKELL_PKG_ID_FILE} 208_HS_PLIST.lib.pkg-id.cmd= ${CAT} ${DESTDIR}${_HASKELL_PKG_ID_FILE}
206_HS_PLIST.lib.pkg-id= ${exists(${DESTDIR}${_HASKELL_PKG_ID_FILE}):?${_HS_PLIST.lib.pkg-id.cmd:sh}:} 209_HS_PLIST.lib.pkg-id= ${exists(${DESTDIR}${_HASKELL_PKG_ID_FILE}):?${_HS_PLIST.lib.pkg-id.cmd:sh}:}
207# Abbreviated compiler version. Used for shared libraries. 210# Abbreviated compiler version. Used for shared libraries.
208_HS_PLIST.short-ver= ${_HASKELL_VERSION:S,-,,} 211_HS_PLIST.short-ver= ${_HASKELL_VERSION:S,-,,}
209 212
210PLIST_SUBST+= HS_PLATFORM=${_HS_PLIST.platform} 213PLIST_SUBST+= HS_PLATFORM=${_HS_PLIST.platform}
211PLIST_SUBST+= HS_VERSION=${_HASKELL_VERSION} 214PLIST_SUBST+= HS_VERSION=${_HASKELL_VERSION}
212PLIST_SUBST+= HS_VER=${_HS_PLIST.short-ver} 215PLIST_SUBST+= HS_VER=${_HS_PLIST.short-ver}
213_HS_PLIST_SUBST.lib= HS_PKGID=${_HS_PLIST.lib.pkg-id} 216_HS_PLIST_SUBST.lib= HS_PKGID=${_HS_PLIST.lib.pkg-id}
214PLIST_SUBST+= ${!empty(_HS_PLIST.lib.pkg-id):?${_HS_PLIST_SUBST.lib}:} 217PLIST_SUBST+= ${!empty(_HS_PLIST.lib.pkg-id):?${_HS_PLIST_SUBST.lib}:}
215 218
216PRINT_PLIST_AWK+= { gsub("${_HS_PLIST.platform}", "$${HS_PLATFORM}") } 219PRINT_PLIST_AWK+= { gsub("${_HS_PLIST.platform}", "$${HS_PLATFORM}") }
217PRINT_PLIST_AWK+= { gsub("${_HASKELL_VERSION}", "$${HS_VERSION}" ) } 220PRINT_PLIST_AWK+= { gsub("${_HASKELL_VERSION}", "$${HS_VERSION}" ) }
218PRINT_PLIST_AWK+= { gsub("${_HS_PLIST.short-ver}", "$${HS_VER}" ) } 221PRINT_PLIST_AWK+= { gsub("${_HS_PLIST.short-ver}", "$${HS_VER}" ) }
219_HS_PRINT_PLIST_AWK.lib={ gsub("${_HS_PLIST.lib.pkg-id}", "$${HS_PKGID}" ) } 222_HS_PRINT_PLIST_AWK.lib={ gsub("${_HS_PLIST.lib.pkg-id}", "$${HS_PKGID}" ) }
220PRINT_PLIST_AWK+= ${!empty(_HS_PLIST.lib.pkg-id):?${_HS_PRINT_PLIST_AWK.lib}:} 223PRINT_PLIST_AWK+= ${!empty(_HS_PLIST.lib.pkg-id):?${_HS_PRINT_PLIST_AWK.lib}:}
221 224
222.if ${_HS_PLIST_STATUS} == missing || ${_HS_PLIST_STATUS} == outdated 225.if ${_HS_PLIST_STATUS} == missing || ${_HS_PLIST_STATUS} == outdated
223. if ${HS_UPDATE_PLIST} == yes 226. if ${HS_UPDATE_PLIST} == yes
224GENERATE_PLIST+= ${MAKE} print-PLIST > ${PKGDIR}/PLIST; 227GENERATE_PLIST+= ${MAKE} print-PLIST > ${PKGDIR}/PLIST;
225. endif 228. endif
226GENERATE_PLIST+= \ 229GENERATE_PLIST+= \
227 cd ${DESTDIR:Q}${PREFIX:Q} && \ 230 cd ${DESTDIR:Q}${PREFIX:Q} && \
228 ${FIND} * \( -type f -o -type l \) | ${SORT}; 231 ${FIND} * \( -type f -o -type l \) | ${SORT};
229PLIST_SRC= # none 232PLIST_SRC= # none
230.endif 233.endif
231 234
232.if ${_HS_PLIST_STATUS} == outdated && ${HS_UPDATE_PLIST} == no 235.if ${_HS_PLIST_STATUS} == outdated && ${HS_UPDATE_PLIST} == no
233WARNINGS+= "[haskell.mk] The PLIST format is outdated." 236WARNINGS+= "[haskell.mk] The PLIST format is outdated."
234WARNINGS+= "[haskell.mk] Set HS_UPDATE_PLIST=yes to update it automatically." 237WARNINGS+= "[haskell.mk] Set HS_UPDATE_PLIST=yes to update it automatically."
235.endif 238.endif
236 239
237# Define configure target. We might not have any working Haskell 240# Define configure target. We might not have any working Haskell
238# interpreter so compile Setup.?hs to a binary. Since dynamic linkage 241# interpreter so compile Setup.?hs to a binary. Since dynamic linkage
239# is much faster, we try it and then fall back to static linkage if 242# is much faster, we try it and then fall back to static linkage if
240# that didn't work. 243# that didn't work.
241do-configure: 244do-configure:
242# Cabal packages are expected to have either Setup.hs or Setup.lhs, 245# Cabal packages are expected to have either Setup.hs or Setup.lhs,
243# but its existence is not mandatory these days because the standard 246# but its existence is not mandatory these days because the standard
244# way to build a cabal package is to use the cabal-install command, 247# way to build a cabal package is to use the cabal-install command,
245# which is not always available to us. As a result some packages 248# which is not always available to us. As a result some packages
246# actually lack it. The problem is that its expected content depends 249# actually lack it. The problem is that its expected content depends
247# on the build-type field in *.cabal so we have to read it. 250# on the build-type field in *.cabal so we have to read it.
248 ${RUN} if ! ${TEST} -f ${WRKSRC}/Setup.hs -o -f ${WRKSRC}/Setup.lhs; then \ 251 ${RUN} if ! ${TEST} -f ${WRKSRC}/Setup.hs -o -f ${WRKSRC}/Setup.lhs; then \
249 buildType=`${AWK} -f ../../mk/haskell/build-type.awk ${WRKSRC}/*.cabal`; \ 252 buildType=`${AWK} -f ../../mk/haskell/build-type.awk ${WRKSRC}/*.cabal`; \
250 ${SH} ../../mk/haskell/gen-setup.sh "$$buildType" > ${WRKDIR}/.setup.hs; \ 253 ${SH} ../../mk/haskell/gen-setup.sh "$$buildType" > ${WRKDIR}/.setup.hs; \
251 ret=$$?; \ 254 ret=$$?; \
252 if ${TEST} $$ret -eq 0; then \ 255 if ${TEST} $$ret -eq 0; then \
253 ${MV} -f ${WRKDIR}/.setup.hs ${WRKSRC}/Setup.hs; \ 256 ${MV} -f ${WRKDIR}/.setup.hs ${WRKSRC}/Setup.hs; \
254 else \ 257 else \
255 exit $$ret; \ 258 exit $$ret; \
256 fi; \ 259 fi; \
257 fi 260 fi
258 ${RUN} ${_ULIMIT_CMD} cd ${WRKSRC} && \ 261 ${RUN} ${_ULIMIT_CMD} cd ${WRKSRC} && \
259 ( ${_HASKELL_BIN:Q} ${_HASKELL_BUILD_SETUP_OPTS} --make Setup -dynamic || \ 262 ( ${_HASKELL_BIN:Q} ${_HASKELL_BUILD_SETUP_OPTS} --make Setup -dynamic || \
260 ${_HASKELL_BIN:Q} ${_HASKELL_BUILD_SETUP_OPTS} --make Setup -static ) 263 ${_HASKELL_BIN:Q} ${_HASKELL_BUILD_SETUP_OPTS} --make Setup -static )
261 ${RUN} ${_ULIMIT_CMD} cd ${WRKSRC:Q} && \ 264 ${RUN} ${_ULIMIT_CMD} cd ${WRKSRC:Q} && \
262 ${SETENV} ${CONFIGURE_ENV} \ 265 ${SETENV} ${CONFIGURE_ENV} \
263 ./Setup configure ${PKG_VERBOSE:D-v} ${CONFIGURE_ARGS} 266 ./Setup configure ${PKG_VERBOSE:D-v} ${CONFIGURE_ARGS}
264 267
265# Define build target. _MAKE_JOBS_N is defined in build/build.mk 268# Define build target. _MAKE_JOBS_N is defined in build/build.mk
266do-build: 269do-build:
267 ${RUN} ${_ULIMIT_CMD} cd ${WRKSRC:Q} && \ 270 ${RUN} ${_ULIMIT_CMD} cd ${WRKSRC:Q} && \
268 ${SETENV} ${MAKE_ENV} \ 271 ${SETENV} ${MAKE_ENV} \
269 ./Setup build ${PKG_VERBOSE:D-v} -j${_MAKE_JOBS_N} 272 ./Setup build ${PKG_VERBOSE:D-v} -j${_MAKE_JOBS_N}
270.if ${HASKELL_ENABLE_HADDOCK_DOCUMENTATION} == "yes" 273.if ${HASKELL_ENABLE_HADDOCK_DOCUMENTATION} == "yes"
271 ${RUN} ${_ULIMIT_CMD} cd ${WRKSRC:Q} && \ 274 ${RUN} ${_ULIMIT_CMD} cd ${WRKSRC:Q} && \
272 ${SETENV} ${MAKE_ENV} \ 275 ${SETENV} ${MAKE_ENV} \
273 ./Setup haddock ${PKG_VERBOSE:D-v} 276 ./Setup haddock ${PKG_VERBOSE:D-v}
274.endif 277.endif
275 278
276# Define install target. We need installed-pkg-config to be installed 279# Define install target. We need installed-pkg-config to be installed
277# for package registration (if any). 280# for package registration (if any).
278HASKELL_PKG_NAME?= ${DISTNAME} 281HASKELL_PKG_NAME?= ${DISTNAME}
279_HASKELL_PKG_DESCR_DIR= ${PREFIX}/lib/${HASKELL_PKG_NAME}/${_HASKELL_VERSION} 282_HASKELL_PKG_DESCR_DIR= ${PREFIX}/lib/${HASKELL_PKG_NAME}/${_HASKELL_VERSION}
280_HASKELL_PKG_DESCR_FILE= ${_HASKELL_PKG_DESCR_DIR}/package-description 283_HASKELL_PKG_DESCR_FILE= ${_HASKELL_PKG_DESCR_DIR}/package-description
281_HASKELL_PKG_ID_FILE= ${_HASKELL_PKG_DESCR_DIR}/package-id 284_HASKELL_PKG_ID_FILE= ${_HASKELL_PKG_DESCR_DIR}/package-id
282 285
283INSTALLATION_DIRS+= ${_HASKELL_PKG_DESCR_DIR} 286INSTALLATION_DIRS+= ${_HASKELL_PKG_DESCR_DIR}
284do-install: 287do-install:
285 ${RUN} ${_ULIMIT_CMD} cd ${WRKSRC} && \ 288 ${RUN} ${_ULIMIT_CMD} cd ${WRKSRC} && \
286 ./Setup register ${PKG_VERBOSE:D-v} \ 289 ./Setup register ${PKG_VERBOSE:D-v} \
287 --gen-pkg-config=dist/package-description \ 290 --gen-pkg-config=dist/package-description \
288 --print-ipid \ 291 --print-ipid \
289 > dist/package-id && \ 292 > dist/package-id && \
290 ./Setup copy ${PKG_VERBOSE:D-v} --destdir=${DESTDIR:Q} && \ 293 ./Setup copy ${PKG_VERBOSE:D-v} --destdir=${DESTDIR:Q} && \
291 if [ -f dist/package-description ]; then \ 294 if [ -f dist/package-description ]; then \
292 ${INSTALL_DATA} dist/package-description \ 295 ${INSTALL_DATA} dist/package-description \
293 ${DESTDIR:Q}${_HASKELL_PKG_DESCR_FILE:Q}; \ 296 ${DESTDIR:Q}${_HASKELL_PKG_DESCR_FILE:Q}; \
294 ${INSTALL_DATA} dist/package-id \ 297 ${INSTALL_DATA} dist/package-id \
295 ${DESTDIR:Q}${_HASKELL_PKG_ID_FILE:Q}; \ 298 ${DESTDIR:Q}${_HASKELL_PKG_ID_FILE:Q}; \
296 fi 299 fi
297# Executable-only packages tend to create an empty directory tree in 300# Executable-only packages tend to create an empty directory tree in
298# lib/ which results in useless @pkgdir in PLIST. 301# lib/ which results in useless @pkgdir in PLIST.
299 ${RUN}${FIND} ${DESTDIR:Q}${PREFIX}/lib -type d | \ 302 ${RUN}${FIND} ${DESTDIR:Q}${PREFIX}/lib -type d | \
300 ${TAIL} -n 1 | \ 303 ${TAIL} -n 1 | \
301 ${XARGS} ${RMDIR} -p 2>/dev/null || ${TRUE} 304 ${XARGS} ${RMDIR} -p 2>/dev/null || ${TRUE}
302 305
303# Define test target. 306# Define test target.
304do-test: 307do-test:
305 ${RUN} ${_ULIMIT_CMD} cd ${WRKSRC} && \ 308 ${RUN} ${_ULIMIT_CMD} cd ${WRKSRC} && \
306 ./Setup test ${PKG_VERBOSE:D-v} 309 ./Setup test ${PKG_VERBOSE:D-v}
307 310
308# Substitutions for INSTALL and DEINSTALL. 311# Substitutions for INSTALL and DEINSTALL.
309FILES_SUBST+= HASKELL_PKG_BIN=${_HASKELL_PKG_BIN} 312FILES_SUBST+= HASKELL_PKG_BIN=${_HASKELL_PKG_BIN}
310FILES_SUBST+= HASKELL_PKG_DESCR_FILE=${_HASKELL_PKG_DESCR_FILE} 313FILES_SUBST+= HASKELL_PKG_DESCR_FILE=${_HASKELL_PKG_DESCR_FILE}
311FILES_SUBST+= HASKELL_PKG_ID_FILE=${_HASKELL_PKG_ID_FILE} 314FILES_SUBST+= HASKELL_PKG_ID_FILE=${_HASKELL_PKG_ID_FILE}
312 315
313INSTALL_TEMPLATES+= ../../mk/haskell/INSTALL.in 316INSTALL_TEMPLATES+= ../../mk/haskell/INSTALL.in
314DEINSTALL_TEMPLATES+= ../../mk/haskell/DEINSTALL.in 317DEINSTALL_TEMPLATES+= ../../mk/haskell/DEINSTALL.in
315 318
316# Only present these variables if the definitions can be extracted 319# Only present these variables if the definitions can be extracted
317# from the files in DESTDIR. 320# from the files in DESTDIR.
318_DEF_VARS.haskell+= _HS_PLIST.platform 321_DEF_VARS.haskell+= _HS_PLIST.platform
319_DEF_VARS.haskell+= _HS_PLIST.short-ver 322_DEF_VARS.haskell+= _HS_PLIST.short-ver
320_DEF_VARS.haskell+= ${!empty(_HS_PLIST.lib.pkg-id):?_HS_PLIST.lib.pkg-id:} 323_DEF_VARS.haskell+= ${!empty(_HS_PLIST.lib.pkg-id):?_HS_PLIST.lib.pkg-id:}
321 324
322.endif # HASKELL_MK 325.endif # HASKELL_MK