18c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci# We need this for the "cc-option" macro. 38c2ecf20Sopenharmony_ciinclude ../../../scripts/Kbuild.include 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ciVERSION = 1.0 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ciBINDIR=usr/bin 88c2ecf20Sopenharmony_ciWARNFLAGS=-Wall -Wshadow -W -Wformat -Wimplicit-function-declaration -Wimplicit-int 98c2ecf20Sopenharmony_cioverride CFLAGS+= $(call cc-option,-O3,-O1) ${WARNFLAGS} 108c2ecf20Sopenharmony_ci# Add "-fstack-protector" only if toolchain supports it. 118c2ecf20Sopenharmony_cioverride CFLAGS+= $(call cc-option,-fstack-protector-strong) 128c2ecf20Sopenharmony_ciCC?= $(CROSS_COMPILE)gcc 138c2ecf20Sopenharmony_ciPKG_CONFIG?= $(CROSS_COMPILE)pkg-config 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_cioverride CFLAGS+=-D VERSION=\"$(VERSION)\" 168c2ecf20Sopenharmony_ciLDFLAGS+= 178c2ecf20Sopenharmony_ciTARGET=tmon 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ciINSTALL_PROGRAM=install -m 755 -p 208c2ecf20Sopenharmony_ciDEL_FILE=rm -f 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci# Static builds might require -ltinfo, for instance 238c2ecf20Sopenharmony_ciifneq ($(findstring -static, $(LDFLAGS)),) 248c2ecf20Sopenharmony_ciSTATIC := --static 258c2ecf20Sopenharmony_ciendif 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ciTMON_LIBS=-lm -lpthread 288c2ecf20Sopenharmony_ciTMON_LIBS += $(shell $(PKG_CONFIG) --libs $(STATIC) panelw ncursesw 2> /dev/null || \ 298c2ecf20Sopenharmony_ci $(PKG_CONFIG) --libs $(STATIC) panel ncurses 2> /dev/null || \ 308c2ecf20Sopenharmony_ci echo -lpanel -lncurses) 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_cioverride CFLAGS += $(shell $(PKG_CONFIG) --cflags $(STATIC) panelw ncursesw 2> /dev/null || \ 338c2ecf20Sopenharmony_ci $(PKG_CONFIG) --cflags $(STATIC) panel ncurses 2> /dev/null) 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ciOBJS = tmon.o tui.o sysfs.o pid.o 368c2ecf20Sopenharmony_ciOBJS += 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_citmon: $(OBJS) Makefile tmon.h 398c2ecf20Sopenharmony_ci $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $(TARGET) $(TMON_LIBS) 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_civalgrind: tmon 428c2ecf20Sopenharmony_ci sudo valgrind -v --track-origins=yes --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes ./$(TARGET) 1> /dev/null 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ciinstall: 458c2ecf20Sopenharmony_ci - mkdir -p $(INSTALL_ROOT)/$(BINDIR) 468c2ecf20Sopenharmony_ci - $(INSTALL_PROGRAM) "$(TARGET)" "$(INSTALL_ROOT)/$(BINDIR)/$(TARGET)" 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ciuninstall: 498c2ecf20Sopenharmony_ci $(DEL_FILE) "$(INSTALL_ROOT)/$(BINDIR)/$(TARGET)" 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ciclean: 528c2ecf20Sopenharmony_ci find . -name "*.o" | xargs $(DEL_FILE) 538c2ecf20Sopenharmony_ci rm -f $(TARGET) 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_cidist: 568c2ecf20Sopenharmony_ci git tag v$(VERSION) 578c2ecf20Sopenharmony_ci git archive --format=tar --prefix="$(TARGET)-$(VERSION)/" v$(VERSION) | \ 588c2ecf20Sopenharmony_ci gzip > $(TARGET)-$(VERSION).tar.gz 59