From a66dcb959c09549a32827fbde2351670967f9c13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Tue, 10 Jan 2023 21:03:45 +0100 Subject: [PATCH] Work on Makefile --- Makefile | 39 ++++++++++++------- utils/Makefile | 16 ++++++-- .../{adept_load_mgt.1 => adept_loan_mgt.1} | 0 3 files changed, 36 insertions(+), 19 deletions(-) rename utils/man/{adept_load_mgt.1 => adept_loan_mgt.1} (100%) diff --git a/Makefile b/Makefile index 98b7aa4..61a54a9 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,6 @@ +LIBDIR ?= /usr/lib +INCDIR ?= /usr/include + AR ?= $(CROSS)ar CXX ?= $(CROSS)g++ @@ -17,14 +20,14 @@ BUILD_SHARED ?= 1 BUILD_UTILS ?= 1 TARGETS = -TARGET_BINARIES = +TARGET_LIBRARIES = ifneq ($(BUILD_STATIC), 0) TARGETS += libgourou.a - TARGET_BINARIES += libgourou.a + TARGET_LIBRARIES += libgourou.a endif ifneq ($(BUILD_SHARED), 0) TARGETS += libgourou.so - TARGET_BINARIES += libgourou.so libgourou.so.$(VERSION) + TARGET_LIBRARIES += libgourou.so libgourou.so.$(VERSION) endif ifneq ($(BUILD_UTILS), 0) TARGETS += build_utils @@ -42,9 +45,7 @@ CXXFLAGS += -DSTATIC_NONCE=1 endif SRCDIR := src -INCDIR := inc BUILDDIR := obj -TARGETDIR := bin SRCEXT := cpp OBJEXT := o @@ -74,25 +75,33 @@ libgourou: libgourou.a libgourou.so libgourou.a: $(OBJECTS) $(UPDFPARSERLIB) $(AR) crs $@ obj/*.o $(UPDFPARSERLIB) -libgourou.so: $(OBJECTS) $(UPDFPARSERLIB) - $(CXX) obj/*.o -Wl,-soname,$@.$(VERSION) $(LDFLAGS) -o $@.$(VERSION) -shared - rm -f $@ - ln -s $@.$(VERSION) $@ +libgourou.so.$(VERSION): $(OBJECTS) $(UPDFPARSERLIB) + $(CXX) obj/*.o -Wl,-soname,$@ $(LDFLAGS) -o $@ -shared -build_utils: +libgourou.so: libgourou.so.$(VERSION) + ln -f -s $^ $@ + +build_utils: $(TARGET_LIBRARIES) make -C utils ROOT=$(PWD) CXX=$(CXX) AR=$(AR) DEBUG=$(DEBUG) STATIC_UTILS=$(STATIC_UTILS) DEST_DIR=$(DEST_DIR) PREFIX=$(PREFIX) -install: - install -d $(DESTDIR)$(PREFIX)/lib/ +install: $(TARGET_LIBRARIES) + install -d $(DESTDIR)$(PREFIX)$(LIBDIR) # Use cp to preserver symlinks - cp --no-dereference $(TARGET_BINARIES) $(DESTDIR)$(PREFIX)/lib/ + cp --no-dereference $(TARGET_LIBRARIES) $(DESTDIR)$(PREFIX)$(LIBDIR) make -C utils ROOT=$(PWD) CXX=$(CXX) AR=$(AR) DEBUG=$(DEBUG) STATIC_UTILS=$(STATIC_UTILS) DEST_DIR=$(DEST_DIR) PREFIX=$(PREFIX) install uninstall: - cd $(DESTDIR)$(PREFIX)/lib/ - rm -f $(TARGET_BINARIES) libgourou.so.$(VERSION) + cd $(DESTDIR)$(PREFIX)/$(LIBDIR) + rm -f $(TARGET_LIBRARIES) libgourou.so.$(VERSION) cd - +install_headers: + install -d $(DESTDIR)$(PREFIX)/$(INCDIR)/libgourou + cp --no-dereference include/*.h $(DESTDIR)$(PREFIX)/$(INCDIR)/libgourou + +uninstall_headers: + rm -rf $(DESTDIR)$(PREFIX)/$(INCDIR)/libgourou + clean: rm -rf libgourou.a libgourou.so libgourou.so.$(VERSION)* obj make -C utils clean diff --git a/utils/Makefile b/utils/Makefile index 84ab81a..e7d0ae5 100644 --- a/utils/Makefile +++ b/utils/Makefile @@ -1,7 +1,11 @@ +BINDIR ?= /usr/bin +MANDIR ?= /usr/share/man TARGET_BINARIES=acsmdownloader adept_activate adept_remove adept_loan_mgt TARGETS=$(TARGET_BINARIES) launcher +MAN_PAGES=acsmdownloader adept_activate adept_remove adept_loan_mgt + CXXFLAGS=-Wall -fPIC -I$(ROOT)/include -I$(ROOT)/lib/pugixml/src/ STATIC_DEP= @@ -33,14 +37,18 @@ ${COMMON_LIB}: ${COMMON_DEPS} ${STATIC_DEP} %: %.cpp ${COMMON_LIB} $(CXX) $(CXXFLAGS) $^ $(LDFLAGS) -o $@ -install: - install -d $(DESTDIR)$(PREFIX)/bin/ - install -m 644 $(TARGET_BINARIES) $(DESTDIR)$(PREFIX)/bin/ +install: $(TARGET_BINARIES) + install -d $(DESTDIR)$(PREFIX)/$(BINDIR) + install -m 755 $(TARGET_BINARIES) $(DESTDIR)$(PREFIX)/$(BINDIR) + install -d $(DESTDIR)$(PREFIX)/$(MANDIR)/man1 + install -m 644 man/*.1 $(DESTDIR)$(PREFIX)/$(MANDIR)/man1 uninstall: - cd $(DESTDIR)$(PREFIX)/bin/ + cd $(DESTDIR)$(PREFIX)/$(BINDIR) rm -f $(TARGET_BINARIES) cd - + cd $(DESTDIR)$(PREFIX)/$(MANDIR)/man1 + rm -f $(addsuffix .1,$(TARGET_BINARIES) clean: rm -f $(TARGETS) $(COMMON_LIB) diff --git a/utils/man/adept_load_mgt.1 b/utils/man/adept_loan_mgt.1 similarity index 100% rename from utils/man/adept_load_mgt.1 rename to utils/man/adept_loan_mgt.1