summaryrefslogtreecommitdiff
path: root/mk/tools.mk
diff options
context:
space:
mode:
authorgrant <grant>2003-08-02 03:46:34 +0000
committergrant <grant>2003-08-02 03:46:34 +0000
commite031c36fce8acfc5b3dad1904e7de7474e327039 (patch)
tree8309a0b93b91256184a0d43cfadfc9b9fbd00897 /mk/tools.mk
parentb4db3b44a8c2c8dda70e08459001e2846cfbbadb (diff)
downloadpkgsrc-e031c36fce8acfc5b3dad1904e7de7474e327039.tar.gz
handle platforms with broken tools in the base system, such as sed
and awk. as proposed on tech-pkg@, with some changes to set the appropriate tool variables and handle OSs which provide GNU tools in the base system (ie. do nothing). this allows packages or users to force the use of pkgsrc GNU tools when they are not present in the base system by defining e.g. USE_GNU_TOOLS="awk sed". Solaris' sed is marked as incompatible, as even the XPG4 sed is too limited for a number of packages (especially large ones which use libtool, as libtool calls blind 'sed'), so GNU sed is always used on Solaris.
Diffstat (limited to 'mk/tools.mk')
-rw-r--r--mk/tools.mk173
1 files changed, 173 insertions, 0 deletions
diff --git a/mk/tools.mk b/mk/tools.mk
new file mode 100644
index 00000000000..a872a774106
--- /dev/null
+++ b/mk/tools.mk
@@ -0,0 +1,173 @@
+# $NetBSD: tools.mk,v 1.1 2003/08/02 03:46:34 grant Exp $
+#
+# handle platforms with broken tools in the base system, such as sed
+# and awk.
+#
+# symlink the suitable versions of tools into .buildlink/bin (if they
+# exist in the base system) and allow packages or users to force the use
+# of pkgsrc GNU tools when they are not present in the base system by
+# defining e.g. USE_GNU_TOOLS="awk sed". version numbers are not
+# considered.
+#
+# this functionality is buildlink2 only.
+#
+
+.if !defined(TOOLS_MK)
+TOOLS_MK= # defined
+
+.if empty(USE_BUILDLINK2:M[nN][oO])
+_TOOLS= awk grep sed
+
+# define which platforms already have GNU tools, so no need to pull in
+# the pkgsrc versions.
+_TOOLS_OPSYS_HAS_GNU.awk+= FreeBSD-*-* Linux-*-* NetBSD-*-* OpenBSD-*-*
+_TOOLS_OPSYS_HAS_GNU.grep+= Darwin-*-* FreeBSD-*-* Linux-*-*
+_TOOLS_OPSYS_HAS_GNU.grep+= NetBSD-*-* OpenBSD-*-*
+_TOOLS_OPSYS_HAS_GNU.sed+= Linux-*-*
+
+# where said tool is completely unusable, and no suitable replacement
+# is available.
+_TOOLS_OPSYS_INCOMPAT.awk+= # empty
+_TOOLS_OPSYS_INCOMPAT.grep+= # empty
+
+# Solaris includes a less broken sed in /usr/xpg4/bin, which is mostly
+# adequate for pkgsrc internal use, but pkg builds have shown they
+# demand more, so mark it incompatible.
+_TOOLS_OPSYS_INCOMPAT.sed+= SunOS-*-*
+
+# a suitable alternative version is available in the base system, as
+# eg. ${AWK}, ${SED}, ... refer to defs.*.mk for the definitions.
+_TOOLS_REPLACE_OPSYS.awk+= SunOS-*-*
+_TOOLS_REPLACE_OPSYS.grep+= SunOS-*-*
+_TOOLS_REPLACE_OPSYS.sed+= # empty
+
+# what GNU tools did the package or user ask for, and does the OS
+# already have it?
+.for _tool_ in ${USE_GNU_TOOLS}
+_TOOLS_NEED_GNU.${_tool_}= YES
+. for _pattern_ in ${_TOOLS_OPSYS_HAS_GNU.${_tool_}}
+. if !empty(MACHINE_PLATFORM:M${_pattern_})
+_TOOLS_NEED_GNU.${_tool_}= NO
+. endif
+. endfor
+.endfor
+
+# default to not requiring GNU tools.
+.for _tool_ in ${_TOOLS}
+_TOOLS_NEED_GNU.${_tool_}?= NO
+_TOOLS_REPLACE.${_tool_}?= NO
+
+# do we know it's broken?
+. for _pattern_ in ${_TOOLS_OPSYS_INCOMPAT.${_tool_}}
+. if !empty(MACHINE_PLATFORM:M${_pattern_})
+_TOOLS_NEED_GNU.${_tool_}= YES
+. endif
+. endfor
+
+# are we replacing it with a better version?
+. for _pattern_ in ${_TOOLS_REPLACE_OPSYS.${_tool_}}
+. if !empty(MACHINE_PLATFORM:M${_pattern_})
+_TOOLS_REPLACE.${_tool_}= YES
+. endif
+. endfor
+
+.endfor # ${_TOOLS}
+
+.if ${_TOOLS_NEED_GNU.awk} == "YES" && empty(PKGPATH:Mlang/gawk)
+_TOOLS_PROGNAME.gawk= ${LOCALBASE}/bin/${GNU_PROGRAM_PREFIX}awk
+# catch the case where we are in between package installs, thus don't
+# have gawk available yet.
+. if exists(${_TOOLS_PROGNAME.gawk})
+AWK= ${_TOOLS_PROGNAME.gawk}
+. endif
+BUILDLINK_DEPENDS.gawk?= gawk>=3.1.1
+BUILDLINK_PKGSRCDIR.gawk?= ../../lang/gawk
+BUILDLINK_DEPMETHOD.gawk?= build
+BUILDLINK_PACKAGES+= gawk
+BUILDLINK_PREFIX.gawk_DEFAULT= ${LOCALBASE}
+BUILDLINK_FILES.gawk= bin/${GNU_PROGRAM_PREFIX}awk
+EVAL_PREFIX+= BUILDLINK_PREFIX.gawk=gawk
+.endif
+
+.if ${_TOOLS_NEED_GNU.awk} == "YES" || ${_TOOLS_REPLACE.awk} == "YES"
+BUILDLINK_TARGETS+= gawk-buildlink gawk-buildlink-bin
+.endif
+
+.if ${_TOOLS_NEED_GNU.grep} == "YES" && empty(PKGPATH:Mtextproc/grep)
+_TOOLS_PROGNAME.grep= ${LOCALBASE}/bin/${GNU_PROGRAM_PREFIX}grep
+. if exists(${_TOOLS_PROGNAME.grep})
+GREP= ${_TOOLS_PROGNAME.grep}
+. endif
+BUILDLINK_DEPENDS.grep?= grep>=3.1.1
+BUILDLINK_PKGSRCDIR.grep?= ../../textproc/grep
+BUILDLINK_DEPMETHOD.grep?= build
+BUILDLINK_PACKAGES+= grep
+BUILDLINK_PREFIX.grep= ${LOCALBASE}
+BUILDLINK_FILES.grep= bin/${GNU_PROGRAM_PREFIX}grep
+EVAL_PREFIX+= BUILDLINK_PREFIX.grep=grep
+.endif
+
+.if ${_TOOLS_NEED_GNU.grep} == "YES" || ${_TOOLS_REPLACE.grep} == "YES"
+BUILDLINK_TARGETS+= grep-buildlink grep-buildlink-bin
+.endif
+
+.if ${_TOOLS_NEED_GNU.sed} == "YES" && empty(PKGPATH:Mtextproc/gsed)
+_TOOLS_PROGNAME.gsed= ${LOCALBASE}/bin/${GNU_PROGRAM_PREFIX}sed
+. if exists(${_TOOLS_PROGNAME.gsed})
+SED= ${_TOOLS_PROGNAME.gsed}
+. endif
+BUILDLINK_DEPENDS.gsed?= gsed>=3.0.2
+BUILDLINK_PKGSRCDIR.gsed?= ../../textproc/gsed
+BUILDLINK_DEPMETHOD.gsed?= build
+BUILDLINK_PACKAGES+= gsed
+BUILDLINK_PREFIX.gsed_DEFAULT= ${LOCALBASE}
+BUILDLINK_FILES.gsed= bin/${GNU_PROGRAM_PREFIX}sed
+EVAL_PREFIX+= BUILDLINK_PREFIX.gsed=gsed
+.endif
+
+.if ${_TOOLS_NEED_GNU.sed} == "YES" || ${_TOOLS_REPLACE.sed} == "YES"
+BUILDLINK_TARGETS+= gsed-buildlink gsed-buildlink-bin
+.endif
+
+gawk-buildlink: _BUILDLINK_USE
+gawk-buildlink-bin:
+.if ${_TOOLS_NEED_GNU.awk} == "YES" && empty(PKGPATH:Mlang/gawk)
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ [ ! -f ${BUILDLINK_DIR}/bin/awk ] && \
+ ${LN} -fs ${LOCALBASE}/bin/${GNU_PROGRAM_PREFIX}awk \
+ ${BUILDLINK_DIR}/bin/awk
+.elif ${_TOOLS_REPLACE.awk} == "YES"
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ [ ! -f ${BUILDLINK_DIR}/bin/awk ] && \
+ ${LN} -fs ${AWK} ${BUILDLINK_DIR}/bin/awk
+.endif
+
+grep-buildlink: _BUILDLINK_USE
+grep-buildlink-bin:
+.if ${_TOOLS_NEED_GNU.grep} == "YES" && empty(PKGPATH:Mtextproc/grep)
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ [ ! -f ${BUILDLINK_DIR}/bin/grep ] && \
+ ${LN} -fs ${LOCALBASE}/bin/${GNU_PROGRAM_PREFIX}grep \
+ ${BUILDLINK_DIR}/bin/grep
+.elif ${_TOOLS_REPLACE.grep} == "YES"
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ [ ! -f ${BUILDLINK_DIR}/bin/grep ] && \
+ ${LN} -fs ${GREP} ${BUILDLINK_DIR}/bin/grep
+.endif
+
+gsed-buildlink: _BUILDLINK_USE
+gsed-buildlink-bin:
+.if ${_TOOLS_NEED_GNU.sed} == "YES" && empty(PKGPATH:Mtextproc/gsed)
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ [ ! -f ${BUILDLINK_DIR}/bin/sed ] && \
+ ${LN} -fs ${LOCALBASE}/bin/${GNU_PROGRAM_PREFIX}sed \
+ ${BUILDLINK_DIR}/bin/sed
+.elif ${_TOOLS_REPLACE.sed} == "YES"
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ [ ! -f ${BUILDLINK_DIR}/bin/sed ] && \
+ ${LN} -fs ${SED} ${BUILDLINK_DIR}/bin/sed
+.endif
+
+.endif # USE_BUILDLINK2
+
+.endif # TOOLS_MK