HDRPATH = posixx
+# prefix for installing the binaries
+prefix = /usr/local
+
+
+# install command
+INSTALL = install -p -m 0644 -D
+
+
+# install utility functions
+install_msg = echo " INSTALL $(1)"
+
+install_files = @$(call install_msg,$(2)) && \
+ for f in $(1); do \
+ $(call install,$$f,$(2)/$$f); \
+ done && \
+ touch $@
+
ifneq ($(V), 1)
-NICE_NOP =
-NICE = @
+NICE_CLEAN = @echo " CLEAN"; $(RM)
+install = $(INSTALL) $(1) $(2)
else
-NICE_NOP = @echo "Nothing to do, headers only"
-NICE =
+NICE_CLEAN = $(RM) -v
+install = $(call install_msg,$(2)); $(INSTALL) $(1) $(2)
endif
default: all
all:
- $(NICE_NOP)
-
-install-headers: $(HEADERS)
- $(NICE) for f in $(HEADERS); do \
- echo " INSTALL $(prefix)/include/$(HDRPATH)/$$f"; \
- install -m 0644 -D $$f $(prefix)/include/$(HDRPATH)/$$f; \
- done
install: install-headers
+install-headers: .install-headers-stamp
+
+.install-headers-stamp: $(HEADERS)
+ $(call install_files,$^,$(prefix)/include/$(HDRPATH))
+
clean:
- $(NICE_NOP)
+ $(NICE_CLEAN) .*-stamp
-.PHONY: default all clean install-headers install
+.PHONY: default all install install-headers clean