ngmachado
August 7th, 2008, 03:04 PM
Hi,
I have a folder with lots of .c files, .pdf files and a makefile.
Each .c file should output an executable. So, if I have 10 .c files, I'll end with 10 binaries.
The name of the binary should be the name of the .c file (without the .c).
The makefile has 2 rules: all and clean. The clean rules is:
clean:
find . \! -name "*.c" -and \! -name "*.pdf" -and \! -name "makefile" -delete
It'll remove all the binaries (all the files except .c, .pdf and the makefile itself).
Now I need help writing the "All" rule. It should find all the .c files, and send them to gcc compiler.
I'm using:
all:
find . -name "*.c" -exec gcc {} \;
But it generates only one binary file, it's being rewritten every time. I know I should use the -o option of the GCC but I do I get the filenames of the .c files without the .c and send them to GCC?
Any help would be vastly appreciated.
I have a folder with lots of .c files, .pdf files and a makefile.
Each .c file should output an executable. So, if I have 10 .c files, I'll end with 10 binaries.
The name of the binary should be the name of the .c file (without the .c).
The makefile has 2 rules: all and clean. The clean rules is:
clean:
find . \! -name "*.c" -and \! -name "*.pdf" -and \! -name "makefile" -delete
It'll remove all the binaries (all the files except .c, .pdf and the makefile itself).
Now I need help writing the "All" rule. It should find all the .c files, and send them to gcc compiler.
I'm using:
all:
find . -name "*.c" -exec gcc {} \;
But it generates only one binary file, it's being rewritten every time. I know I should use the -o option of the GCC but I do I get the filenames of the .c files without the .c and send them to GCC?
Any help would be vastly appreciated.