summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJasper Lievisse Adriaanse <jasper@cvs.openbsd.org>2012-07-07 08:14:44 +0000
committerJasper Lievisse Adriaanse <jasper@cvs.openbsd.org>2012-07-07 08:14:44 +0000
commitca7e2bf40aba251b909cf75b84479abfeb537390 (patch)
treed564d51c74f0deea946cfaf09f03a9d209eff88f /lib
parentf02ad9249c30f685b86595c434a87ba99f7ed7c1 (diff)
add expat.pc
based on a diff by brad ok sthen@
Diffstat (limited to 'lib')
-rw-r--r--lib/libexpat/Makefile11
-rw-r--r--lib/libexpat/generate_pkgconfig.sh72
2 files changed, 82 insertions, 1 deletions
diff --git a/lib/libexpat/Makefile b/lib/libexpat/Makefile
index bc4978c6309..44ae9e65a04 100644
--- a/lib/libexpat/Makefile
+++ b/lib/libexpat/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.6 2007/10/19 16:06:39 deraadt Exp $
+# $OpenBSD: Makefile,v 1.7 2012/07/07 08:14:43 jasper Exp $
.PATH: ${.CURDIR}/lib
@@ -7,6 +7,9 @@ WANTLINT=
SRCS= xmlparse.c xmltok.c xmlrole.c
CFLAGS+=-I${.CURDIR} -DHAVE_EXPAT_CONFIG_H
+PC_FILES=expat.pc
+CLEANFILES+=${PC_FILES}
+
includes:
cmp -s ${DESTDIR}/usr/include/expat.h ${.CURDIR}/lib/expat.h || \
${INSTALL} ${INSTALL_COPY} -m 444 -o $(BINOWN) -g $(BINGRP) \
@@ -15,4 +18,10 @@ includes:
${INSTALL} ${INSTALL_COPY} -m 444 -o $(BINOWN) -g $(BINGRP) \
${.CURDIR}/lib/expat_external.h ${DESTDIR}/usr/include/expat_external.h
+beforeinstall:
+ /bin/sh ${.CURDIR}/generate_pkgconfig.sh -c ${.CURDIR} -o ${.OBJDIR}
+ ${INSTALL} ${INSTALL_COPY} -o root -g ${SHAREGRP} \
+ -m ${SHAREMODE} ${.OBJDIR}/${PC_FILES} ${DESTDIR}/usr/lib/pkgconfig/
+
+.include <bsd.prog.mk>
.include <bsd.lib.mk>
diff --git a/lib/libexpat/generate_pkgconfig.sh b/lib/libexpat/generate_pkgconfig.sh
new file mode 100644
index 00000000000..8e72dd2644f
--- /dev/null
+++ b/lib/libexpat/generate_pkgconfig.sh
@@ -0,0 +1,72 @@
+#!/bin/sh
+#
+# $OpenBSD: generate_pkgconfig.sh,v 1.1 2012/07/07 08:14:43 jasper Exp $
+#
+# Copyright (c) 2010-2012 Jasper Lievisse Adriaanse <jasper@openbsd.org>
+#
+# Permission to use, copy, modify, and distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#
+# Generate pkg-config file for expat.
+
+usage() {
+ echo "usage: ${0##*/} -c current_directory -o obj_directory"
+ exit 1
+}
+
+curdir=
+objdir=
+while getopts "c:o:" flag; do
+ case "$flag" in
+ c)
+ curdir=$OPTARG
+ ;;
+ o)
+ objdir=$OPTARG
+ ;;
+ *)
+ usage
+ ;;
+ esac
+done
+
+[ -n "${curdir}" ] || usage
+if [ ! -d "${curdir}" ]; then
+ echo "${0##*/}: ${curdir}: not found"
+ exit 1
+fi
+[ -n "${objdir}" ] || usage
+if [ ! -w "${objdir}" ]; then
+ echo "${0##*/}: ${objdir}: not found or not writable"
+ exit 1
+fi
+
+version_major_re="s/#define[[:blank:]]XML_MAJOR_VERSION[[:blank:]](.*)/\1/p"
+version_minor_re="s/#define[[:blank:]]XML_MINOR_VERSION[[:blank:]](.*)/\1/p"
+version_micro_re="s/#define[[:blank:]]XML_MICRO_VERSION[[:blank:]](.*)/\1/p"
+version_file=${curdir}/lib/expat.h
+lib_version=$(sed -nE ${version_major_re} ${version_file}).$(sed -nE ${version_minor_re} ${version_file}).$(sed -nE ${version_micro_re} ${version_file})
+
+pc_file="${objdir}/expat.pc"
+cat > ${pc_file} << __EOF__
+prefix=/usr
+exec_prefix=\${prefix}
+libdir=\${exec_prefix}/lib
+includedir=\${prefix}/include
+
+Name: expat
+Description: expat XML parser
+Version: ${lib_version}
+Requires:
+Libs: -L\${libdir} -lexpat
+Cflags: -I\${includedir}
+__EOF__