build: Support $(DESTDIR).
[paraslash.git] / Makefile.real
index 980192ecf5543bcde432575128ad0723e5ab82f8..4970696b67ec9b38a365aabb992e240b6ecce853 100644 (file)
@@ -18,7 +18,7 @@ uname_s := $(shell uname -s 2>/dev/null || echo "UNKNOWN_OS")
 uname_rs := $(shell uname -rs)
 cc_version := $(shell $(CC) --version | head -n 1)
 GIT_VERSION := $(shell ./GIT-VERSION-GEN git-version.h)
-COPYRIGHT_YEAR := 2016
+COPYRIGHT_YEAR := 2017
 
 ifeq ("$(origin O)", "command line")
        build_dir := $(O)
@@ -63,7 +63,7 @@ tarball_pfx := $(PACKAGE_TARNAME)-$(GIT_VERSION)
 tarball_delete := $(addprefix $(tarball_pfx)/, web .gitignore)
 tarball := $(tarball_pfx).tar.bz2
 
-.PHONY: all clean clean2 distclean maintainer-clean install man tarball
+.PHONY: all mostlyclean clean distclean maintainer-clean install man tarball
 all: $(prefixed_executables) $(man_pages)
 man: $(man_pages)
 tarball: $(tarball)
@@ -125,6 +125,13 @@ ifeq ($(uname_s),Linux)
        LDFLAGS += -Wl,--gc-sections
 endif
 
+cc-option = $(shell \
+       $(CC) $(1) -Werror -c -x c /dev/null -o /dev/null > /dev/null 2>&1 \
+       && echo "$(1)" \
+)
+
+STRICT_CFLAGS += $(call cc-option, -Wformat-signedness)
+
 # To put more focus on warnings, be less verbose as default
 # Use 'make V=1' to see the full commands
 ifeq ("$(origin V)", "command line")
@@ -330,29 +337,28 @@ $(prefixed_executables):
        @[ -z "$(Q)" ] || echo 'LD $@'
        $(Q) $(CC) $^ -o $@ $(LDFLAGS)
 
-clean:
-       @[ -z "$(Q)" ] || echo 'CLEAN'
+mostlyclean:
+       @[ -z "$(Q)" ] || echo 'MOSTLYCLEAN'
        $(Q) rm -f para_*
        $(Q) rm -rf $(object_dir)
-
-clean2: clean
-       @[ -z "$(Q)" ] || echo 'CLEAN2'
+clean: mostlyclean
+       @[ -z "$(Q)" ] || echo 'CLEAN'
        $(Q) rm -rf $(build_dir)
-distclean: clean2 test-clean
+distclean: clean
        @[ -z "$(Q)" ] || echo 'DISTCLEAN'
        $(Q) rm -f Makefile autoscan.log config.status config.log
-       $(Q) rm -f GPATH GRTAGS GSYMS GTAGS
-
+       $(Q) rm -f config.h configure config.h.in
 maintainer-clean: distclean
        @[ -z "$(Q)" ] || echo 'MAINTAINER-CLEAN'
-       $(Q) rm -f *.tar.bz2 config.h configure config.h.in
+       $(Q) rm -f *.tar.bz2
+       $(Q) rm -f GPATH GRTAGS GSYMS GTAGS
 
 install: all man
-       $(MKDIR_P) $(bindir) $(mandir)
+       $(MKDIR_P) $(DESTDIR)$(bindir) $(DESTDIR)$(mandir)
        $(INSTALL) -s --strip-program $(STRIP) -m 755 \
-               $(prefixed_executables) $(bindir)
-       $(INSTALL) -m 644 $(man_pages) $(mandir)
-       $(MKDIR_P) $(vardir) >/dev/null 2>&1 || true # not fatal, so don't complain
+               $(prefixed_executables) $(DESTDIR)$(bindir)
+       $(INSTALL) -m 644 $(man_pages) $(DESTDIR)$(mandir)
+       $(MKDIR_P) $(DESTDIR)$(vardir) >/dev/null 2>&1 || true # not fatal, so don't complain
 
 $(tarball):
        $(Q) rm -rf $(tarball) $(tarball_pfx)