-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
66 lines (49 loc) · 1.18 KB
/
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
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
# Target definition
TARGET:=libRconnection2.a
C_SOURCES:=sisocks.c
CXX_SOURCES:=Rconnection2.cpp
OBJECTS:=$(patsubst %.c,%.o,$(C_SOURCES))
OBJECTS+=$(patsubst %.cpp,%.o,$(CXX_SOURCES))
# Toolchain options
CC=gcc
CXX:=g++
AR:=ar
DEFS:=-Dunix -DNO_CONFIG_H -DHAVE_NETINET_TCP_H -DHAVE_NETINET_IN_H
CFLAGS:=-m64 -pthread -g3 -ggdb -std=c99 -Wall -Werror -Wextra -Wpedantic -fmax-errors=3
CXXFLAGS:=-m64 -pthread -g3 -ggdb -std=c++11 -Wall -Werror -Wextra -Wpedantic -fmax-errors=3
ARFLAGS:=
ifeq ("$(DEBUG)", "1")
CFLAGS+=-Og -DDEBUG -D_DEBUG
CXXFLAGS+=-Og -DDEBUG -D_DEBUG
else
CFLAGS+=-O2 -DNDEBUG
CXXFLAGS+=-O2 -DNDEBUG
ifeq ("$(LTO)", "1")
CFLAGS+=-flto
CXXFLAGS+=-flto
endif
endif
ifeq ("$(WEFFCXX)", "1")
CXXFLAGS+=-Weffc++ -Wno-error=effc++
endif
# Target building riles
.SUFFIXES:
.PHONY: all build clean rebuild
all: build
build: $(TARGET)
clean:
echo Cleaning up $(TARGET)...
-rm -f $(TARGET)
-rm -f *.o
rebuild:
echo Rebuilding $(TARGET)...
$(MAKE) clean
$(MAKE) build
$(TARGET): $(OBJECTS)
echo Creating library $@...
echo $(OBJECTS)
$(AR) rvs $(ARFLAGS) $@ $(OBJECTS)
%.o: %.c
$(CC) -o $@ $(CFLAGS) $(DEFS) -c $<
%.o: %.cpp
$(CXX) -o $@ $(CXXFLAGS) $(DEFS) -c $<