summaryrefslogtreecommitdiff
path: root/pkgtools/createbuildlink
diff options
context:
space:
mode:
authorrh <rh>2002-04-29 11:03:54 +0000
committerrh <rh>2002-04-29 11:03:54 +0000
commitc22241479ba3e594e7c6680adfcb0277caae66a4 (patch)
tree3a049fefd84ce5f378a9039e1b98833b85b4a62c /pkgtools/createbuildlink
parent7c583f984baf0130434402550634c1e05e423d62 (diff)
downloadpkgsrc-c22241479ba3e594e7c6680adfcb0277caae66a4.tar.gz
Initial import of createbuildlink-1.0, a simple script that helps creating
a buildlink.mk from a package's Makefile and PLIST. XXX: this is an attempt to make the creation of buildlink.mk files more XXX: systematic and less error-prone than copying existing buildlink.mk XXX: files and modifying them for a new package. Any help in making this XXX: script less simplistic and more versatile is gladly welcome!
Diffstat (limited to 'pkgtools/createbuildlink')
-rw-r--r--pkgtools/createbuildlink/DESCR7
-rw-r--r--pkgtools/createbuildlink/Makefile23
-rw-r--r--pkgtools/createbuildlink/PLIST3
-rwxr-xr-xpkgtools/createbuildlink/files/createbuildlink207
-rw-r--r--pkgtools/createbuildlink/files/createbuildlink.889
5 files changed, 329 insertions, 0 deletions
diff --git a/pkgtools/createbuildlink/DESCR b/pkgtools/createbuildlink/DESCR
new file mode 100644
index 00000000000..b439912a303
--- /dev/null
+++ b/pkgtools/createbuildlink/DESCR
@@ -0,0 +1,7 @@
+This package installs a shell script that will take a Makefile
+and a PLIST file of an existing package and create an initial
+buildlink.mk file from it. The script tries to interpret the
+contents of the include and lib subdirectories (if any) of the
+package and add the corresponding BUILDLINK files. In addition
+it tries to identify possible config scripts and create the
+corresponding wrapper entries for them.
diff --git a/pkgtools/createbuildlink/Makefile b/pkgtools/createbuildlink/Makefile
new file mode 100644
index 00000000000..a4d7a5d72ab
--- /dev/null
+++ b/pkgtools/createbuildlink/Makefile
@@ -0,0 +1,23 @@
+# $NetBSD: Makefile,v 1.1.1.1 2002/04/29 11:03:54 rh Exp $
+#
+
+DISTNAME= createbuildlink-1.0
+CATEGORIES= pkgtools sysutils
+MASTER_SITES= # Nothing
+DISTFILES= # Nothing
+
+MAINTAINER= rh@netbsd.org
+COMMENT= Shell script to help creating a buildlink.mk file
+
+EXTRACT_ONLY= # empty
+WRKSRC= ${WRKDIR}
+NO_CHECKSUM= yes
+NO_BUILD= yes
+NO_PATCH= yes
+EXTRACT_CMD= ${ECHO}
+
+do-install:
+ ${INSTALL_SCRIPT} ${FILESDIR}/${DISTNAME:C/-.*$//} ${PREFIX}/bin/${DISTNAME:C/-.*$//}
+ ${INSTALL_MAN} ${FILESDIR}/${DISTNAME:C/-.*$//}.8 ${PREFIX}/man/man8
+
+.include "../../mk/bsd.pkg.mk"
diff --git a/pkgtools/createbuildlink/PLIST b/pkgtools/createbuildlink/PLIST
new file mode 100644
index 00000000000..44a0c7e9163
--- /dev/null
+++ b/pkgtools/createbuildlink/PLIST
@@ -0,0 +1,3 @@
+@comment $NetBSD: PLIST,v 1.1.1.1 2002/04/29 11:03:54 rh Exp $
+bin/createbuildlink
+man/man8/createbuildlink.8
diff --git a/pkgtools/createbuildlink/files/createbuildlink b/pkgtools/createbuildlink/files/createbuildlink
new file mode 100755
index 00000000000..358054be26a
--- /dev/null
+++ b/pkgtools/createbuildlink/files/createbuildlink
@@ -0,0 +1,207 @@
+#!/bin/sh
+#
+# $NetBSD: createbuildlink,v 1.1.1.1 2002/04/29 11:03:55 rh Exp $
+#
+# Copyright (c) 2002 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Rene Hexel.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by the NetBSD
+# Foundation, Inc. and its contributors.
+# 4. Neither the name of The NetBSD Foundation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# Create an initial buildlink.mk from a package's Makefile and PLIST
+#
+
+tmpdir=/tmp
+makefile=Makefile
+sedrules=$tmpdir/sedrules.buildlink.$$
+PLIST=PLIST
+
+##
+## some simple integrity checking
+##
+if [ ! -f $makefile ]; then
+ echo "===> Incomplete package! To create a buildlink.mk <==="
+ echo "===> a working $makefile is required! <==="
+ exit 1
+fi
+
+if [ ! -f "$PLIST" ]; then
+ echo "===> Incomplete package! To create a buildlink.mk <==="
+ echo "===> a working PLIST is required! <==="
+ exit 1
+fi
+
+##
+## package specific variables
+##
+CURDIR=`pwd | sed 's|^.*/\([^/]*/[^/]*\)$|\1|'`
+PKGNAME=`make show-var VARNAME=PKGNAME`
+PKGVER=`echo $PKGNAME | sed -e 's/^.*-//'`
+PKGNOVER=`echo $PKGNAME | sed -e 's/-[^-]*$//'`
+PKGUPPER=`echo $PKGNOVER | tr '[:lower:]' '[:upper:]' | tr - _`
+USE_X11BASE=`make show-var VARNAME=USE_X11BASE`
+if [ -z "$USE_X11BASE" ]; then
+ PREFIX=LOCALBASE
+else
+ PREFIX=X11PREFIX
+fi
+
+##
+## create sed rules
+##
+echo >$sedrules "s|@@CURDIR@@|$CURDIR|g"
+echo >>$sedrules "s|@@ID@@|\$NetBSD\$|g"
+echo >>$sedrules "s|@@PKGNAME@@|$PKGNAME|g"
+echo >>$sedrules "s|@@PKGNOVER@@|$PKGNOVER|g"
+echo >>$sedrules "s|@@PKGUPPER@@|$PKGUPPER|g"
+echo >>$sedrules "s|@@PKGVER@@|$PKGVER|g"
+echo >>$sedrules "s|@@PREFIX@@|$PREFIX|g"
+
+#
+# buildlink header
+#
+sed -f $sedrules <<EOF
+# @@ID@@
+#
+# This Makefile fragment is included by packages that use $PKGNOVER.
+#
+# This file was created automatically using the createbuildlink script
+#
+# To use this Makefile fragment, simply:
+#
+# (1) Optionally define BUILDLINK_DEPENDS.$PKGNOVER to the dependency pattern
+# for the version of $PKGNOVER desired.
+# (2) Include this Makefile fragment in the package Makefile,
+# (3) Add \${BUILDLINK_DIR}/include to the front of the C preprocessor's header
+# search path, and
+# (4) Add \${BUILDLINK_DIR}/lib to the front of the linker's library search
+# path.
+
+.if !defined(${PKGUPPER}_BUILDLINK_MK)
+${PKGUPPER}_BUILDLINK_MK= # defined
+
+.include "../../mk/bsd.buildlink.mk"
+
+BUILDLINK_DEPENDS.$PKGNOVER?= $PKGNOVER>=$PKGVER
+DEPENDS+= \${BUILDLINK_DEPENDS.$PKGNOVER}:../../$CURDIR
+
+EVAL_PREFIX+= BUILDLINK_PREFIX.$PKGNOVER=$PKGNOVER
+BUILDLINK_PREFIX.${PKGNOVER}_DEFAULT= \${$PREFIX}
+EOF
+
+##
+## buildlinked includes
+##
+for i in `grep "^include/" $PLIST`; do
+ echo "BUILDLINK_FILES.$PKGNOVER+= $i"
+done
+
+##
+## buildlinked libraries
+##
+for i in `grep "^lib/" $PLIST | \
+sed -e 's/\.a$/.*/' -e 's/\.la$/.*/' -e 's/\.so.*$/.*/' | sort | uniq`; do
+ echo "BUILDLINK_FILES.$PKGNOVER+= $i"
+done
+
+echo ""
+
+##
+## buildlinked dependencies
+##
+grep '^.include.*\.\.\/.*\/.*/buildlink.mk\"' $makefile
+
+##
+## check for pkgconfig style config files
+##
+pkgconfigs=`grep "^lib/pkgconfig/.*.pc" $PLIST`
+[ -z "$pkgconfigs" ] || echo ".include \"../../devel/pkgconfig/buildlink.mk\""
+
+##
+## main buildlink target for this package
+##
+echo ""
+echo "BUILDLINK_TARGETS.$PKGNOVER= ${PKGNOVER}-buildlink"
+
+##
+## config wrappers for the buildlink directories
+##
+configs=`grep 'bin/.*-config$' $PLIST`
+
+for i in $configs ; do
+ cfg=`echo $i | sed 's|.*/||'`
+ echo "BUILDLINK_TARGETS.$PKGNOVER+= $PKGNOVER-buildlink-$cfg-wrapper"
+done
+
+echo "BUILDLINK_TARGETS+= \${BUILDLINK_TARGETS.$PKGNOVER}"
+[ -z "$pkgconfigs" ] || \
+echo "BUILDLINK_TARGETS+= \${BUILDLINK_PKG_CONFIG}"
+echo ""
+
+for i in $configs ; do
+ cfg=`echo $i | sed 's|.*/||'`
+ echo "BUILDLINK_CONFIG.$PKGNOVER.$cfg= \${BUILDLINK_PREFIX.$PKGNOVER}/$i"
+ echo "BUILDLINK_CONFIG_WRAPPER.$PKGNOVER.$cfg= \${BUILDLINK_DIR}/$i"
+ echo "REPLACE_BUILDLINK_SED+= \\"
+ echo "-e \"s|\${BUILDLINK_CONFIG_WRAPPER.$PKGNOVER.$cfg}|\${BUILDLINK_CONFIG.$PKGNOVER.$cfg}|g"
+done
+
+##
+## environment variables to help dependent packages find config scripts
+##
+if [ ! -z "$configs" ]; then
+ echo ""
+ echo '.if defined(USE_CONFIG_WRAPPER)'
+ for i in $configs ; do
+ cfg=`echo $i | sed 's|.*/||'`
+ CFG=`echo $cfg | tr '[:lower:]' '[:upper:]' | tr - _`
+ echo "${PKGUPPER}_${CFG}?= \${BUILDLINK_CONFIG_WRAPPER.$PKGNOVER.$cfg}"
+ echo "CONFIGURE_ENV+= \${PKGUPPER}_${CFG}=\"\${${PKGUPPER}_${CFG}}\""
+ echo "MAKE_ENV+= \${PKGUPPER}_${CFG}=\"\${${PKGUPPER}_${CFG}}\""
+ done
+ echo ".endif"
+ echo ""
+fi
+
+##
+## buildlink targets for this package
+##
+echo "pre-configure: \${BUILDLINK_TARGETS}"
+echo "${PKGNOVER}-buildlink: _BUILDLINK_USE"
+for i in $configs ; do
+ cfg=`echo $i | sed 's|.*/||'`
+ echo "$PKGNOVER-buildlink-$cfg-wrapper: _BUILDLINK_CONFIG_WRAPPER_USE"
+done
+
+echo ""
+echo ".endif # ${PKGUPPER}_BUILDLINK_MK"
+
+rm -f $sedrules
diff --git a/pkgtools/createbuildlink/files/createbuildlink.8 b/pkgtools/createbuildlink/files/createbuildlink.8
new file mode 100644
index 00000000000..f3433934af6
--- /dev/null
+++ b/pkgtools/createbuildlink/files/createbuildlink.8
@@ -0,0 +1,89 @@
+.\" $NetBSD: createbuildlink.8,v 1.1.1.1 2002/04/29 11:03:54 rh Exp $
+.\"
+.\" Copyright (c) 2002 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Rene Hexel.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgement:
+.\" This product includes software developed by the NetBSD
+.\" Foundation, Inc. and its contributors.
+.\" 4. Neither the name of The NetBSD Foundation nor the names of its
+.\" contributors may be used to endorse or promote products derived
+.\" from this software without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
+.\"
+.Dd April 29, 2002
+.Dt CREATEBUILDLINK 8
+.Os
+.Sh NAME
+.Nm createbuildlink
+.Nd Automatic NetBSD buildlink.mk generator
+.Sh SYNOPSIS
+.Nm
+.Sh DESCRIPTION
+.Nm
+reads in the
+.Pa Makefile
+and
+.Pa PLIST
+of a package and creates
+an initial
+.Pa buildlink.mk
+file on stdout.
+.Pp
+While
+.Nm
+is supposed to help starting create a
+.Pa buildlink.mk
+for a package, it is not intended to fly on autopilot, though.
+That means that while the script makes some simplistic attempts
+to interpret some elements of the
+.Pa Makefile
+and the
+.Pa PLIST
+such as the contents of the include and lib subdirectories or
+package config scripts, the results should not be put into a
+package directory without some scrutiny.
+.Pp
+Using
+.Nm
+helps maneuver through the initial process of creating a
+.Pa buildlink.mk
+file for a package to be included by depending packages.
+Using
+.Nm
+is less error-prone than copying an existing
+.Pa buildlink.mk
+as a template and renaming the entries in there.
+.Sh SEE ALSO
+.Xr packages 7 ,
+.Xr url2pkg 8
+.Sh AUTHORS
+.Nm
+was written by
+.An Rene Hexel Aq rh@netbsd.org
+.Sh BUGS
+.Nm
+is in its very early stages. Use with caution!