-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile_2_subdirs
31 lines (27 loc) · 936 Bytes
/
Makefile_2_subdirs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Makefile
# 1. Generating prerequisites automatically for header files
# 2. Compile source files automatically in current directory tree
# .
# ├── f1.c
# ├── f1.h
# ├── f2
# │ ├── f22
# │ │ ├── f22.c
# │ │ └── f22.h
# │ ├── f2.c
# │ └── f2.h
# ├── main.c
# ├── Makefile
# └── print_log.h
# build shared library with -fPIC, -shared
CFLAGS = -g # -O3 # -fPIC # CXXFLAGS for .cpp
LDFLAGS = # -L../bar -Wl,-rpath,/foo/bar # -shared
LDLIBS = # -bar
CPPFLAGS = -MMD -MP # -I../bar
#CC = $(CXX) # link with CXX for .cpp
#LDFLAGS += -install_name @rpath/bar # macOS .dylib
# target name is basename of one of the source files
main : $(patsubst %.c,%.o,$(shell find . -type f -name "*.c")) # .cpp
-include $(shell find . -type f -name "*.d")
clean : ; -rm -fr `find . -type f -name "*.o" -o -name "*.d"`
.PHONY : clean