i have a C project , all source file (C and H files)in src directory , have lots of subdirectories
now I want to
1 copy all h files to .\header, without folder struct
2 complier all c files to .\obj, without folder stuct
3 myproject.exe in .\bin
D:\myproject
+---bin
+---header
+---obj
\---src
| main.c
| main.h
|
+---sub1
| | 1.c
| | 1.h
| |
| \---sub11
| | 11.c
| | 11.h
| |
| \---sub111
| 111.c
| 111.h
|
\---sub2
| 2.c
| 2.h
|
\---sub22
| 22.c
| 22.h
|
\---sub221
221.c
221.h
the expected output as follows:
D:.
+---bin
| myproject.exe
|
+---header
| 1.h
| 11.h
| 111.h
| 2.h
| 22.h
| 221.h
| main.h
|
+---obj
| 1.o
| 11.o
| 111.o
| 2.o
| 22.o
| 221.o
| main.o
|
\---src
| main.c
|
+---sub1
| | 1.c
| | 1.h
| |
| \---sub11
| | 11.c
| | 11.h
| |
| \---sub111
| 111.c
| 111.h
|
\---sub2
| 2.c
| 2.h
|
\---sub22
| 22.c
| 22.h
|
\---sub221
221.c
221.h
the follows posts give a good reference , but this post can not support if the source in multiple directory , all obj files is in the same directory as c file
Makefile : Automatically compile all c files, keeping .o files in separate folder
How can I create a Makefile for C projects with SRC, OBJ, and BIN subdirectories?
can any give some example makefile?