help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to switch behaviour according to glibc version?


From: David Aldrich
Subject: How to switch behaviour according to glibc version?
Date: Tue, 5 Apr 2016 08:54:01 +0000

Hi

I am running gnu make 4.1 on Ubuntu.  Make builds my C++ application that 
requires glibc 2.22 or higher.  Ubuntu 14.04 has only glibc 2.19 so my makefile 
checks the host o/s and, if it's Ubuntu, it links to my private copy of glibc 
2.22:

GLIBC_FLAGS=
ifeq ($(DISTRO),debian)
    echo "Warning: detected Ubuntu o/s so using different glibc to that 
installed on this system"
    GLIBC=$(MY_OPEN_SOURCE_LIBS)/glibc/v2_22/
    GLIBC_FLAGS= 
-Wl,-rpath=${GLIBC}:${GLIBC}/math:${GLIBC}/elf:${GLIBC}/dlfcn:${GLIBC}/nss:${GLIBC}/nis:${GLIBC}/rt:${GLIBC}/resolv:${GLIBC}/crypt:${GLIBC}/nptl\
    -Wl,--dynamic-linker=${GLIBC}/elf/ld.so
endif

Now, Ubuntu 16.04 has glibc 2.23, so there I can use the standard glibc 
packaged for the o/s.  So I want to change the makefile code to only use my 
private copy of glibc if glibc is <2.22.

I'm not sure whether it's best to detect the o/s version or the glibc version.  
I can do the latter with:

~$ ldd --version
ldd (Ubuntu GLIBC 2.23-0ubuntu2) 2.23
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

My question is, how can I extract the glibc version number from that ldd 
response and use it in my makefile to only set GLIBC and GLIBC_FLAGS if the 
glibc version is <2.22?

Best regards

David



reply via email to

[Prev in Thread] Current Thread [Next in Thread]