在Makefile.am中调用SED作为源 [英] Calling SED for a source in Makefile.am

查看:82
本文介绍了在Makefile.am中调用SED作为源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有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:

gentest.cc:

$(SED) -i "s|FIND|REPLACE|" gentest.cc

如果您对我为什么要这样做感兴趣,那是因为我用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.pychmod +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.

EXTRA_DIST=testite.sh slider3_base.py

bin_SCRIPTS = slider3.py

CLEANFILES = $(bin_SCRIPTS)

slider3.py: slider3_base.py

rm -f slider3.py

echo "#! " $(PYTHON) > slider3.py

cat slider3_base.py >> slider3.py

chmod +x slider3.py

gentest是在Makefile.am中定义的:

bin_PROGRAMS = gentest

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) -i "s|__PREFIX__|@prefix@|" gentest.cc

关于在编译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作为源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆