-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
84 lines (68 loc) · 1.56 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
73
74
75
76
77
78
79
80
81
82
83
84
#
# Specify the compiler
#
CXX = g++
#
# Compiler options
#
CXXFLAGS = -Isrc -rdynamic
LIBS = -ldl $(OPTLIBS)
#
# Installation prefix
#
PREFIX?=/usr/local
SOURCES=$(wildcard src/**/*.cc src/*.cc)
OBJECTS=$(patsubst %.cc,%.o,$(SOURCES))
TEST_SOURCES=$(wildcard tests/*.cc)
TEST_OBJECTS=$(patsubst %.cc,%.o,$(TEST_SOURCES))
TARGET=build/libiris.a
SO_TARGET=$(patsubst %.a,%.so,$(TARGET))
#
# Build the library
#
all: $(TARGET) $(SO_TARGET) tests
#dev: CFLAGS=-g -Wall -Isrc -Wall -Wextra $(OPTFLAGS)
dev: CXXFLAGS=-g -Wall -Isrc -Wall -Wextra $(OPTFLAGS)
dev: all
$(TARGET): CXXFLAGS += -fPIC
$(TARGET): build $(OBJECTS)
ar rcs $@ $(OBJECTS)
ranlib $@
$(SO_TARGET): $(TARGET) $(OBJECTS)
$(CXX) -shared -o $@ $(OBJECTS)
build:
@mkdir -p build
#
# Build the unit tests
#
.PHONY: tests
tests: CXXFLAGS += $(TARGET)
tests: $(TEST_OBJECTS)
$(TEST_OBJECTS): %.o: %.cc
$(CXX) -o $(patsubst %.o,%,$@) $< $(TARGET)
#
# Cleaning
#
clean:
rm -rf build $(OBJECTS) $(TEST_OBJECTS)
find . -name "*.gc*" -exec rm {} \;
rm -rf `find . -name "*dSYM" -print`
#
# Installing
#
install: all
install -d $(DESTDIR)/$(PREFIX)/lib/
install $(TARGET) $(DESTDIR)/$(PREFIX)/lib/
@mkdir -p $(DESTDIR)/$(PREFIX)/include/libiris
install src/*.h $(DESTDIR)/$(PREFIX)/include/libiris/.
#
# Removing
#
remove:
rm -rf $(DESTDIR)/$(PREFIX)/lib/libiris.*
rm -rf $(DESTDIR)/$(PREFIX)/include/libiris*
# Checker
BADFUNCS='[^_.>a-zA-Z0-9](str(n?cpy|n?cat|xfrm|n?dup|str|pbrk|tok|_)|stpn?cpy|a?sn?printf|byte_)'
check:
@echo "Files with potentially dangerous functions."
@egrep $(BADFUNCS) $(SOURCES) || true