compiling coreutils

Hi gurus
I am trying to compile coreutils for studying purposes. I downloaded package (exact version which target system already contains) and tried following:

./configure
make

but compiling ands with some header file dependency problem. Then I tried compile particular binary

cd src
gcc id.c -o id

also tried

export CFLAGS="-static -02 -g"
./configure
cd src
gcc -std=gnu99 -I../lib -static -O2 -g -MT uniq.o -MD -MP -MF .deps/uniq.Tpo -c -o uniq.o uniq.c

But there was also missing header files problem.

So I tried to find particular file on system and link to /usr/include location for example:

ln -s /usr/lib/syslinux/com32/include/syslinux/config.h /usr/include/config.h
ln -s /usr/lib/syslinux/com32/include/com32.h /usr/include/com32.h
ln -s /usr/lib/syslinux/com32/include/klibc/compiler.h /usr/include/klibc/compiler.h
ln -s /usr/lib/gcc/i686-pc-linux-gnu/4.5.2/plugin/include/system.h /usr/include/system.h
ln -s /usr/lib/gcc/i686-pc-linux-gnu/4.5.2/plugin/include/safe-ctype.h /usr/include/safe-ctype.h
ln -s /usr/lib/gcc/i686-pc-linux-gnu/4.5.2/plugin/include/hwint.h /usr/include/hwint.h
ln -s /usr/lib/gcc/i686-pc-linux-gnu/4.5.2/plugin/include/filenames.h /usr/include/filenames.h

maybe further more header files I dont know - but the result is the same header file problem.
I tried the metioned procedure on Archbang and Fedora (on both the coreutils was the same version whih is already installed and is working properly)

Thanks a lot

If you tell us what it actually did, maybe we can actually help you. But my crystal ball is still in for maintenance so I can't tell you why those errors were happening, or what they even were. "some header file dependency problem" doesn't cut it. There might be reasons you're missing a specific header. I can't tell you why you might be missing any random header.

Please don't throw random symlinks into /usr/include. Take out the ones you put before you forget where they are. They'll come back to haunt you later.

Thank you for reply
symlinks from /usr/include is removed.

ARCHBANG
[cepido@archbang ~]$ pacman -Q | grep coreutils
coreutils 8.10-1
[cepido@archbang ~]$ cd coreutils-8.10/src/
[cepido@archbang src]$ gcc -std=gnu99 -I../lib -static -O2 -g -MT uniq.o -MD -MP -MF .deps/uniq.Tpo -c -o uniq.o uniq.c
In file included from uniq.c:24:0:
system.h:49:24: fatal error: configmake.h: No such file or directory
compilation terminated.
[cepido@archbang src]$ gcc uniq.c -o uniq
uniq.c:19:20: fatal error: config.h: No such file or directory
compilation terminated.


FEDORA
[cepido@localhost /]$ yum list installed | grep core
coreutils.i686      8.5-7.fc14      @updates
coreutils-libs.i686 8.5-7.fc14      @updates
[cepido@localhost ~]$ cd coreutils-8.5/src/
[cepido@localhost src]$ gcc -std=gnu99 -I../lib -static -O2 -g -MT uniq.o -MD -MP -MF .deps/uniq.Tpo -c -o uniq.o uniq.c
uniq.c:19:20: fatal error: config.h: No such file or directory
compilation terminated.
[cepido@localhost src]$ gcc uniq.c -o uniq
uniq.c:19:20: fatal error: config.h: No such file or directory
compilation terminated.

Are you sure that ./configure succeeded? config.h is one of the files that ought to be autogenerated by it. Run ./configure again and check closely if it bombs out.

Also, run 'make' from the base directory where you extracted that, not basedir/src. The base makefile might have exported something important.

would be nice if you paste the result of the configure script. Also check the exit status and try to locate the "missing header" using a simple find if you can find it.

Hi people - sorry for long response
I tried that:

[root@localhost coreutils-8.5]# tar -xvzf coreutils-8.5.tar.gz
[root@localhost coreutils-8.5]# cd coreutils-8.5
[root@localhost coreutils-8.5]# ./configure
long output
long output
long output
configure: WARNING: libgmp development library was not found or not usable.
configure: WARNING: GNU coreutils will be built without GMP support.
long output
long output
[root@localhost coreutils-8.5]# echo $0
0
[root@localhost coreutils-8.5]# make
long utput
long utput
long utput
make[4]: Entering directory `/root/coreutils-8.5/gnulib-tests'
make[4]: Nothing to be done for `all-am'.
make[4]: Leaving directory `/root/coreutils-8.5/gnulib-tests'
make[3]: Leaving directory `/root/coreutils-8.5/gnulib-tests'
make[2]: Leaving directory `/root/coreutils-8.5/gnulib-tests'
make[2]: Entering directory `/root/coreutils-8.5'
make[2]: Nothing to be done for `all-am'.
make[2]: Leaving directory `/root/coreutils-8.5'
make[1]: Leaving directory `/root/coreutils-8.5'
[root@localhost coreutils-8.5]# echo $?
0
[root@localhost coreutils-8.5]# src/whoami
root

Seems make works. This package has been installed since last post.

[root@localhost src]# yum list installed coreutils-debuginfo
Loaded plugins: auto-update-debuginfo
Installed Packages
coreutils-debuginfo.i686                                                    8.5-7.fc14                                                     @updates-debuginfo

Also two questions

  • is it possible to compile only specific binary ? (id.c uniq.c cat.c etc) and not whole package ?
  • where to find another packages that I can compile from source ? for example passwd command ?

I tried to search for passwd-0.78-1.fc14.i686 tar gz but no luck

id.c, cat.c, and uniq.c aren't binaries so you're barking up the wrong tree. You're also assuming all the source code for id resides in id.c and so forth, which isn't necessarily true, they may have other source files in common.

You might try 'cd src ; make id'

Just as the 'id' utility doesn't reside in id-0.78-1.fc14.i686.tar.gz, not every individual program has its own tiny individual package. I think passwd belongs to the shadow password tools.

Before ./configure

[cepido@localhost src]$ make id
cc     id.c   -o id
id.c:20:20: fatal error: config.h: No such file or directory
compilation terminated.
make: *** [id] Error 1
[cepido@localhost src]$ echo $?
2

After ./configure

[cepido@localhost src]$ make id
  CC       id.o
id.c:26:29: fatal error: selinux/selinux.h: No such file or directory
compilation terminated.
make: *** [id.o] Error 1
[cepido@localhost src]$ echo $?
2
[cepido@localhost src]$ rpm -qf `which passwd`
passwd-0.78-1.fc14.i686

seems passwd utility resides in passwd package :slight_smile:

It's never going to work before ./configure .

Try make src/id from the main dir then.

Hi guys and sorry for very long reply and for weird questions :slight_smile:
My goal was to modify particular binary from package and compile only particular binary, because this is less time consuming than compile whole package.
Now I am able to do it: ./configure && make && cd src && change something in binary.c and compile it via make binary_name.
Thanks all for patience and sorry again for weird questions.