-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
33 lines (28 loc) · 844 Bytes
/
Makefile
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
32
33
# step 1:
# prepare the compiler
# prepare targe file name
# prepare dependecy libarary
CC = g++
CFLAGS := -Wall -O2 -fPIC -std=c++11
LDFLAGS = -lpthread
# header file's path
INCLUDE_PATH = -I ./include
SRC_PATH = ./src/
# .o file with the same name of .ccc file
OBJS = threadpool_impl.o env_posix.o env.o
SRCS = $(SRC_PATH)threadpool_impl.cc $(SRC_PATH)env_posix.cc $(SRC_PATH)env.cc
TARGET = libthreadpool.so
STATIC_TARGET = libthreadpool.a
# step 2:
# produce the .o files
$(OBJS):$(SRCS)
$(CC) $(CFLAGS) $(INCLUDE_PATH) -c $^
# 3. produce the .so file
# 'ar crv' produce static lib
# 'cc - shared' produce shared lib
all : $(OBJS)
ar crv $(STATIC_TARGET) $(OBJS)
$(CC) -shared $(CFLAGS) $(INCLUDE_PATH) -o $(TARGET) $(OBJS) $(LDFLAGS)
# 4. clean the files except source file
clean:
rm -f $(OBJS) $(LIB) $(TARGET) $(STATIC_TARGET)