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

$(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)$(PREFIX)/lib/
	install -m 644 $(LIBRARY) $(DESTDIR)$(PREFIX)/lib/
	install -d $(DESTDIR)$(PREFIX)/include/
	install -m 644 src/lib/libbible.h $(DESTDIR)$(PREFIX)/include/
	install -d $(DESTDIR)$(PREFIX)/bin/
	install -m 755 $(EXECUTABLE) $(DESTDIR)$(PREFIX)/bin/
	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