-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
66 lines (50 loc) · 1.89 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
CXX = c++
LD = c++
CXXFLAGS += -Os -Wall -std=c++1z -MD -fPIC -Wno-unused-parameter -g -pthread -Wno-unused-variable
SOFLAGS += -shared
LDFLAGS += -pthread
LIBRARIES += -lboost_filesystem -lboost_system -ldl
SOURCES := $(shell find . -name "*.cpp" ! -wholename "./tests/*" ! -name "main.cpp" ! -wholename "./main/*" ! -wholename "./plugins/*" ! -name "buildlist.cpp")
MAINSRC := $(shell find ./main/ -name "*.cpp") main.cpp
TESTSRC := $(shell find ./tests/ -name "*.cpp")
OBJECTS := $(SOURCES:.cpp=.o)
MAINOBJ := $(MAINSRC:.cpp=.o)
TESTOBJ := $(TESTSRC:.cpp=.o)
PREFIX ?= /usr/local
EXEC_PREFIX ?= $(PREFIX)
BINDIR ?= $(EXEC_PREFIX)/bin
LIBDIR ?= $(EXEC_PREFIX)/lib
INCLUDEDIR ?= $(PREFIX)/include
LIBRARY = libdespayre.so
EXECUTABLE = despayre
all: $(EXECUTABLE)
library: $(LIBRARY)
$(EXECUTABLE): $(MAINOBJ) $(LIBRARY)
$(LD) $(CXXFLAGS) $(LDFLAGS) $(MAINOBJ) -o $@ $(LIBRARIES) -L. -ldespayre
$(LIBRARY): $(OBJECTS)
$(LD) $(CXXFLAGS) $(SOFLAGS) $(OBJECTS) -o $@ $(LIBRARIES)
test: ./tests/test
./tests/test: $(TESTOBJ) $(LIBRARY)
$(LD) $(CXXFLAGS) $(LDFLAGS) $(TESTOBJ) -o $@ $(LIBRARIES) -lboost_system -lboost_iostreams -lboost_program_options -ldl -pthread -L. -ldespayre
install: $(LIBRARY) $(EXECUTABLE)
@cp $(EXECUTABLE) $(DESTDIR)$(BINDIR)/$(EXECUTABLE)
@cp $(LIBRARY) $(DESTDIR)$(LIBDIR)/$(LIBRARY).1
@ln -sfn $(DESTDIR)$(LIBDIR)/$(LIBRARY).1 $(DESTDIR)$(LIBDIR)/$(LIBRARY)
@mkdir -p $(DESTDIR)$(INCLUDEDIR)/reaver
@cp -RT include $(DESTDIR)$(INCLUDEDIR)
%.o: %.cpp
$(CXX) -c $(CXXFLAGS) $< -o $@ -I./include/reaver
./tests/%.o: ./tests/%.cpp
$(CXX) -c $(CXXFLAGS) $< -o $@ -I./include/reaver
clean:
@find . -name "*.o" -delete
@find . -name "*.d" -delete
@rm -f $(LIBRARY)
@rm -f $(EXECUTABLE)
@rm -f tests/test
@rm -rf stage-{2,3}
.PHONY: install clean library test
-include $(shell find plugins -name "*.mk")
-include $(SOURCES:.cpp=.d)
-include $(MAINSRC:.cpp=.d)
-include $(TESTSRC:.cpp=.d)