# $NetBSD: Makefile.common,v 1.27 2022/12/19 18:14:57 tron Exp $
#
# used by emulators/suse131_alsa/Makefile
# used by emulators/suse131_aspell/Makefile
# used by emulators/suse131_base/Makefile
# used by emulators/suse131_binutils/Makefile
# used by emulators/suse131_compat/Makefile
# used by emulators/suse131_cyrus-sasl/Makefile
# used by emulators/suse131_dbus-glib/Makefile
# used by emulators/suse131_expat/Makefile
# used by emulators/suse131_fontconfig/Makefile
# used by emulators/suse131_freetype2/Makefile
# used by emulators/suse131_glib2/Makefile
# used by emulators/suse131_glx/Makefile
# used by emulators/suse131_gtk2/Makefile
# used by emulators/suse131_gtk3/Makefile
# used by emulators/suse131_krb5/Makefile
# used by emulators/suse131_libSDL/Makefile
# used by emulators/suse131_libaudiofile/Makefile
# used by emulators/suse131_libcups/Makefile
# used by emulators/suse131_libcurl/Makefile
# used by emulators/suse131_libdbus/Makefile
# used by emulators/suse131_libdrm/Makefile
# used by emulators/suse131_libesd/Makefile
# used by emulators/suse131_libffi/Makefile
# used by emulators/suse131_libgc/Makefile
# used by emulators/suse131_libidn/Makefile
# used by emulators/suse131_libjpeg/Makefile
# used by emulators/suse131_libjson/Makefile
# used by emulators/suse131_libpng/Makefile
# used by emulators/suse131_libsigc++2/Makefile
# used by emulators/suse131_libsndfile/Makefile
# used by emulators/suse131_libssh/Makefile
# used by emulators/suse131_libtiff/Makefile
# used by emulators/suse131_libwebp/Makefile
# used by emulators/suse131_libwrap/Makefile
# used by emulators/suse131_libxml2/Makefile
# used by emulators/suse131_libxslt/Makefile
# used by emulators/suse131_locale/Makefile
# used by emulators/suse131_lsb/Makefile
# used by emulators/suse131_motif/Makefile
# used by emulators/suse131_mozilla-nspr/Makefile
# used by emulators/suse131_mozilla-nss/Makefile
# used by emulators/suse131_openal/Makefile
# used by emulators/suse131_openldap/Makefile
# used by emulators/suse131_openssl/Makefile
# used by emulators/suse131_pulseaudio/Makefile
# used by emulators/suse131_qt4/Makefile
# used by emulators/suse131_slang/Makefile
# used by emulators/suse131_x11/Makefile
# used by meta-pkgs/suse131/Makefile

SUSE_PKG=		yes
SUSE_VERSION=		13.1
EMUL_REQD=		suse>=${SUSE_VERSION}

# The SuSE 13.x Linux packages are only usable on the following platforms.
# The SUSE_COMPAT32 packages are available only on x86_64 and they emulate i386.
# The non-SUSE_COMPAT32 packages are available on both i386 and x86_64
# and they emulate the corresponding linux platform.
.if !defined(SUSE_COMPAT32)
EMUL_PLATFORMS+=	linux-x86_64
ONLY_FOR_PLATFORM+=	NetBSD-5.99*-i386
ONLY_FOR_PLATFORM+=	NetBSD-[6-9]*-i386
ONLY_FOR_PLATFORM+=	NetBSD-[1-9][0-9].*-i386
ONLY_FOR_PLATFORM+=	FreeBSD-*-i386
.endif
EMUL_PLATFORMS+=	linux-i386
ONLY_FOR_PLATFORM+=	NetBSD-6.99*-x86_64
ONLY_FOR_PLATFORM+=	NetBSD-[7-9]*-x86_64
ONLY_FOR_PLATFORM+=	NetBSD-[1-9][0-9].*-x86_64
ONLY_FOR_PLATFORM+=	FreeBSD-1[0-9]*-x86_64

CHECK_PIE_SUPPORTED=	no
CHECK_RELRO_SUPPORTED=	no

.include "../../mk/bsd.prefs.mk"

# _SUSE_ARCH.* is a table of ${EMUL_ARCH} to SuSE architectures.
_SUSE_ARCH.${EMUL_ARCH}=	${EMUL_ARCH}
_SUSE_ARCH.i386=		i586
_SUSE_ARCH=			${_SUSE_ARCH.${EMUL_ARCH}}
SUSE_ARCH=			${_SUSE_ARCH}

_SUSE_FTP_SUBDIR=	distribution/${SUSE_VERSION}/repo/oss/suse/
_SUSE_FTP_SUBDIR_UPD=	update/${SUSE_VERSION}/

MASTER_SITE_SUSE_${SUSE_VERSION}= \
	http://ftp5.gwdg.de/pub/opensuse/discontinued/${_SUSE_FTP_SUBDIR}

MASTER_SITE_SUSE_${SUSE_VERSION}_UPD= \
	http://ftp5.gwdg.de/pub/opensuse/discontinued/${_SUSE_FTP_SUBDIR_UPD}

MASTER_SITES?=		${MASTER_SITE_SUSE_${SUSE_VERSION}}/${SUSE_ARCH}/
DIST_SUBDIR?=		suse${SUSE_VERSION:S/.//}

HOMEPAGE?=		https://www.opensuse.org/

WRKSRC?=		${WRKDIR}
BUILD_DIRS?=		# empty
MANCOMPRESSED?=		yes

EMUL_PKG_FMT?=		rpm
RPM2PKG_PREFIX?=	${DESTDIR}${PREFIX}
RPM2PKG_SUBPREFIX?=	${EMULSUBDIR}
RPM2PKG_STAGE?=		do-install

SUSE_PKGSRCDIR=		${.CURDIR}/../${.CURDIR:T:S/_32_/_/}
FILESDIR=		${SUSE_PKGSRCDIR}/files
PATCHDIR=		${SUSE_PKGSRCDIR}/patches
PKGDIR=			${SUSE_PKGSRCDIR}

.if defined(SUSE_COMPAT32)
PKGNAME:=		${PKGNAME:S/^suse_/suse32_/}
COMMENT:=		${COMMENT:S/Linux/Linux 32-bit/}
.if defined(CONFLICTS)
CONFLICTS:=		${CONFLICTS:S/^suse_/suse32_/}
.endif
LINUX_BASE=		linux32
.else
LINUX_BASE=		linux
.endif
PLIST_SUBST+=		LINUX_BASE=${LINUX_BASE:Q}
FILES_SUBST+=		LINUX_BASE=${LINUX_BASE:Q}

LINUX_LIBSUBDIR?=	lib
PLIST_SUBST+=		LINUX_LIBSUBDIR=${LINUX_LIBSUBDIR:Q}
FILES_SUBST+=		LINUX_LIBSUBDIR=${LINUX_LIBSUBDIR:Q}

# Include an "override" SuSE-specific and architecture-specific
# Makefile fragment if it exists.
#
.sinclude "${SUSE_PKGSRCDIR}/suse.${EMUL_ARCH}.mk"

# By default, run ldconfig(8) after installing a SuSE package.
RUN_LDCONFIG?=		yes

.if make(distinfo) || make(makedistinfo) || make(mdi) || make(makesum)
PKG_FAIL_REASON+=	"please use make emul-fetch or make emul-distinfo"
.endif

.if defined(RPMPKGS) && !empty(RPMPKGS)
.  for distfile in ${RPMPKGS}
DISTFILES+=	${distfile}.rpm
SITES.${distfile:T:S/=/--/}.rpm?=	\
	${MASTER_SITE_SUSE_${SUSE_VERSION}}${distfile:E}/
.  endfor
.endif
.if defined(RPMUPDPKGS) && !empty(RPMUPDPKGS)
.  for distfile in ${RPMUPDPKGS}
DISTFILES+=	${distfile}.rpm
SITES.${distfile:T:S/=/--/}.rpm?=	\
	${MASTER_SITE_SUSE_${SUSE_VERSION}_UPD}${distfile:E}/
.  endfor
.endif
