Tweak math/octave-forge-stk version 2.3.4
[dports.git] / Mk / bsd.linux-rpm.mk
1 #-*- tab-width: 4; -*-
2 # ex:ts=4
3 #
4 # $FreeBSD$
5 #
6
7 # Variables:
8 # LINUX_DIST            - Will be used to set some dist-specific presets.
9 #                                         Valid values: fedora
10 # LINUX_DIST_VER        - Use depends upon the dist-specific presets.
11 #                                         Valid values for "fedora": all version numbers
12 #                                         e.g. 10 for fedora 10
13 #                                         Valid values for "centos": all version numbers
14 #                                         e.g. 6.7 for centos 6.7
15 #                                         This is used to set MASTER_SITE_{,SRC_}SUBDIR
16 #                                         if it isn't already set.
17 # MASTER_SITE_SRC_SUBDIR
18 #                                       - The subdir for the src RPM's.
19 # DISTFILES                     - For simple cases this will be set automatically
20 #                                         based upon the DISTNAME.
21 # SRC_DISTFILES         - Variable which contains the corresponding src RPM's.
22 #                                         If there's no corresponding src RPM, it has to be
23 #                                         set to the empty value (SRC_DISTFILES=        "").
24 # AUTOMATIC_PLIST       - Generate a dynamic plist (please have a look at the
25 #                                         porters handbook section which talks about plists.
26 #                                         This feature is reserved for rare cases).
27 # BRANDELF_DIRS         - A list of directories with executables to brand
28 #                                         as a linux executable. The directories has to not
29 #                                         contain libraries.
30 # BRANDELF_FILES        - A list of files to brand as a linux executable in
31 #                                         case BRANDELF_DIRS can't be used.
32
33 .if !defined(_POSTMKINCLUDED) && !defined(Linux_RPM_Pre_Include)
34
35 Linux_RPM_Include_MAINTAINER=   emulation@FreeBSD.org
36 Linux_RPM_Pre_Include=                  bsd.linux-rpm.mk
37
38 EXTRACT_SUFX?=          .${LINUX_RPM_ARCH}.rpm
39 SRC_SUFX?=              .src.rpm
40
41 USE_LINUX?=                     yes
42 USE_LINUX_PREFIX=       yes
43
44 NO_WRKSUBDIR=           yes
45 NO_BUILD=                       yes
46
47 .       if ${USE_LINUX} == "c6" || ${USE_LINUX} == "c6_64" || ${USE_LINUX} == "yes" # default to CentOS
48 # Do not build CentOS 6 ports if overridden by f10
49 .               if defined(OVERRIDE_LINUX_NONBASE_PORTS) && ${OVERRIDE_LINUX_NONBASE_PORTS} == "f10"
50 IGNORE= This port requires CentOS ${LINUX_DIST_VER}. Please remove OVERRIDE_LINUX_NONBASE_PORTS=f10 in /etc/make.conf.
51 .               endif
52 .       endif
53
54 .endif
55
56 .if defined(_POSTMKINCLUDED) && !defined(Linux_RPM_Post_Include)
57
58 Linux_RPM_Post_Include= bsd.linux-rpm.mk
59
60 .if ${USE_LINUX} == "f10"
61 USE_LINUX?=     "f10"
62 LINUX_DIST=     fedora
63 LINUX_DIST_VER= 10
64 .else                   # default to CentOS
65 LINUX_DIST=     centos
66 LINUX_DIST_VER= 6.7
67 .endif
68
69 .if defined(LINUX_DIST)
70 DIST_SUBDIR?=   rpm/${LINUX_RPM_ARCH}/${LINUX_DIST}/${LINUX_DIST_VER}
71
72 .       if ${LINUX_DIST} == "fedora"
73 # we do not want to define MASTER_SITES and MASTER_SITE_* if they are already defined
74 # ex.: MASTER_SITES=file:///...
75 .               ifndef MASTER_SITES
76 MASTER_SITES=           ${MASTER_SITE_FEDORA_LINUX}
77 .                       if ${LINUX_DIST_VER} == 10
78 MASTER_SITE_SUBDIR?=    ../releases/${LINUX_DIST_VER}/Everything/${LINUX_RPM_ARCH}/os/Packages \
79                         ../updates/${LINUX_DIST_VER}/${LINUX_RPM_ARCH}
80 MASTER_SITE_SRC_SUBDIR?=        ../releases/${LINUX_DIST_VER}/Everything/source/SRPMS \
81                                 ../updates/${LINUX_DIST_VER}/SRPMS
82 .                       else
83 MASTER_SITE_SUBDIR?=    ${LINUX_DIST_VER}/${LINUX_RPM_ARCH}/os/Fedora/RPMS \
84                         updates/${LINUX_DIST_VER}/${LINUX_RPM_ARCH}
85 MASTER_SITE_SRC_SUBDIR?=        ${LINUX_DIST_VER}/SRPMS \
86                                 updates/${LINUX_DIST_VER}/SRPMS
87 .                       endif
88 .               endif
89 .       elif ${LINUX_DIST} == "centos"
90 MASTER_SITES?=          ${MASTER_SITE_CENTOS_LINUX} ${MASTER_SITE_CENTOS_LINUX_UPDATES}
91 MASTER_SITE_SUBDIR?=    centos/${LINUX_DIST_VER}/os/${LINUX_REPO_ARCH}/Packages/ \
92                         centos/${LINUX_DIST_VER}/updates/${LINUX_REPO_ARCH}/Packages/
93 .               if ${LINUX_DIST_VER} == "5" #needed for Qt...
94 LINUX_RPM_ARCH=         i386
95 MASTER_SITE_SUBDIR=     centos/5/os/i386/Packages/
96 .               endif
97 .               if defined(PACKAGE_BUILDING)
98 _SRC_GROUP=:SOURCE
99 MASTER_SITES+=  http://vault.centos.org/%SUBDIR%/:SOURCE
100 MASTER_SITE_SUBDIR+=    ${LINUX_DIST_VER}/os/Source/SPackages/:SOURCE
101 .               endif
102 .       endif
103 .endif
104
105 PKGNAMEPREFIX?=                 linux-${USE_LINUX}-
106
107 # DISTFILES and SRC_DISTFILES assume that there is only one bindist
108 # and one src file.
109 # Please, define them in the Makefile of the port in case this assumption
110 # is not true.
111
112 DISTVERSION=    ${PORTVERSION}-${RPMVERSION}
113 DISTNAME?=              ${PORTNAME}-${DISTVERSION}
114 DISTFILES?=             ${DISTNAME}${EXTRACT_SUFX}
115 BIN_DISTFILES:=         ${DISTFILES} ${LIB_DISTFILES}
116 SRC_DISTFILES?=         ${DISTNAME}${SRC_SUFX}${_SRC_GROUP}
117 EXTRACT_ONLY?=          ${BIN_DISTFILES:C/:[^:]+$//}
118 WRKSRC:=                ${WRKSRC:S/-${RPMVERSION}$//}
119
120 # Define files to install.
121 # Ports can want to install 32bit things only (if OVERRIDE_LINUX_NONBASE_PORTS) is off,
122 # they can want to install both 32bit and 64bit things of only one package,
123 # or they can want to install a 64bit only binary and e.g. 32/64bit libraries.
124
125 # The following glue is supposed to handle this.
126 # FIXME: Sensibly refactor this part, it looks like spaghetti.
127
128 .   if defined(OVERRIDE_LINUX_NONBASE_PORTS) && ${OVERRIDE_LINUX_NONBASE_PORTS} == "c6_64"
129 _32BIT_LINUX_RPM_ARCH=  i686
130 .       if ${DISTFILES} == ${DISTNAME}${EXTRACT_SUFX} && ${USE_LINUX_RPM} != "nolib"
131 _32BIT_LIB_DISTFILES:=   ${DISTFILES:S/${LINUX_RPM_ARCH}/${_32BIT_LINUX_RPM_ARCH}/g}
132 .       elif defined(LIB_DISTFILES)
133 _32BIT_LIB_DISTFILES=   ${LIB_DISTFILES:S/${LINUX_RPM_ARCH}/${_32BIT_LINUX_RPM_ARCH}/g}
134 .       endif
135
136 BIN_DISTFILES:=         ${BIN_DISTFILES} ${_32BIT_LIB_DISTFILES}
137 DISTFILES+=             ${_32BIT_LIB_DISTFILES}
138 .   endif
139 DISTFILES+=             ${LIB_DISTFILES}
140
141
142 .       if defined(PACKAGE_BUILDING)
143 DISTFILES+=             ${SRC_DISTFILES}
144 MASTER_SITE_SUBDIR+=    ${MASTER_SITE_SRC_SUBDIR}
145 ALWAYS_KEEP_DISTFILES=  yes
146 .       endif
147
148 .if !defined(USE_LINUX_RPM_BAD_PERMS)
149 EXTRACT_CMD?=                   ${TAR}
150 EXTRACT_BEFORE_ARGS?=   --no-same-permissions --no-same-owner -xf
151 EXTRACT_AFTER_ARGS?=
152 .else
153 EXTRACT_DEPENDS+=       rpm2archive:archivers/rpm4
154 EXTRACT_CMD?=   rpm2archive
155 EXTRACT_BEFORE_ARGS?=   <
156 EXTRACT_AFTER_ARGS?=    | ${TAR} xf - --no-same-permissions --no-same-owner
157 .endif
158
159 DISTINFO_FILE?=                         ${MASTERDIR}/distinfo.${LINUX_RPM_ARCH}
160
161 BRANDELF_DIRS?=
162 BRANDELF_FILES?=
163
164 # For ports that define PORTDOCS, be sure not to install
165 # documentation if NOPORTDOCS is defined
166 .  if defined(PORTDOCS) && defined(NOPORTDOCS)
167 pre-patch: linux-rpm-clean-portdocs
168
169 .               if !target(linux-rpm-clean-portdocs)
170 linux-rpm-clean-portdocs:
171 .                       for x in ${PORTDOCS}
172         @${RM} -f ${WRKSRC}/${DOCSDIR_REL}/${x}
173 .                       endfor
174         @${RMDIR} ${WRKSRC}/${DOCSDIR_REL}
175 .               endif
176 .  endif
177
178 .  if ${USE_LINUX} != "f10"
179 PLIST?=         ${MASTERDIR}/pkg-plist.${LINUX_RPM_ARCH}
180 .  endif
181
182 .  if defined(AUTOMATIC_PLIST)
183
184 .       if ${USE_LINUX} == "f10"
185 _LINUX_BASE_SUFFIX=             f10
186 .       elif ${USE_LINUX} == "c6" || ${USE_LINUX} == "yes"
187 _LINUX_BASE_SUFFIX=             c6
188 .       elif ${USE_LINUX} == "c6_64"
189 _LINUX_BASE_SUFFIX=             c6
190 .       else
191 # other linux_base ports do not provide a pkg-plist file
192 IGNORE=                                 uses AUTOMATIC_PLIST with an unsupported USE_LINUX, \"${USE_LINUX}\". Supported values are \"yes\", \"f10\", \"c6\", and \"c6_64\"
193 .  endif
194
195 PLIST?=                                 ${WRKDIR}/.PLIST.linux-rpm
196
197 pre-install: linux-rpm-generate-plist
198
199 .  if !target(linux-rpm-generate-plist)
200 linux-rpm-generate-plist:
201         cd ${WRKSRC} && \
202         ${FIND} * ! -type d | ${SORT} > ${PLIST}
203 .       endif
204 .  endif
205
206 .  if !target(do-install)
207 do-install:
208 .       if ${BRANDELF_DIRS}
209                 @cd ${WRKSRC} && ${FIND} ${BRANDELF_DIRS} -type f -print0 \
210                 | ${XARGS} -0 ${FILE} | ${GREP} ELF | ${CUT} -d : -f 1 \
211                 | ${XARGS} ${BRANDELF} -t Linux
212 .       endif
213 .       if ${BRANDELF_FILES}
214                 @cd ${WRKSRC} && ${BRANDELF} -t Linux ${BRANDELF_FILES}
215 .       endif
216         cd ${WRKSRC} && ${FIND} * -type d -exec ${MKDIR} "${STAGEDIR}${PREFIX}/{}" \;
217         cd ${WRKSRC} && ${FIND} * ! -type d | ${CPIO} -pm -R root:wheel ${STAGEDIR}${PREFIX}
218 .  endif
219 .endif