-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
72 lines (58 loc) · 1.43 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
67
68
69
70
71
72
CC?=gcc
CXX?=g++
# clang needs some extra include directories to find its stuff
#CC=clang++ -I/usr/include
PG_CONFIG?=pg_config
PREFIX?=/usr/local
# remove the comment from the following line to enable debug statements
#DEBUG=-DDEBUG=1
PQ_LIBS=-lpq
PQ_FLAGS=
PQ_INCLUDES=-I $(shell $(PG_CONFIG) --includedir)
CFLAGS=-Wall -Wextra \
-Wno-format-extra-args \
-Wformat-nonliteral \
-Wformat-security \
-Wformat=2 \
-D_XOPEN_SOURCE=600 $(DEBUG)
ifeq ($(strip $(DEBUG)), )
# production build
CFLAGS+=-O2 -DNDEBUG
ifeq ($(CXX), g++)
CFLAGS+=-s
endif
else
# debug build - add debug info to the binaries
CFLAGS+=-g -O0
ifeq ($(CXX), g++)
CFLAGS+=-Weffc++
endif
endif
CXXFLAGS=$(CFLAGS) $(PQ_FLAGS)
ifeq ($(CXX), g++)
CXXFLAGS+=-std=gnu++98
endif
INCLUDES=-I src/ $(PQ_INCLUDES)
LIBS=$(PQ_LIBS)
CXX_SOURCES := $(wildcard src/*.cc)
HEADERS := $(wildcard src/*.h)
SOURCES := $(CXX_SOURCES)
OBJECTS := $(patsubst %.cc,%.o,$(CXX_SOURCES))
BIN_PSQLCHUNKS=psqlchunks
all: $(BIN_PSQLCHUNKS)
dist: all strip
strip: $(BIN_PSQLCHUNKS)
strip $(BIN_PSQLCHUNKS)
install: dist
install $(BIN_PSQLCHUNKS) $(PREFIX)/bin/
$(BIN_PSQLCHUNKS): $(OBJECTS)
$(CXX) $(CXXFLAGS) $(INCLUDES) -o $(BIN_PSQLCHUNKS) $(OBJECTS) $(LIBS)
clean:
find ./src/ -name '*.o' -delete
rm -f $(BIN_PSQLCHUNKS)
# trigger a complete rebuild if a header changed
$(OBJECTS): $(HEADERS)
%.o: %.cc
$(CXX) $(CXXFLAGS) $(INCLUDES) -o $*.o -c $*.cc
cppcheck:
cppcheck -q --enable=all src