summaryrefslogtreecommitdiff
path: root/emulators/compat_netbsd/Makefile.common
blob: b9e690a9b6f3a9df68d2c787ebdd60b5094d3136 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# $NetBSD: Makefile.common,v 1.2 2007/08/23 15:59:33 jlam Exp $
#
# Common infrastructure for NetBSD compat* packages.
#
# This file should be included after EMUL_PLATFORMS and NETBSD_VERSION are
# defined and before EMUL_PLATFORM is used.
#

PKGNAME=		${DISTNAME:S/-${EMUL_ARCH}-/-/}
CATEGORIES=		emulators
MASTER_SITES=		${MASTER_SITE_LOCAL}
EXTRACT_SUFX=		.tar.bz2

MAINTAINER=		pkgsrc-users@NetBSD.org

NO_SRC_ON_FTP=		Already in MASTER_SITE_LOCAL

NETBSD_PKG=		yes
NETBSD_VERSION_REQD=	${NETBSD_VERSION}

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

.if defined(NETBSD_COMPAT32) && defined(ACCEPTABLE_NETBSD)
ONLY_FOR_PLATFORM+=	${ACCEPTABLE_NETBSD:S/$/-sparc64/}
ONLY_FOR_PLATFORM+=	${ACCEPTABLE_NETBSD:S/$/-x86_64/}
.endif

NETBSD_PKGSRCDIR?=	${.CURDIR}/../${.CURDIR:T:S/^netbsd32_//}
FILESDIR=		${NETBSD_PKGSRCDIR}/files
PATCHDIR=		${NETBSD_PKGSRCDIR}/patches
PKGDIR=			${NETBSD_PKGSRCDIR}

.if ((${EMUL_ARCH} == "i386") && (${MACHINE_ARCH} == "x86_64")) || \
    ((${EMUL_ARCH} == "sparc") && (${MACHINE_ARCH} == "sparc64"))
PKGNAME:=		${PKGNAME:S/^/netbsd32_/}
COMMENT:=		${COMMENT:S/NetBSD/NetBSD 32-bit/}
NETBSD_BASE=		netbsd32_
.else
NETBSD_BASE=		# empty
.endif

BUILD_DIRS=		# empty
MAKE_DIRS+=		${EMULDIR}
ELF_SYMLINKS_DATA=	${WRKDIR}/.symlinks-data

.include "../../mk/emulator/emulator-opsys.mk"

#
# PLISTs are composed from the following bits, in order:
#
#	PLIST.${EMUL_ARCH}	e.g. PLIST.alpha
#	PLIST.${EMUL_EXEC_FMT}	e.g. PLIST.ELF
#	PLIST			e.g. PLIST
#
.if exists(${PKGDIR}/PLIST.${EMUL_ARCH})
PLIST_SRC+=		${PKGDIR}/PLIST.${EMUL_ARCH}
.endif
.if exists(${PKGDIR}/PLIST.${EMUL_EXEC_FMT})
PLIST_SRC+=		${PKGDIR}/PLIST.${EMUL_EXEC_FMT}
.endif
.if exists(${PKGDIR}/PLIST)
PLIST_SRC+=		${PKGDIR}/PLIST
.endif

#
# Different combinations of the native executable format and the emulated
# executable format require different ways of making the installed shared
# libraries useful after installation.
#
#	native	emul	action
#	-----	----	------
#	a.out	a.out	append to ld.so.conf and run ldconfig
#	ELF	a.out	run ldconfig
#	ELF	ELF	create symlinks to shlibs into base system
#	ELF64	ELF32	nothing
#
.if (${NATIVE_EXEC_FMT} == "a.out") && (${EMUL_EXEC_FMT} == "a.out")
INSTALL_TEMPLATES+=	${PKGSRCDIR}/emulators/compat_netbsd/INSTALL.a.out

.elif (${NATIVE_EXEC_FMT} == "ELF") && (${EMUL_EXEC_FMT} == "a.out")
INSTALL_TEMPLATES+=	${PKGSRCDIR}/emulators/compat_netbsd/INSTALL.emulaout

.elif defined(NETBSD_COMPAT32)
INSTALL_TEMPLATES+=	${PKGSRCDIR}/emulators/compat_netbsd/INSTALL.emulnetbsd32

.else # (${NATIVE_EXEC_FMT} == "ELF") && (${EMUL_EXEC_FMT} == "ELF")
INSTALL_TEMPLATES+=	${PKGSRCDIR}/emulators/compat_netbsd/INSTALL.ELF
INSTALL_TEMPLATES+=	${ELF_SYMLINKS_DATA}
post-build: symlinks-data
.endif

DEINSTALL_TEMPLATES+=	${PKGSRCDIR}/emulators/compat_netbsd/DEINSTALL

#
# For ELF platforms, the INSTALL.ELF script needs SYMLINK data lines to
# tell it which shared libraries need to be symlinked to where.  Generate
# this information from the PLIST.
#
.PHONY: symlinks-data
symlinks-data: ${ELF_SYMLINKS_DATA}
${ELF_SYMLINKS_DATA}: plist
	${RUN} ${CAT} ${PLIST} | ${AWK}					\
	'BEGIN { print "#" } END { print "#" } /^@/ { next }		\
	 { src = $$0; dst = src; sub("^${EMULSUBDIRSLASH}", "/", dst);	\
	   print "# SYMLINK: " src " " dst }' > ${.TARGET}

#
# The compat* packages have a very strict package layout:
#
#	${WRKSRC}/lib
#	${WRKSRC}/libexec
#	${WRKSRC}/usr
#
# Each of these directories, if they exist, are copied directly into
# ${EMULDIR}.
#
.PHONY: compat-install
do-install: compat-install
compat-install:
	${INSTALL_DATA_DIR} ${PREFIX}/${EMULSUBDIR}
	cd ${WRKSRC} && for dir in lib libexec usr; do			\
		if ${TEST} -d "$$dir"; then				\
			${PAX} -rw "$$dir" ${PREFIX}/${EMULSUBDIR};	\
		fi;							\
	done