1 # $NetBSD: Makefile.common,v 1.10 2008/03/03 19:21:37 jlam Exp $
3 # Common infrastructure for NetBSD compat* packages.
5 # This file should be included after EMUL_PLATFORMS and NETBSD_VERSION are
6 # defined and before EMUL_PLATFORM is used.
10 MASTER_SITES= ${MASTER_SITE_LOCAL:=${DIST_SUBDIR}${DIST_SUBDIR:D/}}
11 EXTRACT_SUFX= .tar.bz2
13 MAINTAINER= pkgsrc-users@NetBSD.org
15 PKG_DESTDIR_SUPPORT= destdir
17 NO_SRC_ON_FTP= Already in MASTER_SITE_LOCAL
22 EMUL_REQD= netbsd>=${NETBSD_VERSION}
24 .include "../../mk/bsd.prefs.mk"
26 .if defined(NETBSD_COMPAT32) && defined(ACCEPTABLE_NETBSD)
27 ONLY_FOR_PLATFORM+= ${ACCEPTABLE_NETBSD:S/$/-sparc64/}
28 ONLY_FOR_PLATFORM+= ${ACCEPTABLE_NETBSD:S/$/-x86_64/}
31 NETBSD_PKGSRCDIR?= ${.CURDIR}/../${.CURDIR:T:S/^netbsd32_//}
32 FILESDIR= ${NETBSD_PKGSRCDIR}/files
33 PATCHDIR= ${NETBSD_PKGSRCDIR}/patches
34 PKGDIR= ${NETBSD_PKGSRCDIR}
36 .if defined(NETBSD_COMPAT32)
37 PKGNAME= netbsd32_${DISTNAME:S/-${EMUL_ARCH}-/-/}
38 COMMENT:= ${COMMENT:S/NetBSD/NetBSD 32-bit/}
39 NETBSD_BASE= netbsd32_
41 PKGNAME= ${DISTNAME:S/-${EMUL_ARCH}-/-/}
46 MAKE_DIRS+= ${EMULDIR}
47 ELF_SYMLINKS_DATA= ${WRKDIR}/.symlinks-data
50 # PLISTs are composed from the following bits, in order:
52 # PLIST.${EMUL_ARCH} e.g. PLIST.alpha
53 # PLIST.${EMUL_EXEC_FMT} e.g. PLIST.ELF
56 .if exists(${PKGDIR}/PLIST.${EMUL_ARCH})
57 PLIST_SRC+= ${PKGDIR}/PLIST.${EMUL_ARCH}
59 .if exists(${PKGDIR}/PLIST.${EMUL_EXEC_FMT})
60 PLIST_SRC+= ${PKGDIR}/PLIST.${EMUL_EXEC_FMT}
62 .if exists(${PKGDIR}/PLIST)
63 PLIST_SRC+= ${PKGDIR}/PLIST
66 # Set NATIVE_EXEC_FMT and EMUL_EXEC_FMT appropriately. Normally, these
67 # are set by mk/emulator.mk, included in bsd.pkg.mk, but this happens
68 # too late for us here.
70 # Directly set NATIVE_EXEC_FMT and include the correct emulator.mk file
71 # to define EMUL_EXEC_FMT.
73 NATIVE_EXEC_FMT= ${_NATIVE_EXEC_FMT_cmd:sh}
74 _NATIVE_EXEC_FMT_cmd= sh ${.CURDIR}/../../mk/scripts/shlib-type \
75 ${_OPSYS_SHLIB_TYPE:Q} ${MAKE:Q}
77 .include "${PKGSRCDIR}/emulators/${COMPAT_PKG}/emulator.mk"
80 # Different combinations of the native executable format and the emulated
81 # executable format require different ways of making the installed shared
82 # libraries useful after installation.
86 # a.out a.out append to ld.so.conf and run ldconfig
87 # ELF a.out run ldconfig
88 # ELF ELF create symlinks to shlibs into base system
91 .if (${NATIVE_EXEC_FMT} == "a.out") && (${EMUL_EXEC_FMT} == "a.out")
92 INSTALL_TEMPLATES+= ${PKGSRCDIR}/emulators/compat_netbsd/INSTALL.a.out
94 .elif (${NATIVE_EXEC_FMT} == "ELF") && (${EMUL_EXEC_FMT} == "a.out")
95 INSTALL_TEMPLATES+= ${PKGSRCDIR}/emulators/compat_netbsd/INSTALL.emulaout
97 .elif defined(NETBSD_COMPAT32)
98 INSTALL_TEMPLATES+= ${PKGSRCDIR}/emulators/compat_netbsd/INSTALL.emulnetbsd32
100 .else # (${NATIVE_EXEC_FMT} == "ELF") && (${EMUL_EXEC_FMT} == "ELF")
101 INSTALL_TEMPLATES+= ${PKGSRCDIR}/emulators/compat_netbsd/INSTALL.ELF
102 INSTALL_TEMPLATES+= ${ELF_SYMLINKS_DATA}
103 post-build: symlinks-data
106 DEINSTALL_TEMPLATES+= ${PKGSRCDIR}/emulators/compat_netbsd/DEINSTALL
109 # For ELF platforms, the INSTALL.ELF script needs SYMLINK data lines to
110 # tell it which shared libraries need to be symlinked to where. Generate
111 # this information from the PLIST.
113 .PHONY: symlinks-data
114 symlinks-data: ${ELF_SYMLINKS_DATA}
115 ${ELF_SYMLINKS_DATA}: plist
116 ${RUN} ${CAT} ${PLIST} | ${AWK} \
117 'BEGIN { print "#" } END { print "#" } /^@/ { next } \
118 { src = $$0; dst = src; sub("^${EMULSUBDIRSLASH}", "/", dst); \
119 print "# SYMLINK: " src " " dst }' > ${.TARGET}
122 # The compat* packages have a very strict package layout:
128 # Each of these directories, if they exist, are copied directly into
131 .PHONY: compat-install
132 do-install: compat-install
134 ${INSTALL_DATA_DIR} ${DESTDIR}${PREFIX}/${EMULSUBDIR}
135 cd ${WRKSRC} && for dir in lib libexec usr; do \
136 if ${TEST} -d "$$dir"; then \
138 ${DESTDIR}${PREFIX}/${EMULSUBDIR}; \