yy5*_*502 5 c linux gcc makefile compilation
我需要从Linux coreutils源文件编译cp(复制)和mv(移动)实用程序的特定版本。而不是使用以下命令编译整个程序包:
./configure
make
Run Code Online (Sandbox Code Playgroud)
这需要很长时间,我如何才能仅编译cp(./src/cp.c)和mv(./src/mv.c)?
我试图删除不相关的c文件,但是cp.c和mv.c有太多依赖关系无法跟踪...而且我意识到这是简化问题的一种愚蠢方法。必须有一个单行或某些东西告诉make或gcc仅编译cp和mv!
使用的示例源代码:http : //ftp.gnu.org/gnu/coreutils/coreutils-8.21.tar.xz
提前致谢!
运行make src/cp src/mv后configure应该可以运行,但是coreutils构建系统没有正确设置依赖项。cp并mv取决于Makefile不会跟踪的生成的源文件。但是,您需要的生成文件是在default的开头立即创建的make all,因此您可以启动完整构建,并在超过限制后立即将其杀死GEN:
$ ./configure
...
$ make
GEN lib/alloca.h
GEN lib/c++defs.h
...
GEN src/version.c
GEN src/version.h
make all-recursive
make[1]: Entering directory `/home/andrew/coreutils-8.21'
Making all in po
make[2]: Entering directory `/home/andrew/coreutils-8.21/po'
make[2]: Leaving directory `/home/andrew/coreutils-8.21/po'
Making all in .
make[2]: Entering directory `/home/andrew/coreutils-8.21'
CC lib/set-mode-acl.o
CC lib/copy-acl.o
^C
make[2]: *** wait: No child processes. Stop.
make[2]: *** Waiting for unfinished jobs....
make[2]: *** wait: No child processes. Stop.
make[1]: *** wait: No child processes. Stop.
make[1]: *** Waiting for unfinished jobs....
make[1]: *** wait: No child processes. Stop.
make: *** wait: No child processes. Stop.
make: *** Waiting for unfinished jobs....
make: *** wait: No child processes. Stop.
Run Code Online (Sandbox Code Playgroud)
然后运行make src/cp src/mv以构建所需的程序:
$ make src/cp src/mv
CC src/cp.o
CC src/copy.o
CC src/cp-hash.o
CC src/extent-scan.o
CC src/version.o
AR src/libver.a
CC lib/argmatch.o
CC lib/argv-iter.o
CC lib/backupfile.o
... 230 other files ...
CC lib/vasprintf.o
CC lib/vfprintf.o
CC lib/vprintf.o
AR lib/libcoreutils.a
CCLD src/cp
CC src/mv.o
CC src/remove.o
CCLD src/mv
$ src/cp --version
cp (GNU coreutils) 8.21
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Torbjörn Granlund, David MacKenzie, and Jim Meyering.
Run Code Online (Sandbox Code Playgroud)