For reasons that are not important here, I have a source code that I process automatically file-by-file and the processed source files are renamed in a systematic manner. For example, I start out with files called
and end up with files
I want the Makefile to be adapted automatically, too. A bare-bones version of the Makefile is
SRC= fun1.c fun2.c %.o: $.c $(CC) $(CFLAGS) -c $< -o $@ OBJ= $(SRC:.c=.o) fun2.o: fun1.o
How can I best process the file so each entry in the definition of the source files and the dependencies is changed as needed, but the pattern rules are left untouched? In other words, what I need is:
SRC= fun1_a.c fun2_a.c %.o: $.c $(CC) $(CFLAGS) -c $< -o $@ OBJ= $(SRC:.c=.o) fun2_a.o: fun1_a.o
I assume this is trivial, but my scripting abilities, especially in
perl are limited.
EDIT: Please note that in practice, not all the files will be called
x is an integer, so I'm looking for a solution that will work with any filename.