Tweak sysutils/healthd version 0.7.9_2
[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 #                                         This is used to set MASTER_SITE_{,SRC_}SUBDIR
14 #                                         if it isn't already set.
15 # MASTER_SITE_SRC_SUBDIR
16 #                                       - The subdir for the src RPM's.
17 # DISTFILES                     - For simple cases this will be set automatically
18 #                                         based upon the DISTNAME.
19 # SRC_DISTFILES         - Variable which contains the corresponding src RPM's.
20 #                                         If there's no corresponding src RPM, it has to be
21 #                                         set to the empty value (SRC_DISTFILES=        "").
22 # AUTOMATIC_PLIST       - Generate a dynamic plist (please have a look at the
23 #                                         porters handbook section which talks about plists.
24 #                                         This feature is reserved for rare cases).
25 # BRANDELF_DIRS         - A list of directories with executables to brand
26 #                                         as a linux executable. The directories has to not
27 #                                         contain libraries.
28 # BRANDELF_FILES        - A list of files to brand as a linux executable in
29 #                                         case BRANDELF_DIRS can't be used.
30
31 .if !defined(_POSTMKINCLUDED) && !defined(Linux_RPM_Pre_Include)
32
33 Linux_RPM_Include_MAINTAINER=   emulation@FreeBSD.org
34 Linux_RPM_Pre_Include=                  bsd.linux-rpm.mk
35
36 EXTRACT_SUFX?=          .${LINUX_RPM_ARCH}.rpm
37 SRC_SUFX?=              .src.rpm
38
39 USE_LINUX?=                     yes
40 USE_LINUX_PREFIX=       yes
41
42 NO_WRKSUBDIR=           yes
43 NO_BUILD=                       yes
44
45 .       if ${ARCH} == "amd64" || ${ARCH} == "i386"
46 .               if ${USE_LINUX} == "c6" || ${USE_LINUX} == "yes" # default to CentOS
47 # Do not build CentOS 6 ports if overridden by f10
48 .                       if defined(OVERRIDE_LINUX_BASE_PORT) && ${OVERRIDE_LINUX_NONBASE_PORTS} == "f10"
49 IGNORE=         This port requires CentOS ${LINUX_DIST_VER}. Please remove OVERRIDE_LINUX_NONBASE_PORTS=f10 in /etc/make.conf.
50 .                       endif
51 LINUX_RPM_ARCH?=        i686    # ?= because of nasty c5 qt ports
52 .               elif ${USE_LINUX} == "f10"
53 # Do not build Fedora 10 ports unless specifically overridden.
54 #.                      if ! defined(OVERRIDE_LINUX_NONBASE_PORTS) || ${OVERRIDE_LINUX_NONBASE_PORTS} != "f10"
55 #IGNORE=                This port requires Fedora 10, yet Fedora 10 is heavily outdated and contains many vulnerable ports. If you really need it, add OVERRIDE_LINUX_NONBASE_PORTS=f10 in /etc/make.conf.
56 #.                      endif
57 LINUX_RPM_ARCH?=        i386    # the linuxulator does not yet support amd64 code
58 .               else
59 LINUX_RPM_ARCH?=        ${ARCH}
60 .               endif
61
62 .       elif ${ARCH} == "powerpc"
63 LINUX_RPM_ARCH?=        ppc
64 .       endif
65 .endif
66
67 .if defined(_POSTMKINCLUDED) && !defined(Linux_RPM_Post_Include)
68
69 Linux_RPM_Post_Include= bsd.linux-rpm.mk
70
71 .if ${USE_LINUX} == "f10"
72 USE_LINUX?=     "f10"
73 LINUX_DIST=     fedora
74 LINUX_DIST_VER= 10
75 .else                   # default to CentOS
76 LINUX_DIST=     centos
77 LINUX_DIST_VER= 6.6
78 .endif
79
80 .       if defined(LINUX_DIST)
81 DIST_SUBDIR?=   rpm/${LINUX_RPM_ARCH}/${LINUX_DIST}/${LINUX_DIST_VER}
82
83 .               if ${LINUX_DIST} == "fedora"
84 # we do not want to define MASTER_SITES and MASTER_SITE_* if they are already defined
85 # ex.: MASTER_SITES=file:///...
86 .                       ifndef MASTER_SITES
87 MASTER_SITES=                   ${MASTER_SITE_FEDORA_LINUX}
88 .                               if ${LINUX_DIST_VER} == 10
89 MASTER_SITE_SUBDIR?=    ../releases/${LINUX_DIST_VER}/Everything/${LINUX_RPM_ARCH}/os/Packages \
90                         ../updates/${LINUX_DIST_VER}/${LINUX_RPM_ARCH}
91 MASTER_SITE_SRC_SUBDIR?=        ../releases/${LINUX_DIST_VER}/Everything/source/SRPMS \
92                                 ../updates/${LINUX_DIST_VER}/SRPMS
93 .                               else
94 MASTER_SITE_SUBDIR?=    ${LINUX_DIST_VER}/${LINUX_RPM_ARCH}/os/Fedora/RPMS \
95                         updates/${LINUX_DIST_VER}/${LINUX_RPM_ARCH}
96 MASTER_SITE_SRC_SUBDIR?=        ${LINUX_DIST_VER}/SRPMS \
97                                 updates/${LINUX_DIST_VER}/SRPMS
98 .                               endif
99 .                       endif
100 .               elif ${LINUX_DIST} == "centos"
101 MASTER_SITES_SUBDIR=    /centos/6/os/i386/Packages/
102 .                       if ${LINUX_DIST_VER} == "5" #needed for Qt...
103 LINUX_RPM_ARCH= i386
104 MASTER_SITES_SUBDIR=    /centos/5/os/i386/Packages/
105 .                       endif
106
107 .                       ifndef MASTER_SITES
108 MASTER_SITES=   ${MASTER_SITE_CENTOS_LINUX}
109 .                               if ${LINUX_DIST_VER} == "6.6"
110 .                                       if ! defined(PACKAGE_BUILDING)
111 MASTER_SITES=   http://mirror.centos.org/centos/6/os/i386/Packages/
112 MASTER_SITES_SUBDIR=    /centos/6/os/i386/Packages/
113 .                                       else
114 MASTER_SITES?=  http://vault.centos.org/%SUBDIR%/
115 MASTER_SITES_SUBDIR=    /${LINUX_DIST_VER}/os/Source/SPackages/
116 .                                       endif
117
118 .                               else
119 MASTER_SITES=   http://vault.centos.org/${LINUX_DIST_VER}/os/i386/Packages/
120 .                               endif
121 .                       endif
122
123 .               endif
124 .       endif
125
126
127 #.if ${USE_LINUX:L} == "yes" #redundant with bsd.port.mk fu
128 #USE_LINUX=     c6
129 #.endif
130 PKGNAMEPREFIX?=                 linux-${USE_LINUX}-
131
132 # DISTFILES and SRC_DISTFILES assume that there is only one bindist
133 # and one src file.
134 # Please, define them in the Makefile of the port in case this assumption
135 # is not true.
136
137 DISTVERSION=    ${PORTVERSION}-${RPMVERSION}
138 DISTNAME?=              ${PORTNAME}-${DISTVERSION}
139 DISTFILES?=             ${DISTNAME}${EXTRACT_SUFX}
140 BIN_DISTFILES:=         ${DISTFILES}
141 SRC_DISTFILES?=         ${DISTNAME}${SRC_SUFX}
142 EXTRACT_ONLY?=          ${BIN_DISTFILES:C/:[^:]+$//}
143
144 .       if defined(PACKAGE_BUILDING)
145 DISTFILES+=             ${SRC_DISTFILES}
146 MASTER_SITE_SUBDIR+=    ${MASTER_SITE_SRC_SUBDIR}
147 ALWAYS_KEEP_DISTFILES=  yes
148 .       endif
149
150 EXTRACT_CMD?=                   ${TAR}
151 EXTRACT_BEFORE_ARGS?=   -xf
152 EXTRACT_AFTER_ARGS?=
153
154 DISTINFO_FILE?=                         ${MASTERDIR}/distinfo.${LINUX_RPM_ARCH}
155
156 BRANDELF_DIRS?=
157 BRANDELF_FILES?=
158
159 # For ports that define PORTDOCS, be sure not to install
160 # documentation if NOPORTDOCS is defined
161 .  if defined(PORTDOCS) && defined(NOPORTDOCS)
162 pre-patch: linux-rpm-clean-portdocs
163
164 .               if !target(linux-rpm-clean-portdocs)
165 linux-rpm-clean-portdocs:
166 .                       for x in ${PORTDOCS}
167         @${RM} -f ${WRKDIR}/${DOCSDIR_REL}/${x}
168 .                       endfor
169         @${RMDIR} ${WRKDIR}/${DOCSDIR_REL}
170 .               endif
171 .  endif
172
173 .  if defined(AUTOMATIC_PLIST)
174
175 .       if ${USE_LINUX} == "f10" || ${USE_LINUX} == "yes"
176 _LINUX_BASE_SUFFIX=             f10
177 .       elif ${USE_LINUX} == "c6"
178 USE_LINUX=      c6
179 _LINUX_BASE_SUFFIX=             c6
180 .       else
181 # other linux_base ports do not provide a pkg-plist file
182 IGNORE=                                 uses AUTOMATIC_PLIST with an unsupported USE_LINUX, \"${USE_LINUX}\". Supported values are \"yes\", \"f10\" and \"c6\"
183 .  endif
184
185 PLIST?=                                 ${WRKDIR}/.PLIST.linux-rpm
186
187 pre-install: linux-rpm-generate-plist
188
189 .  if !target(linux-rpm-generate-plist)
190 linux-rpm-generate-plist:
191         cd ${WRKSRC} && \
192         ${FIND} * ! -path "stage/*" ! -type d | ${SORT} > ${PLIST}
193 .       endif
194 .  endif
195
196 .  if !target(do-install)
197 do-install:
198 .       if ${BRANDELF_DIRS}
199                 @cd ${WRKSRC} && ${FIND} ${BRANDELF_DIRS} -type f -print0 \
200                 | ${XARGS} -0 ${FILE} | ${GREP} ELF | ${CUT} -d : -f 1 \
201                 | ${XARGS} ${BRANDELF} -t Linux
202 .       endif
203 .       if ${BRANDELF_FILES}
204                 @cd ${WRKSRC} && ${BRANDELF} -t Linux ${BRANDELF_FILES}
205 .       endif
206         cd ${WRKSRC} && ${FIND} * ! -path "stage*" -type d -exec ${MKDIR} "${STAGEDIR}${PREFIX}/{}" \;
207         cd ${WRKSRC} && ${FIND} * ! -path "stage/*" ! -type d | ${CPIO} -pm -R root:wheel ${STAGEDIR}${PREFIX}
208 .  endif
209 .endif