Incorrect @libdir@ when building *.pc using config.site?
Asked Answered
B

1

1

I'm working on Fedora x86_64. It uses /lib64, /usr/lib64 and friends. I have the following *.pc.in file:

$ cat libcryptopp.pc.in
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
...

My config.site has the following. It was copied from Fedora's config.site at /usr/share/config.site. The copy was used because of config.site for vendor libs on Fedora x86_64.

$ cat /usr/local/share/config.site
...

# Note: This file includes also RHEL/Fedora fix for installing libraries into
# "/lib/lib64" on 64bit systems.

if test -n "$host"; then
    # skip when cross-compiling
    return 0
fi

if test "$prefix" = /usr \
   || { test "$prefix" = NONE && test "$ac_default_prefix" = /usr ; }
then
    test "$sysconfdir" = '${prefix}/etc' && sysconfdir=/etc
    test "$sharedstatedir" = '${prefix}/com' && sharedstatedir=/var
    test "$localstatedir" = '${prefix}/var' && localstatedir=/var

    ARCH=`uname -m`
    for i in x86_64 ppc64 s390x aarch64; do
        if test $ARCH = $i; then
            test libdir='${exec_prefix}/lib64'
            break
        fi
    done
fi

However, after Autoconf processes my *.pc.in file:

$ autoreconf --install --force
...
$ ./configure
...

$ cat libcryptopp.pc
prefix=/usr/local
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
...

Notice libdir=${exec_prefix}/lib, and not libdir=${exec_prefix}/lib64.

GCC is definitely building 64-bit binaries for the package. I did not add -mx32 or -m32:

$ gcc -dumpmachine
x86_64-redhat-linux

Why is the wrong lib/ directory being used, and how do I fix it?

Bonnie answered 5/11, 2017 at 16:46 Comment(0)
B
1

The /usr/local/share/config.site is wrong. Though it was copied from Fedora's config.site and placed in /usr/local/share, the prefix directories are wrong. The prefix test should use /usr/local and not /usr.

Below is the corrected one.

$ cat /usr/local/share/config.site
...

if test -n "$host"; then
    # skip when cross-compiling
    return 0
fi

if test "$prefix" = /usr/local \
   || { test "$prefix" = NONE && test "$ac_default_prefix" = /usr/local ; }
then
    test "$sysconfdir" = '${prefix}/etc' && sysconfdir=/etc
    test "$sharedstatedir" = '${prefix}/com' && sharedstatedir=/var
    test "$localstatedir" = '${prefix}/var' && localstatedir=/var

    ARCH=`uname -m`
    for i in x86_64 ppc64 s390x aarch64; do
        if test $ARCH = $i; then
            test "$libdir" = '${exec_prefix}/lib' && libdir='${exec_prefix}/lib64'
            break
        fi
    done
fi

Now, the next question is, why Fedora's /usr/share/config.site is not handling prefix=/usr/local properly. That's an open question at Issue 1510073 : Autoconf does not honor libdir in config.site for "libdir=@libdir@" in *.pc file, which has been closed as NOT A BUG.

Bonnie answered 6/11, 2017 at 17:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.