凝结makefile.am
我正在使用自动工具来构建一个项目。我有一个configure.ac
,makefile.am
和autogen.sh
。这一切都很好。我的詹金斯管道可以捡起并运行它。我的问题是makefile.am
越来越长。最近,我在项目中添加了一些第三部分供应商代码。
这是当前的makefile.am
AUTOMAKE_OPTIONS = foreign subdir-objects
bin_PROGRAMS = MAIN_Application
MAIN_Application_LDADD = -lsocketcan -lpthread -lm
AM_CPPFLAGS = \
-I$(srcdir)/include \
-I$(srcdir)/include/utilities \
-I$(srcdir)/include/comms \
-I$(srcdir)/include/config_parsing \
-I$(srcdir)/vendor/my_vendor/host/include \
-I$(srcdir)/vendor/my_vendor/host/source/lib/comm_mgr/inc \
-I$(srcdir)/vendor/my_vendor/host/source/lib/mem_pool/inc \
-I$(srcdir)/vendor/my_vendor/host/source/lib/osal/inc \
-I$(srcdir)/vendor/my_vendor/production/source/lib/FFT \
-I$(srcdir)/vendor/my_vendor/public/common \
-I$(srcdir)/vendor/my_vendor/public/host \
-I$(srcdir)/vendor/my_vendor/public/production
MAIN_Application_SOURCES = \
src/main.cpp \
src/scheduler.c \
src/thread_health.c \
src/signal_handler.c \
src/utilities/time_conversions.c \
src/utilities/ring_buffer.c \
src/utilities/logger.c \
src/utilities/string_operations.c \
src/config_parsing/file_operations.c \
src/config_parsing/config_parser.c \
src/comms/can.c \
src/comms/can_ring_buffer.c \
vendor/my_vendor/production/source/lib/FFT/FFT.c \
vendor/my_vendor/production/source/PROD_lib.c \
vendor/my_vendor/host/source/HLB_helper.c \
vendor/my_vendor/host/source/HLB_nscm.c \
vendor/my_vendor/host/source/HLB_apcm.c \
vendor/my_vendor/host/source/HLB_fwload.c \
vendor/my_vendor/host/source/HLB_host.c \
vendor/my_vendor/host/source/HLB_noise_floor.c \
vendor/my_vendor/host/source/lib/mem_pool/src/mem_pool.c \
vendor/my_vendor/host/source/lib/comm_mgr/src/comm_mgr_lib.c \
vendor/my_vendor/host/source/lib/osal/src/osal.c \
vendor/my_vendor/host/source/HLB_legacy_commands.c \
vendor/my_vendor/host/source/HLB_protocol.c
我真的必须分别包括每个.c
文件吗?为什么供应商/my_vendor/host/*/**
不起作用?如何压缩此makefile.am
?
I am using autotools to build a project. I have a configure.ac
, makefile.am
and autogen.sh
. This all works great. My Jenkins pipeline can pick this up and run it. My issue is the makefile.am
is getting longer and longer. Recently I added some 3rd part vendor code to my project.
This is the current makefile.am
AUTOMAKE_OPTIONS = foreign subdir-objects
bin_PROGRAMS = MAIN_Application
MAIN_Application_LDADD = -lsocketcan -lpthread -lm
AM_CPPFLAGS = \
-I$(srcdir)/include \
-I$(srcdir)/include/utilities \
-I$(srcdir)/include/comms \
-I$(srcdir)/include/config_parsing \
-I$(srcdir)/vendor/my_vendor/host/include \
-I$(srcdir)/vendor/my_vendor/host/source/lib/comm_mgr/inc \
-I$(srcdir)/vendor/my_vendor/host/source/lib/mem_pool/inc \
-I$(srcdir)/vendor/my_vendor/host/source/lib/osal/inc \
-I$(srcdir)/vendor/my_vendor/production/source/lib/FFT \
-I$(srcdir)/vendor/my_vendor/public/common \
-I$(srcdir)/vendor/my_vendor/public/host \
-I$(srcdir)/vendor/my_vendor/public/production
MAIN_Application_SOURCES = \
src/main.cpp \
src/scheduler.c \
src/thread_health.c \
src/signal_handler.c \
src/utilities/time_conversions.c \
src/utilities/ring_buffer.c \
src/utilities/logger.c \
src/utilities/string_operations.c \
src/config_parsing/file_operations.c \
src/config_parsing/config_parser.c \
src/comms/can.c \
src/comms/can_ring_buffer.c \
vendor/my_vendor/production/source/lib/FFT/FFT.c \
vendor/my_vendor/production/source/PROD_lib.c \
vendor/my_vendor/host/source/HLB_helper.c \
vendor/my_vendor/host/source/HLB_nscm.c \
vendor/my_vendor/host/source/HLB_apcm.c \
vendor/my_vendor/host/source/HLB_fwload.c \
vendor/my_vendor/host/source/HLB_host.c \
vendor/my_vendor/host/source/HLB_noise_floor.c \
vendor/my_vendor/host/source/lib/mem_pool/src/mem_pool.c \
vendor/my_vendor/host/source/lib/comm_mgr/src/comm_mgr_lib.c \
vendor/my_vendor/host/source/lib/osal/src/osal.c \
vendor/my_vendor/host/source/HLB_legacy_commands.c \
vendor/my_vendor/host/source/HLB_protocol.c
Do I really have to include each .c
file individually? Why does vendor/my_vendor/host/*/**
not work? How can I compress this makefile.am
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Autotools开发人员认为明确列出所有源文件是最佳实践。这避免了测试或调试源等诸如分发软件包之类的事情。
您不能使用
**
,因为此语法是一种非标准扩展,专门在诸如bash
和zsh
之类的外壳中可用,这是不支持的按标准Posix Globbing(这是用于其地球扩展的原因)。我认为在
makefile.am
中使用简单的球(即,即*。c
)将有效,但是当然,您仍然需要使用每个目录。只是为了补充:
您还可以通过将源分为多个部分来制作Makefile的“整洁”。因此,例如,您可能有类似的东西:
或类似的东西,或者甚至可以使用其他变量,然后将它们添加在一起。也许这有助于可读性。
Autotools developers consider it to be best practice to explicitly list all the source files. This avoids things like test or debug sources etc. creeping into distribution packages.
You can't use
**
because this syntax is a non-standard extension available specifically in shells likebash
andzsh
, that is not supported by standard POSIX globbing (which is what make uses for its glob expansion).I think it would work to use simple globbing (that is,
*.c
) inMakefile.am
but of course you'd still need to use each directory.Just to add:
You can also make your makefile "tidier" by breaking up the sources into sections. So for example you might have something like:
or something like that, or you could even use other variables and then add them together. Maybe that helps with readability.