Calling SED for a source in Makefile.am
automake, autotools, sed
Solution
Don't use in-place sed.
Instead:
gentest_SOURCES = gentest-seded.cc
gentest-seded.cc : gentest.cc
$(SED) "s|__PREFIX__|@prefix@|" $< >$@
Problem
I've got c++ code that needs a sed done to it prior to compilation. How do I place this into `Makefile.am`? I tried the typical makefile setup and the target appears to not exist: `gentest.cc:` `$(SED) -i "s|FIND|REPLACE|" gentest.cc` 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;` `} ...` 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` is defined this way in `Makefile.am`: `bin_PROGRAMS = gentest` `gentest_SOURCES = gentest.cc` `gentest_LDADD = libgen.a #../libsbsat.la $(LIBM)` 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` Any ideas on how to get `sed` to run before compiling `gentest.cc`?