Makefile 1023 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. include ../make.inc
  2. CFLAGS += $(BASE_CFLAGS) -flto $(WARN_CFLAGS)
  3. LDFLAGS ?=
  4. LIBS ?= -lX11
  5. BIN = pwrtray-xlock
  6. SRCS = main.c
  7. V = @ # Verbose build: make V=1
  8. Q = $(V:1=)
  9. QUIET_CC = $(Q:@=@echo ' CC '$@;)$(CC)
  10. QUIET_DEPEND = $(Q:@=@echo ' DEPEND '$@;)$(CC)
  11. DEPS = $(patsubst %.c,dep/%.d,$(1))
  12. OBJS = $(patsubst %.c,obj/%.o,$(1))
  13. .SUFFIXES:
  14. .PHONY: all install clean
  15. .DEFAULT_GOAL := all
  16. # Generate dependencies
  17. $(call DEPS,$(SRCS)): dep/%.d: %.c
  18. @mkdir -p $(dir $@)
  19. $(QUIET_DEPEND) -o $@.tmp -MM -MT "$@ $(patsubst dep/%.d,obj/%.o,$@)" $(CFLAGS) $< && mv -f $@.tmp $@
  20. -include $(call DEPS,$(SRCS))
  21. # Generate object files
  22. $(call OBJS,$(SRCS)): obj/%.o:
  23. @mkdir -p $(dir $@)
  24. $(QUIET_CC) -o $@ -c $(CFLAGS) $<
  25. all: $(BIN)
  26. $(BIN): $(call OBJS,$(SRCS))
  27. $(QUIET_CC) $(CFLAGS) -o $(BIN) $(LDFLAGS) $(LIBS) $(call OBJS,$(SRCS))
  28. clean:
  29. rm -Rf dep obj core *~ $(BIN)
  30. install: $(BIN)
  31. $(INSTALL) -d -m755 $(DESTDIR)$(PREFIX)/bin/
  32. $(INSTALL) -m755 $(BIN) $(DESTDIR)$(PREFIX)/bin/