aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: b1ad36b57fc2cf50493e471a98611c7c8b3cde1b (plain)
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
LIBS = sword minizip
override CXXFLAGS += -MMD -Wall -fPIC -std=c++20 `pkg-config $(LIBS) --cflags`
override LDFLAGS += -lstdc++fs `pkg-config $(LIBS) --libs`
SOURCES = $(wildcard src/*.cc) $(wildcard src/lib/*.cc)
OBJECTS = $(SOURCES:.cc=.o)
DEPS = $(OBJECTS:.o=.d)
EXECUTABLE = bible
LIBRARY = libbible.so
PREFIX ?= /usr
EXEC_PREFIX ?= $(PREFIX)
LIBDIR ?= $(EXEC_PREFIX)/lib
BINDIR ?= $(EXEC_PREFIX)/bin
INCLUDEDIR ?= $(PREFIX)/include

$(EXECUTABLE): $(OBJECTS)
	$(CXX) $(OBJECTS) -o $@ $(LDFLAGS)

-include $(DEPS)

$(LIBRARY): $(OBJECTS)
	$(CXX) $(OBJECTS) -shared -o $@ $(LDFLAGS)

.PHONY: test
test: $(LIBRARY)
	$(MAKE) -C src/test/ test

install: $(LIBRARY) $(EXECUTABLE)
	install -d $(DESTDIR)$(LIBDIR)
	install -m 644 $(LIBRARY) $(DESTDIR)$(LIBDIR)
	install -d $(DESTDIR)$(INCLUDEDIR)
	install -m 644 src/lib/libbible.h $(DESTDIR)$(INCLUDEDIR)
	install -d $(DESTDIR)$(BINDIR)
	install -m 755 $(EXECUTABLE) $(DESTDIR)$(BINDIR)
	install -d $(DESTDIR)`pkg-config --variable=completionsdir bash-completion`
	install -m 644 bible.bash $(DESTDIR)`pkg-config --variable=completionsdir bash-completion`/$(EXECUTABLE)

.PHONY: clean
clean:
	$(RM) $(OBJECTS) $(DEPS) $(EXECUTABLE) $(LIBRARY) $(TEST)
	$(MAKE) -C src/test/ clean