aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 61b42b824035a0221ebea974bcd6316575d3d14c (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
41
42
43
44
45
export version = 1.0.5
export soname_version = $(word 1, $(subst ., , $(version)))
override CXXFLAGS += -MMD -Wall -std=c++20
SOURCES = $(wildcard src/*.cc)
OBJECTS = $(SOURCES:.cc=.o)
DEPS = $(OBJECTS:.o=.d)
EXECUTABLE = bible
prefix ?= /usr
exec_prefix ?= $(prefix)
libdir ?= $(exec_prefix)/lib
bindir ?= $(exec_prefix)/bin
includedir ?= $(prefix)/include
completions ?= `pkg-config --variable=completionsdir bash-completion`

$(EXECUTABLE): $(OBJECTS) libbible
	$(CXX) $(OBJECTS) -o $@ $(LDFLAGS) -Lsrc/lib -lbible

-include $(DEPS)

.PHONY: libbible
libbible:
	$(MAKE) -C src/lib

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

install: libbible $(EXECUTABLE)
	install -d $(DESTDIR)$(libdir)
	install -m 644 src/lib/libbible.so $(DESTDIR)$(libdir)/libbible.so.$(version)
	ln -sf libbible.so.$(soname_version) $(DESTDIR)$(libdir)/libbible.so
	ln -sf libbible.so.$(version) $(DESTDIR)$(libdir)/libbible.so.$(soname_version)
	install -m 644 src/lib/libbible.a $(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)$(completions)
	install -m 644 bible.bash $(DESTDIR)$(completions)/$(EXECUTABLE)

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