93 lines
2.2 KiB
Makefile
93 lines
2.2 KiB
Makefile
# dwm - dynamic window manager
|
|
# See LICENSE file for copyright and license details.
|
|
|
|
-include config.mk
|
|
|
|
VERSION = 6.7
|
|
|
|
INSTALL ?= install
|
|
GZIP ?= gzip
|
|
TAR ?= tar
|
|
|
|
CFLAGS := -Os $(CFLAGS) -g -std=gnu99\
|
|
-Wall -Wextra -Wpedantic -Wno-pointer-arith
|
|
CPPFLAGS := -DNDEBUG $(CPPFLAGS)\
|
|
-DVERSION=\"$(VERSION)\" -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=700L -DXINERAMA
|
|
LDFLAGS := -flto $(LDFLAGS)
|
|
LDLIBS := $(LDLIBS) -lm
|
|
|
|
# Use pkg-config to locate dependencies, and set the correct flags.
|
|
ifeq (,$(shell command -v pkg-config))
|
|
$(error Failed to locate pkg-config, please make sure it is installed or acessible through PATH.)
|
|
else
|
|
CPPFLAGS += $(shell pkg-config --cflags-only-I x11 xinerama)
|
|
LDFLAGS += $(shell pkg-config --libs-only-L x11 xinerama)
|
|
LDLIBS += $(shell pkg-config --libs-only-l x11 xinerama)
|
|
endif
|
|
|
|
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
|