# dwm - dynamic window manager # See LICENSE file for copyright and license details. include config.mk INSTALL ?= install GZIP ?= gzip TAR ?= tar SRC := $(wildcard src/*.c) OBJ := $(addsuffix .o,$(SRC)) DEP := $(addsuffix .d,$(SRC)) # Set Q to @ to silence commands being printed, unless --no-silent has been set ifeq (0, $(words $(findstring --no-silent,$(MAKEFLAGS)))) Q=@ endif msg = @printf '%-8s %s\n' "$(1)" "$(2)" .PHONY: all: bin/dwm .PHONY: install: $(DESTDIR)/bin/dwm $(DESTDIR)/share/man/man1/dwm.1.gz $(DESTDIR)/bin/%: bin/% $(call msg,INSTALL,$@) $(Q)$(INSTALL) -D -m0755 $< $@ $(DESTDIR)/share/man/%: man/% $(call msg,INSTALL,$@) $(Q)$(INSTALL) -D -m0644 $< $@ .PHONY: uninstall: $(Q)$(RM) $(DESTDIR)/bin/dwm\ $(DESTDIR)/share/man/man1/dwm.1.gz .PHONY: clean: $(call msg,CLEAN,src/) $(Q)$(RM) $(OBJ) $(call msg,CLEAN,man/) $(Q)$(RM) $(MAN) $(call msg,CLEAN,bin/) $(Q)$(RM) -r bin/ # Links together the object files into the final binary. bin/dwm: $(OBJ) | bin/ $(call msg,LD,$@) $(Q)$(CC) $(LDFLAGS) $(LDLIBS) -o $@ $^ # Compiles C sources into Object files %.c.o: %.c $(call msg,CC,$@) $(Q)$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $< # Compress files requested for compression using GZIP %.gz: % $(call msg,GZIP,$@) $(Q)$(GZIP) -k $< # Create directories %/: $(call msg-mkdir,$@) $(Q)mkdir $@ # Generate and include dependencies, # ignoring any errors that may occur when doing so. %.c.d: %.c $(Q)$(CC) -MM $(CPPFLAGS) -MF $@ $< ifeq (0, $(words $(findstring $(MAKECMDGOALS), clean))) -include $(DEP) endif