问题描述
我有C ++代码,需要在编译之前对其进行sed处理.如何将其放入Makefile.am
?
I've got c++ code that needs a sed done to it prior to compilation. How do I place this into Makefile.am
?
我尝试了典型的makefile设置,但目标似乎不存在:
I tried the typical makefile setup and the target appears to not exist:
如果您对我为什么要这样做感兴趣,那是因为我用python编写了程序(slider3.py
),而我的伴侣也用c ++(gentest.cc
)编写了他的程序,并且他需要调用我的程序.我是通过编辑argv
然后使用execv()
来完成此操作的.
If you are interested as to why I want to do this, it's because I wrote my program (slider3.py
) in python and my partner wrote his in c++ (gentest.cc
) and his needs to call mine. I'm accomplishing this by editing the argv
and then using execv()
.
char **argv2 = new char*[argc];
memset(argv2,0,sizeof(argv2));
argv2[0] = "__PREFIX__/bin/slider3.py";
memcpy(argv2 + 1, argv + 2, sizeof(char *) * (argc - 2));
int oranges = execv(argv2[0], argv2);
printf("%s\n", strerror(oranges));
return oranges;
} ...
我已经通过使用不适用于gentest.cc
的方法处理了将#!
添加到slider3.py
和chmod +x
的问题.我还处理过将slider3.py
添加到要安装的文件列表中.
I've already handled getting the #!
added to slider3.py
and chmod +x
by using the method that was not working for gentest.cc
. I've also handled adding slider3.py
to the list of files that get installed.
bin_SCRIPTS = slider3.py
CLEANFILES = $(bin_SCRIPTS)
slider3.py: slider3_base.py
echo "#! " $(PYTHON) > slider3.py
cat slider3_base.py >> slider3.py
chmod +x slider3.py
gentest
是在Makefile.am
中定义的:
gentest_SOURCES = gentest.cc
gentest_LDADD = libgen.a #../libsbsat.la $(LIBM)
并且此操作在make期间无法运行(请注意@
模式已在Makefile
中成功展开):
And this fails to be run during make (note the @
pattern is successfully expanded in Makefile
):
关于在编译gentest.cc
之前如何运行sed
的任何想法?
Any ideas on how to get sed
to run before compiling gentest.cc
?
推荐答案
请勿使用就地sed.
相反:
gentest_SOURCES = gentest-seded.cc
gentest-seded.cc : gentest.cc
$(SED) "s|__PREFIX__|@prefix@|" $< >$@
这篇关于在Makefile.am中调用SED作为源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!