Monday, May 28, 2018

Building pkg-config 0.29.2

The latest version, 0.29.2 (up to this writing), of the pkg-config tool from FreeeDesktop.org, is missing in Solaris 11 Express, but present on Solaris 11.3 GA under an IPS package of the same name, although outdated as to version 0.23. This small utility is extremely handy while building software from source-code and can also be integrated into GNU autoconf and automake utilities.

What surprised me was its dependency on at least glib-2.0. The bundled version of glib failed to build (at least under a 32-bits Solaris 11 Express). But that wasn't really an issue because since Solaris 11 Express, glib is part of Solaris 11 IPS repositories.

The basic building strategy and general assumptions have been detailed on a previous post Staged Building.

$ pwd
/stage/build

$ ./gnu-build-preparation ../source/.../pkg-config-0.29.2.tar.gz
...

$ cd pkg-config/pkg-config-0.29.2-32

In this particular case a slight tweak will be necessary to my setenv-0.29.2 script. The following environment variables will have to be added in order to publish the location of glib 2.0 headers and libraries:

export GLIB_CFLAGS="-I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include"
export GLIB_LIBS="-lglib-2.0"


$ source ../setenv-0.29.2 32
...

$ ./configure \
  --build=i386-pc-solaris2.11 \
  --prefix=/opt/usr
checking for a BSD-compatible install... /usr/bin/ginstall -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/gnu/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking build system type... i386-pc-solaris2.11
checking host system type... i386-pc-solaris2.11
checking how to print strings... print -r
checking for style of include used by make... GNU
checking for gcc... /usr/bin/gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether /usr/bin/gcc accepts -g... yes
checking for /usr/bin/gcc option to accept ISO C89... none needed
checking whether /usr/bin/gcc understands -c and -o together... yes
checking dependency style of /usr/bin/gcc... gcc3
checking for a sed that does not truncate output... /usr/gnu/bin/sed
checking for grep that handles long lines and -e... /usr/gnu/bin/grep
checking for egrep... /usr/gnu/bin/grep -E
checking for fgrep... /usr/gnu/bin/grep -F
checking for ld used by /usr/bin/gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... no
checking for BSD- or MS-compatible name lister (nm)... /usr/gnu/bin/nm -B
checking the name lister (/usr/gnu/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 786240
checking how to convert i386-pc-solaris2.11 file names to i386-pc-solaris2.11 format... func_convert_file_noop
checking how to convert i386-pc-solaris2.11 file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... print -r --
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/gnu/bin/nm -B output from /usr/bin/gcc object... ok
checking for sysroot... no
checking for a working dd... /usr/gnu/bin/dd
checking how to truncate binary pipes... /usr/gnu/bin/dd bs=4096 count=1
checking for mt... mt
checking if mt is a manifest tool... no
checking how to run the C preprocessor... /usr/bin/gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if /usr/bin/gcc supports -fno-rtti -fno-exceptions... no
checking for /usr/bin/gcc option to produce PIC... -fPIC -DPIC
checking if /usr/bin/gcc PIC flag -fPIC -DPIC works... yes
checking if /usr/bin/gcc static flag -static works... no
checking if /usr/bin/gcc supports -c -o file.o... yes
checking if /usr/bin/gcc supports -c -o file.o... (cached) yes
checking whether the /usr/bin/gcc linker (/usr/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... yes
checking dynamic linker characteristics... solaris2.11 ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking whether make supports nested variables... (cached) yes
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... 64
checking for gcc... (cached) /usr/bin/gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether /usr/bin/gcc accepts -g... (cached) yes
checking for /usr/bin/gcc option to accept ISO C89... (cached) none needed
checking whether /usr/bin/gcc understands -c and -o together... (cached) yes
checking dependency style of /usr/bin/gcc... (cached) gcc3
checking for ln... ln
checking dirent.h usability... yes
checking dirent.h presence... yes
checking for dirent.h... yes
checking for unistd.h... (cached) yes
checking sys/wait.h usability... yes
checking sys/wait.h presence... yes
checking for sys/wait.h... yes
checking malloc.h usability... yes
checking malloc.h presence... yes
checking for malloc.h... yes
checking for bash... /usr/bin/bash
checking for default search path for .pc files... ${libdir}/pkgconfig:${datadir}/pkgconfig
checking for system include path to avoid -I flags... /usr/include
checking for system library path to avoid -L flags... /usr/lib:/lib
configure: creating ./config.lt
config.lt: creating libtool
checking whether to list both direct and indirect dependencies... no
checking for Win32... no
checking if prefix should be redefined at runtime... no
checking if internal glib should be used... no
checking for pkg-config... no
checking for glib-2.0 >= 2.16... yes
checking if host- prefixed tool should be installed... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating pkg.m4
config.status: creating check/Makefile
config.status: creating check/config.sh
config.status: creating config.h.win32
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands


$ gmake
gmake  all-recursive
gmake[1]: Entering directory `/stage/build/pkg-config/pkg-config-0.29.2-32'
Making all in .
gmake[2]: Entering directory `/stage/build/pkg-config/pkg-config-0.29.2-32'
  CC       pkg.o
  CC       parse.o
  CC       rpmvercmp.o
  CC       main.o
  CCLD     pkg-config
gmake[2]: Leaving directory `/stage/build/pkg-config/pkg-config-0.29.2-32'
Making all in check
gmake[2]: Entering directory `/stage/build/pkg-config/pkg-config-0.29.2-32/check'
gmake[2]: Nothing to be done for `all'.
gmake[2]: Leaving directory `/stage/build/pkg-config/pkg-config-0.29.2-32/check'
gmake[1]: Leaving directory `/stage/build/pkg-config/pkg-config-0.29.2-32
'

$ sudo gmake install
...
Making install in .
gmake[1]: Entering directory `/stage/build/pkg-config/pkg-config-0.29.2-32'
gmake[2]: Entering directory `/stage/build/pkg-config/pkg-config-0.29.2-32'
 /usr/gnu/bin/mkdir -p '/opt/usr/bin'
  /bin/sh ./libtool   --mode=install /usr/bin/ginstall -c pkg-config '/opt/usr/bin'
libtool: install: /usr/bin/ginstall -c pkg-config /opt/usr/bin/pkg-config
gmake  install-exec-hook
gmake[3]: Entering directory `/stage/build/pkg-config/pkg-config-0.29.2-32'
cd /opt/usr/bin && ln -f pkg-config i386-pc-solaris2.11-pkg-config
gmake[3]: Leaving directory `/stage/build/pkg-config/pkg-config-0.29.2-32'
 /usr/gnu/bin/mkdir -p '/opt/usr/share/doc/pkg-config'
 /usr/bin/ginstall -c -m 644 pkg-config-guide.html '/opt/usr/share/doc/pkg-config'
 /usr/gnu/bin/mkdir -p '/opt/usr/share/aclocal'
 /usr/bin/ginstall -c -m 644 pkg.m4 '/opt/usr/share/aclocal'
 /usr/gnu/bin/mkdir -p '/opt/usr/share/man/man1'
 /usr/bin/ginstall -c -m 644 pkg-config.1 '/opt/usr/share/man/man1'
gmake[2]: Leaving directory `/stage/build/pkg-config/pkg-config-0.29.2-32'
gmake[1]: Leaving directory `/stage/build/pkg-config/pkg-config-0.29.2-32'
Making install in check
gmake[1]: Entering directory `/stage/build/pkg-config/pkg-config-0.29.2-32/check'
gmake[2]: Entering directory `/stage/build/pkg-config/pkg-config-0.29.2-32/check'
gmake[2]: Nothing to be done for `install-exec-am'.
gmake[2]: Nothing to be done for `install-data-am'.
gmake[2]: Leaving directory `/stage/build/pkg-config/pkg-config-0.29.2-32/check'
gmake[1]: Leaving directory `/stage/build/pkg-config/pkg-config-0.29.2-32/check'


$ sudo zfs snapshot -r .../opt/usr@pkg-config-0.29.2
 
As a quick and dirty verification:

$ pkg-config --version
0.29.2

$ pkg-config --help
Usage:
  pkg-config [OPTION...]
...


As usual (and already considered on my setenv scripts in general) the environment variable PKG_CONFIG_PATH should be properly built and set before using pkg-config, otherwise one gets diagnostics messages such as:

$ pkg-config glib-2.0 --cflags --libs
Package glib-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `glib-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'glib-2.0' found


That's it.