From 55d58a16e2511741cc625e203205dec86144faf3 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 18 Feb 2022 20:35:38 -0500 Subject: Reorganized repository layout --- Makefile | 58 +++++++++++++++++++++++++--------------------------------- 1 file changed, 25 insertions(+), 33 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 6b367f8..40d2712 100644 --- a/Makefile +++ b/Makefile @@ -1,44 +1,36 @@ -CC=g++ -LIBS=sword minizip -CFLAGS=-c -Wall -fPIC -std=c++20 -LDLIBS=-lstdc++fs -SOURCES=libbible.cc mods.cc settings.cc -OBJECTS=$(SOURCES:.cc=.o) -LIBRARY=libbible.so -EXECUTABLE=bible -ifeq ($(PREFIX),) - PREFIX := /usr -endif +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 -all: $(SOURCES) $(LIBRARY) $(EXECUTABLE) +$(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 libbible.h $(DESTDIR)$(PREFIX)/include/ + install -m 644 src/lib/libbible.h $(DESTDIR)$(PREFIX)/include/ install -d $(DESTDIR)$(PREFIX)/bin/ - install -m 755 bible $(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) -test: $(OBJECTS) testLibbible.o - $(CC) $(OBJECTS) testLibbible.o -o $@ $(LDFLAGS) `pkg-config $(LIBS) --libs` -lcppunit - -testLibbible.o: testLibbible.cc - $(CC) $(CFLAGS) testLibbible.cc -o $@ - -bible: $(OBJECTS) bible.o - $(CC) $(OBJECTS) bible.o -o $@ $(LDFLAGS) `pkg-config $(LIBS) --libs` $(LDLIBS) - -bible.o: bible.cc - $(CC) $(CFLAGS) bible.cc -o $@ - -$(LIBRARY): $(OBJECTS) - $(CC) $(OBJECTS) -shared -o $@ $(LDFLAGS) `pkg-config $(LIBS) --libs` $(LDLIBS) - -.cc.o: - $(CC) $(CFLAGS) $< -o $@ `pkg-config $(LIBS) --cflags` - +.PHONY: clean clean: - rm -rf *.o $(LIBRARY) test bible + $(RM) $(OBJECTS) $(DEPS) $(EXECUTABLE) $(LIBRARY) $(TEST) + $(MAKE) -C src/test/ clean -- cgit v1.2.3