aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: b7eba211e4192b9bbdaabe6d25bc776387137b9b (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