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
This commit is contained in:
Juan RP 2010-01-24 13:59:58 +01:00
parent f613e8e49d
commit a0b5e9e83a
5 changed files with 37 additions and 38 deletions

View File

@ -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

View File

@ -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:

View File

@ -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:

25
prog.mk
View File

@ -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 $@

10
vars.mk
View File

@ -1,10 +1,10 @@
# Common variables.
PREFIX ?= /usr/local
SBINDIR ?= $(DESTDIR)$(PREFIX)/sbin
LIBDIR ?= $(DESTDIR)$(PREFIX)/lib
INCLUDEDIR ?= $(DESTDIR)$(PREFIX)/include
MANDIR ?= $(DESTDIR)$(PREFIX)/share/man/man8
SBINDIR ?= $(PREFIX)/sbin
LIBDIR ?= $(PREFIX)/lib
INCLUDEDIR ?= $(PREFIX)/include
MANDIR ?= $(PREFIX)/share/man
TOPDIR ?= ..
INSTALL_STRIPPED ?= -s
@ -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