Compile only parts of glibc

1.3k Views Asked by At

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.
2

There are 2 best solutions below

0
Employed Russian On

This should do it:

mkdir build && cd build && ../configure $your_flags &&
make -j20 rt/librt.a
1
Mike Frysinger On

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