Re: add pkg-config files for readline, editline, ncurses
On 2019/07/26 01:23, Stephen Gregoratto wrote: > 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. Just patch the configure script. It's going to be horrible to validate adding these pc files across the ports tree, and unless there are a bunch of ports needing patches due to us not having this, the work isn't justifiable. > there are a couple editline libraries floating around, > each differing slightly with each other: exactly, this gives me the feeling that this is opening a can of worms. (While on the subject of pkg-config files, the bogus version number in the libressl ones is a small problem for ports, though I have no idea what we'd change it to instead ...)
Re: add pkg-config files for readline, editline, ncurses
Hi Stephen, Stephen Gregoratto wrote on Fri, Jul 26, 2019 at 01:23:21AM +1000: > 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. It is not obvious to me whether or not that is desirable. It depends on which version of readline mrsh requires. If mrsh builds and is usable with our base system readline (which is quite old), what you propose may help. On the other hand, if it requires a newer readline or doesn't work well with the base readline, adding a library dependency on ports readline might be better. > 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, I think that ought to be a completely separate change because a program either uses base libedit or base readline or ports readline but never more than one of these. I know relatively little about pkg-config(1); the reason i'm speaking up here is that nobody else spoke up so far and that i occasionally worked on libedit in the past. Now, as far as i understand (take this with a grain of salt), the effect of adding a pkg-config file for libedit would possibly be that additional ports might pick up our base libedit that now think that no libedit is available and consequently compile without it. That might improve some ports - and/or break others. So i suspect that adding libedit.pc to base would probably require a bulk build before commit to make sure nothing breaks. Also - even though it seems less likely that anything in the base system looks at *.pc files - it would probably require a complete make build & release of base and xenocara. For adding readline.pc, the same caveats apply, only even more so. I suspect that the risk of breaking ports by adding readline.pc to base is larger than for editline because probaly more ports use readline than editline and those that do are probably more likely to use pkg-config(1) and those that do both are probably more likely to be unhappy with our base readline, whereas ports looking for editline probably have a better chance to be happy with our base editline. As far as i understand, adding editline.pc does not necessarily require also adding ncurses.pc, nor does it require Requires: lines. So far, we don't have a single non-empty Requires: line in base even though libssl depends on libcrypto. Again, the effect of adding ncurses.pc to base might be that some ports suddenly pick up our base curses, for good or ill. If there is a benefit to that, i suspect it might make sense to test that change independently from libedit.pc. I don't think we want a bulk build with three combined changes and lots of fallout, because then we would be forced to figure out which fallout was caused by which part of the changes, which sounds like gratuitious additional pain. > 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: *If* we want editline.pc, then i expect we probably just want one, for our own editline. Additional ones would only make sense to me in the context of a port of one of the other editline implementations. But i don't really see the point of such a port. If some port does not work with our editline but does work with a different editline, we should probably either fix our editline or patch the port to work with our editline, depending on what exactly to port is doing. > 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. I doubt it. In any case, the base system should contain one *curses*.pc at most, i think, because we only have one curses in base. Any other *curses*.pc would be a matter of ports - and like for editline, i doubt that having a port of a different version of curses makes sense. That said, even though you are changing the base system, i suspect discussing this kind of patches may be more fruitful on ports@ because that's where all the ports developers are that will be affected by such changes. I suggest that you decide which of the three changes you care about most, then send a patch to ports@ with only that one change, explaining what exactly it is supposed to improve (and how you tested that it indeed does), and what exactly you already tested in addition to that (for example, building which ports that use pkg-config(1) and the library in question), asking for feedback. The feedback you get
add pkg-config files for readline, editline, ncurses
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 , . - Uses ncurses. OpenBSD editline - Provides . - Uses ncurses. Jess Thrysøe editline[2] - Cross platform autotool port of NetBSD editline. - Provides and - Uses ncurses. Joachim Nilsson editline[3] - Updated version of Rich Salz/Simmule Turner editline. - Call compatible with GNU Readline. - Provides . - 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/Makefile15 Jan 2019 01:54:00 - 1.32 +++ lib/libedit/Makefile25 Jul 2019 14:00:00 - @@ -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 .include 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 - +++ lib/libedit/generate_pkgconfig.sh 25 Jul 2019 14:00:00 - @@ -0,0 +1,71 @@ +#!/bin/sh +# +# $OpenBSD$ +# +# Copyright (c) 2010,2011 Jasper Lievisse Adriaanse +# +# 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_versio