summaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
authormarkd <markd@pkgsrc.org>2007-12-12 01:00:38 +0000
committermarkd <markd@pkgsrc.org>2007-12-12 01:00:38 +0000
commitec09af76f04aba9128001e761e195a4fb53e7d1b (patch)
tree4905d075ccb909845351ec3ab71f9410106ea29f /mk
parent27a1a5eca55b6c28de42203bde64703535aa5e1f (diff)
downloadpkgsrc-ec09af76f04aba9128001e761e195a4fb53e7d1b.tar.gz
Add support for cmake as a tool (USE_TOOLS+=cmake) and for using it in
the configure stage of a build (by setting USE_CMAKE=yes).
Diffstat (limited to 'mk')
-rw-r--r--mk/cmake-Modules/Platform/UnixPaths.cmake14
-rw-r--r--mk/configure/cmake-rewrite.awk29
-rw-r--r--mk/configure/cmake.mk58
-rw-r--r--mk/configure/configure.mk32
-rw-r--r--mk/tools/defaults.mk3
-rw-r--r--mk/tools/replace.mk13
6 files changed, 144 insertions, 5 deletions
diff --git a/mk/cmake-Modules/Platform/UnixPaths.cmake b/mk/cmake-Modules/Platform/UnixPaths.cmake
new file mode 100644
index 00000000000..aa0541b55df
--- /dev/null
+++ b/mk/cmake-Modules/Platform/UnixPaths.cmake
@@ -0,0 +1,14 @@
+SET(CMAKE_SYSTEM_INCLUDE_PATH ${CMAKE_SYSTEM_INCLUDE_PATH}
+ # Standard
+ $ENV{BUILDLINK_DIR}/include /include /usr/include
+
+ )
+
+SET(CMAKE_SYSTEM_LIBRARY_PATH ${CMAKE_SYSTEM_LIBRARY_PATH}
+ # Standard
+ $ENV{BUILDLINK_DIR}/lib /lib /usr/lib
+ )
+
+SET(CMAKE_SYSTEM_PROGRAM_PATH ${CMAKE_SYSTEM_PROGRAM_PATH}
+ /bin /usr/bin /usr/local/bin /usr/pkg/bin /sbin
+ )
diff --git a/mk/configure/cmake-rewrite.awk b/mk/configure/cmake-rewrite.awk
new file mode 100644
index 00000000000..87132479eef
--- /dev/null
+++ b/mk/configure/cmake-rewrite.awk
@@ -0,0 +1,29 @@
+# $NetBSD: cmake-rewrite.awk,v 1.1 2007/12/12 01:00:38 markd Exp $
+#
+# cleanup references to libraries in the buildlink tree in files
+# written by cmake's export_library_dependencies() function
+#
+BEGIN { buildlink_dir = ARGV[1]; delete ARGV[1] }
+{
+ match($0, "_LIB_DEPENDS \"")
+ if (RSTART == 0) {
+ print
+ } else {
+ printf "%s \"", $1
+ d=substr($0,RSTART+RLENGTH,length($0))
+ while ( d != "\")") {
+ match(d,"[^;]*")
+ dep=substr(d,RSTART,RLENGTH)
+ d=substr(d,RLENGTH+2,length(d))
+ if (dep ~ "^" buildlink_dir) {
+ "ls -l " dep | getline ls_out
+ match(ls_out,"-> ")
+ if (RSTART > 0) {
+ dep=substr(ls_out,RSTART+RLENGTH,length(ls_out))
+ }
+ }
+ printf "%s;",dep
+ }
+ print d
+ }
+}
diff --git a/mk/configure/cmake.mk b/mk/configure/cmake.mk
new file mode 100644
index 00000000000..647ebefffb9
--- /dev/null
+++ b/mk/configure/cmake.mk
@@ -0,0 +1,58 @@
+# $NetBSD: cmake.mk,v 1.1 2007/12/12 01:00:39 markd Exp $
+
+_CMAKE_DIR= ${BUILDLINK_DIR}/cmake-Modules
+
+USE_TOOLS+= cmake
+CMAKE_ARGS+= -DCMAKE_INSTALL_PREFIX:PATH=${PREFIX}
+CMAKE_ARGS+= -DCMAKE_MODULE_PATH:PATH=${_CMAKE_DIR}
+
+CMAKE_MODULE_PATH_OVERRIDE+= CMakeLists.txt
+
+######################################################################
+### configure-cmake-override (PRIVATE)
+######################################################################
+### configure-cmake-override modifies the cmake CMakeLists.txt file in
+### ${WRKSRC} so that if CMAKE_MODULE_PATH is set we add our Module
+### directory before any others.
+###
+
+SUBST_CLASSES+= cmake
+SUBST_STAGE.cmake= do-configure-pre-hook
+SUBST_MESSAGE.cmake= Fixing CMAKE_MODULE_PATH in CMakeLists.txt
+SUBST_FILES.cmake= ${CMAKE_MODULE_PATH_OVERRIDE}
+SUBST_SED.cmake= \
+ 's|set *( *CMAKE_MODULE_PATH |set (CMAKE_MODULE_PATH "${_CMAKE_DIR}" |'
+
+do-configure-pre-hook: cmake-copy-module-tree
+
+.PHONY: cmake-copy-module-tree
+cmake-copy-module-tree:
+ ${_PKG_SILENT}${_PKG_DEBUG}set -e; \
+ cd ${PKGSRCDIR}/mk; ${CP} -R cmake-Modules ${_CMAKE_DIR}
+
+
+######################################################################
+### cmake-dependencies-rewrite (PRIVATE)
+######################################################################
+### The cmake function export_library_dependencies() writes out
+### library dependency info to a file and this may contain buildlink
+### paths.
+### cmake-dependencies-rewrite modifies any such files, listed in
+### ${CMAKE_DEPENDENCIES_REWRITE} (relative to ${WRKSRC}) to have the
+### real dependencies
+###
+
+do-configure-post-hook: cmake-dependencies-rewrite
+
+.PHONY: cmake-dependencies-rewrite
+cmake-dependencies-rewrite:
+ @${STEP_MSG} "Rewrite cmake Dependencies files"
+.if defined(CMAKE_DEPENDENCIES_REWRITE) && !empty(CMAKE_DEPENDENCIES_REWRITE)
+ ${_PKG_SILENT}${_PKG_DEBUG}set -e; \
+ cd ${WRKSRC}; \
+ for file in ${CMAKE_DEPENDENCIES_REWRITE}; do \
+ ${TEST} -f "$$file" || continue; \
+ ${AWK} -f ${PKGSRCDIR}/mk/configure/cmake-rewrite.awk ${BUILDLINK_DIR} $$file > $$file.override; \
+ ${MV} -f $$file.override $$file; \
+ done
+.endif
diff --git a/mk/configure/configure.mk b/mk/configure/configure.mk
index 3f8566c663c..67d3b442ee1 100644
--- a/mk/configure/configure.mk
+++ b/mk/configure/configure.mk
@@ -1,4 +1,4 @@
-# $NetBSD: configure.mk,v 1.20 2007/12/01 11:11:55 rillig Exp $
+# $NetBSD: configure.mk,v 1.21 2007/12/12 01:00:40 markd Exp $
#
# = Package-settable variables =
#
@@ -48,14 +48,17 @@ _VARGROUPS+= configure
_USER_VARS.configure= CONFIG_SHELL_FLAGS
_PKG_VARS.configure= CONFIGURE_ENV CONFIG_SHELL CONFIGURE_SCRIPT \
CONFIGURE_ARGS OVERRIDE_GNU_CONFIG_SCRIPTS HAS_CONFIGURE \
- GNU_CONFIGURE PKGCONFIG_OVERRIDE USE_PKGLOCALEDIR
+ GNU_CONFIGURE PKGCONFIG_OVERRIDE USE_PKGLOCALEDIR \
+ CMAKE_ARGS CMAKE_ARG_PATH
CONFIGURE_SCRIPT?= ./configure
CONFIGURE_ENV+= ${ALL_ENV}
CONFIGURE_ARGS?= # empty
CONFIG_SHELL?= ${SH}
CONFIG_SHELL_FLAGS?= # none
-_BUILD_DEFS+= CONFIGURE_ENV CONFIGURE_ARGS
+CMAKE_ARGS?= # empty
+CMAKE_ARG_PATH?= .
+_BUILD_DEFS+= CONFIGURE_ENV CONFIGURE_ARGS CMAKE_ARGS
.if defined(GNU_CONFIGURE)
. include "${PKGSRCDIR}/mk/configure/gnu-configure.mk"
@@ -76,6 +79,9 @@ _BUILD_DEFS+= CONFIGURE_ENV CONFIGURE_ARGS
.if defined(USE_PKGLOCALEDIR)
. include "${PKGSRCDIR}/mk/configure/replace-localedir.mk"
.endif
+.if defined(USE_CMAKE)
+. include "${PKGSRCDIR}/mk/configure/cmake.mk"
+.endif
######################################################################
### configure (PUBLIC)
@@ -222,6 +228,25 @@ do-configure-imake:
.endfor
######################################################################
+### do-configure-cmake (PRIVATE)
+######################################################################
+### do-configure-cmake runs cmake to configure the software for
+### building.
+###
+_CONFIGURE_CMAKE_ENV+= BUILDLINK_DIR=${BUILDLINK_DIR}
+_CONFIGURE_CMAKE_ENV+= ${CONFIGURE_ENV}
+
+
+.PHONY: do-configure-cmake
+do-configure-cmake:
+.for _dir_ in ${CONFIGURE_DIRS}
+ ${_PKG_SILENT}${_PKG_DEBUG}${_ULIMIT_CMD} \
+ cd ${WRKSRC} && cd ${_dir_} && \
+ ${SETENV} ${_CONFIGURE_CMAKE_ENV} \
+ cmake ${CMAKE_ARGS} ${CMAKE_ARG_PATH}
+.endfor
+
+######################################################################
### pre-configure, do-configure, post-configure (PUBLIC, override)
######################################################################
### {pre,do,post}-configure are the heart of the package-customizable
@@ -231,6 +256,7 @@ do-configure-imake:
_DO_CONFIGURE_TARGETS+= ${HAS_CONFIGURE:D do-configure-script}
_DO_CONFIGURE_TARGETS+= ${USE_IMAKE:D do-configure-imake}
+_DO_CONFIGURE_TARGETS+= ${USE_CMAKE:D do-configure-cmake}
.if !target(do-configure)
do-configure: ${_DO_CONFIGURE_TARGETS}
diff --git a/mk/tools/defaults.mk b/mk/tools/defaults.mk
index a9917bf9978..135f6d4a90a 100644
--- a/mk/tools/defaults.mk
+++ b/mk/tools/defaults.mk
@@ -1,4 +1,4 @@
-# $NetBSD: defaults.mk,v 1.52 2007/08/10 03:46:10 jlam Exp $
+# $NetBSD: defaults.mk,v 1.53 2007/12/12 01:00:40 markd Exp $
#
# Copyright (c) 2005 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -63,6 +63,7 @@ _TOOLS_VARNAME.cat= CAT
_TOOLS_VARNAME.chgrp= CHGRP
_TOOLS_VARNAME.chmod= CHMOD
_TOOLS_VARNAME.chown= CHOWN
+_TOOLS_VARNAME.cmake= CMAKE
_TOOLS_VARNAME.cmp= CMP
_TOOLS_VARNAME.cp= CP
_TOOLS_VARNAME.csh= CSH
diff --git a/mk/tools/replace.mk b/mk/tools/replace.mk
index e2388f64037..aaba146a4ac 100644
--- a/mk/tools/replace.mk
+++ b/mk/tools/replace.mk
@@ -1,4 +1,4 @@
-# $NetBSD: replace.mk,v 1.201 2007/11/08 19:31:40 joerg Exp $
+# $NetBSD: replace.mk,v 1.202 2007/12/12 01:00:40 markd Exp $
#
# Copyright (c) 2005 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -283,6 +283,17 @@ TOOLS_PATH.bzcat= ${TOOLS_PREFIX.${_t_}}/bin/${_t_}
. endif
.endfor
+.if !defined(TOOLS_IGNORE.cmake) && !empty(_USE_TOOLS:Mcmake)
+. if !empty(PKGPATH:Mdevel/cmake)
+MAKEFLAGS+= TOOLS_IGNORE.cmake=
+. elif !empty(_TOOLS_USE_PKGSRC.cmake:M[yY][eE][sS])
+TOOLS_DEPENDS.cmake?= cmake>=2.4.6nb3:../../devel/cmake
+TOOLS_CREATE+= cmake
+TOOLS_FIND_PREFIX+= TOOLS_PREFIX.cmake=cmake
+TOOLS_PATH.cmake= ${TOOLS_PREFIX.cmake}/bin/cmake
+. endif
+.endif
+
.if !defined(TOOLS_IGNORE.csh) && !empty(_USE_TOOLS:Mcsh)
. if !empty(PKGPATH:Mshells/tcsh)
MAKEFLAGS+= TOOLS_IGNORE.csh=