diff options
author | jlam <jlam@pkgsrc.org> | 2006-07-05 06:09:15 +0000 |
---|---|---|
committer | jlam <jlam@pkgsrc.org> | 2006-07-05 06:09:15 +0000 |
commit | e31200b87c973f65d2a1f7c8949cc1891040e67e (patch) | |
tree | 5cda57cdca85b18146d681fc321900e0b05b7666 /mk/build | |
parent | 00478b39e6c53023f76627af6ffacebafc9db9d6 (diff) | |
download | pkgsrc-e31200b87c973f65d2a1f7c8949cc1891040e67e.tar.gz |
Refactor configure, build, test and wrapper phases out of bsd.pkg.mk
and into their own directories. Also do some cleanups with build/_build
and pkginstall -- we get rid of _build and simply run pkginstall as
part of the "build" target.
Introduce a new mechanism to handle varying directory depths under
${WRKSRC} in which we find files to override, e.g. configure, config.*,
libtool, etc. OVERRIDE_DIRDEPTH is a package-settable variable that
specifies how far under ${WRKSRC} the various targets should look,
and it defaults to "2". We preserve the
meaning of the various *_OVERRIDE variables, so if they are defined,
then their values supersede the OVERRIDE_DIRDEPTH mechanism.
devel/tla will need to specially set OVERRIDE_DIRDEPTH to 3 (see log
for revision 1.1857 for bsd.pkg.mk -- to be done in a separate commit.
Diffstat (limited to 'mk/build')
-rw-r--r-- | mk/build/bsd.build-vars.mk | 47 | ||||
-rw-r--r-- | mk/build/bsd.build.mk | 43 | ||||
-rw-r--r-- | mk/build/build.mk | 119 | ||||
-rw-r--r-- | mk/build/test.mk | 123 |
4 files changed, 332 insertions, 0 deletions
diff --git a/mk/build/bsd.build-vars.mk b/mk/build/bsd.build-vars.mk new file mode 100644 index 00000000000..5b70338890b --- /dev/null +++ b/mk/build/bsd.build-vars.mk @@ -0,0 +1,47 @@ +# $NetBSD: bsd.build-vars.mk,v 1.1 2006/07/05 06:09:15 jlam Exp $ +# +# BUILD_DIRS is the list of directories in which to perform the build +# process. If the directories are relative paths, then they +# are assumed to be relative to ${WRKSRC}. +# +# MAKE_PROGRAM is the path to the make executable that is run to +# process the source makefiles. This is always overridden by +# the tools framework in pkgsrc/mk/tools/make.mk, but we provide +# a default here for documentation purposes. +# +# MAKE_ENV is the shell environment that is exported to the make +# process. +# +# MAKE_FLAGS is a list of arguments that is pass to the make process. +# +# MAKEFILE is the path to the makefile that is processed by the make +# executable. If the path is relative, then it is assumed to +# be relative to each directory listed in BUILD_DIRS. +# +BUILD_DIRS?= ${CONFIGURE_DIRS} +MAKE_PROGRAM?= ${MAKE} +MAKE_ENV?= # empty +MAKE_FLAGS?= # empty +MAKEFILE?= Makefile + +MAKE_ENV+= ${ALL_ENV} +MAKE_ENV+= ${NO_EXPORT_CPP:D:UCPP=${CPP:Q}} +MAKE_ENV+= LINK_ALL_LIBGCC_HACK=${LINK_ALL_LIBGCC_HACK:Q} +MAKE_ENV+= LOCALBASE=${LOCALBASE:Q} +MAKE_ENV+= NO_WHOLE_ARCHIVE_FLAG=${NO_WHOLE_ARCHIVE_FLAG:Q} +MAKE_ENV+= WHOLE_ARCHIVE_FLAG=${WHOLE_ARCHIVE_FLAG:Q} +MAKE_ENV+= X11BASE=${X11BASE:Q} +MAKE_ENV+= X11PREFIX=${X11PREFIX:Q} +MAKE_ENV+= PKGMANDIR=${PKGMANDIR:Q} + +# Provide a consistent environment for packages using (Net)BSD-style +# Makefiles. +# +MAKE_ENV+= MAKECONF=${PKGMAKECONF:U/dev/null} +MAKE_ENV+= OBJECT_FMT=${OBJECT_FMT:Q} +MAKE_ENV+= ${USETOOLS:DUSETOOLS=${USETOOLS:Q}} + +# Add these bits to the environment used when invoking the recursive make +# processes for build-related phases. +# +BUILD_ENV+= PATH=${PATH:Q} diff --git a/mk/build/bsd.build.mk b/mk/build/bsd.build.mk new file mode 100644 index 00000000000..8b1e0aaf444 --- /dev/null +++ b/mk/build/bsd.build.mk @@ -0,0 +1,43 @@ +# $NetBSD: bsd.build.mk,v 1.1 2006/07/05 06:09:15 jlam Exp $ +# +# This Makefile fragment is included by bsd.pkg.mk and provides all +# variables and targets related to building sources for a package. +# +# The following are the "public" targets provided by this module: +# +# build, test +# +# The following targets may be overridden in a package Makefile: +# +# pre-build, do-build, post-build +# pre-test, do-test, post-test +# + +_BUILD_COOKIE= ${WRKDIR}/.build_done +_TEST_COOKIE= ${WRKDIR}/.test_done + +###################################################################### +### build (PUBLIC) +###################################################################### +### build is a public target to build the sources for the package. +### +.PHONY: build +.if defined(NO_BUILD) +. if !target(build) +build: configure build-cookie +. endif +.else +. include "${PKGSRCDIR}/mk/build/build.mk" +.endif + +.include "${PKGSRCDIR}/mk/build/test.mk" + +###################################################################### +### build-cookie (PRIVATE) +###################################################################### +### build-cookie creates the "build" cookie file. +### +.PHONY: build-cookie +build-cookie: + ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${_BUILD_COOKIE:H} + ${_PKG_SILENT}${_PKG_DEBUG}${ECHO} ${PKGNAME} >> ${_BUILD_COOKIE} diff --git a/mk/build/build.mk b/mk/build/build.mk new file mode 100644 index 00000000000..db9ad7dfce8 --- /dev/null +++ b/mk/build/build.mk @@ -0,0 +1,119 @@ +# $NetBSD: build.mk,v 1.1 2006/07/05 06:09:15 jlam Exp $ +# +# BUILD_MAKE_FLAGS is the list of arguments that is passed to the make +# process. +# +# BUILD_TARGET is the target from ${MAKEFILE} that should be invoked +# to build the sources. +# +BUILD_MAKE_FLAGS?= ${MAKE_FLAGS} +BUILD_TARGET?= all + +###################################################################### +### build (PUBLIC) +###################################################################### +### build is a public target to build the sources from the package. +### +_BUILD_TARGETS+= configure +_BUILD_TARGETS+= acquire-build-lock +_BUILD_TARGETS+= ${_BUILD_COOKIE} +_BUILD_TARGETS+= release-build-lock +_BUILD_TARGETS+= pkginstall + +.PHONY: build +.if !target(build) +build: ${_BUILD_TARGETS} +.endif + +.PHONY: acquire-build-lock release-build-lock +acquire-build-lock: acquire-lock +release-build-lock: release-lock + +.if !exists(${_BUILD_COOKIE}) +${_BUILD_COOKIE}: + ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${SETENV} ${BUILD_ENV} ${MAKE} ${MAKEFLAGS} real-build PKG_PHASE=build || ${PKG_ERROR_HANDLER.build} +.else +${_BUILD_COOKIE}: + @${DO_NADA} +.endif + +PKG_ERROR_CLASSES+= build +PKG_ERROR_MSG.build= \ + "" \ + "There was an error during the \`\`build'' phase." \ + "Please investigate the following for more information:" \ + " * log of the build" \ + " * ${WRKLOG}" \ + "" +.if defined(BROKEN_IN) +PKG_ERROR_MSG.build+= \ + " * This package is broken in ${BROKEN_IN}." \ + " * It may be removed in the next branch unless fixed." +.endif + +###################################################################### +### real-build (PRIVATE) +###################################################################### +### real-build is a helper target onto which one can hook all of the +### targets that do the actual building of the sources. +### +_REAL_BUILD_TARGETS+= build-check-interactive +_REAL_BUILD_TARGETS+= build-message +_REAL_BUILD_TARGETS+= build-vars +_REAL_BUILD_TARGETS+= pre-build +_REAL_BUILD_TARGETS+= do-build +_REAL_BUILD_TARGETS+= post-build +_REAL_BUILD_TARGETS+= build-cookie +_REAL_BUILD_TARGETS+= error-check + +.PHONY: real-build +real-build: ${_REAL_BUILD_TARGETS} + +.PHONY: build-message +build-message: + @${PHASE_MSG} "Building for ${PKGNAME}" + +###################################################################### +### build-check-interactive (PRIVATE) +###################################################################### +### build-check-interactive checks whether we must do an interactive +### build or not. +### +build-check-interactive: +.if !empty(INTERACTIVE_STAGE:Mbuild) && defined(BATCH) + @${ERROR_MSG} "The build stage of this package requires user interaction" + @${ERROR_MSG} "Please build manually with:" + @${ERROR_MSG} " \"cd ${.CURDIR} && ${MAKE} build\"" + @${TOUCH} ${_INTERACTIVE_COOKIE} + @${FALSE} +.else + @${DO_NADA} +.endif + +###################################################################### +### pre-build, do-build, post-build (PUBLIC, override) +###################################################################### +### {pre,do,post}-build are the heart of the package-customizable +### build targets, and may be overridden within a package Makefile. +### +.PHONY: pre-build do-build post-build + +.if !target(do-build) +do-build: +. for _dir_ in ${BUILD_DIRS} + ${_PKG_SILENT}${_PKG_DEBUG}${_ULIMIT_CMD} \ + cd ${WRKSRC} && cd ${_dir_} && \ + ${SETENV} ${MAKE_ENV} ${MAKE_PROGRAM} ${BUILD_MAKE_FLAGS} \ + -f ${MAKEFILE} ${BUILD_TARGET} +. endfor +.endif + +.if !target(pre-build) +pre-build: + @${DO_NADA} +.endif + +.if !target(post-build) +post-build: + @${DO_NADA} +.endif diff --git a/mk/build/test.mk b/mk/build/test.mk new file mode 100644 index 00000000000..6e242cf5f97 --- /dev/null +++ b/mk/build/test.mk @@ -0,0 +1,123 @@ +# $NetBSD: test.mk,v 1.1 2006/07/05 06:09:15 jlam Exp $ +# +# TEST_DIRS is the list of directories in which to perform the build +# process. If the directories are relative paths, then they +# are assumed to be relative to ${WRKSRC}. +# +# TEST_ENV is the shell environment that is exported to the make +# process. +# +# TEST_MAKE_FLAGS is the list of arguments that is passed to the make +# process. +# +TEST_DIRS?= ${BUILD_DIRS} +TEST_ENV+= ${MAKE_ENV} +TEST_MAKE_FLAGS?= ${MAKE_FLAGS} + +###################################################################### +### test (PUBLIC) +###################################################################### +### build is a public target to build the sources from the package. +### +_TEST_TARGETS+= build +_TEST_TARGETS+= acquire-test-lock +_TEST_TARGETS+= ${_TEST_COOKIE} +_TEST_TARGETS+= release-test-lock + +.PHONY: test +.if !target(test) +test: ${_TEST_TARGETS} +.endif + +.PHONY: acquire-test-lock release-test-lock +acquire-test-lock: acquire-lock +release-test-lock: release-lock + +.if !exists(${_TEST_COOKIE}) +${_TEST_COOKIE}: + ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${SETENV} ${BUILD_ENV} ${MAKE} ${MAKEFLAGS} real-test PKG_PHASE=build +.else +${_TEST_COOKIE}: + @${DO_NADA} +.endif + +###################################################################### +### real-test (PRIVATE) +###################################################################### +### real-test is a helper target onto which one can hook all of the +### targets that do the actual test of the built objects. +### +_REAL_TEST_TARGETS+= test-check-interactive +_REAL_TEST_TARGETS+= test-message +_REAL_TEST_TARGETS+= pre-test +_REAL_TEST_TARGETS+= do-test +_REAL_TEST_TARGETS+= post-test +_REAL_TEST_TARGETS+= test-cookie +_REAL_TEST_TARGETS+= error-check + +.PHONY: real-test +real-test: ${_REAL_TEST_TARGETS} + +.PHONY: test-message +test-message: + @${PHASE_MSG} "Testing for ${PKGNAME}" + +###################################################################### +### test-check-interactive (PRIVATE) +###################################################################### +### test-check-interactive checks whether we must do an interactive +### test or not. +### +test-check-interactive: +.if !empty(INTERACTIVE_STAGE:Mtest) && defined(BATCH) + @${ERROR_MSG} "The test stage of this package requires user interaction" + @${ERROR_MSG} "Please test manually with:" + @${ERROR_MSG} " \"cd ${.CURDIR} && ${MAKE} test\"" + @${TOUCH} ${_INTERACTIVE_COOKIE} + @${FALSE} +.else + @${DO_NADA} +.endif + +###################################################################### +### pre-test, do-test, post-test (PUBLIC, override) +###################################################################### +### {pre,do,post}-test are the heart of the package-customizable +### test targets, and may be overridden within a package Makefile. +### +.PHONY: pre-test do-test post-test + +.if !target(do-test) +. if defined(TEST_TARGET) && !empty(TEST_TARGET) +do-test: +. for _dir_ in ${TEST_DIRS} + ${_PKG_SILENT}${_PKG_DEBUG}${_ULIMIT_CMD} \ + cd ${WRKSRC} && cd ${_dir_} && \ + ${SETENV} ${MAKE_ENV} ${MAKE_PROGRAM} ${TEST_MAKE_FLAGS} \ + -f ${MAKEFILE} ${TEST_TARGET} +. endfor +. else +do-test: + @${DO_NADA} +. endif +.endif + +.if !target(pre-test) +pre-test: + @${DO_NADA} +.endif + +.if !target(post-test) +post-test: + @${DO_NADA} +.endif + +###################################################################### +### test-cookie (PRIVATE) +###################################################################### +### test-cookie creates the "test" cookie file. +### +.PHONY: test-cookie +test-cookie: + ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${_TEST_COOKIE:H} + ${_PKG_SILENT}${_PKG_DEBUG}${ECHO} ${PKGNAME} >> ${_TEST_COOKIE} |