On Tue, 12 Apr 2022, LM wrote:
> On Mon, Apr 11, 2022 at 6:09 PM Richard Narron <[email protected]> wrote:
>
> The PDCurses 3.9 package on SLackBuilds.org now creates a pkg-config
> file
> for use in building the Hessling editor 3.3RC8.
>
>
> Nice addition.
>
>
> Ideally this file would be named the same as the library:
>
> /usr/lib64/pkgconfig/LibXCurses.pc
>
> And also it would have Libs: for dynamic loading and and Libs.private:
> for static loading.
>
> Libs: -lXCurses
> Libs.private: -l:libXCurses.a -lXaw -lXmu -lXt -lX11 -lXpm -lSM -lICE
> -lXext
>
> More information on creating these files is here:
>
> https://www.freedesktop.org/wiki/Software/pkg-config/
>
>
>
> I use pkgconf ( https://github.com/pkgconf/pkgconf ) with almost all of my
> builds and I have scripts similar to
> Slackbuilds (for a variety of operating systems) that generate a .pc file as
> well.
>
> Here's part of a script for MinGW on Windows:
>
> #!/bin/bash
> ...
> cat > pdcurses.pc << EOF
> prefix=/opt
> exec_prefix=\${prefix}
> libdir=\${exec_prefix}/lib
> includedir=\${prefix}/include
> Name: pdcurses
> Description: Public Domain Curses screen library
> Version: 3.4
> Requires:
> Requires.private:
> Libs: -L\${libdir} -lpdcurses
> Libs.private:
> Cflags: -I\${includedir}
> EOF
>
> It gets tricky tracking the different dependent libraries on different
> operating systems. None of the X libraries
> are typically used on Windows (unless you're developing for a target like
> Cygwin).
>
> I investigated naming the pc file something generic like curses.pc so I could
> switch out curses libraries and use
> either pdcurses or ncurses as desired. Didn't work out that well so I just
> use pdcurses.pc.
I discovered that the pkg-config program looks at a global variable,
PKG_CONFIG_PATH, that is searched before the usual spot,
/usr/lib/pkgconfig.
This allowed me to move the code to generate the libpdconfig-x11.pc file
from the PDCurses package build to the THE (The Hessling Editor)
package build.
Rather than make a hereis file, a template pc file is included
with the THE.SlackBuild script called libpdcurses-x11.pc:
-----------------------------------------------
prefix=/usr
exec_prefix=${prefix}
libdir=${prefix}/XLIBDIR
includedir=${prefix}/include/xcurses
version=XVERSION
Name: PDCurses
Description: PDCurses ${version} X11 library
Version: ${version}
URL: https://pdcurses.org
Requires.private:
Libs: -lXCurses
Libs.private: -l:libXCurses.a -lXaw -lXmu -lXt -lX11 -lXpm -lSM -lICE
-lXext
Cflags: -DXCURSES -I${includedir} -I/usr/include/X11
-----------------------------------------------
The THE.SlackBuild bash script uses sed to substitue the XLIBDIR and
XVERSION words before putting the completed template pc file in a newly
created pkgconfig/ directory:
LIBDIRSUFFIX="64"
SLKCFLAGS="-O2"
...
# for XCurses, create pdcurses-x11.pc pkg-config
XLIBDIR=lib${LIBDIRSUFFIX}
XVERSION=$(xcurses-config --version)
mkdir -p pkgconfig
sed -e "s/XLIBDIR/${XLIBDIR}/" \
-e "s/XVERSION/${XVERSION}/" \
< $CWD/libpdcurses-x11.pc \
> pkgconfig/libpdcurses-x11.pc
PKG_CONFIG_PATH=pkgconfig \
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
../configure \
--with-curses=pdcurses-x11 \
...
make the-x11
So the completed pkgconfig/libpdcurses-x11.pc file looks like this:
-----------------------------------------------
prefix=/usr
exec_prefix=${prefix}
libdir=${prefix}/lib64
includedir=${prefix}/include/xcurses
version=3.9
Name: PDCurses
Description: PDCurses ${version} X11 library
Version: ${version}
URL: https://pdcurses.org
Requires.private:
Libs: -lXCurses
Libs.private: -l:libXCurses.a -lXaw -lXmu -lXt -lX11 -lXpm -lSM -lICE
-lXext
Cflags: -DXCURSES -I${includedir} -I/usr/include/X11
-----------------------------------------------
I tested this THE bash build script and it worked fine using both PDCurses
3.9 and 3.8.
Regards,
Richard Narron