mrsh[1], a cross-platform shell, can use readline in interactive mode. It's configure script detects the presence of readline using pkg-config(1). Thus, this patch adds a pkg-config file for our readline. I just copied over the generate_pkgconfig.sh script/make rules found in other libraries and edited to fit.
I also added pkg-config files for libedit and libcurses, since libedit requires linking with libcurses. I started getting build errors before I realised that there are a couple editline libraries floating around, each differing slightly with each other: NetBSD editline - Provides <readline/*.h>, <histedit.h>. - Uses ncurses. OpenBSD editline - Provides <histedit.h>. - Uses ncurses. Jess Thrysøe editline[2] - Cross platform autotool port of NetBSD editline. - Provides <editline/*.h> and <histedit.h> - Uses ncurses. Joachim Nilsson editline[3] - Updated version of Rich Salz/Simmule Turner editline. - Call compatible with GNU Readline. - Provides <editline.h>. - Doesn't require ncurses. A very confusing mess. Some Linux systems (e.g. Arch) generate pkg-config files for the different "types" of ncurses: /usr/lib/pkgconfig/ncurses++.pc -> ncurses++w.pc /usr/lib/pkgconfig/ncurses++w.pc /usr/lib/pkgconfig/ncurses.pc -> ncursesw.pc /usr/lib/pkgconfig/ncursesw.pc /usr/lib/pkgconfig/tic.pc -> ncursesw.pc /usr/lib/pkgconfig/tinfo.pc -> ncursesw.pc Not sure if this is something I should do here. [1] https://git.sr.ht/~emersion/mrsh [2] https://thrysoee.dk/editline/ [3] https://github.com/troglobit/editline Index: lib/libedit/Makefile =================================================================== RCS file: /cvs/src/lib/libedit/Makefile,v retrieving revision 1.32 diff -u -p -r1.32 Makefile --- lib/libedit/Makefile 15 Jan 2019 01:54:00 -0000 1.32 +++ lib/libedit/Makefile 25 Jul 2019 14:00:00 -0000 @@ -19,6 +19,9 @@ LIBEDITDIR?=${.CURDIR} INCS= histedit.h INCSDIR=/usr/include +PC_FILES=libedit.pc +CLEANFILES+=${PC_FILES} + CLEANFILES+=common.h.tmp emacs.h.tmp fcns.h.tmp func.h.tmp CLEANFILES+=help.h.tmp vi.h.tmp tc1.o tc1 @@ -78,6 +81,14 @@ includes: /dev/null 2>&1 || \ ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m 444 histedit.h \ ${DESTDIR}/usr/include + +all: ${PC_FILES} +${PC_FILES}: histedit.h + /bin/sh ${.CURDIR}/generate_pkgconfig.sh -c ${.CURDIR} -o ${.OBJDIR} + +beforeinstall: + ${INSTALL} ${INSTALL_COPY} -o root -g ${SHAREGRP} \ + -m ${SHAREMODE} ${.OBJDIR}/${PC_FILES} ${DESTDIR}/usr/lib/pkgconfig/ .include <bsd.lib.mk> .include <bsd.subdir.mk> Index: lib/libedit/generate_pkgconfig.sh =================================================================== RCS file: lib/libedit/generate_pkgconfig.sh diff -N lib/libedit/generate_pkgconfig.sh --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lib/libedit/generate_pkgconfig.sh 25 Jul 2019 14:00:00 -0000 @@ -0,0 +1,71 @@ +#!/bin/sh +# +# $OpenBSD$ +# +# Copyright (c) 2010,2011 Jasper Lievisse Adriaanse <[email protected]> +# +# 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 libedit. + +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:]]LIBEDIT_MAJOR[[:blank:]]([0-9]+).*/\1/p" +version_minor_re="s/^#define[[:blank:]]LIBEDIT_MINOR[[:blank:]]([0-9]+).*/\1/p" +version_file=${curdir}/histedit.h +lib_version=$(sed -nE ${version_major_re} ${version_file}).$(sed -nE ${version_minor_re} ${version_file}) + +pc_file="${objdir}/libedit.pc" +cat > ${pc_file} << __EOF__ +prefix=/usr +exec_prefix=\${prefix} +libdir=\${exec_prefix}/lib +includedir=\${prefix}/include + +Name: editline +Description: line editor, history and tokenization library +Version: ${lib_version} +Requires: ncurses +Libs: -L\${libdir} -ledit +Cflags: -I\${includedir} +__EOF__ Index: lib/libcurses/Makefile =================================================================== RCS file: /cvs/src/lib/libcurses/Makefile,v retrieving revision 1.74 diff -u -p -r1.74 Makefile --- lib/libcurses/Makefile 13 Feb 2019 15:10:40 -0000 1.74 +++ lib/libcurses/Makefile 25 Jul 2019 14:00:00 -0000 @@ -99,6 +99,9 @@ CLEANFILES+= ${GENERATED} BUILDFIRST = ${GENERATED} +PC_FILES=ncurses.pc +CLEANFILES+=${PC_FILES} + includes: @cmp -s ${DESTDIR}/usr/include/ncurses.h ${.CURDIR}/curses.h || \ ${INSTALL} ${INSTALL_COPY} -m 444 -o $(BINOWN) -g $(BINGRP) \ @@ -153,6 +156,14 @@ unctrl.c: ${.CURDIR}/base/MKunctrl.awk echo | ${AWK} -f ${.CURDIR}/base/MKunctrl.awk bigstrings=1 > ${.TARGET} .include <bsd.own.mk> + +all: ${PC_FILES} +${PC_FILES}: curses.h + /bin/sh ${.CURDIR}/generate_pkgconfig.sh -c ${.CURDIR} -o ${.OBJDIR} + +beforeinstall: + ${INSTALL} ${INSTALL_COPY} -o root -g ${SHAREGRP} \ + -m ${SHAREMODE} ${.OBJDIR}/${PC_FILES} ${DESTDIR}/usr/lib/pkgconfig/ # Link libtermlib, libtermcap to libcurses so we don't break people's Makefiles afterinstall: Index: lib/libcurses/generate_pkgconfig.sh =================================================================== RCS file: lib/libcurses/generate_pkgconfig.sh diff -N lib/libcurses/generate_pkgconfig.sh --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lib/libcurses/generate_pkgconfig.sh 25 Jul 2019 14:00:00 -0000 @@ -0,0 +1,69 @@ +#!/bin/sh +# +# $OpenBSD$ +# +# Copyright (c) 2010,2011 Jasper Lievisse Adriaanse <[email protected]> +# +# 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 ncurses. + +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_re="s/^#define[[:blank:]]+NCURSES_VERSION[[:blank:]]+\"(.*)\".*/\1/p" +version_file=${curdir}/curses.h +lib_version=$(sed -nE ${version_re} ${version_file}) + +pc_file="${objdir}/ncurses.pc" +cat > ${pc_file} << __EOF__ +prefix=/usr +exec_prefix=\${prefix} +libdir=\${exec_prefix}/lib +includedir=\${prefix}/include + +Name: ncurses +Description: ncurses library +Version: ${lib_version} +Libs: -L\${libdir} -lcurses +Cflags: -I\${includedir} +__EOF__ Index: gnu/lib/libreadline/Makefile =================================================================== RCS file: /cvs/src/gnu/lib/libreadline/Makefile,v retrieving revision 1.9 diff -u -p -r1.9 Makefile --- gnu/lib/libreadline/Makefile 15 Jan 2019 01:54:00 -0000 1.9 +++ gnu/lib/libreadline/Makefile 25 Jul 2019 14:00:00 -0000 @@ -13,6 +13,9 @@ CPPFLAGS+=-DHAVE_CONFIG_H -I${.CURDIR} LDADD+= -L${BSDOBJDIR}/lib/libcurses -lcurses DPADD+= ${LIBCURSES} +PC_FILES=readline.pc +CLEANFILES+=${PC_FILES} + includes: ${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 755 \ ${DESTDIR}/usr/include/readline @@ -23,6 +26,14 @@ includes: echo $$j; \ eval "$$j"; \ done + +all: ${PC_FILES} +${PC_FILES}: readline.h + /bin/sh ${.CURDIR}/generate_pkgconfig.sh -c ${.CURDIR} -o ${.OBJDIR} + +beforeinstall: + ${INSTALL} ${INSTALL_COPY} -o root -g ${SHAREGRP} \ + -m ${SHAREMODE} ${.OBJDIR}/${PC_FILES} ${DESTDIR}/usr/lib/pkgconfig/ .include <bsd.lib.mk> .include <bsd.subdir.mk> Index: gnu/lib/libreadline/generate_pkgconfig.sh =================================================================== RCS file: gnu/lib/libreadline/generate_pkgconfig.sh diff -N gnu/lib/libreadline/generate_pkgconfig.sh --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gnu/lib/libreadline/generate_pkgconfig.sh 25 Jul 2019 14:00:00 -0000 @@ -0,0 +1,70 @@ +#!/bin/sh +# +# $OpenBSD$ +# +# Copyright (c) 2010,2011 Jasper Lievisse Adriaanse <[email protected]> +# +# 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 readline. + +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:]]+RL_VERSION_MAJOR[[:blank:]]+([0-9]+).*/\1/p" +version_minor_re="s/^#define[[:blank:]]+RL_VERSION_MINOR[[:blank:]]+([0-9]+).*/\1/p" +version_file=${curdir}/readline.h +lib_version=$(sed -nE ${version_major_re} ${version_file}).$(sed -nE ${version_minor_re} ${version_file}) + +pc_file="${objdir}/readline.pc" +cat > ${pc_file} << __EOF__ +prefix=/usr +exec_prefix=\${prefix} +libdir=\${exec_prefix}/lib +includedir=\${prefix}/include + +Name: Readline +Description: GNU readline library +Version: ${lib_version} +Libs: -L\${libdir} -lreadline +Cflags: -I\${includedir} +__EOF__ -- Stephen Gregoratto
