compile specific source file in Linux coreutils package

S

Sanfoor

Guest
I need to compile a specific version of cp (copy) command from the Linux coreutils source file. Instead of compiling the whole package.
iam just add a printf statement at the end of the function.
I am using Ubuntu 14.04, the source code of cp command is exist in the following directory.

/tmp/coreutils/coreutils-8.21/src/cp.c

how to compile it, so when run the cp command i can see the statement that i had added it in the code?
 


OP
J

JasKinasis

Guest
From taking a look at the sources, it doesn't look like it would be particularly easy to compile a single program in the package. I just downloaded the source package and the build dependencies and took a look at the Makefile that is generated by the configure script. I don't fancy trying to work out all of the dependencies required for cp from the > 10,000 line makefile that is generated by configure.
It should be possible to compile a single program, but it might take a while to get the exact command line worked out for gcc.

Rather than taking hours trying to pick apart all of the dependencies in order to get one component to build, you might just be better served building the entire package.

Once you have the entire package built; And as long as you only make changes to cp.c: On subsequent builds the make script will not find anything to do for the other modules, so cp will be the only module that will build. Because of the complexity of the package, the build script will probably still take a little while to complete on the subsequent builds, but they will complete much faster than the initial build! Just my two cents!
 
OP
R

ryanvade

Guest
You can change which parts of the entire package are built using configure.
Code:
./configure --prefix=/usr --libexecdir=/usr/lib \
              --enable-no-install-program=groups,hostname,kill,uptime
for example is used to build advanced copy.
 
OP
G

GrumpyOldMan

Guest
don't forget you can run ./configure --help to see all the options that will support. It may tell you exactly which options you'll need for a particular binary.
 
OP
J

JasKinasis

Guest
I forgot to mention the configure options... I did take a brief look at configure and the configure help when I made my post. I didn't immediately see anything obvious in there that would allow a single module to be built - forgot to mention that. So I decided to see what was in the makefile generated after configure. Also, I was in a bit of a rush. Didn't really have enough time to spend too long looking into it!
 
$100 Digital Ocean Credit
Get a free VM to test out Linux!

Linux.org Hosting Donations
Consider making a donation

Members online


Top