From a0b5e9e83a0ec4c8af93f81398bc5a8def27e438 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sun, 24 Jan 2010 13:59:58 +0100 Subject: [PATCH] Rework Makefiles one more time. - use printf to print commands rather than echo, which it may not have support for escape sequences (-e). - Remove DESTDIR from SBINDIR, MANDIR, LIBDIR and INCLUDEDIR so that you can override it. --HG-- extra : convert_revision : xtraeme%40gmail.com-20100124125958-8mscedj5ntf288jd --- Makefile | 4 ++-- include/Makefile | 6 +++--- lib/Makefile | 26 +++++++++++++------------- prog.mk | 25 ++++++++++++------------- vars.mk | 14 +++++++------- 5 files changed, 37 insertions(+), 38 deletions(-) diff --git a/Makefile b/Makefile index 0408ce05..23b0a6fb 100644 --- a/Makefile +++ b/Makefile @@ -18,8 +18,8 @@ install: $(MAKE) -C $$dir install || exit 1; \ done @echo - @echo "Binaries have been installed into $(SBINDIR)." - @echo "Librares have been installed into $(LIBDIR)." + @echo "Binaries have been installed into $(DESTDIR)$(SBINDIR)." + @echo "Librares have been installed into $(DESTDIR)$(LIBDIR)." @echo @echo "WARNING: Don't forget to rerun ldconfig(1)." @echo diff --git a/include/Makefile b/include/Makefile index 0af39821..db569079 100644 --- a/include/Makefile +++ b/include/Makefile @@ -7,12 +7,12 @@ all: .PHONY: install install: - install -d $(INCLUDEDIR) - install -m 644 $(INCS) $(INCLUDEDIR) + install -d $(DESTDIR)$(INCLUDEDIR) + install -m 644 $(INCS) $(DESTDIR)$(INCLUDEDIR) .PHONY: uninstall uninstall: - -rm -f $(INCLUDEDIR)/$(INCS) + -rm -f $(DESTDIR)$(INCLUDEDIR)/$(INCS) .PHONY: clean clean: diff --git a/lib/Makefile b/lib/Makefile index a7e10431..5f815669 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -28,45 +28,45 @@ OBJS += sortdeps.o state.o unpack.o util.o pkgmatch.o mkpath.o all: libxbps.so libxbps.a fetch/ftperr.h: fetch/ftp.errors - @echo " [GEN]\t\t$@" + @printf " [GEN]\t\t$@\n" @./fetch/errlist.sh ftp_errlist FTP $< > $@ fetch/httperr.h: fetch/http.errors - @echo " [GEN]\t\t$@" + @printf " [GEN]\t\t$@\n" @./fetch/errlist.sh http_errlist HTTP $< > $@ $(LIBFETCH_OBJS): %.o: %.c $(LIBFETCH_INCS) $(LIBFETCH_GEN) - @echo " [CC]\t\t$@" + @printf " [CC]\t\t$@\n" @$(CC) $(CPPFLAGS) $(LIBFETCH_CPPFLAGS) $(CFLAGS) \ $(LIBFETCH_CFLAGS) $(LIBFETCH_SHLIBCFLAGS) -c $< -o $@ $(OBJS): %.o: %.c - @echo " [CC]\t\t$@" + @printf " [CC]\t\t$@\n" @$(CC) $(CPPFLAGS) $(CFLAGS) $(SHAREDLIB_CFLAGS) -c $< -o $@ libxbps.so: $(OBJS) $(LIBFETCH_OBJS) - @echo " [CCLD]\t\t$@" + @printf " [CCLD]\t\t$@\n" @$(CC) $(LDFLAGS) $^ -o $(LIBXBPS_SHLIB) @-ln -sf $(LIBXBPS_SHLIB) libxbps.so.$(LIBXBPS_MAJOR) @-ln -sf $(LIBXBPS_SHLIB) libxbps.so libxbps.a: $(OBJS) $(LIBFETCH_OBJS) - @echo " [AR]\t\t$@" + @printf " [AR]\t\t$@\n" @$(AR) rcs $@ $^ - @echo " [RANLIB]\t$@" + @printf " [RANLIB]\t$@\n" @ranlib $@ .PHONY: install install: all - install -d $(LIBDIR) - install -m 644 libxbps.a $(LIBDIR) - install -m 755 $(LIBXBPS_SHLIB) $(LIBDIR) - cp -a libxbps.so $(LIBDIR) - cp -a libxbps.so.$(LIBXBPS_MAJOR) $(LIBDIR) + install -d $(DESTDIR)$(LIBDIR) + install -m 644 libxbps.a $(DESTDIR)$(LIBDIR) + install -m 755 $(LIBXBPS_SHLIB) $(DESTDIR)$(LIBDIR) + cp -a libxbps.so $(DESTDIR)$(LIBDIR) + cp -a libxbps.so.$(LIBXBPS_MAJOR) $(DESTDIR)$(LIBDIR) .PHONY: uninstall uninstall: - -rm -f $(LIBDIR)/libxbps.* + -rm -f $(DESTDIR)$(LIBDIR)/libxbps.* .PHONY: clean clean: diff --git a/prog.mk b/prog.mk index fe2ce05c..7bc17345 100644 --- a/prog.mk +++ b/prog.mk @@ -13,37 +13,36 @@ clean: .PHONY: install install: all - install -d $(SBINDIR) - install $(INSTALL_STRIPPED) -m 755 $(BIN) $(SBINDIR) - install $(INSTALL_STRIPPED) -m 755 $(BIN).static $(SBINDIR) + install -d $(DESTDIR)$(SBINDIR) + install $(INSTALL_STRIPPED) -m 755 $(BIN) $(DESTDIR)$(SBINDIR) + install $(INSTALL_STRIPPED) -m 755 $(BIN).static $(DESTDIR)$(SBINDIR) ifdef MAN - install -d $(MANDIR) - install -m 644 $(MAN) $(MANDIR) + install -d $(DESTDIR)$(MANDIR)/man8 + install -m 644 $(MAN) $(DESTDIR)$(MANDIR)/man8 endif .PHONY: uninstall uninstall: - -rm -f $(SBINDIR)/$(BIN) - -rm -f $(SBINDIR)/$(BIN).static - + -rm -f $(DESTDIR)$(SBINDIR)/$(BIN) + -rm -f $(DESTDIR)$(SBINDIR)/$(BIN).static ifdef MAN - -rm -f $(MANDIR)/$(MAN) + -rm -f $(DESTDIR)$(MANDIR)/man8/$(MAN) endif %.o: %.c - @echo " [CC]\t\t$@" + @printf " [CC]\t\t$@\n" @$(CC) $(CPPFLAGS) $(CFLAGS) -c $< $(MAN): - @echo " [ASCIIDOC]\t$(MAN)" + @printf " [ASCIIDOC]\t$(MAN)\n" @a2x -f manpage $(MAN).txt $(BIN).static: $(OBJS) - @echo " [CCLD]\t\t$@" + @printf " [CCLD]\t\t$@\n" @$(CC) -static $^ $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) \ $(STATIC_LIBS) -o $@ >/dev/null 2>&1 $(BIN): $(OBJS) - @echo " [CCLD]\t\t$@" + @printf " [CCLD]\t\t$@\n" @$(CC) $^ $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -pie -o $@ diff --git a/vars.mk b/vars.mk index 55023a4e..897132ac 100644 --- a/vars.mk +++ b/vars.mk @@ -1,11 +1,11 @@ # Common variables. -PREFIX ?= /usr/local -SBINDIR ?= $(DESTDIR)$(PREFIX)/sbin -LIBDIR ?= $(DESTDIR)$(PREFIX)/lib -INCLUDEDIR ?= $(DESTDIR)$(PREFIX)/include -MANDIR ?= $(DESTDIR)$(PREFIX)/share/man/man8 -TOPDIR ?= .. +PREFIX ?= /usr/local +SBINDIR ?= $(PREFIX)/sbin +LIBDIR ?= $(PREFIX)/lib +INCLUDEDIR ?= $(PREFIX)/include +MANDIR ?= $(PREFIX)/share/man +TOPDIR ?= .. INSTALL_STRIPPED ?= -s # To build the libxbps API documentation, requires graphviz and doxygen. @@ -17,7 +17,7 @@ CPPFLAGS = -I$(TOPDIR)/include -D_XOPEN_SOURCE=600 -D_GNU_SOURCE CPPFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES ifdef DEBUG -INSTALL_STRIPPED= +INSTALL_STRIPPED = DEBUG_FLAGS = -g CPPFLAGS += -DDEBUG endif