forked from mrtazz/restclient-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
78 lines (59 loc) · 1.31 KB
/
Makefile
File metadata and controls
78 lines (59 loc) · 1.31 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#
# Makefile for restclient-cpp
#
# set compiler and linker
CC = g++
LD = g++
# logfile for HTTP test server
LOGFILE = test_server.log
# binaries and folders
BINDIR = bin
LIBDIR = lib
TEST = $(BINDIR)/test
LIBNAME = librestclient-cpp.so
LIB = $(LIBDIR)/$(LIBNAME)
STATIC = $(LIBDIR)/librestclient-cpp.a
# set library and include paths
INCLUDE = -I. -I/usr/local/include
TESTLIBS = -lgtest -lcurl
LIBS = -lcurl
# set compiler and linker flags
CCFLAGS = -fPIC -O3 -W -Wall
LDFLAGS = -W -Wall -L/usr/local/lib
# source files
SRCS = source/restclient.cpp
# test source files
TESTSRCS = $(SRCS)
TESTSRCS += $(wildcard test/test*.cpp)
# dependencies
# object files
OBJS = $(SRCS:.cpp=.o)
TESTOBJS = $(TESTSRCS:.cpp=.o)
# linking rule
$(TEST): $(TESTOBJS) $(BINDIR)
$(LD) $(LDFLAGS) $(TESTOBJS) -o $(TEST) $(TESTLIBS)
# dynamic lib rule
$(LIB): $(OBJS) $(LIBDIR)
$(LD) $(LDFLAGS) -shared -soname,$(LIBNAME) -o $(LIB) $(OBJS) $(LIBS)
# static lib rule
$(STATIC): $(OBJS) $(LIBDIR)
ar rcs $(STATIC) $(OBJS)
# compile rule
.cpp.o:
$(CC) $(CCFLAGS) $(INCLUDE) -c $< -o $@
$(BINDIR):
@mkdir -p $(BINDIR)
$(LIBDIR):
@mkdir -p $(LIBDIR)
# tasks
.PHONY: clean
clean:
@rm -rf test/*.o
@rm -rf source/*.o
@rm -rf bin
@rm -rf lib
test: $(TEST)
@echo Running tests...
@./bin/test
dynamiclibrary: $(LIB)
staticlibrary: $(STATIC)