1

I want to compile only one of the many libs that come with glibc.

Namely all I need is the static version of the librt library (librt.a). Is there a way to tell configure/make to do just that?

Right now, I have a process set up where I set specific CFLAGS when running configure and then compile the whole glibc and simply extract librt.a after the compile - but that certainly seems like 99% waste and 1% yield.

edit:

The suggested command make rt/librt.a yields

make -r PARALLELMFLAGS="" -C .. objdir=`pwd` rt/librt.a
make[1]: Entering directory '/data/soft/glibc-2.24'
make[1]: *** No rule to make target 'rt/librt.a'.  Stop.
make[1]: Leaving directory '/data/soft/glibc-2.24'
make: *** [Makefile:9: rt/librt.a] Error 2

and when I looked at the output of the complete make run, librt was built like

make  subdir=rt -C rt ..=../ subdir_lib

unfortunately, this command too yields no good result:

$ make  subdir=rt -C rt ..=../ subdir_lib
make: Entering directory '/data/soft/glibc-2.24/build-tree/rt'
make: *** No rule to make target 'subdir_lib'.  Stop.
make: Leaving directory '/data/soft/glibc-2.24/build-tree/rt'

Interestingly, when - after a complete make run - I try the suggested command, I get

$ make -j 4 rt/librt.a
make: 'rt/librt.a' is up to date.
Perlator
  • 241
  • 1
  • 2
  • 11

2 Answers2

2

the glibc build is centered around the objdir variable. export it to the path where you ran configure, and then you can use make in surce subdirs.

for example:

cd .../glibc/
mkdir build
cd build
../configure --prefix=/usr
export objdir=$PWD
cd ../rt
make -j4
Mike Frysinger
  • 2,827
  • 1
  • 21
  • 26
  • configure needs a --prefix under linux, but even if I give that, the compile ends with this error `make: *** No rule to make target '/data/glibc-2.24/build/csu/stamp.o', needed by '/data/glibc-2.24/build/libc.a'. Stop.` if I then go into the csu dir and issue a make there, that runs through. If - after that - I return back to the rt dir, and continue with make, I get: `../sysdeps/unix/sysv/linux/x86_64/cancellation.S:69: Error: invalid operands (*UND* and *UND* sections) for "|"` – Perlator Jan 14 '17 at 18:16
1

This should do it:

mkdir build && cd build && ../configure $your_flags &&
make -j20 rt/librt.a
Employed Russian
  • 199,314
  • 34
  • 295
  • 362