- USE_CROSS_COMPILATION activates it, CROSS_DESTDIR specifies root of the target filesystem - derive _CROSS_DESTDIR from CROSS_DESTDIR or MAKEOBJDIR - buildlink3.mk prefixes the files to symlink with _CROSS_DESTDIR - compiler/gcc.mk knows about the target prefix (e.g. i386--netbsdelf) - PKG_DBDIR is prefixed with _CROSS_DESTDIR - package-install and bin-install are not called with su - install and strip are redirected to the tool version - links for the target specific ar, as, ld, nm, objdump, ranlib and strip are added - compiler wrapper detect if linking is requested or not - special command sinks for CPP and CC/CXX add the cross-compile magic: - modify include dirs to get the target /usr/include - modify linker dirs and runpath to use target /usr/lib at link time, but keep correct rpath entries Supported-by: Google SoC 2007 Basic tests by he@ on Sparc. Review from jlam@.
151 lines
5.2 KiB
Makefile
151 lines
5.2 KiB
Makefile
# $NetBSD: package.mk,v 1.8 2007/08/02 18:19:32 joerg Exp $
|
|
|
|
PKG_SUFX?= .tgz
|
|
PKGFILE?= ${PKGREPOSITORY}/${PKGNAME}${PKG_SUFX}
|
|
PKGREPOSITORY?= ${PACKAGES}/${PKGREPOSITORYSUBDIR}
|
|
PKGREPOSITORYSUBDIR?= All
|
|
|
|
######################################################################
|
|
### package-check-installed (PRIVATE, pkgsrc/mk/package/package.mk)
|
|
######################################################################
|
|
### package-check-installed verifies that the package is installed on
|
|
### the system.
|
|
###
|
|
.PHONY: package-check-installed
|
|
package-check-installed:
|
|
${_PKG_SILENT}${_PKG_DEBUG} \
|
|
${PKG_INFO} -qe ${PKGNAME}; \
|
|
if ${TEST} $$? -ne 0; then \
|
|
${ERROR_MSG} "${PKGNAME} is not installed."; \
|
|
exit 1; \
|
|
fi
|
|
|
|
######################################################################
|
|
### package-create (PRIVATE, pkgsrc/mk/package/package.mk)
|
|
######################################################################
|
|
### package-create creates the binary package.
|
|
###
|
|
.PHONY: package-create
|
|
package-create: package-remove ${PKGFILE} package-links
|
|
|
|
_PKG_ARGS_PACKAGE+= ${_PKG_CREATE_ARGS}
|
|
.if ${_USE_DESTDIR} == "no"
|
|
_PKG_ARGS_PACKAGE+= -p ${PREFIX}
|
|
.else
|
|
_PKG_ARGS_PACKAGE+= -I ${PREFIX} -p ${DESTDIR}${PREFIX}
|
|
.endif
|
|
_PKG_ARGS_PACKAGE+= -L ${DESTDIR}${PREFIX} # @src ...
|
|
.if ${PKG_INSTALLATION_TYPE} == "pkgviews"
|
|
_PKG_ARGS_PACKAGE+= -E
|
|
.endif
|
|
|
|
${PKGFILE}: ${_CONTENTS_TARGETS}
|
|
${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
|
|
${_PKG_SILENT}${_PKG_DEBUG} set -e; \
|
|
${PKG_CREATE} ${_PKG_ARGS_PACKAGE} ${.TARGET} || { \
|
|
exitcode=$$?; \
|
|
${ERROR_MSG} "${PKG_CREATE:T} failed ($$exitcode)"; \
|
|
${RM} -f ${.TARGET}; \
|
|
exit 1; \
|
|
}
|
|
|
|
######################################################################
|
|
### package-remove (PRIVATE)
|
|
######################################################################
|
|
### package-remove removes the binary package from the package
|
|
### repository.
|
|
###
|
|
.PHONY: package-remove
|
|
package-remove:
|
|
${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${PKGFILE}
|
|
|
|
######################################################################
|
|
### package-links (PRIVATE)
|
|
######################################################################
|
|
### package-links creates symlinks to the binary package from the
|
|
### non-primary categories to which the package belongs.
|
|
###
|
|
package-links: delete-package-links
|
|
.for _dir_ in ${CATEGORIES:S/^/${PACKAGES}\//}
|
|
${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${_dir_:Q}
|
|
${_PKG_SILENT}${_PKG_DEBUG} \
|
|
if ${TEST} ! -d ${_dir_:Q}; then \
|
|
${ERROR_MSG} "Can't create directory "${_dir_:Q}"."; \
|
|
exit 1; \
|
|
fi
|
|
${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${_dir_:Q}/${PKGFILE:T}
|
|
${_PKG_SILENT}${_PKG_DEBUG}${LN} -s ../${PKGREPOSITORYSUBDIR}/${PKGFILE:T} ${_dir_:Q}
|
|
.endfor
|
|
|
|
######################################################################
|
|
### delete-package-links (PRIVATE)
|
|
######################################################################
|
|
### delete-package-links removes the symlinks to the binary package from
|
|
### the non-primary categories to which the package belongs.
|
|
###
|
|
delete-package-links:
|
|
${_PKG_SILENT}${_PKG_DEBUG} \
|
|
${FIND} ${PACKAGES} -type l -name ${PKGFILE:T} -print | \
|
|
${XARGS} ${RM} -f
|
|
|
|
######################################################################
|
|
### tarup (PUBLIC)
|
|
######################################################################
|
|
### tarup is a public target to generate a binary package from an
|
|
### installed package instance.
|
|
###
|
|
_PKG_TARUP_CMD= ${LOCALBASE}/bin/pkg_tarup
|
|
|
|
.PHONY: tarup
|
|
tarup: package-remove tarup-pkg package-links
|
|
|
|
######################################################################
|
|
### tarup-pkg (PRIVATE)
|
|
######################################################################
|
|
### tarup-pkg creates a binary package from an installed package instance
|
|
### using "pkg_tarup".
|
|
###
|
|
tarup-pkg:
|
|
${_PKG_SILENT}${_PKG_DEBUG} \
|
|
${TEST} -x ${_PKG_TARUP_CMD} || exit 1; \
|
|
${SETENV} PKG_DBDIR=${_PKG_DBDIR} PKG_SUFX=${PKG_SUFX} \
|
|
PKGREPOSITORY=${PKGREPOSITORY} \
|
|
${_PKG_TARUP_CMD} ${PKGNAME}
|
|
|
|
######################################################################
|
|
### package-install (PUBLIC)
|
|
######################################################################
|
|
### When DESTDIR support is active, package-install uses package to
|
|
### create a binary package and installs it.
|
|
### Otherwise it is identical to calling package.
|
|
###
|
|
|
|
.PHONY: package-install real-package-install su-real-package-install
|
|
.if defined(_PKGSRC_BARRIER)
|
|
package-install: package real-package-install
|
|
.else
|
|
package-install: barrier
|
|
.endif
|
|
|
|
.if ${_USE_DESTDIR} != "no"
|
|
. if !empty(USE_CROSS_COMPILE:M[yY][eE][sS])
|
|
real-package-install: su-real-package-install
|
|
. else
|
|
real-package-install: su-target
|
|
. endif
|
|
.else
|
|
real-package-install:
|
|
@${DO_NADA}
|
|
.endif
|
|
|
|
su-real-package-install:
|
|
@${PHASE_MSG} "Install binary package of "${PKGNAME:Q}
|
|
.if !empty(USE_CROSS_COMPILE:M[yY][eE][sS])
|
|
@${MKDIR} ${_CROSS_DESTDIR}${PREFIX}
|
|
${PKG_ADD} -f -I -p ${_CROSS_DESTDIR}${PREFIX} ${PKGFILE}
|
|
@${ECHO} "Fixing recorded cwd..."
|
|
@${SED} -e 's|@cwd ${_CROSS_DESTDIR}|@cwd |' ${_PKG_DBDIR}/${PKGNAME:Q}/+CONTENTS > ${_PKG_DBDIR}/${PKGNAME:Q}/+CONTENTS.tmp
|
|
@${MV} ${_PKG_DBDIR}/${PKGNAME:Q}/+CONTENTS.tmp ${_PKG_DBDIR}/${PKGNAME:Q}/+CONTENTS
|
|
.else
|
|
${PKG_ADD} ${PKGFILE}
|
|
.endif
|