简体   繁体   English

Automake Variables整理Makefile.am

[英]Automake Variables to tidy up Makefile.am

I have a directory /src containing all of my source files, and /bin to store all binary after running make command. 我有一个目录/ src包含我的所有源文件,/ bin用于在运行make命令后存储所有二进制文件。 The directory is something like below: 该目录如下所示:

/BuildDirectory
- - /src
- - /bin
- - configure
- - Makefile.am
- - configure.ac 
- - ... 

Now in Makefile.am, I have to specified: 现在在Makefile.am中,我必须指定:

bin_PROGRAMS = bin/x bin/y bin/z bin/k ...

bin_x_SOURCES = src/x.cpp
bin_y_SOURCES = src/y.cpp
bin_z_SOURCES = src/z.cpp

Is there any variable that can help to get rid of all "bin/" and "src/" ? 是否有任何变量可以帮助摆脱所有“bin /”和“src /”? For example I just specify: 例如,我只需指定:

$BIN = bin
$SRC = src 

And they will look for the correct files in correct folders and compile it to the correct places. 他们将在正确的文件夹中查找正确的文件并将其编译到正确的位置。

Thanks 谢谢

You could take advantage of remote building. 你可以利用远程建设。 Place this makefile in the bin dir: 将此makefile放在bin目录中:

VPATH = ../src
bin_PROGRAMS = x y z k ...

x_SOURCES = x.cpp
y_SOURCES = y.cpp
z_SOURCES = z.cpp

Now replace the current Makefile.am with this one: 现在用这个替换当前的Makefile.am:

SUBDIRS = bin

Now tweak your configure.ac to also generate bin/Makefile 现在调整你的configure.ac以生成bin / Makefile

AC_CONFIG_FILES([Makefile
        bin/Makefile])

and you should be set for life. 你应该为生活做好准备。

Not to my knowledge. 据我所知。 If you're looking to separate your compiled files from your source files, remember that you can build outside of the tree: 如果您希望将已编译的文件与源文件分开,请记住您可以在树之外构建:

$ cd foo-1.2.3
$ mkdir build
$ cd build
$ ../configure
$ make
$ make install

If this is what you're looking to do, you can make the Makefile.am simpler by creating binaries without a directory prefix (and still referencing things in src/ by hand). 如果这是你想要做的,你可以通过创建没有目录前缀的二进制文件(并且仍然手动引用src/的东西)来使Makefile.am更简单。

If what you're trying to do is what I think you're trying to do, you're trying to achieve something like: 如果你想要做的就是我认为你想要做的事情,那么你正在努力实现以下目标:

SRCDIR  = src
BINDIR  = bin

bin_PROGRAMS = $(BINDIR)/x $(BINDIR)/y $(BINDIR)/z

bin_x_SOURCES = $(SRCDIR)/x.cpp
bin_y_SOURCES = $(SRCDIR)/y.cpp
bin_z_SOURCES = $(SRCDIR)/z.cpp

I've tested this a few times in various forms, and it won't compile the code as it would with your example; 我已经以各种形式对它进行了几次测试,它不会像你的例子那样编译代码; I somehow convinced it that it was compiling C at one stage: 我以某种方式确信它在一个阶段编译C:

gmake[1]: *** No rule to make target `bin/x.c', needed by `x.o'.  Stop.

I'm thus fairly certain that it's not possible. 因此我很确定这是不可能的。 Sorry. 抱歉。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM