Makefile 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. OBJS = tmon.o tui.o sysfs.o pid.o
  20. OBJS +=
  21. tmon: $(OBJS) Makefile tmon.h
  22. $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $(TARGET) $(TMON_LIBS)
  23. valgrind: tmon
  24. sudo valgrind -v --track-origins=yes --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes ./$(TARGET) 1> /dev/null
  25. install:
  26. - mkdir -p $(INSTALL_ROOT)/$(BINDIR)
  27. - $(INSTALL_PROGRAM) "$(TARGET)" "$(INSTALL_ROOT)/$(BINDIR)/$(TARGET)"
  28. uninstall:
  29. $(DEL_FILE) "$(INSTALL_ROOT)/$(BINDIR)/$(TARGET)"
  30. clean:
  31. find . -name "*.o" | xargs $(DEL_FILE)
  32. rm -f $(TARGET)
  33. dist:
  34. git tag v$(VERSION)
  35. git archive --format=tar --prefix="$(TARGET)-$(VERSION)/" v$(VERSION) | \
  36. gzip > $(TARGET)-$(VERSION).tar.gz