Makefile 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. VERSION = 1.0
  2. BINDIR=usr/bin
  3. WARNFLAGS=-Wall -Wshadow -W -Wformat -Wimplicit-function-declaration -Wimplicit-int
  4. CFLAGS+= -O1 ${WARNFLAGS} -fstack-protector
  5. CC=$(CROSS_COMPILE)gcc
  6. CFLAGS+=-D VERSION=\"$(VERSION)\"
  7. LDFLAGS+=
  8. TARGET=tmon
  9. INSTALL_PROGRAM=install -m 755 -p
  10. DEL_FILE=rm -f
  11. # Static builds might require -ltinfo, for instance
  12. ifneq ($(findstring -static, $(LDFLAGS)),)
  13. STATIC := --static
  14. endif
  15. TMON_LIBS=-lm -lpthread
  16. TMON_LIBS += $(shell pkg-config --libs $(STATIC) panelw ncursesw 2> /dev/null || \
  17. pkg-config --libs $(STATIC) panel ncurses 2> /dev/null || \
  18. echo -lpanel -lncurses)
  19. CFLAGS += $(shell pkg-config --cflags $(STATIC) panelw ncursesw 2> /dev/null || \
  20. pkg-config --cflags $(STATIC) panel ncurses 2> /dev/null)
  21. OBJS = tmon.o tui.o sysfs.o pid.o
  22. OBJS +=
  23. tmon: $(OBJS) Makefile tmon.h
  24. $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $(TARGET) $(TMON_LIBS)
  25. valgrind: tmon
  26. sudo valgrind -v --track-origins=yes --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes ./$(TARGET) 1> /dev/null
  27. install:
  28. - mkdir -p $(INSTALL_ROOT)/$(BINDIR)
  29. - $(INSTALL_PROGRAM) "$(TARGET)" "$(INSTALL_ROOT)/$(BINDIR)/$(TARGET)"
  30. uninstall:
  31. $(DEL_FILE) "$(INSTALL_ROOT)/$(BINDIR)/$(TARGET)"
  32. clean:
  33. find . -name "*.o" | xargs $(DEL_FILE)
  34. rm -f $(TARGET)
  35. dist:
  36. git tag v$(VERSION)
  37. git archive --format=tar --prefix="$(TARGET)-$(VERSION)/" v$(VERSION) | \
  38. gzip > $(TARGET)-$(VERSION).tar.gz